babylon.max.js 7.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826
  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. this._syncRoot = null;
  2350. /**
  2351. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2352. * This will only apply for non looping animation (default is true)
  2353. */
  2354. this.disposeOnEnd = true;
  2355. /**
  2356. * Gets a boolean indicating if the animation has started
  2357. */
  2358. this.animationStarted = false;
  2359. /**
  2360. * Observer raised when the animation ends
  2361. */
  2362. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2363. /**
  2364. * Observer raised when the animation loops
  2365. */
  2366. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2367. this._scene = scene;
  2368. if (animations) {
  2369. this.appendAnimations(target, animations);
  2370. }
  2371. this._speedRatio = speedRatio;
  2372. scene._activeAnimatables.push(this);
  2373. }
  2374. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2375. /**
  2376. * Gets the root Animatable used to synchronize and normalize animations
  2377. */
  2378. get: function () {
  2379. return this._syncRoot;
  2380. },
  2381. enumerable: true,
  2382. configurable: true
  2383. });
  2384. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2385. /**
  2386. * Gets the current frame of the first RuntimeAnimation
  2387. * Used to synchronize Animatables
  2388. */
  2389. get: function () {
  2390. if (this._runtimeAnimations.length === 0) {
  2391. return 0;
  2392. }
  2393. return this._runtimeAnimations[0].currentFrame;
  2394. },
  2395. enumerable: true,
  2396. configurable: true
  2397. });
  2398. Object.defineProperty(Animatable.prototype, "weight", {
  2399. /**
  2400. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2401. */
  2402. get: function () {
  2403. return this._weight;
  2404. },
  2405. set: function (value) {
  2406. if (value === -1) { // -1 is ok and means no weight
  2407. this._weight = -1;
  2408. return;
  2409. }
  2410. // Else weight must be in [0, 1] range
  2411. this._weight = Math.min(Math.max(value, 0), 1.0);
  2412. },
  2413. enumerable: true,
  2414. configurable: true
  2415. });
  2416. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2417. /**
  2418. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2419. */
  2420. get: function () {
  2421. return this._speedRatio;
  2422. },
  2423. set: function (value) {
  2424. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2425. var animation = this._runtimeAnimations[index];
  2426. animation._prepareForSpeedRatioChange(value);
  2427. }
  2428. this._speedRatio = value;
  2429. },
  2430. enumerable: true,
  2431. configurable: true
  2432. });
  2433. // Methods
  2434. /**
  2435. * Synchronize and normalize current Animatable with a source Animatable
  2436. * This is useful when using animation weights and when animations are not of the same length
  2437. * @param root defines the root Animatable to synchronize with
  2438. * @returns the current Animatable
  2439. */
  2440. Animatable.prototype.syncWith = function (root) {
  2441. this._syncRoot = root;
  2442. if (root) {
  2443. // Make sure this animatable will animate after the root
  2444. var index = this._scene._activeAnimatables.indexOf(this);
  2445. if (index > -1) {
  2446. this._scene._activeAnimatables.splice(index, 1);
  2447. this._scene._activeAnimatables.push(this);
  2448. }
  2449. }
  2450. return this;
  2451. };
  2452. /**
  2453. * Gets the list of runtime animations
  2454. * @returns an array of RuntimeAnimation
  2455. */
  2456. Animatable.prototype.getAnimations = function () {
  2457. return this._runtimeAnimations;
  2458. };
  2459. /**
  2460. * Adds more animations to the current animatable
  2461. * @param target defines the target of the animations
  2462. * @param animations defines the new animations to add
  2463. */
  2464. Animatable.prototype.appendAnimations = function (target, animations) {
  2465. var _this = this;
  2466. for (var index = 0; index < animations.length; index++) {
  2467. var animation = animations[index];
  2468. var newRuntimeAnimation = new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__["RuntimeAnimation"](target, animation, this._scene, this);
  2469. newRuntimeAnimation._onLoop = function () {
  2470. _this.onAnimationLoopObservable.notifyObservers(_this);
  2471. if (_this.onAnimationLoop) {
  2472. _this.onAnimationLoop();
  2473. }
  2474. };
  2475. this._runtimeAnimations.push(newRuntimeAnimation);
  2476. }
  2477. };
  2478. /**
  2479. * Gets the source animation for a specific property
  2480. * @param property defines the propertyu to look for
  2481. * @returns null or the source animation for the given property
  2482. */
  2483. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2484. var runtimeAnimations = this._runtimeAnimations;
  2485. for (var index = 0; index < runtimeAnimations.length; index++) {
  2486. if (runtimeAnimations[index].animation.targetProperty === property) {
  2487. return runtimeAnimations[index].animation;
  2488. }
  2489. }
  2490. return null;
  2491. };
  2492. /**
  2493. * Gets the runtime animation for a specific property
  2494. * @param property defines the propertyu to look for
  2495. * @returns null or the runtime animation for the given property
  2496. */
  2497. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2498. var runtimeAnimations = this._runtimeAnimations;
  2499. for (var index = 0; index < runtimeAnimations.length; index++) {
  2500. if (runtimeAnimations[index].animation.targetProperty === property) {
  2501. return runtimeAnimations[index];
  2502. }
  2503. }
  2504. return null;
  2505. };
  2506. /**
  2507. * Resets the animatable to its original state
  2508. */
  2509. Animatable.prototype.reset = function () {
  2510. var runtimeAnimations = this._runtimeAnimations;
  2511. for (var index = 0; index < runtimeAnimations.length; index++) {
  2512. runtimeAnimations[index].reset(true);
  2513. }
  2514. this._localDelayOffset = null;
  2515. this._pausedDelay = null;
  2516. };
  2517. /**
  2518. * Allows the animatable to blend with current running animations
  2519. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2520. * @param blendingSpeed defines the blending speed to use
  2521. */
  2522. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2523. var runtimeAnimations = this._runtimeAnimations;
  2524. for (var index = 0; index < runtimeAnimations.length; index++) {
  2525. runtimeAnimations[index].animation.enableBlending = true;
  2526. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2527. }
  2528. };
  2529. /**
  2530. * Disable animation blending
  2531. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2532. */
  2533. Animatable.prototype.disableBlending = function () {
  2534. var runtimeAnimations = this._runtimeAnimations;
  2535. for (var index = 0; index < runtimeAnimations.length; index++) {
  2536. runtimeAnimations[index].animation.enableBlending = false;
  2537. }
  2538. };
  2539. /**
  2540. * Jump directly to a given frame
  2541. * @param frame defines the frame to jump to
  2542. */
  2543. Animatable.prototype.goToFrame = function (frame) {
  2544. var runtimeAnimations = this._runtimeAnimations;
  2545. if (runtimeAnimations[0]) {
  2546. var fps = runtimeAnimations[0].animation.framePerSecond;
  2547. var currentFrame = runtimeAnimations[0].currentFrame;
  2548. var adjustTime = frame - currentFrame;
  2549. var delay = this.speedRatio !== 0 ? adjustTime * 1000 / (fps * this.speedRatio) : 0;
  2550. if (this._localDelayOffset === null) {
  2551. this._localDelayOffset = 0;
  2552. }
  2553. this._localDelayOffset -= delay;
  2554. }
  2555. for (var index = 0; index < runtimeAnimations.length; index++) {
  2556. runtimeAnimations[index].goToFrame(frame);
  2557. }
  2558. };
  2559. /**
  2560. * Pause the animation
  2561. */
  2562. Animatable.prototype.pause = function () {
  2563. if (this._paused) {
  2564. return;
  2565. }
  2566. this._paused = true;
  2567. };
  2568. /**
  2569. * Restart the animation
  2570. */
  2571. Animatable.prototype.restart = function () {
  2572. this._paused = false;
  2573. };
  2574. Animatable.prototype._raiseOnAnimationEnd = function () {
  2575. if (this.onAnimationEnd) {
  2576. this.onAnimationEnd();
  2577. }
  2578. this.onAnimationEndObservable.notifyObservers(this);
  2579. };
  2580. /**
  2581. * Stop and delete the current animation
  2582. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2583. * @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)
  2584. */
  2585. Animatable.prototype.stop = function (animationName, targetMask) {
  2586. if (animationName || targetMask) {
  2587. var idx = this._scene._activeAnimatables.indexOf(this);
  2588. if (idx > -1) {
  2589. var runtimeAnimations = this._runtimeAnimations;
  2590. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2591. var runtimeAnimation = runtimeAnimations[index];
  2592. if (animationName && runtimeAnimation.animation.name != animationName) {
  2593. continue;
  2594. }
  2595. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2596. continue;
  2597. }
  2598. runtimeAnimation.dispose();
  2599. runtimeAnimations.splice(index, 1);
  2600. }
  2601. if (runtimeAnimations.length == 0) {
  2602. this._scene._activeAnimatables.splice(idx, 1);
  2603. this._raiseOnAnimationEnd();
  2604. }
  2605. }
  2606. }
  2607. else {
  2608. var index = this._scene._activeAnimatables.indexOf(this);
  2609. if (index > -1) {
  2610. this._scene._activeAnimatables.splice(index, 1);
  2611. var runtimeAnimations = this._runtimeAnimations;
  2612. for (var index = 0; index < runtimeAnimations.length; index++) {
  2613. runtimeAnimations[index].dispose();
  2614. }
  2615. this._raiseOnAnimationEnd();
  2616. }
  2617. }
  2618. };
  2619. /**
  2620. * Wait asynchronously for the animation to end
  2621. * @returns a promise which will be fullfilled when the animation ends
  2622. */
  2623. Animatable.prototype.waitAsync = function () {
  2624. var _this = this;
  2625. return new Promise(function (resolve, reject) {
  2626. _this.onAnimationEndObservable.add(function () {
  2627. resolve(_this);
  2628. }, undefined, undefined, _this, true);
  2629. });
  2630. };
  2631. /** @hidden */
  2632. Animatable.prototype._animate = function (delay) {
  2633. if (this._paused) {
  2634. this.animationStarted = false;
  2635. if (this._pausedDelay === null) {
  2636. this._pausedDelay = delay;
  2637. }
  2638. return true;
  2639. }
  2640. if (this._localDelayOffset === null) {
  2641. this._localDelayOffset = delay;
  2642. this._pausedDelay = null;
  2643. }
  2644. else if (this._pausedDelay !== null) {
  2645. this._localDelayOffset += delay - this._pausedDelay;
  2646. this._pausedDelay = null;
  2647. }
  2648. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2649. return true;
  2650. }
  2651. // Animating
  2652. var running = false;
  2653. var runtimeAnimations = this._runtimeAnimations;
  2654. var index;
  2655. for (index = 0; index < runtimeAnimations.length; index++) {
  2656. var animation = runtimeAnimations[index];
  2657. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight);
  2658. running = running || isRunning;
  2659. }
  2660. this.animationStarted = running;
  2661. if (!running) {
  2662. if (this.disposeOnEnd) {
  2663. // Remove from active animatables
  2664. index = this._scene._activeAnimatables.indexOf(this);
  2665. this._scene._activeAnimatables.splice(index, 1);
  2666. // Dispose all runtime animations
  2667. for (index = 0; index < runtimeAnimations.length; index++) {
  2668. runtimeAnimations[index].dispose();
  2669. }
  2670. }
  2671. this._raiseOnAnimationEnd();
  2672. if (this.disposeOnEnd) {
  2673. this.onAnimationEnd = null;
  2674. this.onAnimationLoop = null;
  2675. this.onAnimationLoopObservable.clear();
  2676. this.onAnimationEndObservable.clear();
  2677. }
  2678. }
  2679. return running;
  2680. };
  2681. return Animatable;
  2682. }());
  2683. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._animate = function () {
  2684. if (!this.animationsEnabled) {
  2685. return;
  2686. }
  2687. var animatables = this._activeAnimatables;
  2688. if (animatables.length === 0) {
  2689. return;
  2690. }
  2691. // Getting time
  2692. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__["PrecisionDate"].Now;
  2693. if (!this._animationTimeLast) {
  2694. if (this._pendingData.length > 0) {
  2695. return;
  2696. }
  2697. this._animationTimeLast = now;
  2698. }
  2699. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  2700. this._animationTime += deltaTime;
  2701. var animationTime = this._animationTime;
  2702. this._animationTimeLast = now;
  2703. for (var index = 0; index < animatables.length; index++) {
  2704. animatables[index]._animate(animationTime);
  2705. }
  2706. // Late animation bindings
  2707. this._processLateAnimationBindings();
  2708. };
  2709. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  2710. if (weight === void 0) { weight = 1.0; }
  2711. if (speedRatio === void 0) { speedRatio = 1.0; }
  2712. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  2713. returnedAnimatable.weight = weight;
  2714. return returnedAnimatable;
  2715. };
  2716. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2717. if (speedRatio === void 0) { speedRatio = 1.0; }
  2718. if (stopCurrent === void 0) { stopCurrent = true; }
  2719. if (from > to && speedRatio > 0) {
  2720. speedRatio *= -1;
  2721. }
  2722. if (stopCurrent) {
  2723. this.stopAnimation(target, undefined, targetMask);
  2724. }
  2725. if (!animatable) {
  2726. animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  2727. }
  2728. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  2729. // Local animations
  2730. if (target.animations && shouldRunTargetAnimations) {
  2731. animatable.appendAnimations(target, target.animations);
  2732. }
  2733. // Children animations
  2734. if (target.getAnimatables) {
  2735. var animatables = target.getAnimatables();
  2736. for (var index = 0; index < animatables.length; index++) {
  2737. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  2738. }
  2739. }
  2740. animatable.reset();
  2741. return animatable;
  2742. };
  2743. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2744. if (speedRatio === void 0) { speedRatio = 1.0; }
  2745. if (stopCurrent === void 0) { stopCurrent = true; }
  2746. var children = target.getDescendants(directDescendantsOnly);
  2747. var result = [];
  2748. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2749. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  2750. var child = children_1[_i];
  2751. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2752. }
  2753. return result;
  2754. };
  2755. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2756. if (speedRatio === undefined) {
  2757. speedRatio = 1.0;
  2758. }
  2759. var animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  2760. return animatable;
  2761. };
  2762. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2763. var children = target.getDescendants(directDescendantsOnly);
  2764. var result = [];
  2765. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2766. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  2767. var child = children_2[_i];
  2768. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2769. }
  2770. return result;
  2771. };
  2772. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAnimatableByTarget = function (target) {
  2773. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2774. if (this._activeAnimatables[index].target === target) {
  2775. return this._activeAnimatables[index];
  2776. }
  2777. }
  2778. return null;
  2779. };
  2780. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAllAnimatablesByTarget = function (target) {
  2781. var result = [];
  2782. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2783. if (this._activeAnimatables[index].target === target) {
  2784. result.push(this._activeAnimatables[index]);
  2785. }
  2786. }
  2787. return result;
  2788. };
  2789. /**
  2790. * Will stop the animation of the given target
  2791. * @param target - the target
  2792. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  2793. * @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)
  2794. */
  2795. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAnimation = function (target, animationName, targetMask) {
  2796. var animatables = this.getAllAnimatablesByTarget(target);
  2797. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  2798. var animatable = animatables_1[_i];
  2799. animatable.stop(animationName, targetMask);
  2800. }
  2801. };
  2802. /**
  2803. * Stops and removes all animations that have been applied to the scene
  2804. */
  2805. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAllAnimations = function () {
  2806. if (this._activeAnimatables) {
  2807. for (var i = 0; i < this._activeAnimatables.length; i++) {
  2808. this._activeAnimatables[i].stop();
  2809. }
  2810. this._activeAnimatables = [];
  2811. }
  2812. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  2813. var group = _a[_i];
  2814. group.stop();
  2815. }
  2816. };
  2817. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  2818. var target = runtimeAnimation.target;
  2819. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  2820. if (!target._lateAnimationHolders) {
  2821. target._lateAnimationHolders = {};
  2822. }
  2823. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  2824. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  2825. totalWeight: 0,
  2826. animations: [],
  2827. originalValue: originalValue
  2828. };
  2829. }
  2830. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  2831. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  2832. };
  2833. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForMatrices = function (holder) {
  2834. var normalizer = 1.0;
  2835. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  2836. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  2837. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  2838. var startIndex = 0;
  2839. var originalAnimation = holder.animations[0];
  2840. var originalValue = holder.originalValue;
  2841. var scale = 1;
  2842. if (holder.totalWeight < 1.0) {
  2843. // We need to mix the original value in
  2844. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2845. scale = 1.0 - holder.totalWeight;
  2846. }
  2847. else {
  2848. startIndex = 1;
  2849. // We need to normalize the weights
  2850. normalizer = holder.totalWeight;
  2851. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2852. scale = originalAnimation.weight / normalizer;
  2853. if (scale == 1) {
  2854. return originalAnimation.currentValue;
  2855. }
  2856. }
  2857. finalScaling.scaleInPlace(scale);
  2858. finalPosition.scaleInPlace(scale);
  2859. finalQuaternion.scaleInPlace(scale);
  2860. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2861. var runtimeAnimation = holder.animations[animIndex];
  2862. var scale = runtimeAnimation.weight / normalizer;
  2863. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  2864. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  2865. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  2866. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  2867. currentScaling.scaleAndAddToRef(scale, finalScaling);
  2868. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  2869. currentPosition.scaleAndAddToRef(scale, finalPosition);
  2870. }
  2871. var workValue = originalAnimation._animationState.workValue;
  2872. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, workValue);
  2873. return workValue;
  2874. };
  2875. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  2876. var originalAnimation = holder.animations[0];
  2877. var originalValue = holder.originalValue;
  2878. if (holder.animations.length === 1) {
  2879. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  2880. return refQuaternion;
  2881. }
  2882. var normalizer = 1.0;
  2883. var quaternions;
  2884. var weights;
  2885. if (holder.totalWeight < 1.0) {
  2886. var scale = 1.0 - holder.totalWeight;
  2887. quaternions = [];
  2888. weights = [];
  2889. quaternions.push(originalValue);
  2890. weights.push(scale);
  2891. }
  2892. else {
  2893. if (holder.animations.length === 2) { // Slerp as soon as we can
  2894. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  2895. return refQuaternion;
  2896. }
  2897. quaternions = [];
  2898. weights = [];
  2899. normalizer = holder.totalWeight;
  2900. }
  2901. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  2902. var runtimeAnimation = holder.animations[animIndex];
  2903. quaternions.push(runtimeAnimation.currentValue);
  2904. weights.push(runtimeAnimation.weight / normalizer);
  2905. }
  2906. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  2907. var cumulativeAmount = 0;
  2908. var cumulativeQuaternion = null;
  2909. for (var index = 0; index < quaternions.length;) {
  2910. if (!cumulativeQuaternion) {
  2911. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  2912. cumulativeQuaternion = refQuaternion;
  2913. cumulativeAmount = weights[index] + weights[index + 1];
  2914. index += 2;
  2915. continue;
  2916. }
  2917. cumulativeAmount += weights[index];
  2918. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  2919. index++;
  2920. }
  2921. return cumulativeQuaternion;
  2922. };
  2923. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindings = function () {
  2924. if (!this._registeredForLateAnimationBindings.length) {
  2925. return;
  2926. }
  2927. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  2928. var target = this._registeredForLateAnimationBindings.data[index];
  2929. for (var path in target._lateAnimationHolders) {
  2930. var holder = target._lateAnimationHolders[path];
  2931. var originalAnimation = holder.animations[0];
  2932. var originalValue = holder.originalValue;
  2933. var matrixDecomposeMode = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  2934. var finalValue = target[path];
  2935. if (matrixDecomposeMode) {
  2936. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  2937. }
  2938. else {
  2939. var quaternionMode = originalValue.w !== undefined;
  2940. if (quaternionMode) {
  2941. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity());
  2942. }
  2943. else {
  2944. var startIndex = 0;
  2945. var normalizer = 1.0;
  2946. if (holder.totalWeight < 1.0) {
  2947. // We need to mix the original value in
  2948. if (originalValue.scale) {
  2949. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  2950. }
  2951. else {
  2952. finalValue = originalValue * (1.0 - holder.totalWeight);
  2953. }
  2954. }
  2955. else {
  2956. // We need to normalize the weights
  2957. normalizer = holder.totalWeight;
  2958. var scale_1 = originalAnimation.weight / normalizer;
  2959. if (scale_1 !== 1) {
  2960. if (originalAnimation.currentValue.scale) {
  2961. finalValue = originalAnimation.currentValue.scale(scale_1);
  2962. }
  2963. else {
  2964. finalValue = originalAnimation.currentValue * scale_1;
  2965. }
  2966. }
  2967. else {
  2968. finalValue = originalAnimation.currentValue;
  2969. }
  2970. startIndex = 1;
  2971. }
  2972. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2973. var runtimeAnimation = holder.animations[animIndex];
  2974. var scale = runtimeAnimation.weight / normalizer;
  2975. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  2976. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  2977. }
  2978. else {
  2979. finalValue += runtimeAnimation.currentValue * scale;
  2980. }
  2981. }
  2982. }
  2983. }
  2984. target[path] = finalValue;
  2985. }
  2986. target._lateAnimationHolders = {};
  2987. }
  2988. this._registeredForLateAnimationBindings.reset();
  2989. };
  2990. _Bones_bone__WEBPACK_IMPORTED_MODULE_6__["Bone"].prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  2991. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  2992. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  2993. // all animation may be coming from a library skeleton, so may need to create animation
  2994. if (this.animations.length === 0) {
  2995. 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));
  2996. this.animations[0].setKeys([]);
  2997. }
  2998. // get animation info / verify there is such a range from the source bone
  2999. var sourceRange = source.animations[0].getRange(rangeName);
  3000. if (!sourceRange) {
  3001. return false;
  3002. }
  3003. var from = sourceRange.from;
  3004. var to = sourceRange.to;
  3005. var sourceKeys = source.animations[0].getKeys();
  3006. // rescaling prep
  3007. var sourceBoneLength = source.length;
  3008. var sourceParent = source.getParent();
  3009. var parent = this.getParent();
  3010. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  3011. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  3012. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  3013. var destKeys = this.animations[0].getKeys();
  3014. // loop vars declaration
  3015. var orig;
  3016. var origTranslation;
  3017. var mat;
  3018. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  3019. orig = sourceKeys[key];
  3020. if (orig.frame >= from && orig.frame <= to) {
  3021. if (rescaleAsRequired) {
  3022. mat = orig.value.clone();
  3023. // scale based on parent ratio, when bone has parent
  3024. if (parentScalingReqd) {
  3025. origTranslation = mat.getTranslation();
  3026. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  3027. // scale based on skeleton dimension ratio when root bone, and value is passed
  3028. }
  3029. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  3030. origTranslation = mat.getTranslation();
  3031. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  3032. // use original when root bone, and no data for skelDimensionsRatio
  3033. }
  3034. else {
  3035. mat = orig.value;
  3036. }
  3037. }
  3038. else {
  3039. mat = orig.value;
  3040. }
  3041. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  3042. }
  3043. }
  3044. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  3045. return true;
  3046. };
  3047. /***/ }),
  3048. /***/ "./Animations/animation.ts":
  3049. /*!*********************************!*\
  3050. !*** ./Animations/animation.ts ***!
  3051. \*********************************/
  3052. /*! exports provided: _IAnimationState, Animation */
  3053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3054. "use strict";
  3055. __webpack_require__.r(__webpack_exports__);
  3056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _IAnimationState; });
  3057. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  3058. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  3059. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  3060. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  3061. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  3062. /* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  3063. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  3064. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  3065. /**
  3066. * @hidden
  3067. */
  3068. var _IAnimationState = /** @class */ (function () {
  3069. function _IAnimationState() {
  3070. }
  3071. return _IAnimationState;
  3072. }());
  3073. /**
  3074. * Class used to store any kind of animation
  3075. */
  3076. var Animation = /** @class */ (function () {
  3077. /**
  3078. * Initializes the animation
  3079. * @param name Name of the animation
  3080. * @param targetProperty Property to animate
  3081. * @param framePerSecond The frames per second of the animation
  3082. * @param dataType The data type of the animation
  3083. * @param loopMode The loop mode of the animation
  3084. * @param enableBlending Specifies if blending should be enabled
  3085. */
  3086. function Animation(
  3087. /**Name of the animation */
  3088. name,
  3089. /**Property to animate */
  3090. targetProperty,
  3091. /**The frames per second of the animation */
  3092. framePerSecond,
  3093. /**The data type of the animation */
  3094. dataType,
  3095. /**The loop mode of the animation */
  3096. loopMode,
  3097. /**Specifies if blending should be enabled */
  3098. enableBlending) {
  3099. this.name = name;
  3100. this.targetProperty = targetProperty;
  3101. this.framePerSecond = framePerSecond;
  3102. this.dataType = dataType;
  3103. this.loopMode = loopMode;
  3104. this.enableBlending = enableBlending;
  3105. /**
  3106. * @hidden Internal use only
  3107. */
  3108. this._runtimeAnimations = new Array();
  3109. /**
  3110. * The set of event that will be linked to this animation
  3111. */
  3112. this._events = new Array();
  3113. /**
  3114. * Stores the blending speed of the animation
  3115. */
  3116. this.blendingSpeed = 0.01;
  3117. /**
  3118. * Stores the animation ranges for the animation
  3119. */
  3120. this._ranges = {};
  3121. this.targetPropertyPath = targetProperty.split(".");
  3122. this.dataType = dataType;
  3123. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  3124. }
  3125. /**
  3126. * @hidden Internal use
  3127. */
  3128. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  3129. var dataType = undefined;
  3130. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  3131. dataType = Animation.ANIMATIONTYPE_FLOAT;
  3132. }
  3133. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  3134. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  3135. }
  3136. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  3137. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  3138. }
  3139. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  3140. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  3141. }
  3142. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  3143. dataType = Animation.ANIMATIONTYPE_COLOR3;
  3144. }
  3145. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  3146. dataType = Animation.ANIMATIONTYPE_SIZE;
  3147. }
  3148. if (dataType == undefined) {
  3149. return null;
  3150. }
  3151. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  3152. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  3153. animation.setKeys(keys);
  3154. if (easingFunction !== undefined) {
  3155. animation.setEasingFunction(easingFunction);
  3156. }
  3157. return animation;
  3158. };
  3159. /**
  3160. * Sets up an animation
  3161. * @param property The property to animate
  3162. * @param animationType The animation type to apply
  3163. * @param framePerSecond The frames per second of the animation
  3164. * @param easingFunction The easing function used in the animation
  3165. * @returns The created animation
  3166. */
  3167. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  3168. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  3169. animation.setEasingFunction(easingFunction);
  3170. return animation;
  3171. };
  3172. /**
  3173. * Create and start an animation on a node
  3174. * @param name defines the name of the global animation that will be run on all nodes
  3175. * @param node defines the root node where the animation will take place
  3176. * @param targetProperty defines property to animate
  3177. * @param framePerSecond defines the number of frame per second yo use
  3178. * @param totalFrame defines the number of frames in total
  3179. * @param from defines the initial value
  3180. * @param to defines the final value
  3181. * @param loopMode defines which loop mode you want to use (off by default)
  3182. * @param easingFunction defines the easing function to use (linear by default)
  3183. * @param onAnimationEnd defines the callback to call when animation end
  3184. * @returns the animatable created for this animation
  3185. */
  3186. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3187. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3188. if (!animation) {
  3189. return null;
  3190. }
  3191. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3192. };
  3193. /**
  3194. * Create and start an animation on a node and its descendants
  3195. * @param name defines the name of the global animation that will be run on all nodes
  3196. * @param node defines the root node where the animation will take place
  3197. * @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
  3198. * @param targetProperty defines property to animate
  3199. * @param framePerSecond defines the number of frame per second to use
  3200. * @param totalFrame defines the number of frames in total
  3201. * @param from defines the initial value
  3202. * @param to defines the final value
  3203. * @param loopMode defines which loop mode you want to use (off by default)
  3204. * @param easingFunction defines the easing function to use (linear by default)
  3205. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3206. * @returns the list of animatables created for all nodes
  3207. * @example https://www.babylonjs-playground.com/#MH0VLI
  3208. */
  3209. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3210. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3211. if (!animation) {
  3212. return null;
  3213. }
  3214. var scene = node.getScene();
  3215. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3216. };
  3217. /**
  3218. * Creates a new animation, merges it with the existing animations and starts it
  3219. * @param name Name of the animation
  3220. * @param node Node which contains the scene that begins the animations
  3221. * @param targetProperty Specifies which property to animate
  3222. * @param framePerSecond The frames per second of the animation
  3223. * @param totalFrame The total number of frames
  3224. * @param from The frame at the beginning of the animation
  3225. * @param to The frame at the end of the animation
  3226. * @param loopMode Specifies the loop mode of the animation
  3227. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3228. * @param onAnimationEnd Callback to run once the animation is complete
  3229. * @returns Nullable animation
  3230. */
  3231. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3232. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3233. if (!animation) {
  3234. return null;
  3235. }
  3236. node.animations.push(animation);
  3237. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3238. };
  3239. /**
  3240. * Transition property of an host to the target Value
  3241. * @param property The property to transition
  3242. * @param targetValue The target Value of the property
  3243. * @param host The object where the property to animate belongs
  3244. * @param scene Scene used to run the animation
  3245. * @param frameRate Framerate (in frame/s) to use
  3246. * @param transition The transition type we want to use
  3247. * @param duration The duration of the animation, in milliseconds
  3248. * @param onAnimationEnd Callback trigger at the end of the animation
  3249. * @returns Nullable animation
  3250. */
  3251. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3252. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3253. if (duration <= 0) {
  3254. host[property] = targetValue;
  3255. if (onAnimationEnd) {
  3256. onAnimationEnd();
  3257. }
  3258. return null;
  3259. }
  3260. var endFrame = frameRate * (duration / 1000);
  3261. transition.setKeys([{
  3262. frame: 0,
  3263. value: host[property].clone ? host[property].clone() : host[property]
  3264. },
  3265. {
  3266. frame: endFrame,
  3267. value: targetValue
  3268. }]);
  3269. if (!host.animations) {
  3270. host.animations = [];
  3271. }
  3272. host.animations.push(transition);
  3273. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3274. animation.onAnimationEnd = onAnimationEnd;
  3275. return animation;
  3276. };
  3277. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3278. /**
  3279. * Return the array of runtime animations currently using this animation
  3280. */
  3281. get: function () {
  3282. return this._runtimeAnimations;
  3283. },
  3284. enumerable: true,
  3285. configurable: true
  3286. });
  3287. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3288. /**
  3289. * Specifies if any of the runtime animations are currently running
  3290. */
  3291. get: function () {
  3292. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3293. var runtimeAnimation = _a[_i];
  3294. if (!runtimeAnimation.isStopped) {
  3295. return true;
  3296. }
  3297. }
  3298. return false;
  3299. },
  3300. enumerable: true,
  3301. configurable: true
  3302. });
  3303. // Methods
  3304. /**
  3305. * Converts the animation to a string
  3306. * @param fullDetails support for multiple levels of logging within scene loading
  3307. * @returns String form of the animation
  3308. */
  3309. Animation.prototype.toString = function (fullDetails) {
  3310. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3311. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3312. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3313. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3314. if (fullDetails) {
  3315. ret += ", Ranges: {";
  3316. var first = true;
  3317. for (var name in this._ranges) {
  3318. if (first) {
  3319. ret += ", ";
  3320. first = false;
  3321. }
  3322. ret += name;
  3323. }
  3324. ret += "}";
  3325. }
  3326. return ret;
  3327. };
  3328. /**
  3329. * Add an event to this animation
  3330. * @param event Event to add
  3331. */
  3332. Animation.prototype.addEvent = function (event) {
  3333. this._events.push(event);
  3334. };
  3335. /**
  3336. * Remove all events found at the given frame
  3337. * @param frame The frame to remove events from
  3338. */
  3339. Animation.prototype.removeEvents = function (frame) {
  3340. for (var index = 0; index < this._events.length; index++) {
  3341. if (this._events[index].frame === frame) {
  3342. this._events.splice(index, 1);
  3343. index--;
  3344. }
  3345. }
  3346. };
  3347. /**
  3348. * Retrieves all the events from the animation
  3349. * @returns Events from the animation
  3350. */
  3351. Animation.prototype.getEvents = function () {
  3352. return this._events;
  3353. };
  3354. /**
  3355. * Creates an animation range
  3356. * @param name Name of the animation range
  3357. * @param from Starting frame of the animation range
  3358. * @param to Ending frame of the animation
  3359. */
  3360. Animation.prototype.createRange = function (name, from, to) {
  3361. // check name not already in use; could happen for bones after serialized
  3362. if (!this._ranges[name]) {
  3363. this._ranges[name] = new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  3364. }
  3365. };
  3366. /**
  3367. * Deletes an animation range by name
  3368. * @param name Name of the animation range to delete
  3369. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3370. */
  3371. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3372. if (deleteFrames === void 0) { deleteFrames = true; }
  3373. var range = this._ranges[name];
  3374. if (!range) {
  3375. return;
  3376. }
  3377. if (deleteFrames) {
  3378. var from = range.from;
  3379. var to = range.to;
  3380. // this loop MUST go high to low for multiple splices to work
  3381. for (var key = this._keys.length - 1; key >= 0; key--) {
  3382. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3383. this._keys.splice(key, 1);
  3384. }
  3385. }
  3386. }
  3387. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3388. };
  3389. /**
  3390. * Gets the animation range by name, or null if not defined
  3391. * @param name Name of the animation range
  3392. * @returns Nullable animation range
  3393. */
  3394. Animation.prototype.getRange = function (name) {
  3395. return this._ranges[name];
  3396. };
  3397. /**
  3398. * Gets the key frames from the animation
  3399. * @returns The key frames of the animation
  3400. */
  3401. Animation.prototype.getKeys = function () {
  3402. return this._keys;
  3403. };
  3404. /**
  3405. * Gets the highest frame rate of the animation
  3406. * @returns Highest frame rate of the animation
  3407. */
  3408. Animation.prototype.getHighestFrame = function () {
  3409. var ret = 0;
  3410. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3411. if (ret < this._keys[key].frame) {
  3412. ret = this._keys[key].frame;
  3413. }
  3414. }
  3415. return ret;
  3416. };
  3417. /**
  3418. * Gets the easing function of the animation
  3419. * @returns Easing function of the animation
  3420. */
  3421. Animation.prototype.getEasingFunction = function () {
  3422. return this._easingFunction;
  3423. };
  3424. /**
  3425. * Sets the easing function of the animation
  3426. * @param easingFunction A custom mathematical formula for animation
  3427. */
  3428. Animation.prototype.setEasingFunction = function (easingFunction) {
  3429. this._easingFunction = easingFunction;
  3430. };
  3431. /**
  3432. * Interpolates a scalar linearly
  3433. * @param startValue Start value of the animation curve
  3434. * @param endValue End value of the animation curve
  3435. * @param gradient Scalar amount to interpolate
  3436. * @returns Interpolated scalar value
  3437. */
  3438. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3439. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3440. };
  3441. /**
  3442. * Interpolates a scalar cubically
  3443. * @param startValue Start value of the animation curve
  3444. * @param outTangent End tangent of the animation
  3445. * @param endValue End value of the animation curve
  3446. * @param inTangent Start tangent of the animation curve
  3447. * @param gradient Scalar amount to interpolate
  3448. * @returns Interpolated scalar value
  3449. */
  3450. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3451. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3452. };
  3453. /**
  3454. * Interpolates a quaternion using a spherical linear interpolation
  3455. * @param startValue Start value of the animation curve
  3456. * @param endValue End value of the animation curve
  3457. * @param gradient Scalar amount to interpolate
  3458. * @returns Interpolated quaternion value
  3459. */
  3460. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3461. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3462. };
  3463. /**
  3464. * Interpolates a quaternion cubically
  3465. * @param startValue Start value of the animation curve
  3466. * @param outTangent End tangent of the animation curve
  3467. * @param endValue End value of the animation curve
  3468. * @param inTangent Start tangent of the animation curve
  3469. * @param gradient Scalar amount to interpolate
  3470. * @returns Interpolated quaternion value
  3471. */
  3472. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3473. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3474. };
  3475. /**
  3476. * Interpolates a Vector3 linearl
  3477. * @param startValue Start value of the animation curve
  3478. * @param endValue End value of the animation curve
  3479. * @param gradient Scalar amount to interpolate
  3480. * @returns Interpolated scalar value
  3481. */
  3482. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3483. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3484. };
  3485. /**
  3486. * Interpolates a Vector3 cubically
  3487. * @param startValue Start value of the animation curve
  3488. * @param outTangent End tangent of the animation
  3489. * @param endValue End value of the animation curve
  3490. * @param inTangent Start tangent of the animation curve
  3491. * @param gradient Scalar amount to interpolate
  3492. * @returns InterpolatedVector3 value
  3493. */
  3494. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3495. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3496. };
  3497. /**
  3498. * Interpolates a Vector2 linearly
  3499. * @param startValue Start value of the animation curve
  3500. * @param endValue End value of the animation curve
  3501. * @param gradient Scalar amount to interpolate
  3502. * @returns Interpolated Vector2 value
  3503. */
  3504. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3505. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3506. };
  3507. /**
  3508. * Interpolates a Vector2 cubically
  3509. * @param startValue Start value of the animation curve
  3510. * @param outTangent End tangent of the animation
  3511. * @param endValue End value of the animation curve
  3512. * @param inTangent Start tangent of the animation curve
  3513. * @param gradient Scalar amount to interpolate
  3514. * @returns Interpolated Vector2 value
  3515. */
  3516. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3517. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3518. };
  3519. /**
  3520. * Interpolates a size linearly
  3521. * @param startValue Start value of the animation curve
  3522. * @param endValue End value of the animation curve
  3523. * @param gradient Scalar amount to interpolate
  3524. * @returns Interpolated Size value
  3525. */
  3526. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3527. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3528. };
  3529. /**
  3530. * Interpolates a Color3 linearly
  3531. * @param startValue Start value of the animation curve
  3532. * @param endValue End value of the animation curve
  3533. * @param gradient Scalar amount to interpolate
  3534. * @returns Interpolated Color3 value
  3535. */
  3536. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3537. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3538. };
  3539. /**
  3540. * @hidden Internal use only
  3541. */
  3542. Animation.prototype._getKeyValue = function (value) {
  3543. if (typeof value === "function") {
  3544. return value();
  3545. }
  3546. return value;
  3547. };
  3548. /**
  3549. * @hidden Internal use only
  3550. */
  3551. Animation.prototype._interpolate = function (currentFrame, state) {
  3552. if (state.loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && state.repeatCount > 0) {
  3553. return state.highLimitValue.clone ? state.highLimitValue.clone() : state.highLimitValue;
  3554. }
  3555. var keys = this._keys;
  3556. if (keys.length === 1) {
  3557. return this._getKeyValue(keys[0].value);
  3558. }
  3559. var startKeyIndex = state.key;
  3560. if (keys[startKeyIndex].frame >= currentFrame) {
  3561. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3562. startKeyIndex--;
  3563. }
  3564. }
  3565. for (var key = startKeyIndex; key < keys.length; key++) {
  3566. var endKey = keys[key + 1];
  3567. if (endKey.frame >= currentFrame) {
  3568. state.key = key;
  3569. var startKey = keys[key];
  3570. var startValue = this._getKeyValue(startKey.value);
  3571. if (startKey.interpolation === _animationKey__WEBPACK_IMPORTED_MODULE_4__["AnimationKeyInterpolation"].STEP) {
  3572. return startValue;
  3573. }
  3574. var endValue = this._getKeyValue(endKey.value);
  3575. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3576. var frameDelta = endKey.frame - startKey.frame;
  3577. // gradient : percent of currentFrame between the frame inf and the frame sup
  3578. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3579. // check for easingFunction and correction of gradient
  3580. var easingFunction = this.getEasingFunction();
  3581. if (easingFunction != null) {
  3582. gradient = easingFunction.ease(gradient);
  3583. }
  3584. switch (this.dataType) {
  3585. // Float
  3586. case Animation.ANIMATIONTYPE_FLOAT:
  3587. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3588. switch (state.loopMode) {
  3589. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3590. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3591. return floatValue;
  3592. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3593. return state.offsetValue * state.repeatCount + floatValue;
  3594. }
  3595. break;
  3596. // Quaternion
  3597. case Animation.ANIMATIONTYPE_QUATERNION:
  3598. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3599. switch (state.loopMode) {
  3600. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3601. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3602. return quatValue;
  3603. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3604. return quatValue.addInPlace(state.offsetValue.scale(state.repeatCount));
  3605. }
  3606. return quatValue;
  3607. // Vector3
  3608. case Animation.ANIMATIONTYPE_VECTOR3:
  3609. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3610. switch (state.loopMode) {
  3611. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3612. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3613. return vec3Value;
  3614. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3615. return vec3Value.add(state.offsetValue.scale(state.repeatCount));
  3616. }
  3617. // Vector2
  3618. case Animation.ANIMATIONTYPE_VECTOR2:
  3619. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3620. switch (state.loopMode) {
  3621. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3622. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3623. return vec2Value;
  3624. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3625. return vec2Value.add(state.offsetValue.scale(state.repeatCount));
  3626. }
  3627. // Size
  3628. case Animation.ANIMATIONTYPE_SIZE:
  3629. switch (state.loopMode) {
  3630. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3631. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3632. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3633. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3634. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(state.offsetValue.scale(state.repeatCount));
  3635. }
  3636. // Color3
  3637. case Animation.ANIMATIONTYPE_COLOR3:
  3638. switch (state.loopMode) {
  3639. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3640. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3641. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3642. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3643. return this.color3InterpolateFunction(startValue, endValue, gradient).add(state.offsetValue.scale(state.repeatCount));
  3644. }
  3645. // Matrix
  3646. case Animation.ANIMATIONTYPE_MATRIX:
  3647. switch (state.loopMode) {
  3648. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3649. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3650. if (Animation.AllowMatricesInterpolation) {
  3651. return this.matrixInterpolateFunction(startValue, endValue, gradient, state.workValue);
  3652. }
  3653. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3654. return startValue;
  3655. }
  3656. default:
  3657. break;
  3658. }
  3659. break;
  3660. }
  3661. }
  3662. return this._getKeyValue(keys[keys.length - 1].value);
  3663. };
  3664. /**
  3665. * Defines the function to use to interpolate matrices
  3666. * @param startValue defines the start matrix
  3667. * @param endValue defines the end matrix
  3668. * @param gradient defines the gradient between both matrices
  3669. * @param result defines an optional target matrix where to store the interpolation
  3670. * @returns the interpolated matrix
  3671. */
  3672. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3673. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3674. if (result) {
  3675. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3676. return result;
  3677. }
  3678. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3679. }
  3680. if (result) {
  3681. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3682. return result;
  3683. }
  3684. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3685. };
  3686. /**
  3687. * Makes a copy of the animation
  3688. * @returns Cloned animation
  3689. */
  3690. Animation.prototype.clone = function () {
  3691. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3692. clone.enableBlending = this.enableBlending;
  3693. clone.blendingSpeed = this.blendingSpeed;
  3694. if (this._keys) {
  3695. clone.setKeys(this._keys);
  3696. }
  3697. if (this._ranges) {
  3698. clone._ranges = {};
  3699. for (var name in this._ranges) {
  3700. var range = this._ranges[name];
  3701. if (!range) {
  3702. continue;
  3703. }
  3704. clone._ranges[name] = range.clone();
  3705. }
  3706. }
  3707. return clone;
  3708. };
  3709. /**
  3710. * Sets the key frames of the animation
  3711. * @param values The animation key frames to set
  3712. */
  3713. Animation.prototype.setKeys = function (values) {
  3714. this._keys = values.slice(0);
  3715. };
  3716. /**
  3717. * Serializes the animation to an object
  3718. * @returns Serialized object
  3719. */
  3720. Animation.prototype.serialize = function () {
  3721. var serializationObject = {};
  3722. serializationObject.name = this.name;
  3723. serializationObject.property = this.targetProperty;
  3724. serializationObject.framePerSecond = this.framePerSecond;
  3725. serializationObject.dataType = this.dataType;
  3726. serializationObject.loopBehavior = this.loopMode;
  3727. serializationObject.enableBlending = this.enableBlending;
  3728. serializationObject.blendingSpeed = this.blendingSpeed;
  3729. var dataType = this.dataType;
  3730. serializationObject.keys = [];
  3731. var keys = this.getKeys();
  3732. for (var index = 0; index < keys.length; index++) {
  3733. var animationKey = keys[index];
  3734. var key = {};
  3735. key.frame = animationKey.frame;
  3736. switch (dataType) {
  3737. case Animation.ANIMATIONTYPE_FLOAT:
  3738. key.values = [animationKey.value];
  3739. break;
  3740. case Animation.ANIMATIONTYPE_QUATERNION:
  3741. case Animation.ANIMATIONTYPE_MATRIX:
  3742. case Animation.ANIMATIONTYPE_VECTOR3:
  3743. case Animation.ANIMATIONTYPE_COLOR3:
  3744. key.values = animationKey.value.asArray();
  3745. break;
  3746. }
  3747. serializationObject.keys.push(key);
  3748. }
  3749. serializationObject.ranges = [];
  3750. for (var name in this._ranges) {
  3751. var source = this._ranges[name];
  3752. if (!source) {
  3753. continue;
  3754. }
  3755. var range = {};
  3756. range.name = name;
  3757. range.from = source.from;
  3758. range.to = source.to;
  3759. serializationObject.ranges.push(range);
  3760. }
  3761. return serializationObject;
  3762. };
  3763. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3764. /**
  3765. * Get the float animation type
  3766. */
  3767. get: function () {
  3768. return Animation._ANIMATIONTYPE_FLOAT;
  3769. },
  3770. enumerable: true,
  3771. configurable: true
  3772. });
  3773. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3774. /**
  3775. * Get the Vector3 animation type
  3776. */
  3777. get: function () {
  3778. return Animation._ANIMATIONTYPE_VECTOR3;
  3779. },
  3780. enumerable: true,
  3781. configurable: true
  3782. });
  3783. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3784. /**
  3785. * Get the Vector2 animation type
  3786. */
  3787. get: function () {
  3788. return Animation._ANIMATIONTYPE_VECTOR2;
  3789. },
  3790. enumerable: true,
  3791. configurable: true
  3792. });
  3793. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3794. /**
  3795. * Get the Size animation type
  3796. */
  3797. get: function () {
  3798. return Animation._ANIMATIONTYPE_SIZE;
  3799. },
  3800. enumerable: true,
  3801. configurable: true
  3802. });
  3803. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3804. /**
  3805. * Get the Quaternion animation type
  3806. */
  3807. get: function () {
  3808. return Animation._ANIMATIONTYPE_QUATERNION;
  3809. },
  3810. enumerable: true,
  3811. configurable: true
  3812. });
  3813. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3814. /**
  3815. * Get the Matrix animation type
  3816. */
  3817. get: function () {
  3818. return Animation._ANIMATIONTYPE_MATRIX;
  3819. },
  3820. enumerable: true,
  3821. configurable: true
  3822. });
  3823. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3824. /**
  3825. * Get the Color3 animation type
  3826. */
  3827. get: function () {
  3828. return Animation._ANIMATIONTYPE_COLOR3;
  3829. },
  3830. enumerable: true,
  3831. configurable: true
  3832. });
  3833. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3834. /**
  3835. * Get the Relative Loop Mode
  3836. */
  3837. get: function () {
  3838. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3839. },
  3840. enumerable: true,
  3841. configurable: true
  3842. });
  3843. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3844. /**
  3845. * Get the Cycle Loop Mode
  3846. */
  3847. get: function () {
  3848. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3849. },
  3850. enumerable: true,
  3851. configurable: true
  3852. });
  3853. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3854. /**
  3855. * Get the Constant Loop Mode
  3856. */
  3857. get: function () {
  3858. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3859. },
  3860. enumerable: true,
  3861. configurable: true
  3862. });
  3863. /** @hidden */
  3864. Animation._UniversalLerp = function (left, right, amount) {
  3865. var constructor = left.constructor;
  3866. if (constructor.Lerp) { // Lerp supported
  3867. return constructor.Lerp(left, right, amount);
  3868. }
  3869. else if (constructor.Slerp) { // Slerp supported
  3870. return constructor.Slerp(left, right, amount);
  3871. }
  3872. else if (left.toFixed) { // Number
  3873. return left * (1.0 - amount) + amount * right;
  3874. }
  3875. else { // Blending not supported
  3876. return right;
  3877. }
  3878. };
  3879. /**
  3880. * Parses an animation object and creates an animation
  3881. * @param parsedAnimation Parsed animation object
  3882. * @returns Animation object
  3883. */
  3884. Animation.Parse = function (parsedAnimation) {
  3885. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3886. var dataType = parsedAnimation.dataType;
  3887. var keys = [];
  3888. var data;
  3889. var index;
  3890. if (parsedAnimation.enableBlending) {
  3891. animation.enableBlending = parsedAnimation.enableBlending;
  3892. }
  3893. if (parsedAnimation.blendingSpeed) {
  3894. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3895. }
  3896. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3897. var key = parsedAnimation.keys[index];
  3898. var inTangent;
  3899. var outTangent;
  3900. switch (dataType) {
  3901. case Animation.ANIMATIONTYPE_FLOAT:
  3902. data = key.values[0];
  3903. if (key.values.length >= 1) {
  3904. inTangent = key.values[1];
  3905. }
  3906. if (key.values.length >= 2) {
  3907. outTangent = key.values[2];
  3908. }
  3909. break;
  3910. case Animation.ANIMATIONTYPE_QUATERNION:
  3911. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3912. if (key.values.length >= 8) {
  3913. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3914. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3915. inTangent = _inTangent;
  3916. }
  3917. }
  3918. if (key.values.length >= 12) {
  3919. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3920. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3921. outTangent = _outTangent;
  3922. }
  3923. }
  3924. break;
  3925. case Animation.ANIMATIONTYPE_MATRIX:
  3926. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3927. break;
  3928. case Animation.ANIMATIONTYPE_COLOR3:
  3929. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3930. break;
  3931. case Animation.ANIMATIONTYPE_VECTOR3:
  3932. default:
  3933. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3934. break;
  3935. }
  3936. var keyData = {};
  3937. keyData.frame = key.frame;
  3938. keyData.value = data;
  3939. if (inTangent != undefined) {
  3940. keyData.inTangent = inTangent;
  3941. }
  3942. if (outTangent != undefined) {
  3943. keyData.outTangent = outTangent;
  3944. }
  3945. keys.push(keyData);
  3946. }
  3947. animation.setKeys(keys);
  3948. if (parsedAnimation.ranges) {
  3949. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3950. data = parsedAnimation.ranges[index];
  3951. animation.createRange(data.name, data.from, data.to);
  3952. }
  3953. }
  3954. return animation;
  3955. };
  3956. /**
  3957. * Appends the serialized animations from the source animations
  3958. * @param source Source containing the animations
  3959. * @param destination Target to store the animations
  3960. */
  3961. Animation.AppendSerializedAnimations = function (source, destination) {
  3962. _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3963. };
  3964. /**
  3965. * Use matrix interpolation instead of using direct key value when animating matrices
  3966. */
  3967. Animation.AllowMatricesInterpolation = false;
  3968. /**
  3969. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3970. */
  3971. Animation.AllowMatrixDecomposeForInterpolation = true;
  3972. // Statics
  3973. /**
  3974. * Float animation type
  3975. */
  3976. Animation._ANIMATIONTYPE_FLOAT = 0;
  3977. /**
  3978. * Vector3 animation type
  3979. */
  3980. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3981. /**
  3982. * Quaternion animation type
  3983. */
  3984. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3985. /**
  3986. * Matrix animation type
  3987. */
  3988. Animation._ANIMATIONTYPE_MATRIX = 3;
  3989. /**
  3990. * Color3 animation type
  3991. */
  3992. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3993. /**
  3994. * Vector2 animation type
  3995. */
  3996. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3997. /**
  3998. * Size animation type
  3999. */
  4000. Animation._ANIMATIONTYPE_SIZE = 6;
  4001. /**
  4002. * Relative Loop Mode
  4003. */
  4004. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  4005. /**
  4006. * Cycle Loop Mode
  4007. */
  4008. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  4009. /**
  4010. * Constant Loop Mode
  4011. */
  4012. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  4013. return Animation;
  4014. }());
  4015. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Animation"] = Animation;
  4016. _node__WEBPACK_IMPORTED_MODULE_6__["Node"]._AnimationRangeFactory = function (name, from, to) { return new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to); };
  4017. /***/ }),
  4018. /***/ "./Animations/animationEvent.ts":
  4019. /*!**************************************!*\
  4020. !*** ./Animations/animationEvent.ts ***!
  4021. \**************************************/
  4022. /*! exports provided: AnimationEvent */
  4023. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4024. "use strict";
  4025. __webpack_require__.r(__webpack_exports__);
  4026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  4027. /**
  4028. * Composed of a frame, and an action function
  4029. */
  4030. var AnimationEvent = /** @class */ (function () {
  4031. /**
  4032. * Initializes the animation event
  4033. * @param frame The frame for which the event is triggered
  4034. * @param action The event to perform when triggered
  4035. * @param onlyOnce Specifies if the event should be triggered only once
  4036. */
  4037. function AnimationEvent(
  4038. /** The frame for which the event is triggered **/
  4039. frame,
  4040. /** The event to perform when triggered **/
  4041. action,
  4042. /** Specifies if the event should be triggered only once**/
  4043. onlyOnce) {
  4044. this.frame = frame;
  4045. this.action = action;
  4046. this.onlyOnce = onlyOnce;
  4047. /**
  4048. * Specifies if the animation event is done
  4049. */
  4050. this.isDone = false;
  4051. }
  4052. /** @hidden */
  4053. AnimationEvent.prototype._clone = function () {
  4054. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  4055. };
  4056. return AnimationEvent;
  4057. }());
  4058. /***/ }),
  4059. /***/ "./Animations/animationGroup.ts":
  4060. /*!**************************************!*\
  4061. !*** ./Animations/animationGroup.ts ***!
  4062. \**************************************/
  4063. /*! exports provided: TargetedAnimation, AnimationGroup */
  4064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4065. "use strict";
  4066. __webpack_require__.r(__webpack_exports__);
  4067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  4068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  4069. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4070. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  4071. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  4072. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  4073. /**
  4074. * This class defines the direct association between an animation and a target
  4075. */
  4076. var TargetedAnimation = /** @class */ (function () {
  4077. function TargetedAnimation() {
  4078. }
  4079. return TargetedAnimation;
  4080. }());
  4081. /**
  4082. * Use this class to create coordinated animations on multiple targets
  4083. */
  4084. var AnimationGroup = /** @class */ (function () {
  4085. /**
  4086. * Instantiates a new Animation Group.
  4087. * This helps managing several animations at once.
  4088. * @see http://doc.babylonjs.com/how_to/group
  4089. * @param name Defines the name of the group
  4090. * @param scene Defines the scene the group belongs to
  4091. */
  4092. function AnimationGroup(
  4093. /** The name of the animation group */
  4094. name, scene) {
  4095. if (scene === void 0) { scene = null; }
  4096. this.name = name;
  4097. this._targetedAnimations = new Array();
  4098. this._animatables = new Array();
  4099. this._from = Number.MAX_VALUE;
  4100. this._to = -Number.MAX_VALUE;
  4101. this._speedRatio = 1;
  4102. this._loopAnimation = false;
  4103. /**
  4104. * This observable will notify when one animation have ended
  4105. */
  4106. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4107. /**
  4108. * Observer raised when one animation loops
  4109. */
  4110. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4111. /**
  4112. * This observable will notify when all animations have ended.
  4113. */
  4114. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4115. /**
  4116. * This observable will notify when all animations have paused.
  4117. */
  4118. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4119. /**
  4120. * This observable will notify when all animations are playing.
  4121. */
  4122. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4123. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  4124. this.uniqueId = this._scene.getUniqueId();
  4125. this._scene.animationGroups.push(this);
  4126. }
  4127. Object.defineProperty(AnimationGroup.prototype, "from", {
  4128. /**
  4129. * Gets the first frame
  4130. */
  4131. get: function () {
  4132. return this._from;
  4133. },
  4134. enumerable: true,
  4135. configurable: true
  4136. });
  4137. Object.defineProperty(AnimationGroup.prototype, "to", {
  4138. /**
  4139. * Gets the last frame
  4140. */
  4141. get: function () {
  4142. return this._to;
  4143. },
  4144. enumerable: true,
  4145. configurable: true
  4146. });
  4147. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  4148. /**
  4149. * Define if the animations are started
  4150. */
  4151. get: function () {
  4152. return this._isStarted;
  4153. },
  4154. enumerable: true,
  4155. configurable: true
  4156. });
  4157. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  4158. /**
  4159. * Gets a value indicating that the current group is playing
  4160. */
  4161. get: function () {
  4162. return this._isStarted && !this._isPaused;
  4163. },
  4164. enumerable: true,
  4165. configurable: true
  4166. });
  4167. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  4168. /**
  4169. * Gets or sets the speed ratio to use for all animations
  4170. */
  4171. get: function () {
  4172. return this._speedRatio;
  4173. },
  4174. /**
  4175. * Gets or sets the speed ratio to use for all animations
  4176. */
  4177. set: function (value) {
  4178. if (this._speedRatio === value) {
  4179. return;
  4180. }
  4181. this._speedRatio = value;
  4182. for (var index = 0; index < this._animatables.length; index++) {
  4183. var animatable = this._animatables[index];
  4184. animatable.speedRatio = this._speedRatio;
  4185. }
  4186. },
  4187. enumerable: true,
  4188. configurable: true
  4189. });
  4190. Object.defineProperty(AnimationGroup.prototype, "loopAnimation", {
  4191. /**
  4192. * Gets or sets if all animations should loop or not
  4193. */
  4194. get: function () {
  4195. return this._loopAnimation;
  4196. },
  4197. set: function (value) {
  4198. if (this._loopAnimation === value) {
  4199. return;
  4200. }
  4201. this._loopAnimation = value;
  4202. for (var index = 0; index < this._animatables.length; index++) {
  4203. var animatable = this._animatables[index];
  4204. animatable.loopAnimation = this._loopAnimation;
  4205. }
  4206. },
  4207. enumerable: true,
  4208. configurable: true
  4209. });
  4210. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  4211. /**
  4212. * Gets the targeted animations for this animation group
  4213. */
  4214. get: function () {
  4215. return this._targetedAnimations;
  4216. },
  4217. enumerable: true,
  4218. configurable: true
  4219. });
  4220. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  4221. /**
  4222. * returning the list of animatables controlled by this animation group.
  4223. */
  4224. get: function () {
  4225. return this._animatables;
  4226. },
  4227. enumerable: true,
  4228. configurable: true
  4229. });
  4230. /**
  4231. * Add an animation (with its target) in the group
  4232. * @param animation defines the animation we want to add
  4233. * @param target defines the target of the animation
  4234. * @returns the TargetedAnimation object
  4235. */
  4236. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  4237. var targetedAnimation = {
  4238. animation: animation,
  4239. target: target
  4240. };
  4241. var keys = animation.getKeys();
  4242. if (this._from > keys[0].frame) {
  4243. this._from = keys[0].frame;
  4244. }
  4245. if (this._to < keys[keys.length - 1].frame) {
  4246. this._to = keys[keys.length - 1].frame;
  4247. }
  4248. this._targetedAnimations.push(targetedAnimation);
  4249. return targetedAnimation;
  4250. };
  4251. /**
  4252. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4253. * It can add constant keys at begin or end
  4254. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4255. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4256. * @returns the animation group
  4257. */
  4258. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  4259. if (beginFrame === void 0) { beginFrame = null; }
  4260. if (endFrame === void 0) { endFrame = null; }
  4261. if (beginFrame == null) {
  4262. beginFrame = this._from;
  4263. }
  4264. if (endFrame == null) {
  4265. endFrame = this._to;
  4266. }
  4267. for (var index = 0; index < this._targetedAnimations.length; index++) {
  4268. var targetedAnimation = this._targetedAnimations[index];
  4269. var keys = targetedAnimation.animation.getKeys();
  4270. var startKey = keys[0];
  4271. var endKey = keys[keys.length - 1];
  4272. if (startKey.frame > beginFrame) {
  4273. var newKey = {
  4274. frame: beginFrame,
  4275. value: startKey.value,
  4276. inTangent: startKey.inTangent,
  4277. outTangent: startKey.outTangent,
  4278. interpolation: startKey.interpolation
  4279. };
  4280. keys.splice(0, 0, newKey);
  4281. }
  4282. if (endKey.frame < endFrame) {
  4283. var newKey = {
  4284. frame: endFrame,
  4285. value: endKey.value,
  4286. inTangent: endKey.outTangent,
  4287. outTangent: endKey.outTangent,
  4288. interpolation: endKey.interpolation
  4289. };
  4290. keys.push(newKey);
  4291. }
  4292. }
  4293. this._from = beginFrame;
  4294. this._to = endFrame;
  4295. return this;
  4296. };
  4297. /**
  4298. * Start all animations on given targets
  4299. * @param loop defines if animations must loop
  4300. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4301. * @param from defines the from key (optional)
  4302. * @param to defines the to key (optional)
  4303. * @returns the current animation group
  4304. */
  4305. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4306. var _this = this;
  4307. if (loop === void 0) { loop = false; }
  4308. if (speedRatio === void 0) { speedRatio = 1; }
  4309. if (this._isStarted || this._targetedAnimations.length === 0) {
  4310. return this;
  4311. }
  4312. this._loopAnimation = loop;
  4313. var _loop_1 = function (targetedAnimation) {
  4314. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4315. animatable.onAnimationEnd = function () {
  4316. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4317. _this._checkAnimationGroupEnded(animatable);
  4318. };
  4319. animatable.onAnimationLoop = function () {
  4320. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4321. };
  4322. this_1._animatables.push(animatable);
  4323. };
  4324. var this_1 = this;
  4325. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4326. var targetedAnimation = _a[_i];
  4327. _loop_1(targetedAnimation);
  4328. }
  4329. this._speedRatio = speedRatio;
  4330. if (from !== undefined && to !== undefined) {
  4331. if (from < to && this._speedRatio < 0) {
  4332. var temp = to;
  4333. to = from;
  4334. from = temp;
  4335. }
  4336. else if (from > to && this._speedRatio > 0) {
  4337. this._speedRatio = -speedRatio;
  4338. }
  4339. }
  4340. this._isStarted = true;
  4341. this._isPaused = false;
  4342. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4343. return this;
  4344. };
  4345. /**
  4346. * Pause all animations
  4347. * @returns the animation group
  4348. */
  4349. AnimationGroup.prototype.pause = function () {
  4350. if (!this._isStarted) {
  4351. return this;
  4352. }
  4353. this._isPaused = true;
  4354. for (var index = 0; index < this._animatables.length; index++) {
  4355. var animatable = this._animatables[index];
  4356. animatable.pause();
  4357. }
  4358. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4359. return this;
  4360. };
  4361. /**
  4362. * Play all animations to initial state
  4363. * This function will start() the animations if they were not started or will restart() them if they were paused
  4364. * @param loop defines if animations must loop
  4365. * @returns the animation group
  4366. */
  4367. AnimationGroup.prototype.play = function (loop) {
  4368. // only if all animatables are ready and exist
  4369. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4370. if (loop !== undefined) {
  4371. this.loopAnimation = loop;
  4372. }
  4373. this.restart();
  4374. }
  4375. else {
  4376. this.stop();
  4377. this.start(loop, this._speedRatio);
  4378. }
  4379. this._isPaused = false;
  4380. return this;
  4381. };
  4382. /**
  4383. * Reset all animations to initial state
  4384. * @returns the animation group
  4385. */
  4386. AnimationGroup.prototype.reset = function () {
  4387. if (!this._isStarted) {
  4388. return this;
  4389. }
  4390. for (var index = 0; index < this._animatables.length; index++) {
  4391. var animatable = this._animatables[index];
  4392. animatable.reset();
  4393. }
  4394. return this;
  4395. };
  4396. /**
  4397. * Restart animations from key 0
  4398. * @returns the animation group
  4399. */
  4400. AnimationGroup.prototype.restart = function () {
  4401. if (!this._isStarted) {
  4402. return this;
  4403. }
  4404. for (var index = 0; index < this._animatables.length; index++) {
  4405. var animatable = this._animatables[index];
  4406. animatable.restart();
  4407. }
  4408. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4409. return this;
  4410. };
  4411. /**
  4412. * Stop all animations
  4413. * @returns the animation group
  4414. */
  4415. AnimationGroup.prototype.stop = function () {
  4416. if (!this._isStarted) {
  4417. return this;
  4418. }
  4419. var list = this._animatables.slice();
  4420. for (var index = 0; index < list.length; index++) {
  4421. list[index].stop();
  4422. }
  4423. this._isStarted = false;
  4424. return this;
  4425. };
  4426. /**
  4427. * Set animation weight for all animatables
  4428. * @param weight defines the weight to use
  4429. * @return the animationGroup
  4430. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4431. */
  4432. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4433. for (var index = 0; index < this._animatables.length; index++) {
  4434. var animatable = this._animatables[index];
  4435. animatable.weight = weight;
  4436. }
  4437. return this;
  4438. };
  4439. /**
  4440. * Synchronize and normalize all animatables with a source animatable
  4441. * @param root defines the root animatable to synchronize with
  4442. * @return the animationGroup
  4443. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4444. */
  4445. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4446. for (var index = 0; index < this._animatables.length; index++) {
  4447. var animatable = this._animatables[index];
  4448. animatable.syncWith(root);
  4449. }
  4450. return this;
  4451. };
  4452. /**
  4453. * Goes to a specific frame in this animation group
  4454. * @param frame the frame number to go to
  4455. * @return the animationGroup
  4456. */
  4457. AnimationGroup.prototype.goToFrame = function (frame) {
  4458. if (!this._isStarted) {
  4459. return this;
  4460. }
  4461. for (var index = 0; index < this._animatables.length; index++) {
  4462. var animatable = this._animatables[index];
  4463. animatable.goToFrame(frame);
  4464. }
  4465. return this;
  4466. };
  4467. /**
  4468. * Dispose all associated resources
  4469. */
  4470. AnimationGroup.prototype.dispose = function () {
  4471. this._targetedAnimations = [];
  4472. this._animatables = [];
  4473. var index = this._scene.animationGroups.indexOf(this);
  4474. if (index > -1) {
  4475. this._scene.animationGroups.splice(index, 1);
  4476. }
  4477. this.onAnimationEndObservable.clear();
  4478. this.onAnimationGroupEndObservable.clear();
  4479. this.onAnimationGroupPauseObservable.clear();
  4480. this.onAnimationGroupPlayObservable.clear();
  4481. this.onAnimationLoopObservable.clear();
  4482. };
  4483. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4484. // animatable should be taken out of the array
  4485. var idx = this._animatables.indexOf(animatable);
  4486. if (idx > -1) {
  4487. this._animatables.splice(idx, 1);
  4488. }
  4489. // all animatables were removed? animation group ended!
  4490. if (this._animatables.length === 0) {
  4491. this._isStarted = false;
  4492. this.onAnimationGroupEndObservable.notifyObservers(this);
  4493. }
  4494. };
  4495. /**
  4496. * Clone the current animation group and returns a copy
  4497. * @param newName defines the name of the new group
  4498. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  4499. * @returns the new aniamtion group
  4500. */
  4501. AnimationGroup.prototype.clone = function (newName, targetConverter) {
  4502. var newGroup = new AnimationGroup(newName || this.name, this._scene);
  4503. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4504. var targetAnimation = _a[_i];
  4505. newGroup.addTargetedAnimation(targetAnimation.animation.clone(), targetConverter ? targetConverter(targetAnimation.target) : targetAnimation.target);
  4506. }
  4507. return newGroup;
  4508. };
  4509. // Statics
  4510. /**
  4511. * Returns a new AnimationGroup object parsed from the source provided.
  4512. * @param parsedAnimationGroup defines the source
  4513. * @param scene defines the scene that will receive the animationGroup
  4514. * @returns a new AnimationGroup
  4515. */
  4516. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4517. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4518. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4519. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4520. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4521. var id = targetedAnimation.targetId;
  4522. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4523. var morphTarget = scene.getMorphTargetById(id);
  4524. if (morphTarget) {
  4525. animationGroup.addTargetedAnimation(animation, morphTarget);
  4526. }
  4527. }
  4528. else {
  4529. var targetNode = scene.getNodeByID(id);
  4530. if (targetNode != null) {
  4531. animationGroup.addTargetedAnimation(animation, targetNode);
  4532. }
  4533. }
  4534. }
  4535. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4536. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4537. }
  4538. return animationGroup;
  4539. };
  4540. /**
  4541. * Returns the string "AnimationGroup"
  4542. * @returns "AnimationGroup"
  4543. */
  4544. AnimationGroup.prototype.getClassName = function () {
  4545. return "AnimationGroup";
  4546. };
  4547. /**
  4548. * Creates a detailled string about the object
  4549. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4550. * @returns a string representing the object
  4551. */
  4552. AnimationGroup.prototype.toString = function (fullDetails) {
  4553. var ret = "Name: " + this.name;
  4554. ret += ", type: " + this.getClassName();
  4555. if (fullDetails) {
  4556. ret += ", from: " + this._from;
  4557. ret += ", to: " + this._to;
  4558. ret += ", isStarted: " + this._isStarted;
  4559. ret += ", speedRatio: " + this._speedRatio;
  4560. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4561. ret += ", animatables length: " + this._animatables;
  4562. }
  4563. return ret;
  4564. };
  4565. return AnimationGroup;
  4566. }());
  4567. /***/ }),
  4568. /***/ "./Animations/animationKey.ts":
  4569. /*!************************************!*\
  4570. !*** ./Animations/animationKey.ts ***!
  4571. \************************************/
  4572. /*! exports provided: AnimationKeyInterpolation */
  4573. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4574. "use strict";
  4575. __webpack_require__.r(__webpack_exports__);
  4576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4577. /**
  4578. * Enum for the animation key frame interpolation type
  4579. */
  4580. var AnimationKeyInterpolation;
  4581. (function (AnimationKeyInterpolation) {
  4582. /**
  4583. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4584. */
  4585. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4586. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4587. /***/ }),
  4588. /***/ "./Animations/animationPropertiesOverride.ts":
  4589. /*!***************************************************!*\
  4590. !*** ./Animations/animationPropertiesOverride.ts ***!
  4591. \***************************************************/
  4592. /*! exports provided: AnimationPropertiesOverride */
  4593. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4594. "use strict";
  4595. __webpack_require__.r(__webpack_exports__);
  4596. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4597. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4598. /**
  4599. * Class used to override all child animations of a given target
  4600. */
  4601. var AnimationPropertiesOverride = /** @class */ (function () {
  4602. function AnimationPropertiesOverride() {
  4603. /**
  4604. * Gets or sets a value indicating if animation blending must be used
  4605. */
  4606. this.enableBlending = false;
  4607. /**
  4608. * Gets or sets the blending speed to use when enableBlending is true
  4609. */
  4610. this.blendingSpeed = 0.01;
  4611. /**
  4612. * Gets or sets the default loop mode to use
  4613. */
  4614. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4615. }
  4616. return AnimationPropertiesOverride;
  4617. }());
  4618. /***/ }),
  4619. /***/ "./Animations/animationRange.ts":
  4620. /*!**************************************!*\
  4621. !*** ./Animations/animationRange.ts ***!
  4622. \**************************************/
  4623. /*! exports provided: AnimationRange */
  4624. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4625. "use strict";
  4626. __webpack_require__.r(__webpack_exports__);
  4627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4628. /**
  4629. * Represents the range of an animation
  4630. */
  4631. var AnimationRange = /** @class */ (function () {
  4632. /**
  4633. * Initializes the range of an animation
  4634. * @param name The name of the animation range
  4635. * @param from The starting frame of the animation
  4636. * @param to The ending frame of the animation
  4637. */
  4638. function AnimationRange(
  4639. /**The name of the animation range**/
  4640. name,
  4641. /**The starting frame of the animation */
  4642. from,
  4643. /**The ending frame of the animation*/
  4644. to) {
  4645. this.name = name;
  4646. this.from = from;
  4647. this.to = to;
  4648. }
  4649. /**
  4650. * Makes a copy of the animation range
  4651. * @returns A copy of the animation range
  4652. */
  4653. AnimationRange.prototype.clone = function () {
  4654. return new AnimationRange(this.name, this.from, this.to);
  4655. };
  4656. return AnimationRange;
  4657. }());
  4658. /***/ }),
  4659. /***/ "./Animations/easing.ts":
  4660. /*!******************************!*\
  4661. !*** ./Animations/easing.ts ***!
  4662. \******************************/
  4663. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4665. "use strict";
  4666. __webpack_require__.r(__webpack_exports__);
  4667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4671. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4672. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4673. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4676. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4677. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4680. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4681. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4682. /**
  4683. * Base class used for every default easing function.
  4684. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4685. */
  4686. var EasingFunction = /** @class */ (function () {
  4687. function EasingFunction() {
  4688. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4689. }
  4690. /**
  4691. * Sets the easing mode of the current function.
  4692. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4693. */
  4694. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4695. var n = Math.min(Math.max(easingMode, 0), 2);
  4696. this._easingMode = n;
  4697. };
  4698. /**
  4699. * Gets the current easing mode.
  4700. * @returns the easing mode
  4701. */
  4702. EasingFunction.prototype.getEasingMode = function () {
  4703. return this._easingMode;
  4704. };
  4705. /**
  4706. * @hidden
  4707. */
  4708. EasingFunction.prototype.easeInCore = function (gradient) {
  4709. throw new Error('You must implement this method');
  4710. };
  4711. /**
  4712. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4713. * of the easing function.
  4714. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4715. * @returns the corresponding value on the curve defined by the easing function
  4716. */
  4717. EasingFunction.prototype.ease = function (gradient) {
  4718. switch (this._easingMode) {
  4719. case EasingFunction.EASINGMODE_EASEIN:
  4720. return this.easeInCore(gradient);
  4721. case EasingFunction.EASINGMODE_EASEOUT:
  4722. return (1 - this.easeInCore(1 - gradient));
  4723. }
  4724. if (gradient >= 0.5) {
  4725. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4726. }
  4727. return (this.easeInCore(gradient * 2) * 0.5);
  4728. };
  4729. /**
  4730. * Interpolation follows the mathematical formula associated with the easing function.
  4731. */
  4732. EasingFunction.EASINGMODE_EASEIN = 0;
  4733. /**
  4734. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4735. */
  4736. EasingFunction.EASINGMODE_EASEOUT = 1;
  4737. /**
  4738. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4739. */
  4740. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4741. return EasingFunction;
  4742. }());
  4743. /**
  4744. * Easing function with a circle shape (see link below).
  4745. * @see https://easings.net/#easeInCirc
  4746. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4747. */
  4748. var CircleEase = /** @class */ (function (_super) {
  4749. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4750. function CircleEase() {
  4751. return _super !== null && _super.apply(this, arguments) || this;
  4752. }
  4753. /** @hidden */
  4754. CircleEase.prototype.easeInCore = function (gradient) {
  4755. gradient = Math.max(0, Math.min(1, gradient));
  4756. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4757. };
  4758. return CircleEase;
  4759. }(EasingFunction));
  4760. /**
  4761. * Easing function with a ease back shape (see link below).
  4762. * @see https://easings.net/#easeInBack
  4763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4764. */
  4765. var BackEase = /** @class */ (function (_super) {
  4766. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4767. /**
  4768. * Instantiates a back ease easing
  4769. * @see https://easings.net/#easeInBack
  4770. * @param amplitude Defines the amplitude of the function
  4771. */
  4772. function BackEase(
  4773. /** Defines the amplitude of the function */
  4774. amplitude) {
  4775. if (amplitude === void 0) { amplitude = 1; }
  4776. var _this = _super.call(this) || this;
  4777. _this.amplitude = amplitude;
  4778. return _this;
  4779. }
  4780. /** @hidden */
  4781. BackEase.prototype.easeInCore = function (gradient) {
  4782. var num = Math.max(0, this.amplitude);
  4783. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4784. };
  4785. return BackEase;
  4786. }(EasingFunction));
  4787. /**
  4788. * Easing function with a bouncing shape (see link below).
  4789. * @see https://easings.net/#easeInBounce
  4790. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4791. */
  4792. var BounceEase = /** @class */ (function (_super) {
  4793. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4794. /**
  4795. * Instantiates a bounce easing
  4796. * @see https://easings.net/#easeInBounce
  4797. * @param bounces Defines the number of bounces
  4798. * @param bounciness Defines the amplitude of the bounce
  4799. */
  4800. function BounceEase(
  4801. /** Defines the number of bounces */
  4802. bounces,
  4803. /** Defines the amplitude of the bounce */
  4804. bounciness) {
  4805. if (bounces === void 0) { bounces = 3; }
  4806. if (bounciness === void 0) { bounciness = 2; }
  4807. var _this = _super.call(this) || this;
  4808. _this.bounces = bounces;
  4809. _this.bounciness = bounciness;
  4810. return _this;
  4811. }
  4812. /** @hidden */
  4813. BounceEase.prototype.easeInCore = function (gradient) {
  4814. var y = Math.max(0.0, this.bounces);
  4815. var bounciness = this.bounciness;
  4816. if (bounciness <= 1.0) {
  4817. bounciness = 1.001;
  4818. }
  4819. var num9 = Math.pow(bounciness, y);
  4820. var num5 = 1.0 - bounciness;
  4821. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4822. var num15 = gradient * num4;
  4823. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4824. var num3 = Math.floor(num65);
  4825. var num13 = num3 + 1.0;
  4826. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4827. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4828. var num7 = (num8 + num12) * 0.5;
  4829. var num6 = gradient - num7;
  4830. var num2 = num7 - num8;
  4831. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4832. };
  4833. return BounceEase;
  4834. }(EasingFunction));
  4835. /**
  4836. * Easing function with a power of 3 shape (see link below).
  4837. * @see https://easings.net/#easeInCubic
  4838. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4839. */
  4840. var CubicEase = /** @class */ (function (_super) {
  4841. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4842. function CubicEase() {
  4843. return _super !== null && _super.apply(this, arguments) || this;
  4844. }
  4845. /** @hidden */
  4846. CubicEase.prototype.easeInCore = function (gradient) {
  4847. return (gradient * gradient * gradient);
  4848. };
  4849. return CubicEase;
  4850. }(EasingFunction));
  4851. /**
  4852. * Easing function with an elastic shape (see link below).
  4853. * @see https://easings.net/#easeInElastic
  4854. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4855. */
  4856. var ElasticEase = /** @class */ (function (_super) {
  4857. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4858. /**
  4859. * Instantiates an elastic easing function
  4860. * @see https://easings.net/#easeInElastic
  4861. * @param oscillations Defines the number of oscillations
  4862. * @param springiness Defines the amplitude of the oscillations
  4863. */
  4864. function ElasticEase(
  4865. /** Defines the number of oscillations*/
  4866. oscillations,
  4867. /** Defines the amplitude of the oscillations*/
  4868. springiness) {
  4869. if (oscillations === void 0) { oscillations = 3; }
  4870. if (springiness === void 0) { springiness = 3; }
  4871. var _this = _super.call(this) || this;
  4872. _this.oscillations = oscillations;
  4873. _this.springiness = springiness;
  4874. return _this;
  4875. }
  4876. /** @hidden */
  4877. ElasticEase.prototype.easeInCore = function (gradient) {
  4878. var num2;
  4879. var num3 = Math.max(0.0, this.oscillations);
  4880. var num = Math.max(0.0, this.springiness);
  4881. if (num == 0) {
  4882. num2 = gradient;
  4883. }
  4884. else {
  4885. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4886. }
  4887. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4888. };
  4889. return ElasticEase;
  4890. }(EasingFunction));
  4891. /**
  4892. * Easing function with an exponential shape (see link below).
  4893. * @see https://easings.net/#easeInExpo
  4894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4895. */
  4896. var ExponentialEase = /** @class */ (function (_super) {
  4897. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4898. /**
  4899. * Instantiates an exponential easing function
  4900. * @see https://easings.net/#easeInExpo
  4901. * @param exponent Defines the exponent of the function
  4902. */
  4903. function ExponentialEase(
  4904. /** Defines the exponent of the function */
  4905. exponent) {
  4906. if (exponent === void 0) { exponent = 2; }
  4907. var _this = _super.call(this) || this;
  4908. _this.exponent = exponent;
  4909. return _this;
  4910. }
  4911. /** @hidden */
  4912. ExponentialEase.prototype.easeInCore = function (gradient) {
  4913. if (this.exponent <= 0) {
  4914. return gradient;
  4915. }
  4916. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4917. };
  4918. return ExponentialEase;
  4919. }(EasingFunction));
  4920. /**
  4921. * Easing function with a power shape (see link below).
  4922. * @see https://easings.net/#easeInQuad
  4923. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4924. */
  4925. var PowerEase = /** @class */ (function (_super) {
  4926. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4927. /**
  4928. * Instantiates an power base easing function
  4929. * @see https://easings.net/#easeInQuad
  4930. * @param power Defines the power of the function
  4931. */
  4932. function PowerEase(
  4933. /** Defines the power of the function */
  4934. power) {
  4935. if (power === void 0) { power = 2; }
  4936. var _this = _super.call(this) || this;
  4937. _this.power = power;
  4938. return _this;
  4939. }
  4940. /** @hidden */
  4941. PowerEase.prototype.easeInCore = function (gradient) {
  4942. var y = Math.max(0.0, this.power);
  4943. return Math.pow(gradient, y);
  4944. };
  4945. return PowerEase;
  4946. }(EasingFunction));
  4947. /**
  4948. * Easing function with a power of 2 shape (see link below).
  4949. * @see https://easings.net/#easeInQuad
  4950. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4951. */
  4952. var QuadraticEase = /** @class */ (function (_super) {
  4953. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4954. function QuadraticEase() {
  4955. return _super !== null && _super.apply(this, arguments) || this;
  4956. }
  4957. /** @hidden */
  4958. QuadraticEase.prototype.easeInCore = function (gradient) {
  4959. return (gradient * gradient);
  4960. };
  4961. return QuadraticEase;
  4962. }(EasingFunction));
  4963. /**
  4964. * Easing function with a power of 4 shape (see link below).
  4965. * @see https://easings.net/#easeInQuart
  4966. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4967. */
  4968. var QuarticEase = /** @class */ (function (_super) {
  4969. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4970. function QuarticEase() {
  4971. return _super !== null && _super.apply(this, arguments) || this;
  4972. }
  4973. /** @hidden */
  4974. QuarticEase.prototype.easeInCore = function (gradient) {
  4975. return (gradient * gradient * gradient * gradient);
  4976. };
  4977. return QuarticEase;
  4978. }(EasingFunction));
  4979. /**
  4980. * Easing function with a power of 5 shape (see link below).
  4981. * @see https://easings.net/#easeInQuint
  4982. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4983. */
  4984. var QuinticEase = /** @class */ (function (_super) {
  4985. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4986. function QuinticEase() {
  4987. return _super !== null && _super.apply(this, arguments) || this;
  4988. }
  4989. /** @hidden */
  4990. QuinticEase.prototype.easeInCore = function (gradient) {
  4991. return (gradient * gradient * gradient * gradient * gradient);
  4992. };
  4993. return QuinticEase;
  4994. }(EasingFunction));
  4995. /**
  4996. * Easing function with a sin shape (see link below).
  4997. * @see https://easings.net/#easeInSine
  4998. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4999. */
  5000. var SineEase = /** @class */ (function (_super) {
  5001. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  5002. function SineEase() {
  5003. return _super !== null && _super.apply(this, arguments) || this;
  5004. }
  5005. /** @hidden */
  5006. SineEase.prototype.easeInCore = function (gradient) {
  5007. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  5008. };
  5009. return SineEase;
  5010. }(EasingFunction));
  5011. /**
  5012. * Easing function with a bezier shape (see link below).
  5013. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5014. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5015. */
  5016. var BezierCurveEase = /** @class */ (function (_super) {
  5017. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  5018. /**
  5019. * Instantiates a bezier function
  5020. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5021. * @param x1 Defines the x component of the start tangent in the bezier curve
  5022. * @param y1 Defines the y component of the start tangent in the bezier curve
  5023. * @param x2 Defines the x component of the end tangent in the bezier curve
  5024. * @param y2 Defines the y component of the end tangent in the bezier curve
  5025. */
  5026. function BezierCurveEase(
  5027. /** Defines the x component of the start tangent in the bezier curve */
  5028. x1,
  5029. /** Defines the y component of the start tangent in the bezier curve */
  5030. y1,
  5031. /** Defines the x component of the end tangent in the bezier curve */
  5032. x2,
  5033. /** Defines the y component of the end tangent in the bezier curve */
  5034. y2) {
  5035. if (x1 === void 0) { x1 = 0; }
  5036. if (y1 === void 0) { y1 = 0; }
  5037. if (x2 === void 0) { x2 = 1; }
  5038. if (y2 === void 0) { y2 = 1; }
  5039. var _this = _super.call(this) || this;
  5040. _this.x1 = x1;
  5041. _this.y1 = y1;
  5042. _this.x2 = x2;
  5043. _this.y2 = y2;
  5044. return _this;
  5045. }
  5046. /** @hidden */
  5047. BezierCurveEase.prototype.easeInCore = function (gradient) {
  5048. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  5049. };
  5050. return BezierCurveEase;
  5051. }(EasingFunction));
  5052. /***/ }),
  5053. /***/ "./Animations/index.ts":
  5054. /*!*****************************!*\
  5055. !*** ./Animations/index.ts ***!
  5056. \*****************************/
  5057. /*! 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 */
  5058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5059. "use strict";
  5060. __webpack_require__.r(__webpack_exports__);
  5061. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  5062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  5063. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["_IAnimationState"]; });
  5065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  5066. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5069. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5071. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5085. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5087. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5089. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5091. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5093. /***/ }),
  5094. /***/ "./Animations/runtimeAnimation.ts":
  5095. /*!****************************************!*\
  5096. !*** ./Animations/runtimeAnimation.ts ***!
  5097. \****************************************/
  5098. /*! exports provided: RuntimeAnimation */
  5099. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5100. "use strict";
  5101. __webpack_require__.r(__webpack_exports__);
  5102. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5103. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5104. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5105. // Static values to help the garbage collector
  5106. // Quaternion
  5107. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5108. // Vector3
  5109. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5110. // Vector2
  5111. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5112. // Size
  5113. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  5114. // Color3
  5115. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  5116. /**
  5117. * Defines a runtime animation
  5118. */
  5119. var RuntimeAnimation = /** @class */ (function () {
  5120. /**
  5121. * Create a new RuntimeAnimation object
  5122. * @param target defines the target of the animation
  5123. * @param animation defines the source animation object
  5124. * @param scene defines the hosting scene
  5125. * @param host defines the initiating Animatable
  5126. */
  5127. function RuntimeAnimation(target, animation, scene, host) {
  5128. var _this = this;
  5129. this._events = new Array();
  5130. /**
  5131. * The current frame of the runtime animation
  5132. */
  5133. this._currentFrame = 0;
  5134. /**
  5135. * The original value of the runtime animation
  5136. */
  5137. this._originalValue = new Array();
  5138. /**
  5139. * The original blend value of the runtime animation
  5140. */
  5141. this._originalBlendValue = null;
  5142. /**
  5143. * The offsets cache of the runtime animation
  5144. */
  5145. this._offsetsCache = {};
  5146. /**
  5147. * The high limits cache of the runtime animation
  5148. */
  5149. this._highLimitsCache = {};
  5150. /**
  5151. * Specifies if the runtime animation has been stopped
  5152. */
  5153. this._stopped = false;
  5154. /**
  5155. * The blending factor of the runtime animation
  5156. */
  5157. this._blendingFactor = 0;
  5158. /**
  5159. * The current value of the runtime animation
  5160. */
  5161. this._currentValue = null;
  5162. this._currentActiveTarget = null;
  5163. this._directTarget = null;
  5164. /**
  5165. * The target path of the runtime animation
  5166. */
  5167. this._targetPath = "";
  5168. /**
  5169. * The weight of the runtime animation
  5170. */
  5171. this._weight = 1.0;
  5172. /**
  5173. * The ratio offset of the runtime animation
  5174. */
  5175. this._ratioOffset = 0;
  5176. /**
  5177. * The previous delay of the runtime animation
  5178. */
  5179. this._previousDelay = 0;
  5180. /**
  5181. * The previous ratio of the runtime animation
  5182. */
  5183. this._previousRatio = 0;
  5184. this._targetIsArray = false;
  5185. this._animation = animation;
  5186. this._target = target;
  5187. this._scene = scene;
  5188. this._host = host;
  5189. this._activeTargets = [];
  5190. animation._runtimeAnimations.push(this);
  5191. // State
  5192. this._animationState = {
  5193. key: 0,
  5194. repeatCount: 0,
  5195. loopMode: this._getCorrectLoopMode()
  5196. };
  5197. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX) {
  5198. this._animationState.workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5199. }
  5200. // Limits
  5201. this._keys = this._animation.getKeys();
  5202. this._minFrame = this._keys[0].frame;
  5203. this._maxFrame = this._keys[this._keys.length - 1].frame;
  5204. this._minValue = this._keys[0].value;
  5205. this._maxValue = this._keys[this._keys.length - 1].value;
  5206. // Add a start key at frame 0 if missing
  5207. if (this._minFrame !== 0) {
  5208. var newKey = { frame: 0, value: this._minValue };
  5209. this._keys.splice(0, 0, newKey);
  5210. }
  5211. // Check data
  5212. if (this._target instanceof Array) {
  5213. var index = 0;
  5214. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5215. var target_1 = _a[_i];
  5216. this._preparePath(target_1, index);
  5217. this._getOriginalValues(index);
  5218. index++;
  5219. }
  5220. this._targetIsArray = true;
  5221. }
  5222. else {
  5223. this._preparePath(this._target);
  5224. this._getOriginalValues();
  5225. this._targetIsArray = false;
  5226. this._directTarget = this._activeTargets[0];
  5227. }
  5228. // Cloning events locally
  5229. var events = animation.getEvents();
  5230. if (events && events.length > 0) {
  5231. events.forEach(function (e) {
  5232. _this._events.push(e._clone());
  5233. });
  5234. }
  5235. this._enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5236. }
  5237. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5238. /**
  5239. * Gets the current frame of the runtime animation
  5240. */
  5241. get: function () {
  5242. return this._currentFrame;
  5243. },
  5244. enumerable: true,
  5245. configurable: true
  5246. });
  5247. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5248. /**
  5249. * Gets the weight of the runtime animation
  5250. */
  5251. get: function () {
  5252. return this._weight;
  5253. },
  5254. enumerable: true,
  5255. configurable: true
  5256. });
  5257. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5258. /**
  5259. * Gets the current value of the runtime animation
  5260. */
  5261. get: function () {
  5262. return this._currentValue;
  5263. },
  5264. enumerable: true,
  5265. configurable: true
  5266. });
  5267. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5268. /**
  5269. * Gets the target path of the runtime animation
  5270. */
  5271. get: function () {
  5272. return this._targetPath;
  5273. },
  5274. enumerable: true,
  5275. configurable: true
  5276. });
  5277. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5278. /**
  5279. * Gets the actual target of the runtime animation
  5280. */
  5281. get: function () {
  5282. return this._currentActiveTarget;
  5283. },
  5284. enumerable: true,
  5285. configurable: true
  5286. });
  5287. RuntimeAnimation.prototype._preparePath = function (target, targetIndex) {
  5288. if (targetIndex === void 0) { targetIndex = 0; }
  5289. var targetPropertyPath = this._animation.targetPropertyPath;
  5290. if (targetPropertyPath.length > 1) {
  5291. var property = target[targetPropertyPath[0]];
  5292. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5293. property = property[targetPropertyPath[index]];
  5294. }
  5295. this._targetPath = targetPropertyPath[targetPropertyPath.length - 1];
  5296. this._activeTargets[targetIndex] = property;
  5297. }
  5298. else {
  5299. this._targetPath = targetPropertyPath[0];
  5300. this._activeTargets[targetIndex] = target;
  5301. }
  5302. };
  5303. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5304. /**
  5305. * Gets the animation from the runtime animation
  5306. */
  5307. get: function () {
  5308. return this._animation;
  5309. },
  5310. enumerable: true,
  5311. configurable: true
  5312. });
  5313. /**
  5314. * Resets the runtime animation to the beginning
  5315. * @param restoreOriginal defines whether to restore the target property to the original value
  5316. */
  5317. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5318. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5319. if (restoreOriginal) {
  5320. if (this._target instanceof Array) {
  5321. var index = 0;
  5322. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5323. var target = _a[_i];
  5324. if (this._originalValue[index] !== undefined) {
  5325. this._setValue(target, this._activeTargets[index], this._originalValue[index], -1, index);
  5326. }
  5327. index++;
  5328. }
  5329. }
  5330. else {
  5331. if (this._originalValue[0] !== undefined) {
  5332. this._setValue(this._target, this._directTarget, this._originalValue[0], -1, 0);
  5333. }
  5334. }
  5335. }
  5336. this._offsetsCache = {};
  5337. this._highLimitsCache = {};
  5338. this._currentFrame = 0;
  5339. this._blendingFactor = 0;
  5340. // Events
  5341. for (var index = 0; index < this._events.length; index++) {
  5342. this._events[index].isDone = false;
  5343. }
  5344. };
  5345. /**
  5346. * Specifies if the runtime animation is stopped
  5347. * @returns Boolean specifying if the runtime animation is stopped
  5348. */
  5349. RuntimeAnimation.prototype.isStopped = function () {
  5350. return this._stopped;
  5351. };
  5352. /**
  5353. * Disposes of the runtime animation
  5354. */
  5355. RuntimeAnimation.prototype.dispose = function () {
  5356. var index = this._animation.runtimeAnimations.indexOf(this);
  5357. if (index > -1) {
  5358. this._animation.runtimeAnimations.splice(index, 1);
  5359. }
  5360. };
  5361. /**
  5362. * Apply the interpolated value to the target
  5363. * @param currentValue defines the value computed by the animation
  5364. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5365. */
  5366. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5367. if (this._targetIsArray) {
  5368. for (var index = 0; index < this._target.length; index++) {
  5369. var target = this._target[index];
  5370. this._setValue(target, this._activeTargets[index], currentValue, weight, index);
  5371. }
  5372. return;
  5373. }
  5374. this._setValue(this._target, this._directTarget, currentValue, weight, 0);
  5375. };
  5376. RuntimeAnimation.prototype._getOriginalValues = function (targetIndex) {
  5377. if (targetIndex === void 0) { targetIndex = 0; }
  5378. var originalValue;
  5379. var target = this._activeTargets[targetIndex];
  5380. if (target.getRestPose && this._targetPath === "_matrix") { // For bones
  5381. originalValue = target.getRestPose();
  5382. }
  5383. else {
  5384. originalValue = target[this._targetPath];
  5385. }
  5386. if (originalValue && originalValue.clone) {
  5387. this._originalValue[targetIndex] = originalValue.clone();
  5388. }
  5389. else {
  5390. this._originalValue[targetIndex] = originalValue;
  5391. }
  5392. };
  5393. RuntimeAnimation.prototype._setValue = function (target, destination, currentValue, weight, targetIndex) {
  5394. // Set value
  5395. this._currentActiveTarget = destination;
  5396. this._weight = weight;
  5397. if (this._enableBlending && this._blendingFactor <= 1.0) {
  5398. if (!this._originalBlendValue) {
  5399. var originalValue = destination[this._targetPath];
  5400. if (originalValue.clone) {
  5401. this._originalBlendValue = originalValue.clone();
  5402. }
  5403. else {
  5404. this._originalBlendValue = originalValue;
  5405. }
  5406. }
  5407. if (this._originalBlendValue.m) { // Matrix
  5408. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5409. if (this._currentValue) {
  5410. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5411. }
  5412. else {
  5413. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5414. }
  5415. }
  5416. else {
  5417. if (this._currentValue) {
  5418. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5419. }
  5420. else {
  5421. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5422. }
  5423. }
  5424. }
  5425. else {
  5426. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5427. }
  5428. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5429. this._blendingFactor += blendingSpeed;
  5430. }
  5431. else {
  5432. this._currentValue = currentValue;
  5433. }
  5434. if (weight !== -1.0) {
  5435. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5436. }
  5437. else {
  5438. destination[this._targetPath] = this._currentValue;
  5439. }
  5440. if (target.markAsDirty) {
  5441. target.markAsDirty(this._animation.targetProperty);
  5442. }
  5443. };
  5444. /**
  5445. * Gets the loop pmode of the runtime animation
  5446. * @returns Loop Mode
  5447. */
  5448. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5449. if (this._target && this._target.animationPropertiesOverride) {
  5450. return this._target.animationPropertiesOverride.loopMode;
  5451. }
  5452. return this._animation.loopMode;
  5453. };
  5454. /**
  5455. * Move the current animation to a given frame
  5456. * @param frame defines the frame to move to
  5457. */
  5458. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5459. var keys = this._animation.getKeys();
  5460. if (frame < keys[0].frame) {
  5461. frame = keys[0].frame;
  5462. }
  5463. else if (frame > keys[keys.length - 1].frame) {
  5464. frame = keys[keys.length - 1].frame;
  5465. }
  5466. this._currentFrame = frame;
  5467. var currentValue = this._animation._interpolate(frame, this._animationState);
  5468. this.setValue(currentValue, -1);
  5469. };
  5470. /**
  5471. * @hidden Internal use only
  5472. */
  5473. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5474. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5475. this._ratioOffset = this._previousRatio - newRatio;
  5476. };
  5477. /**
  5478. * Execute the current animation
  5479. * @param delay defines the delay to add to the current frame
  5480. * @param from defines the lower bound of the animation range
  5481. * @param to defines the upper bound of the animation range
  5482. * @param loop defines if the current animation must loop
  5483. * @param speedRatio defines the current speed ratio
  5484. * @param weight defines the weight of the animation (default is -1 so no weight)
  5485. * @param onLoop optional callback called when animation loops
  5486. * @returns a boolean indicating if the animation is running
  5487. */
  5488. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight) {
  5489. if (weight === void 0) { weight = -1.0; }
  5490. var animation = this._animation;
  5491. var targetPropertyPath = animation.targetPropertyPath;
  5492. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5493. this._stopped = true;
  5494. return false;
  5495. }
  5496. var returnValue = true;
  5497. // Check limits
  5498. if (from < this._minFrame || from > this._maxFrame) {
  5499. from = this._minFrame;
  5500. }
  5501. if (to < this._minFrame || to > this._maxFrame) {
  5502. to = this._maxFrame;
  5503. }
  5504. var range = to - from;
  5505. var offsetValue;
  5506. // Compute ratio which represents the frame delta between from and to
  5507. var ratio = (delay * (animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5508. var highLimitValue = 0;
  5509. this._previousDelay = delay;
  5510. this._previousRatio = ratio;
  5511. if (!loop && (to >= from && ratio >= range)) { // If we are out of range and not looping get back to caller
  5512. returnValue = false;
  5513. highLimitValue = animation._getKeyValue(this._maxValue);
  5514. }
  5515. else if (!loop && (from >= to && ratio <= range)) {
  5516. returnValue = false;
  5517. highLimitValue = animation._getKeyValue(this._minValue);
  5518. }
  5519. else if (this._animationState.loopMode !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5520. var keyOffset = to.toString() + from.toString();
  5521. if (!this._offsetsCache[keyOffset]) {
  5522. this._animationState.repeatCount = 0;
  5523. this._animationState.loopMode = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  5524. var fromValue = animation._interpolate(from, this._animationState);
  5525. var toValue = animation._interpolate(to, this._animationState);
  5526. this._animationState.loopMode = this._getCorrectLoopMode();
  5527. switch (animation.dataType) {
  5528. // Float
  5529. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5530. this._offsetsCache[keyOffset] = toValue - fromValue;
  5531. break;
  5532. // Quaternion
  5533. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5534. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5535. break;
  5536. // Vector3
  5537. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5538. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5539. // Vector2
  5540. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5541. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5542. // Size
  5543. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5544. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5545. // Color3
  5546. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5547. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5548. default:
  5549. break;
  5550. }
  5551. this._highLimitsCache[keyOffset] = toValue;
  5552. }
  5553. highLimitValue = this._highLimitsCache[keyOffset];
  5554. offsetValue = this._offsetsCache[keyOffset];
  5555. }
  5556. if (offsetValue === undefined) {
  5557. switch (animation.dataType) {
  5558. // Float
  5559. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5560. offsetValue = 0;
  5561. break;
  5562. // Quaternion
  5563. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5564. offsetValue = _staticOffsetValueQuaternion;
  5565. break;
  5566. // Vector3
  5567. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5568. offsetValue = _staticOffsetValueVector3;
  5569. break;
  5570. // Vector2
  5571. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5572. offsetValue = _staticOffsetValueVector2;
  5573. break;
  5574. // Size
  5575. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5576. offsetValue = _staticOffsetValueSize;
  5577. break;
  5578. // Color3
  5579. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5580. offsetValue = _staticOffsetValueColor3;
  5581. }
  5582. }
  5583. // Compute value
  5584. var currentFrame;
  5585. if (this._host && this._host.syncRoot) {
  5586. var syncRoot = this._host.syncRoot;
  5587. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5588. currentFrame = from + (to - from) * hostNormalizedFrame;
  5589. }
  5590. else {
  5591. currentFrame = (returnValue && range !== 0) ? from + ratio % range : to;
  5592. }
  5593. // Reset events if looping
  5594. var events = this._events;
  5595. if (range > 0 && this.currentFrame > currentFrame ||
  5596. range < 0 && this.currentFrame < currentFrame) {
  5597. this._onLoop();
  5598. // Need to reset animation events
  5599. if (events.length) {
  5600. for (var index = 0; index < events.length; index++) {
  5601. if (!events[index].onlyOnce) {
  5602. // reset event, the animation is looping
  5603. events[index].isDone = false;
  5604. }
  5605. }
  5606. }
  5607. }
  5608. this._currentFrame = currentFrame;
  5609. this._animationState.repeatCount = range === 0 ? 0 : (ratio / range) >> 0;
  5610. this._animationState.highLimitValue = highLimitValue;
  5611. this._animationState.offsetValue = offsetValue;
  5612. var currentValue = animation._interpolate(currentFrame, this._animationState);
  5613. // Set value
  5614. this.setValue(currentValue, weight);
  5615. // Check events
  5616. if (events.length) {
  5617. for (var index = 0; index < events.length; index++) {
  5618. // Make sure current frame has passed event frame and that event frame is within the current range
  5619. // Also, handle both forward and reverse animations
  5620. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5621. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5622. var event = events[index];
  5623. if (!event.isDone) {
  5624. // If event should be done only once, remove it.
  5625. if (event.onlyOnce) {
  5626. events.splice(index, 1);
  5627. index--;
  5628. }
  5629. event.isDone = true;
  5630. event.action(currentFrame);
  5631. } // Don't do anything if the event has already be done.
  5632. }
  5633. }
  5634. }
  5635. if (!returnValue) {
  5636. this._stopped = true;
  5637. }
  5638. return returnValue;
  5639. };
  5640. return RuntimeAnimation;
  5641. }());
  5642. /***/ }),
  5643. /***/ "./Audio/analyser.ts":
  5644. /*!***************************!*\
  5645. !*** ./Audio/analyser.ts ***!
  5646. \***************************/
  5647. /*! exports provided: Analyser */
  5648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5649. "use strict";
  5650. __webpack_require__.r(__webpack_exports__);
  5651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5652. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5653. /**
  5654. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5656. */
  5657. var Analyser = /** @class */ (function () {
  5658. /**
  5659. * Creates a new analyser
  5660. * @param scene defines hosting scene
  5661. */
  5662. function Analyser(scene) {
  5663. /**
  5664. * Gets or sets the smoothing
  5665. * @ignorenaming
  5666. */
  5667. this.SMOOTHING = 0.75;
  5668. /**
  5669. * Gets or sets the FFT table size
  5670. * @ignorenaming
  5671. */
  5672. this.FFT_SIZE = 512;
  5673. /**
  5674. * Gets or sets the bar graph amplitude
  5675. * @ignorenaming
  5676. */
  5677. this.BARGRAPHAMPLITUDE = 256;
  5678. /**
  5679. * Gets or sets the position of the debug canvas
  5680. * @ignorenaming
  5681. */
  5682. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5683. /**
  5684. * Gets or sets the debug canvas size
  5685. * @ignorenaming
  5686. */
  5687. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5688. this._scene = scene;
  5689. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5690. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5691. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5692. this._webAudioAnalyser.minDecibels = -140;
  5693. this._webAudioAnalyser.maxDecibels = 0;
  5694. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5695. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5696. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5697. }
  5698. }
  5699. /**
  5700. * Get the number of data values you will have to play with for the visualization
  5701. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5702. * @returns a number
  5703. */
  5704. Analyser.prototype.getFrequencyBinCount = function () {
  5705. if (this._audioEngine.canUseWebAudio) {
  5706. return this._webAudioAnalyser.frequencyBinCount;
  5707. }
  5708. else {
  5709. return 0;
  5710. }
  5711. };
  5712. /**
  5713. * Gets the current frequency data as a byte array
  5714. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5715. * @returns a Uint8Array
  5716. */
  5717. Analyser.prototype.getByteFrequencyData = function () {
  5718. if (this._audioEngine.canUseWebAudio) {
  5719. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5720. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5721. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5722. }
  5723. return this._byteFreqs;
  5724. };
  5725. /**
  5726. * Gets the current waveform as a byte array
  5727. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5728. * @returns a Uint8Array
  5729. */
  5730. Analyser.prototype.getByteTimeDomainData = function () {
  5731. if (this._audioEngine.canUseWebAudio) {
  5732. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5733. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5734. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5735. }
  5736. return this._byteTime;
  5737. };
  5738. /**
  5739. * Gets the current frequency data as a float array
  5740. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5741. * @returns a Float32Array
  5742. */
  5743. Analyser.prototype.getFloatFrequencyData = function () {
  5744. if (this._audioEngine.canUseWebAudio) {
  5745. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5746. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5747. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5748. }
  5749. return this._floatFreqs;
  5750. };
  5751. /**
  5752. * Renders the debug canvas
  5753. */
  5754. Analyser.prototype.drawDebugCanvas = function () {
  5755. var _this = this;
  5756. if (this._audioEngine.canUseWebAudio) {
  5757. if (!this._debugCanvas) {
  5758. this._debugCanvas = document.createElement("canvas");
  5759. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5760. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5761. this._debugCanvas.style.position = "absolute";
  5762. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5763. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5764. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5765. document.body.appendChild(this._debugCanvas);
  5766. this._registerFunc = function () {
  5767. _this.drawDebugCanvas();
  5768. };
  5769. this._scene.registerBeforeRender(this._registerFunc);
  5770. }
  5771. if (this._registerFunc && this._debugCanvasContext) {
  5772. var workingArray = this.getByteFrequencyData();
  5773. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5774. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5775. // Draw the frequency domain chart.
  5776. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5777. var value = workingArray[i];
  5778. var percent = value / this.BARGRAPHAMPLITUDE;
  5779. var height = this.DEBUGCANVASSIZE.height * percent;
  5780. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5781. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5782. var hue = i / this.getFrequencyBinCount() * 360;
  5783. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5784. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5785. }
  5786. }
  5787. }
  5788. };
  5789. /**
  5790. * Stops rendering the debug canvas and removes it
  5791. */
  5792. Analyser.prototype.stopDebugCanvas = function () {
  5793. if (this._debugCanvas) {
  5794. if (this._registerFunc) {
  5795. this._scene.unregisterBeforeRender(this._registerFunc);
  5796. this._registerFunc = null;
  5797. }
  5798. document.body.removeChild(this._debugCanvas);
  5799. this._debugCanvas = null;
  5800. this._debugCanvasContext = null;
  5801. }
  5802. };
  5803. /**
  5804. * Connects two audio nodes
  5805. * @param inputAudioNode defines first node to connect
  5806. * @param outputAudioNode defines second node to connect
  5807. */
  5808. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5809. if (this._audioEngine.canUseWebAudio) {
  5810. inputAudioNode.connect(this._webAudioAnalyser);
  5811. this._webAudioAnalyser.connect(outputAudioNode);
  5812. }
  5813. };
  5814. /**
  5815. * Releases all associated resources
  5816. */
  5817. Analyser.prototype.dispose = function () {
  5818. if (this._audioEngine.canUseWebAudio) {
  5819. this._webAudioAnalyser.disconnect();
  5820. }
  5821. };
  5822. return Analyser;
  5823. }());
  5824. /***/ }),
  5825. /***/ "./Audio/audioEngine.ts":
  5826. /*!******************************!*\
  5827. !*** ./Audio/audioEngine.ts ***!
  5828. \******************************/
  5829. /*! exports provided: AudioEngine */
  5830. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5831. "use strict";
  5832. __webpack_require__.r(__webpack_exports__);
  5833. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5834. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5835. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5836. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5837. // Sets the default audio engine to Babylon.js
  5838. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5839. /**
  5840. * This represents the default audio engine used in babylon.
  5841. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5843. */
  5844. var AudioEngine = /** @class */ (function () {
  5845. /**
  5846. * Instantiates a new audio engine.
  5847. *
  5848. * There should be only one per page as some browsers restrict the number
  5849. * of audio contexts you can create.
  5850. * @param hostElement defines the host element where to display the mute icon if necessary
  5851. */
  5852. function AudioEngine(hostElement) {
  5853. var _this = this;
  5854. if (hostElement === void 0) { hostElement = null; }
  5855. this._audioContext = null;
  5856. this._audioContextInitialized = false;
  5857. this._muteButton = null;
  5858. /**
  5859. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5860. */
  5861. this.canUseWebAudio = false;
  5862. /**
  5863. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5864. * @ignoreNaming
  5865. */
  5866. this.WarnedWebAudioUnsupported = false;
  5867. /**
  5868. * Gets whether or not mp3 are supported by your browser.
  5869. */
  5870. this.isMP3supported = false;
  5871. /**
  5872. * Gets whether or not ogg are supported by your browser.
  5873. */
  5874. this.isOGGsupported = false;
  5875. /**
  5876. * Gets whether audio has been unlocked on the device.
  5877. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5878. * a user interaction has happened.
  5879. */
  5880. this.unlocked = true;
  5881. /**
  5882. * Defines if the audio engine relies on a custom unlocked button.
  5883. * In this case, the embedded button will not be displayed.
  5884. */
  5885. this.useCustomUnlockedButton = false;
  5886. /**
  5887. * Event raised when audio has been unlocked on the browser.
  5888. */
  5889. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5890. /**
  5891. * Event raised when audio has been locked on the browser.
  5892. */
  5893. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5894. this._tryToRun = false;
  5895. this._onResize = function () {
  5896. _this._moveButtonToTopLeft();
  5897. };
  5898. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5899. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5900. this.canUseWebAudio = true;
  5901. }
  5902. var audioElem = document.createElement('audio');
  5903. this._hostElement = hostElement;
  5904. try {
  5905. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5906. this.isMP3supported = true;
  5907. }
  5908. }
  5909. catch (e) {
  5910. // protect error during capability check.
  5911. }
  5912. try {
  5913. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5914. this.isOGGsupported = true;
  5915. }
  5916. }
  5917. catch (e) {
  5918. // protect error during capability check.
  5919. }
  5920. }
  5921. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5922. /**
  5923. * Gets the current AudioContext if available.
  5924. */
  5925. get: function () {
  5926. if (!this._audioContextInitialized) {
  5927. this._initializeAudioContext();
  5928. }
  5929. else {
  5930. if (!this.unlocked && !this._muteButton) {
  5931. this._displayMuteButton();
  5932. }
  5933. }
  5934. return this._audioContext;
  5935. },
  5936. enumerable: true,
  5937. configurable: true
  5938. });
  5939. /**
  5940. * Flags the audio engine in Locked state.
  5941. * This happens due to new browser policies preventing audio to autoplay.
  5942. */
  5943. AudioEngine.prototype.lock = function () {
  5944. this._triggerSuspendedState();
  5945. };
  5946. /**
  5947. * Unlocks the audio engine once a user action has been done on the dom.
  5948. * This is helpful to resume play once browser policies have been satisfied.
  5949. */
  5950. AudioEngine.prototype.unlock = function () {
  5951. this._triggerRunningState();
  5952. };
  5953. AudioEngine.prototype._resumeAudioContext = function () {
  5954. var result;
  5955. if (this._audioContext.resume) {
  5956. result = this._audioContext.resume();
  5957. }
  5958. return result || Promise.resolve();
  5959. };
  5960. AudioEngine.prototype._initializeAudioContext = function () {
  5961. try {
  5962. if (this.canUseWebAudio) {
  5963. this._audioContext = new AudioContext();
  5964. // create a global volume gain node
  5965. this.masterGain = this._audioContext.createGain();
  5966. this.masterGain.gain.value = 1;
  5967. this.masterGain.connect(this._audioContext.destination);
  5968. this._audioContextInitialized = true;
  5969. if (this._audioContext.state === "running") {
  5970. // Do not wait for the promise to unlock.
  5971. this._triggerRunningState();
  5972. }
  5973. }
  5974. }
  5975. catch (e) {
  5976. this.canUseWebAudio = false;
  5977. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5978. }
  5979. };
  5980. AudioEngine.prototype._triggerRunningState = function () {
  5981. var _this = this;
  5982. if (this._tryToRun) {
  5983. return;
  5984. }
  5985. this._tryToRun = true;
  5986. this._resumeAudioContext()
  5987. .then(function () {
  5988. _this._tryToRun = false;
  5989. if (_this._muteButton) {
  5990. _this._hideMuteButton();
  5991. }
  5992. }).catch(function () {
  5993. _this._tryToRun = false;
  5994. _this.unlocked = false;
  5995. });
  5996. // Notify users that the audio stack is unlocked/unmuted
  5997. this.unlocked = true;
  5998. this.onAudioUnlockedObservable.notifyObservers(this);
  5999. };
  6000. AudioEngine.prototype._triggerSuspendedState = function () {
  6001. this.unlocked = false;
  6002. this.onAudioLockedObservable.notifyObservers(this);
  6003. this._displayMuteButton();
  6004. };
  6005. AudioEngine.prototype._displayMuteButton = function () {
  6006. var _this = this;
  6007. if (this.useCustomUnlockedButton || this._muteButton) {
  6008. return;
  6009. }
  6010. this._muteButton = document.createElement("BUTTON");
  6011. this._muteButton.className = "babylonUnmuteIcon";
  6012. this._muteButton.id = "babylonUnmuteIconBtn";
  6013. this._muteButton.title = "Unmute";
  6014. 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) }";
  6015. var style = document.createElement('style');
  6016. style.appendChild(document.createTextNode(css));
  6017. document.getElementsByTagName('head')[0].appendChild(style);
  6018. document.body.appendChild(this._muteButton);
  6019. this._moveButtonToTopLeft();
  6020. this._muteButton.addEventListener('touchend', function () {
  6021. _this._triggerRunningState();
  6022. }, true);
  6023. this._muteButton.addEventListener('click', function () {
  6024. _this._triggerRunningState();
  6025. }, true);
  6026. window.addEventListener("resize", this._onResize);
  6027. };
  6028. AudioEngine.prototype._moveButtonToTopLeft = function () {
  6029. if (this._hostElement && this._muteButton) {
  6030. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  6031. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  6032. }
  6033. };
  6034. AudioEngine.prototype._hideMuteButton = function () {
  6035. if (this._muteButton) {
  6036. document.body.removeChild(this._muteButton);
  6037. this._muteButton = null;
  6038. }
  6039. };
  6040. /**
  6041. * Destroy and release the resources associated with the audio ccontext.
  6042. */
  6043. AudioEngine.prototype.dispose = function () {
  6044. if (this.canUseWebAudio && this._audioContextInitialized) {
  6045. if (this._connectedAnalyser && this._audioContext) {
  6046. this._connectedAnalyser.stopDebugCanvas();
  6047. this._connectedAnalyser.dispose();
  6048. this.masterGain.disconnect();
  6049. this.masterGain.connect(this._audioContext.destination);
  6050. this._connectedAnalyser = null;
  6051. }
  6052. this.masterGain.gain.value = 1;
  6053. }
  6054. this.WarnedWebAudioUnsupported = false;
  6055. this._hideMuteButton();
  6056. window.removeEventListener("resize", this._onResize);
  6057. this.onAudioUnlockedObservable.clear();
  6058. this.onAudioLockedObservable.clear();
  6059. };
  6060. /**
  6061. * Gets the global volume sets on the master gain.
  6062. * @returns the global volume if set or -1 otherwise
  6063. */
  6064. AudioEngine.prototype.getGlobalVolume = function () {
  6065. if (this.canUseWebAudio && this._audioContextInitialized) {
  6066. return this.masterGain.gain.value;
  6067. }
  6068. else {
  6069. return -1;
  6070. }
  6071. };
  6072. /**
  6073. * Sets the global volume of your experience (sets on the master gain).
  6074. * @param newVolume Defines the new global volume of the application
  6075. */
  6076. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  6077. if (this.canUseWebAudio && this._audioContextInitialized) {
  6078. this.masterGain.gain.value = newVolume;
  6079. }
  6080. };
  6081. /**
  6082. * Connect the audio engine to an audio analyser allowing some amazing
  6083. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  6084. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  6085. * @param analyser The analyser to connect to the engine
  6086. */
  6087. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6088. if (this._connectedAnalyser) {
  6089. this._connectedAnalyser.stopDebugCanvas();
  6090. }
  6091. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6092. this._connectedAnalyser = analyser;
  6093. this.masterGain.disconnect();
  6094. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6095. }
  6096. };
  6097. return AudioEngine;
  6098. }());
  6099. /***/ }),
  6100. /***/ "./Audio/audioSceneComponent.ts":
  6101. /*!**************************************!*\
  6102. !*** ./Audio/audioSceneComponent.ts ***!
  6103. \**************************************/
  6104. /*! exports provided: AudioSceneComponent */
  6105. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6106. "use strict";
  6107. __webpack_require__.r(__webpack_exports__);
  6108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6109. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6110. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6111. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6112. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6113. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6114. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6115. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6116. // Adds the parser to the scene parsers.
  6117. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6118. // TODO: add sound
  6119. var loadedSounds = [];
  6120. var loadedSound;
  6121. container.sounds = container.sounds || [];
  6122. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6123. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6124. var parsedSound = parsedData.sounds[index];
  6125. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6126. if (!parsedSound.url) {
  6127. parsedSound.url = parsedSound.name;
  6128. }
  6129. if (!loadedSounds[parsedSound.url]) {
  6130. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6131. loadedSounds[parsedSound.url] = loadedSound;
  6132. container.sounds.push(loadedSound);
  6133. }
  6134. else {
  6135. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6136. }
  6137. }
  6138. else {
  6139. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6140. }
  6141. }
  6142. }
  6143. loadedSounds = [];
  6144. });
  6145. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6146. get: function () {
  6147. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6148. if (!compo) {
  6149. compo = new AudioSceneComponent(this);
  6150. this._addComponent(compo);
  6151. }
  6152. if (!this._mainSoundTrack) {
  6153. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6154. }
  6155. return this._mainSoundTrack;
  6156. },
  6157. enumerable: true,
  6158. configurable: true
  6159. });
  6160. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6161. var index;
  6162. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6163. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6164. return this.mainSoundTrack.soundCollection[index];
  6165. }
  6166. }
  6167. if (this.soundTracks) {
  6168. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6169. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6170. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6171. return this.soundTracks[sdIndex].soundCollection[index];
  6172. }
  6173. }
  6174. }
  6175. }
  6176. return null;
  6177. };
  6178. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6179. get: function () {
  6180. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6181. if (!compo) {
  6182. compo = new AudioSceneComponent(this);
  6183. this._addComponent(compo);
  6184. }
  6185. return compo.audioEnabled;
  6186. },
  6187. set: function (value) {
  6188. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6189. if (!compo) {
  6190. compo = new AudioSceneComponent(this);
  6191. this._addComponent(compo);
  6192. }
  6193. if (value) {
  6194. compo.enableAudio();
  6195. }
  6196. else {
  6197. compo.disableAudio();
  6198. }
  6199. },
  6200. enumerable: true,
  6201. configurable: true
  6202. });
  6203. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6204. get: function () {
  6205. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6206. if (!compo) {
  6207. compo = new AudioSceneComponent(this);
  6208. this._addComponent(compo);
  6209. }
  6210. return compo.headphone;
  6211. },
  6212. set: function (value) {
  6213. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6214. if (!compo) {
  6215. compo = new AudioSceneComponent(this);
  6216. this._addComponent(compo);
  6217. }
  6218. if (value) {
  6219. compo.switchAudioModeForHeadphones();
  6220. }
  6221. else {
  6222. compo.switchAudioModeForNormalSpeakers();
  6223. }
  6224. },
  6225. enumerable: true,
  6226. configurable: true
  6227. });
  6228. /**
  6229. * Defines the sound scene component responsible to manage any sounds
  6230. * in a given scene.
  6231. */
  6232. var AudioSceneComponent = /** @class */ (function () {
  6233. /**
  6234. * Creates a new instance of the component for the given scene
  6235. * @param scene Defines the scene to register the component in
  6236. */
  6237. function AudioSceneComponent(scene) {
  6238. /**
  6239. * The component name helpfull to identify the component in the list of scene components.
  6240. */
  6241. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6242. this._audioEnabled = true;
  6243. this._headphone = false;
  6244. this.scene = scene;
  6245. scene.soundTracks = new Array();
  6246. scene.sounds = new Array();
  6247. }
  6248. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6249. /**
  6250. * Gets whether audio is enabled or not.
  6251. * Please use related enable/disable method to switch state.
  6252. */
  6253. get: function () {
  6254. return this._audioEnabled;
  6255. },
  6256. enumerable: true,
  6257. configurable: true
  6258. });
  6259. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6260. /**
  6261. * Gets whether audio is outputing to headphone or not.
  6262. * Please use the according Switch methods to change output.
  6263. */
  6264. get: function () {
  6265. return this._headphone;
  6266. },
  6267. enumerable: true,
  6268. configurable: true
  6269. });
  6270. /**
  6271. * Registers the component in a given scene
  6272. */
  6273. AudioSceneComponent.prototype.register = function () {
  6274. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6275. };
  6276. /**
  6277. * Rebuilds the elements related to this component in case of
  6278. * context lost for instance.
  6279. */
  6280. AudioSceneComponent.prototype.rebuild = function () {
  6281. // Nothing to do here. (Not rendering related)
  6282. };
  6283. /**
  6284. * Serializes the component data to the specified json object
  6285. * @param serializationObject The object to serialize to
  6286. */
  6287. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6288. serializationObject.sounds = [];
  6289. if (this.scene.soundTracks) {
  6290. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6291. var soundtrack = this.scene.soundTracks[index];
  6292. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6293. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6294. }
  6295. }
  6296. }
  6297. };
  6298. /**
  6299. * Adds all the element from the container to the scene
  6300. * @param container the container holding the elements
  6301. */
  6302. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6303. var _this = this;
  6304. if (!container.sounds) {
  6305. return;
  6306. }
  6307. container.sounds.forEach(function (sound) {
  6308. sound.play();
  6309. sound.autoplay = true;
  6310. _this.scene.mainSoundTrack.AddSound(sound);
  6311. });
  6312. };
  6313. /**
  6314. * Removes all the elements in the container from the scene
  6315. * @param container contains the elements to remove
  6316. * @param dispose if the removed element should be disposed (default: false)
  6317. */
  6318. AudioSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  6319. var _this = this;
  6320. if (dispose === void 0) { dispose = false; }
  6321. if (!container.sounds) {
  6322. return;
  6323. }
  6324. container.sounds.forEach(function (sound) {
  6325. sound.stop();
  6326. sound.autoplay = false;
  6327. _this.scene.mainSoundTrack.RemoveSound(sound);
  6328. if (dispose) {
  6329. sound.dispose();
  6330. }
  6331. });
  6332. };
  6333. /**
  6334. * Disposes the component and the associated ressources.
  6335. */
  6336. AudioSceneComponent.prototype.dispose = function () {
  6337. var scene = this.scene;
  6338. if (scene._mainSoundTrack) {
  6339. scene.mainSoundTrack.dispose();
  6340. }
  6341. if (scene.soundTracks) {
  6342. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6343. scene.soundTracks[scIndex].dispose();
  6344. }
  6345. }
  6346. };
  6347. /**
  6348. * Disables audio in the associated scene.
  6349. */
  6350. AudioSceneComponent.prototype.disableAudio = function () {
  6351. var scene = this.scene;
  6352. this._audioEnabled = false;
  6353. var i;
  6354. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6355. scene.mainSoundTrack.soundCollection[i].pause();
  6356. }
  6357. if (scene.soundTracks) {
  6358. for (i = 0; i < scene.soundTracks.length; i++) {
  6359. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6360. scene.soundTracks[i].soundCollection[j].pause();
  6361. }
  6362. }
  6363. }
  6364. };
  6365. /**
  6366. * Enables audio in the associated scene.
  6367. */
  6368. AudioSceneComponent.prototype.enableAudio = function () {
  6369. var scene = this.scene;
  6370. this._audioEnabled = true;
  6371. var i;
  6372. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6373. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6374. scene.mainSoundTrack.soundCollection[i].play();
  6375. }
  6376. }
  6377. if (scene.soundTracks) {
  6378. for (i = 0; i < scene.soundTracks.length; i++) {
  6379. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6380. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6381. scene.soundTracks[i].soundCollection[j].play();
  6382. }
  6383. }
  6384. }
  6385. }
  6386. };
  6387. /**
  6388. * Switch audio to headphone output.
  6389. */
  6390. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6391. var scene = this.scene;
  6392. this._headphone = true;
  6393. scene.mainSoundTrack.switchPanningModelToHRTF();
  6394. if (scene.soundTracks) {
  6395. for (var i = 0; i < scene.soundTracks.length; i++) {
  6396. scene.soundTracks[i].switchPanningModelToHRTF();
  6397. }
  6398. }
  6399. };
  6400. /**
  6401. * Switch audio to normal speakers.
  6402. */
  6403. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6404. var scene = this.scene;
  6405. this._headphone = false;
  6406. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6407. if (scene.soundTracks) {
  6408. for (var i = 0; i < scene.soundTracks.length; i++) {
  6409. scene.soundTracks[i].switchPanningModelToEqualPower();
  6410. }
  6411. }
  6412. };
  6413. AudioSceneComponent.prototype._afterRender = function () {
  6414. var scene = this.scene;
  6415. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6416. return;
  6417. }
  6418. var listeningCamera;
  6419. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6420. if (scene.activeCameras.length > 0) {
  6421. listeningCamera = scene.activeCameras[0];
  6422. }
  6423. else {
  6424. listeningCamera = scene.activeCamera;
  6425. }
  6426. if (listeningCamera && audioEngine.audioContext) {
  6427. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6428. // for VR cameras
  6429. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6430. listeningCamera = listeningCamera.rigCameras[0];
  6431. }
  6432. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6433. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6434. cameraDirection.normalize();
  6435. // To avoid some errors on GearVR
  6436. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6437. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6438. }
  6439. var i;
  6440. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6441. var sound = scene.mainSoundTrack.soundCollection[i];
  6442. if (sound.useCustomAttenuation) {
  6443. sound.updateDistanceFromListener();
  6444. }
  6445. }
  6446. if (scene.soundTracks) {
  6447. for (i = 0; i < scene.soundTracks.length; i++) {
  6448. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6449. sound = scene.soundTracks[i].soundCollection[j];
  6450. if (sound.useCustomAttenuation) {
  6451. sound.updateDistanceFromListener();
  6452. }
  6453. }
  6454. }
  6455. }
  6456. }
  6457. };
  6458. return AudioSceneComponent;
  6459. }());
  6460. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6461. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6462. if (!compo) {
  6463. compo = new AudioSceneComponent(scene);
  6464. scene._addComponent(compo);
  6465. }
  6466. };
  6467. /***/ }),
  6468. /***/ "./Audio/index.ts":
  6469. /*!************************!*\
  6470. !*** ./Audio/index.ts ***!
  6471. \************************/
  6472. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6474. "use strict";
  6475. __webpack_require__.r(__webpack_exports__);
  6476. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6478. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6480. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6482. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6484. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6486. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6488. /***/ }),
  6489. /***/ "./Audio/sound.ts":
  6490. /*!************************!*\
  6491. !*** ./Audio/sound.ts ***!
  6492. \************************/
  6493. /*! exports provided: Sound */
  6494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6495. "use strict";
  6496. __webpack_require__.r(__webpack_exports__);
  6497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6498. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6499. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6500. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6501. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6502. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6503. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6504. /**
  6505. * Defines a sound that can be played in the application.
  6506. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6508. */
  6509. var Sound = /** @class */ (function () {
  6510. /**
  6511. * Create a sound and attach it to a scene
  6512. * @param name Name of your sound
  6513. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6514. * @param scene defines the scene the sound belongs to
  6515. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6516. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6517. */
  6518. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6519. var _this = this;
  6520. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6521. /**
  6522. * Does the sound autoplay once loaded.
  6523. */
  6524. this.autoplay = false;
  6525. /**
  6526. * Does the sound loop after it finishes playing once.
  6527. */
  6528. this.loop = false;
  6529. /**
  6530. * Does the sound use a custom attenuation curve to simulate the falloff
  6531. * happening when the source gets further away from the camera.
  6532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6533. */
  6534. this.useCustomAttenuation = false;
  6535. /**
  6536. * Is this sound currently played.
  6537. */
  6538. this.isPlaying = false;
  6539. /**
  6540. * Is this sound currently paused.
  6541. */
  6542. this.isPaused = false;
  6543. /**
  6544. * Does this sound enables spatial sound.
  6545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6546. */
  6547. this.spatialSound = false;
  6548. /**
  6549. * Define the reference distance the sound should be heard perfectly.
  6550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6551. */
  6552. this.refDistance = 1;
  6553. /**
  6554. * Define the roll off factor of spatial sounds.
  6555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6556. */
  6557. this.rolloffFactor = 1;
  6558. /**
  6559. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6561. */
  6562. this.maxDistance = 100;
  6563. /**
  6564. * Define the distance attenuation model the sound will follow.
  6565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6566. */
  6567. this.distanceModel = "linear";
  6568. /**
  6569. * Observable event when the current playing sound finishes.
  6570. */
  6571. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6572. this._panningModel = "equalpower";
  6573. this._playbackRate = 1;
  6574. this._streaming = false;
  6575. this._startTime = 0;
  6576. this._startOffset = 0;
  6577. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6578. /** @hidden */
  6579. this._positionInEmitterSpace = false;
  6580. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6581. this._volume = 1;
  6582. this._isReadyToPlay = false;
  6583. this._isDirectional = false;
  6584. // Used if you'd like to create a directional sound.
  6585. // If not set, the sound will be omnidirectional
  6586. this._coneInnerAngle = 360;
  6587. this._coneOuterAngle = 360;
  6588. this._coneOuterGain = 0;
  6589. this._isOutputConnected = false;
  6590. this._urlType = "Unknown";
  6591. this.name = name;
  6592. this._scene = scene;
  6593. Sound._SceneComponentInitialization(scene);
  6594. this._readyToPlayCallback = readyToPlayCallback;
  6595. // Default custom attenuation function is a linear attenuation
  6596. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6597. if (currentDistance < maxDistance) {
  6598. return currentVolume * (1 - currentDistance / maxDistance);
  6599. }
  6600. else {
  6601. return 0;
  6602. }
  6603. };
  6604. if (options) {
  6605. this.autoplay = options.autoplay || false;
  6606. this.loop = options.loop || false;
  6607. // if volume === 0, we need another way to check this option
  6608. if (options.volume !== undefined) {
  6609. this._volume = options.volume;
  6610. }
  6611. this.spatialSound = options.spatialSound || false;
  6612. this.maxDistance = options.maxDistance || 100;
  6613. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6614. this.rolloffFactor = options.rolloffFactor || 1;
  6615. this.refDistance = options.refDistance || 1;
  6616. this.distanceModel = options.distanceModel || "linear";
  6617. this._playbackRate = options.playbackRate || 1;
  6618. this._streaming = options.streaming || false;
  6619. }
  6620. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6621. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6622. this._soundGain.gain.value = this._volume;
  6623. this._inputAudioNode = this._soundGain;
  6624. this._outputAudioNode = this._soundGain;
  6625. if (this.spatialSound) {
  6626. this._createSpatialParameters();
  6627. }
  6628. this._scene.mainSoundTrack.AddSound(this);
  6629. var validParameter = true;
  6630. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6631. if (urlOrArrayBuffer) {
  6632. try {
  6633. if (typeof (urlOrArrayBuffer) === "string") {
  6634. this._urlType = "String";
  6635. }
  6636. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6637. this._urlType = "ArrayBuffer";
  6638. }
  6639. else if (urlOrArrayBuffer instanceof MediaStream) {
  6640. this._urlType = "MediaStream";
  6641. }
  6642. else if (Array.isArray(urlOrArrayBuffer)) {
  6643. this._urlType = "Array";
  6644. }
  6645. var urls = [];
  6646. var codecSupportedFound = false;
  6647. switch (this._urlType) {
  6648. case "MediaStream":
  6649. this._streaming = true;
  6650. this._isReadyToPlay = true;
  6651. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaStreamSource(urlOrArrayBuffer);
  6652. if (this.autoplay) {
  6653. this.play();
  6654. }
  6655. if (this._readyToPlayCallback) {
  6656. this._readyToPlayCallback();
  6657. }
  6658. break;
  6659. case "ArrayBuffer":
  6660. if (urlOrArrayBuffer.byteLength > 0) {
  6661. codecSupportedFound = true;
  6662. this._soundLoaded(urlOrArrayBuffer);
  6663. }
  6664. break;
  6665. case "String":
  6666. urls.push(urlOrArrayBuffer);
  6667. case "Array":
  6668. if (urls.length === 0) {
  6669. urls = urlOrArrayBuffer;
  6670. }
  6671. // If we found a supported format, we load it immediately and stop the loop
  6672. for (var i = 0; i < urls.length; i++) {
  6673. var url = urls[i];
  6674. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6675. codecSupportedFound = true;
  6676. }
  6677. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6678. codecSupportedFound = true;
  6679. }
  6680. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6681. codecSupportedFound = true;
  6682. }
  6683. if (url.indexOf("blob:") !== -1) {
  6684. codecSupportedFound = true;
  6685. }
  6686. if (codecSupportedFound) {
  6687. // Loading sound using XHR2
  6688. if (!this._streaming) {
  6689. this._scene._loadFile(url, function (data) {
  6690. _this._soundLoaded(data);
  6691. }, undefined, true, true, function (exception) {
  6692. if (exception) {
  6693. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6694. }
  6695. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6696. _this._scene.mainSoundTrack.RemoveSound(_this);
  6697. });
  6698. }
  6699. // Streaming sound using HTML5 Audio tag
  6700. else {
  6701. this._htmlAudioElement = new Audio(url);
  6702. this._htmlAudioElement.controls = false;
  6703. this._htmlAudioElement.loop = this.loop;
  6704. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6705. this._htmlAudioElement.preload = "auto";
  6706. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6707. _this._isReadyToPlay = true;
  6708. if (_this.autoplay) {
  6709. _this.play();
  6710. }
  6711. if (_this._readyToPlayCallback) {
  6712. _this._readyToPlayCallback();
  6713. }
  6714. });
  6715. document.body.appendChild(this._htmlAudioElement);
  6716. this._htmlAudioElement.load();
  6717. }
  6718. break;
  6719. }
  6720. }
  6721. break;
  6722. default:
  6723. validParameter = false;
  6724. break;
  6725. }
  6726. if (!validParameter) {
  6727. _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.");
  6728. }
  6729. else {
  6730. if (!codecSupportedFound) {
  6731. this._isReadyToPlay = true;
  6732. // Simulating a ready to play event to avoid breaking code path
  6733. if (this._readyToPlayCallback) {
  6734. window.setTimeout(function () {
  6735. if (_this._readyToPlayCallback) {
  6736. _this._readyToPlayCallback();
  6737. }
  6738. }, 1000);
  6739. }
  6740. }
  6741. }
  6742. }
  6743. catch (ex) {
  6744. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6745. this._scene.mainSoundTrack.RemoveSound(this);
  6746. }
  6747. }
  6748. }
  6749. else {
  6750. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6751. this._scene.mainSoundTrack.AddSound(this);
  6752. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6753. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6754. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6755. }
  6756. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6757. if (this._readyToPlayCallback) {
  6758. window.setTimeout(function () {
  6759. if (_this._readyToPlayCallback) {
  6760. _this._readyToPlayCallback();
  6761. }
  6762. }, 1000);
  6763. }
  6764. }
  6765. }
  6766. /**
  6767. * Release the sound and its associated resources
  6768. */
  6769. Sound.prototype.dispose = function () {
  6770. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6771. if (this.isPlaying) {
  6772. this.stop();
  6773. }
  6774. this._isReadyToPlay = false;
  6775. if (this.soundTrackId === -1) {
  6776. this._scene.mainSoundTrack.RemoveSound(this);
  6777. }
  6778. else if (this._scene.soundTracks) {
  6779. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6780. }
  6781. if (this._soundGain) {
  6782. this._soundGain.disconnect();
  6783. this._soundGain = null;
  6784. }
  6785. if (this._soundPanner) {
  6786. this._soundPanner.disconnect();
  6787. this._soundPanner = null;
  6788. }
  6789. if (this._soundSource) {
  6790. this._soundSource.disconnect();
  6791. this._soundSource = null;
  6792. }
  6793. this._audioBuffer = null;
  6794. if (this._htmlAudioElement) {
  6795. this._htmlAudioElement.pause();
  6796. this._htmlAudioElement.src = "";
  6797. document.body.removeChild(this._htmlAudioElement);
  6798. }
  6799. if (this._streamingSource) {
  6800. this._streamingSource.disconnect();
  6801. }
  6802. if (this._connectedTransformNode && this._registerFunc) {
  6803. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6804. this._connectedTransformNode = null;
  6805. }
  6806. }
  6807. };
  6808. /**
  6809. * Gets if the sounds is ready to be played or not.
  6810. * @returns true if ready, otherwise false
  6811. */
  6812. Sound.prototype.isReady = function () {
  6813. return this._isReadyToPlay;
  6814. };
  6815. Sound.prototype._soundLoaded = function (audioData) {
  6816. var _this = this;
  6817. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6818. return;
  6819. }
  6820. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6821. _this._audioBuffer = buffer;
  6822. _this._isReadyToPlay = true;
  6823. if (_this.autoplay) {
  6824. _this.play();
  6825. }
  6826. if (_this._readyToPlayCallback) {
  6827. _this._readyToPlayCallback();
  6828. }
  6829. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6830. };
  6831. /**
  6832. * Sets the data of the sound from an audiobuffer
  6833. * @param audioBuffer The audioBuffer containing the data
  6834. */
  6835. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6836. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6837. this._audioBuffer = audioBuffer;
  6838. this._isReadyToPlay = true;
  6839. }
  6840. };
  6841. /**
  6842. * Updates the current sounds options such as maxdistance, loop...
  6843. * @param options A JSON object containing values named as the object properties
  6844. */
  6845. Sound.prototype.updateOptions = function (options) {
  6846. if (options) {
  6847. this.loop = options.loop || this.loop;
  6848. this.maxDistance = options.maxDistance || this.maxDistance;
  6849. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6850. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6851. this.refDistance = options.refDistance || this.refDistance;
  6852. this.distanceModel = options.distanceModel || this.distanceModel;
  6853. this._playbackRate = options.playbackRate || this._playbackRate;
  6854. this._updateSpatialParameters();
  6855. if (this.isPlaying) {
  6856. if (this._streaming && this._htmlAudioElement) {
  6857. this._htmlAudioElement.playbackRate = this._playbackRate;
  6858. }
  6859. else {
  6860. if (this._soundSource) {
  6861. this._soundSource.playbackRate.value = this._playbackRate;
  6862. }
  6863. }
  6864. }
  6865. }
  6866. };
  6867. Sound.prototype._createSpatialParameters = function () {
  6868. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6869. if (this._scene.headphone) {
  6870. this._panningModel = "HRTF";
  6871. }
  6872. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6873. this._updateSpatialParameters();
  6874. this._soundPanner.connect(this._outputAudioNode);
  6875. this._inputAudioNode = this._soundPanner;
  6876. }
  6877. };
  6878. Sound.prototype._updateSpatialParameters = function () {
  6879. if (this.spatialSound && this._soundPanner) {
  6880. if (this.useCustomAttenuation) {
  6881. // Tricks to disable in a way embedded Web Audio attenuation
  6882. this._soundPanner.distanceModel = "linear";
  6883. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6884. this._soundPanner.refDistance = 1;
  6885. this._soundPanner.rolloffFactor = 1;
  6886. this._soundPanner.panningModel = this._panningModel;
  6887. }
  6888. else {
  6889. this._soundPanner.distanceModel = this.distanceModel;
  6890. this._soundPanner.maxDistance = this.maxDistance;
  6891. this._soundPanner.refDistance = this.refDistance;
  6892. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6893. this._soundPanner.panningModel = this._panningModel;
  6894. }
  6895. }
  6896. };
  6897. /**
  6898. * Switch the panning model to HRTF:
  6899. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6900. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6901. */
  6902. Sound.prototype.switchPanningModelToHRTF = function () {
  6903. this._panningModel = "HRTF";
  6904. this._switchPanningModel();
  6905. };
  6906. /**
  6907. * Switch the panning model to Equal Power:
  6908. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6910. */
  6911. Sound.prototype.switchPanningModelToEqualPower = function () {
  6912. this._panningModel = "equalpower";
  6913. this._switchPanningModel();
  6914. };
  6915. Sound.prototype._switchPanningModel = function () {
  6916. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6917. this._soundPanner.panningModel = this._panningModel;
  6918. }
  6919. };
  6920. /**
  6921. * Connect this sound to a sound track audio node like gain...
  6922. * @param soundTrackAudioNode the sound track audio node to connect to
  6923. */
  6924. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6925. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6926. if (this._isOutputConnected) {
  6927. this._outputAudioNode.disconnect();
  6928. }
  6929. this._outputAudioNode.connect(soundTrackAudioNode);
  6930. this._isOutputConnected = true;
  6931. }
  6932. };
  6933. /**
  6934. * Transform this sound into a directional source
  6935. * @param coneInnerAngle Size of the inner cone in degree
  6936. * @param coneOuterAngle Size of the outer cone in degree
  6937. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6938. */
  6939. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6940. if (coneOuterAngle < coneInnerAngle) {
  6941. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6942. return;
  6943. }
  6944. this._coneInnerAngle = coneInnerAngle;
  6945. this._coneOuterAngle = coneOuterAngle;
  6946. this._coneOuterGain = coneOuterGain;
  6947. this._isDirectional = true;
  6948. if (this.isPlaying && this.loop) {
  6949. this.stop();
  6950. this.play();
  6951. }
  6952. };
  6953. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6954. /**
  6955. * Gets or sets the inner angle for the directional cone.
  6956. */
  6957. get: function () {
  6958. return this._coneInnerAngle;
  6959. },
  6960. /**
  6961. * Gets or sets the inner angle for the directional cone.
  6962. */
  6963. set: function (value) {
  6964. if (value != this._coneInnerAngle) {
  6965. if (this._coneOuterAngle < value) {
  6966. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6967. return;
  6968. }
  6969. this._coneInnerAngle = value;
  6970. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6971. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6972. }
  6973. }
  6974. },
  6975. enumerable: true,
  6976. configurable: true
  6977. });
  6978. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6979. /**
  6980. * Gets or sets the outer angle for the directional cone.
  6981. */
  6982. get: function () {
  6983. return this._coneOuterAngle;
  6984. },
  6985. /**
  6986. * Gets or sets the outer angle for the directional cone.
  6987. */
  6988. set: function (value) {
  6989. if (value != this._coneOuterAngle) {
  6990. if (value < this._coneInnerAngle) {
  6991. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6992. return;
  6993. }
  6994. this._coneOuterAngle = value;
  6995. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6996. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6997. }
  6998. }
  6999. },
  7000. enumerable: true,
  7001. configurable: true
  7002. });
  7003. /**
  7004. * Sets the position of the emitter if spatial sound is enabled
  7005. * @param newPosition Defines the new posisiton
  7006. */
  7007. Sound.prototype.setPosition = function (newPosition) {
  7008. this._position = newPosition;
  7009. 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)) {
  7010. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  7011. }
  7012. };
  7013. /**
  7014. * Sets the local direction of the emitter if spatial sound is enabled
  7015. * @param newLocalDirection Defines the new local direction
  7016. */
  7017. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  7018. this._localDirection = newLocalDirection;
  7019. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  7020. this._updateDirection();
  7021. }
  7022. };
  7023. Sound.prototype._updateDirection = function () {
  7024. if (!this._connectedTransformNode || !this._soundPanner) {
  7025. return;
  7026. }
  7027. var mat = this._connectedTransformNode.getWorldMatrix();
  7028. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  7029. direction.normalize();
  7030. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  7031. };
  7032. /** @hidden */
  7033. Sound.prototype.updateDistanceFromListener = function () {
  7034. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  7035. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  7036. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  7037. }
  7038. };
  7039. /**
  7040. * Sets a new custom attenuation function for the sound.
  7041. * @param callback Defines the function used for the attenuation
  7042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  7043. */
  7044. Sound.prototype.setAttenuationFunction = function (callback) {
  7045. this._customAttenuationFunction = callback;
  7046. };
  7047. /**
  7048. * Play the sound
  7049. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  7050. * @param offset (optional) Start the sound setting it at a specific time
  7051. */
  7052. Sound.prototype.play = function (time, offset) {
  7053. var _this = this;
  7054. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7055. try {
  7056. if (this._startOffset < 0) {
  7057. time = -this._startOffset;
  7058. this._startOffset = 0;
  7059. }
  7060. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7061. if (!this._soundSource || !this._streamingSource) {
  7062. if (this.spatialSound && this._soundPanner) {
  7063. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  7064. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  7065. }
  7066. if (this._isDirectional) {
  7067. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  7068. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  7069. this._soundPanner.coneOuterGain = this._coneOuterGain;
  7070. if (this._connectedTransformNode) {
  7071. this._updateDirection();
  7072. }
  7073. else {
  7074. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  7075. }
  7076. }
  7077. }
  7078. }
  7079. if (this._streaming) {
  7080. if (!this._streamingSource) {
  7081. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  7082. this._htmlAudioElement.onended = function () { _this._onended(); };
  7083. this._htmlAudioElement.playbackRate = this._playbackRate;
  7084. }
  7085. this._streamingSource.disconnect();
  7086. this._streamingSource.connect(this._inputAudioNode);
  7087. if (this._htmlAudioElement) {
  7088. // required to manage properly the new suspended default state of Chrome
  7089. // When the option 'streaming: true' is used, we need first to wait for
  7090. // the audio engine to be unlocked by a user gesture before trying to play
  7091. // an HTML Audio elememt
  7092. var tryToPlay = function () {
  7093. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7094. var playPromise = _this._htmlAudioElement.play();
  7095. // In browsers that don’t yet support this functionality,
  7096. // playPromise won’t be defined.
  7097. if (playPromise !== undefined) {
  7098. playPromise.catch(function (error) {
  7099. // Automatic playback failed.
  7100. // Waiting for the audio engine to be unlocked by user click on unmute
  7101. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7102. if (_this.loop || _this.autoplay) {
  7103. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7104. }
  7105. });
  7106. }
  7107. }
  7108. else {
  7109. if (_this.loop || _this.autoplay) {
  7110. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7111. }
  7112. }
  7113. };
  7114. tryToPlay();
  7115. }
  7116. }
  7117. else {
  7118. var tryToPlay = function () {
  7119. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7120. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7121. _this._soundSource.buffer = _this._audioBuffer;
  7122. _this._soundSource.connect(_this._inputAudioNode);
  7123. _this._soundSource.loop = _this.loop;
  7124. _this._soundSource.playbackRate.value = _this._playbackRate;
  7125. _this._soundSource.onended = function () { _this._onended(); };
  7126. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7127. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7128. }
  7129. };
  7130. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7131. // Wait a bit for FF as context seems late to be ready.
  7132. setTimeout(function () {
  7133. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7134. // Automatic playback failed.
  7135. // Waiting for the audio engine to be unlocked by user click on unmute
  7136. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7137. if (_this.loop || _this.autoplay) {
  7138. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7139. }
  7140. }
  7141. else {
  7142. tryToPlay();
  7143. }
  7144. }, 500);
  7145. }
  7146. else {
  7147. tryToPlay();
  7148. }
  7149. }
  7150. this._startTime = startTime;
  7151. this.isPlaying = true;
  7152. this.isPaused = false;
  7153. }
  7154. catch (ex) {
  7155. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7156. }
  7157. }
  7158. };
  7159. Sound.prototype._onended = function () {
  7160. this.isPlaying = false;
  7161. if (this.onended) {
  7162. this.onended();
  7163. }
  7164. this.onEndedObservable.notifyObservers(this);
  7165. };
  7166. /**
  7167. * Stop the sound
  7168. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7169. */
  7170. Sound.prototype.stop = function (time) {
  7171. var _this = this;
  7172. if (this.isPlaying) {
  7173. if (this._streaming) {
  7174. if (this._htmlAudioElement) {
  7175. this._htmlAudioElement.pause();
  7176. // Test needed for Firefox or it will generate an Invalid State Error
  7177. if (this._htmlAudioElement.currentTime > 0) {
  7178. this._htmlAudioElement.currentTime = 0;
  7179. }
  7180. }
  7181. else {
  7182. this._streamingSource.disconnect();
  7183. }
  7184. this.isPlaying = false;
  7185. }
  7186. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7187. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7188. this._soundSource.stop(stopTime);
  7189. this._soundSource.onended = function () { _this.isPlaying = false; };
  7190. if (!this.isPaused) {
  7191. this._startOffset = 0;
  7192. }
  7193. }
  7194. }
  7195. };
  7196. /**
  7197. * Put the sound in pause
  7198. */
  7199. Sound.prototype.pause = function () {
  7200. if (this.isPlaying) {
  7201. this.isPaused = true;
  7202. if (this._streaming) {
  7203. if (this._htmlAudioElement) {
  7204. this._htmlAudioElement.pause();
  7205. }
  7206. else {
  7207. this._streamingSource.disconnect();
  7208. }
  7209. }
  7210. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7211. this.stop(0);
  7212. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7213. }
  7214. }
  7215. };
  7216. /**
  7217. * Sets a dedicated volume for this sounds
  7218. * @param newVolume Define the new volume of the sound
  7219. * @param time Define in how long the sound should be at this value
  7220. */
  7221. Sound.prototype.setVolume = function (newVolume, time) {
  7222. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7223. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7224. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7225. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7226. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7227. }
  7228. else {
  7229. this._soundGain.gain.value = newVolume;
  7230. }
  7231. }
  7232. this._volume = newVolume;
  7233. };
  7234. /**
  7235. * Set the sound play back rate
  7236. * @param newPlaybackRate Define the playback rate the sound should be played at
  7237. */
  7238. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7239. this._playbackRate = newPlaybackRate;
  7240. if (this.isPlaying) {
  7241. if (this._streaming && this._htmlAudioElement) {
  7242. this._htmlAudioElement.playbackRate = this._playbackRate;
  7243. }
  7244. else if (this._soundSource) {
  7245. this._soundSource.playbackRate.value = this._playbackRate;
  7246. }
  7247. }
  7248. };
  7249. /**
  7250. * Gets the volume of the sound.
  7251. * @returns the volume of the sound
  7252. */
  7253. Sound.prototype.getVolume = function () {
  7254. return this._volume;
  7255. };
  7256. /**
  7257. * Attach the sound to a dedicated mesh
  7258. * @param transformNode The transform node to connect the sound with
  7259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7260. */
  7261. Sound.prototype.attachToMesh = function (transformNode) {
  7262. var _this = this;
  7263. if (this._connectedTransformNode && this._registerFunc) {
  7264. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7265. this._registerFunc = null;
  7266. }
  7267. this._connectedTransformNode = transformNode;
  7268. if (!this.spatialSound) {
  7269. this.spatialSound = true;
  7270. this._createSpatialParameters();
  7271. if (this.isPlaying && this.loop) {
  7272. this.stop();
  7273. this.play();
  7274. }
  7275. }
  7276. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7277. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7278. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7279. };
  7280. /**
  7281. * Detach the sound from the previously attached mesh
  7282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7283. */
  7284. Sound.prototype.detachFromMesh = function () {
  7285. if (this._connectedTransformNode && this._registerFunc) {
  7286. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7287. this._registerFunc = null;
  7288. this._connectedTransformNode = null;
  7289. }
  7290. };
  7291. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7292. if (!node.getBoundingInfo) {
  7293. return;
  7294. }
  7295. var mesh = node;
  7296. if (this._positionInEmitterSpace) {
  7297. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  7298. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  7299. }
  7300. else {
  7301. var boundingInfo = mesh.getBoundingInfo();
  7302. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7303. }
  7304. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7305. this._updateDirection();
  7306. }
  7307. };
  7308. /**
  7309. * Clone the current sound in the scene.
  7310. * @returns the new sound clone
  7311. */
  7312. Sound.prototype.clone = function () {
  7313. var _this = this;
  7314. if (!this._streaming) {
  7315. var setBufferAndRun = function () {
  7316. if (_this._isReadyToPlay) {
  7317. clonedSound._audioBuffer = _this.getAudioBuffer();
  7318. clonedSound._isReadyToPlay = true;
  7319. if (clonedSound.autoplay) {
  7320. clonedSound.play();
  7321. }
  7322. }
  7323. else {
  7324. window.setTimeout(setBufferAndRun, 300);
  7325. }
  7326. };
  7327. var currentOptions = {
  7328. autoplay: this.autoplay, loop: this.loop,
  7329. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7330. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7331. refDistance: this.refDistance, distanceModel: this.distanceModel
  7332. };
  7333. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7334. if (this.useCustomAttenuation) {
  7335. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7336. }
  7337. clonedSound.setPosition(this._position);
  7338. clonedSound.setPlaybackRate(this._playbackRate);
  7339. setBufferAndRun();
  7340. return clonedSound;
  7341. }
  7342. // Can't clone a streaming sound
  7343. else {
  7344. return null;
  7345. }
  7346. };
  7347. /**
  7348. * Gets the current underlying audio buffer containing the data
  7349. * @returns the audio buffer
  7350. */
  7351. Sound.prototype.getAudioBuffer = function () {
  7352. return this._audioBuffer;
  7353. };
  7354. /**
  7355. * Serializes the Sound in a JSON representation
  7356. * @returns the JSON representation of the sound
  7357. */
  7358. Sound.prototype.serialize = function () {
  7359. var serializationObject = {
  7360. name: this.name,
  7361. url: this.name,
  7362. autoplay: this.autoplay,
  7363. loop: this.loop,
  7364. volume: this._volume,
  7365. spatialSound: this.spatialSound,
  7366. maxDistance: this.maxDistance,
  7367. rolloffFactor: this.rolloffFactor,
  7368. refDistance: this.refDistance,
  7369. distanceModel: this.distanceModel,
  7370. playbackRate: this._playbackRate,
  7371. panningModel: this._panningModel,
  7372. soundTrackId: this.soundTrackId
  7373. };
  7374. if (this.spatialSound) {
  7375. if (this._connectedTransformNode) {
  7376. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7377. }
  7378. serializationObject.position = this._position.asArray();
  7379. serializationObject.refDistance = this.refDistance;
  7380. serializationObject.distanceModel = this.distanceModel;
  7381. serializationObject.isDirectional = this._isDirectional;
  7382. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7383. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7384. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7385. serializationObject.coneOuterGain = this._coneOuterGain;
  7386. }
  7387. return serializationObject;
  7388. };
  7389. /**
  7390. * Parse a JSON representation of a sound to innstantiate in a given scene
  7391. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7392. * @param scene Define the scene the new parsed sound should be created in
  7393. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7394. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7395. * @returns the newly parsed sound
  7396. */
  7397. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7398. var soundName = parsedSound.name;
  7399. var soundUrl;
  7400. if (parsedSound.url) {
  7401. soundUrl = rootUrl + parsedSound.url;
  7402. }
  7403. else {
  7404. soundUrl = rootUrl + soundName;
  7405. }
  7406. var options = {
  7407. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7408. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7409. rolloffFactor: parsedSound.rolloffFactor,
  7410. refDistance: parsedSound.refDistance,
  7411. distanceModel: parsedSound.distanceModel,
  7412. playbackRate: parsedSound.playbackRate
  7413. };
  7414. var newSound;
  7415. if (!sourceSound) {
  7416. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7417. scene._addPendingData(newSound);
  7418. }
  7419. else {
  7420. var setBufferAndRun = function () {
  7421. if (sourceSound._isReadyToPlay) {
  7422. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7423. newSound._isReadyToPlay = true;
  7424. if (newSound.autoplay) {
  7425. newSound.play();
  7426. }
  7427. }
  7428. else {
  7429. window.setTimeout(setBufferAndRun, 300);
  7430. }
  7431. };
  7432. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7433. setBufferAndRun();
  7434. }
  7435. if (parsedSound.position) {
  7436. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7437. newSound.setPosition(soundPosition);
  7438. }
  7439. if (parsedSound.isDirectional) {
  7440. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7441. if (parsedSound.localDirectionToMesh) {
  7442. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7443. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7444. }
  7445. }
  7446. if (parsedSound.connectedMeshId) {
  7447. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7448. if (connectedMesh) {
  7449. newSound.attachToMesh(connectedMesh);
  7450. }
  7451. }
  7452. return newSound;
  7453. };
  7454. /** @hidden */
  7455. Sound._SceneComponentInitialization = function (_) {
  7456. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AudioSceneComponent");
  7457. };
  7458. return Sound;
  7459. }());
  7460. /***/ }),
  7461. /***/ "./Audio/soundTrack.ts":
  7462. /*!*****************************!*\
  7463. !*** ./Audio/soundTrack.ts ***!
  7464. \*****************************/
  7465. /*! exports provided: SoundTrack */
  7466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7467. "use strict";
  7468. __webpack_require__.r(__webpack_exports__);
  7469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7470. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7471. /**
  7472. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7473. * It will be also used in a future release to apply effects on a specific track.
  7474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7475. */
  7476. var SoundTrack = /** @class */ (function () {
  7477. /**
  7478. * Creates a new sound track.
  7479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7480. * @param scene Define the scene the sound track belongs to
  7481. * @param options
  7482. */
  7483. function SoundTrack(scene, options) {
  7484. if (options === void 0) { options = {}; }
  7485. /**
  7486. * The unique identifier of the sound track in the scene.
  7487. */
  7488. this.id = -1;
  7489. this._isMainTrack = false;
  7490. this._isInitialized = false;
  7491. this._scene = scene;
  7492. this.soundCollection = new Array();
  7493. this._options = options;
  7494. if (!this._isMainTrack && this._scene.soundTracks) {
  7495. this._scene.soundTracks.push(this);
  7496. this.id = this._scene.soundTracks.length - 1;
  7497. }
  7498. }
  7499. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7500. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7501. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7502. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7503. if (this._options) {
  7504. if (this._options.volume) {
  7505. this._outputAudioNode.gain.value = this._options.volume;
  7506. }
  7507. if (this._options.mainTrack) {
  7508. this._isMainTrack = this._options.mainTrack;
  7509. }
  7510. }
  7511. this._isInitialized = true;
  7512. }
  7513. };
  7514. /**
  7515. * Release the sound track and its associated resources
  7516. */
  7517. SoundTrack.prototype.dispose = function () {
  7518. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7519. if (this._connectedAnalyser) {
  7520. this._connectedAnalyser.stopDebugCanvas();
  7521. }
  7522. while (this.soundCollection.length) {
  7523. this.soundCollection[0].dispose();
  7524. }
  7525. if (this._outputAudioNode) {
  7526. this._outputAudioNode.disconnect();
  7527. }
  7528. this._outputAudioNode = null;
  7529. }
  7530. };
  7531. /**
  7532. * Adds a sound to this sound track
  7533. * @param sound define the cound to add
  7534. * @ignoreNaming
  7535. */
  7536. SoundTrack.prototype.AddSound = function (sound) {
  7537. if (!this._isInitialized) {
  7538. this._initializeSoundTrackAudioGraph();
  7539. }
  7540. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7541. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7542. }
  7543. if (sound.soundTrackId) {
  7544. if (sound.soundTrackId === -1) {
  7545. this._scene.mainSoundTrack.RemoveSound(sound);
  7546. }
  7547. else if (this._scene.soundTracks) {
  7548. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7549. }
  7550. }
  7551. this.soundCollection.push(sound);
  7552. sound.soundTrackId = this.id;
  7553. };
  7554. /**
  7555. * Removes a sound to this sound track
  7556. * @param sound define the cound to remove
  7557. * @ignoreNaming
  7558. */
  7559. SoundTrack.prototype.RemoveSound = function (sound) {
  7560. var index = this.soundCollection.indexOf(sound);
  7561. if (index !== -1) {
  7562. this.soundCollection.splice(index, 1);
  7563. }
  7564. };
  7565. /**
  7566. * Set a global volume for the full sound track.
  7567. * @param newVolume Define the new volume of the sound track
  7568. */
  7569. SoundTrack.prototype.setVolume = function (newVolume) {
  7570. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7571. this._outputAudioNode.gain.value = newVolume;
  7572. }
  7573. };
  7574. /**
  7575. * Switch the panning model to HRTF:
  7576. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7577. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7578. */
  7579. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7580. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7581. for (var i = 0; i < this.soundCollection.length; i++) {
  7582. this.soundCollection[i].switchPanningModelToHRTF();
  7583. }
  7584. }
  7585. };
  7586. /**
  7587. * Switch the panning model to Equal Power:
  7588. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7590. */
  7591. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7592. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7593. for (var i = 0; i < this.soundCollection.length; i++) {
  7594. this.soundCollection[i].switchPanningModelToEqualPower();
  7595. }
  7596. }
  7597. };
  7598. /**
  7599. * Connect the sound track to an audio analyser allowing some amazing
  7600. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7602. * @param analyser The analyser to connect to the engine
  7603. */
  7604. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7605. if (this._connectedAnalyser) {
  7606. this._connectedAnalyser.stopDebugCanvas();
  7607. }
  7608. this._connectedAnalyser = analyser;
  7609. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7610. this._outputAudioNode.disconnect();
  7611. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7612. }
  7613. };
  7614. return SoundTrack;
  7615. }());
  7616. /***/ }),
  7617. /***/ "./Audio/weightedsound.ts":
  7618. /*!********************************!*\
  7619. !*** ./Audio/weightedsound.ts ***!
  7620. \********************************/
  7621. /*! exports provided: WeightedSound */
  7622. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7623. "use strict";
  7624. __webpack_require__.r(__webpack_exports__);
  7625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7626. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7627. /**
  7628. * Wraps one or more Sound objects and selects one with random weight for playback.
  7629. */
  7630. var WeightedSound = /** @class */ (function () {
  7631. /**
  7632. * Creates a new WeightedSound from the list of sounds given.
  7633. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7634. * @param sounds Array of Sounds that will be selected from.
  7635. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7636. */
  7637. function WeightedSound(loop, sounds, weights) {
  7638. var _this = this;
  7639. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7640. this.loop = false;
  7641. this._coneInnerAngle = 360;
  7642. this._coneOuterAngle = 360;
  7643. this._volume = 1;
  7644. /** A Sound is currently playing. */
  7645. this.isPlaying = false;
  7646. /** A Sound is currently paused. */
  7647. this.isPaused = false;
  7648. this._sounds = [];
  7649. this._weights = [];
  7650. if (sounds.length !== weights.length) {
  7651. throw new Error('Sounds length does not equal weights length');
  7652. }
  7653. this.loop = loop;
  7654. this._weights = weights;
  7655. // Normalize the weights
  7656. var weightSum = 0;
  7657. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7658. var weight = weights_1[_i];
  7659. weightSum += weight;
  7660. }
  7661. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7662. for (var i = 0; i < this._weights.length; i++) {
  7663. this._weights[i] *= invWeightSum;
  7664. }
  7665. this._sounds = sounds;
  7666. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7667. var sound = _b[_a];
  7668. sound.onEndedObservable.add(function () { _this._onended(); });
  7669. }
  7670. }
  7671. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7672. /**
  7673. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7674. */
  7675. get: function () {
  7676. return this._coneInnerAngle;
  7677. },
  7678. /**
  7679. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7680. */
  7681. set: function (value) {
  7682. if (value !== this._coneInnerAngle) {
  7683. if (this._coneOuterAngle < value) {
  7684. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7685. return;
  7686. }
  7687. this._coneInnerAngle = value;
  7688. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7689. var sound = _a[_i];
  7690. sound.directionalConeInnerAngle = value;
  7691. }
  7692. }
  7693. },
  7694. enumerable: true,
  7695. configurable: true
  7696. });
  7697. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7698. /**
  7699. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7700. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7701. */
  7702. get: function () {
  7703. return this._coneOuterAngle;
  7704. },
  7705. /**
  7706. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7707. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7708. */
  7709. set: function (value) {
  7710. if (value !== this._coneOuterAngle) {
  7711. if (value < this._coneInnerAngle) {
  7712. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7713. return;
  7714. }
  7715. this._coneOuterAngle = value;
  7716. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7717. var sound = _a[_i];
  7718. sound.directionalConeOuterAngle = value;
  7719. }
  7720. }
  7721. },
  7722. enumerable: true,
  7723. configurable: true
  7724. });
  7725. Object.defineProperty(WeightedSound.prototype, "volume", {
  7726. /**
  7727. * Playback volume.
  7728. */
  7729. get: function () {
  7730. return this._volume;
  7731. },
  7732. /**
  7733. * Playback volume.
  7734. */
  7735. set: function (value) {
  7736. if (value !== this._volume) {
  7737. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7738. var sound = _a[_i];
  7739. sound.setVolume(value);
  7740. }
  7741. }
  7742. },
  7743. enumerable: true,
  7744. configurable: true
  7745. });
  7746. WeightedSound.prototype._onended = function () {
  7747. if (this._currentIndex !== undefined) {
  7748. this._sounds[this._currentIndex].autoplay = false;
  7749. }
  7750. if (this.loop && this.isPlaying) {
  7751. this.play();
  7752. }
  7753. else {
  7754. this.isPlaying = false;
  7755. }
  7756. };
  7757. /**
  7758. * Suspend playback
  7759. */
  7760. WeightedSound.prototype.pause = function () {
  7761. this.isPaused = true;
  7762. if (this._currentIndex !== undefined) {
  7763. this._sounds[this._currentIndex].pause();
  7764. }
  7765. };
  7766. /**
  7767. * Stop playback
  7768. */
  7769. WeightedSound.prototype.stop = function () {
  7770. this.isPlaying = false;
  7771. if (this._currentIndex !== undefined) {
  7772. this._sounds[this._currentIndex].stop();
  7773. }
  7774. };
  7775. /**
  7776. * Start playback.
  7777. * @param startOffset Position the clip head at a specific time in seconds.
  7778. */
  7779. WeightedSound.prototype.play = function (startOffset) {
  7780. if (!this.isPaused) {
  7781. this.stop();
  7782. var randomValue = Math.random();
  7783. var total = 0;
  7784. for (var i = 0; i < this._weights.length; i++) {
  7785. total += this._weights[i];
  7786. if (randomValue <= total) {
  7787. this._currentIndex = i;
  7788. break;
  7789. }
  7790. }
  7791. }
  7792. var sound = this._sounds[this._currentIndex];
  7793. if (sound.isReady()) {
  7794. sound.play(0, this.isPaused ? undefined : startOffset);
  7795. }
  7796. else {
  7797. sound.autoplay = true;
  7798. }
  7799. this.isPlaying = true;
  7800. this.isPaused = false;
  7801. };
  7802. return WeightedSound;
  7803. }());
  7804. /***/ }),
  7805. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7806. /*!***************************************************!*\
  7807. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7808. \***************************************************/
  7809. /*! exports provided: AutoRotationBehavior */
  7810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7811. "use strict";
  7812. __webpack_require__.r(__webpack_exports__);
  7813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7814. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7815. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7816. /**
  7817. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7818. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7819. */
  7820. var AutoRotationBehavior = /** @class */ (function () {
  7821. function AutoRotationBehavior() {
  7822. this._zoomStopsAnimation = false;
  7823. this._idleRotationSpeed = 0.05;
  7824. this._idleRotationWaitTime = 2000;
  7825. this._idleRotationSpinupTime = 2000;
  7826. this._isPointerDown = false;
  7827. this._lastFrameTime = null;
  7828. this._lastInteractionTime = -Infinity;
  7829. this._cameraRotationSpeed = 0;
  7830. this._lastFrameRadius = 0;
  7831. }
  7832. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7833. /**
  7834. * Gets the name of the behavior.
  7835. */
  7836. get: function () {
  7837. return "AutoRotation";
  7838. },
  7839. enumerable: true,
  7840. configurable: true
  7841. });
  7842. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7843. /**
  7844. * Gets the flag that indicates if user zooming should stop animation.
  7845. */
  7846. get: function () {
  7847. return this._zoomStopsAnimation;
  7848. },
  7849. /**
  7850. * Sets the flag that indicates if user zooming should stop animation.
  7851. */
  7852. set: function (flag) {
  7853. this._zoomStopsAnimation = flag;
  7854. },
  7855. enumerable: true,
  7856. configurable: true
  7857. });
  7858. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7859. /**
  7860. * Gets the default speed at which the camera rotates around the model.
  7861. */
  7862. get: function () {
  7863. return this._idleRotationSpeed;
  7864. },
  7865. /**
  7866. * Sets the default speed at which the camera rotates around the model.
  7867. */
  7868. set: function (speed) {
  7869. this._idleRotationSpeed = speed;
  7870. },
  7871. enumerable: true,
  7872. configurable: true
  7873. });
  7874. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7875. /**
  7876. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7877. */
  7878. get: function () {
  7879. return this._idleRotationWaitTime;
  7880. },
  7881. /**
  7882. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7883. */
  7884. set: function (time) {
  7885. this._idleRotationWaitTime = time;
  7886. },
  7887. enumerable: true,
  7888. configurable: true
  7889. });
  7890. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7891. /**
  7892. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7893. */
  7894. get: function () {
  7895. return this._idleRotationSpinupTime;
  7896. },
  7897. /**
  7898. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7899. */
  7900. set: function (time) {
  7901. this._idleRotationSpinupTime = time;
  7902. },
  7903. enumerable: true,
  7904. configurable: true
  7905. });
  7906. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7907. /**
  7908. * Gets a value indicating if the camera is currently rotating because of this behavior
  7909. */
  7910. get: function () {
  7911. return Math.abs(this._cameraRotationSpeed) > 0;
  7912. },
  7913. enumerable: true,
  7914. configurable: true
  7915. });
  7916. /**
  7917. * Initializes the behavior.
  7918. */
  7919. AutoRotationBehavior.prototype.init = function () {
  7920. // Do notihng
  7921. };
  7922. /**
  7923. * Attaches the behavior to its arc rotate camera.
  7924. * @param camera Defines the camera to attach the behavior to
  7925. */
  7926. AutoRotationBehavior.prototype.attach = function (camera) {
  7927. var _this = this;
  7928. this._attachedCamera = camera;
  7929. var scene = this._attachedCamera.getScene();
  7930. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7931. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7932. _this._isPointerDown = true;
  7933. return;
  7934. }
  7935. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7936. _this._isPointerDown = false;
  7937. }
  7938. });
  7939. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7940. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7941. var dt = 0;
  7942. if (_this._lastFrameTime != null) {
  7943. dt = now - _this._lastFrameTime;
  7944. }
  7945. _this._lastFrameTime = now;
  7946. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7947. _this._applyUserInteraction();
  7948. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7949. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7950. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7951. // Step camera rotation by rotation speed
  7952. if (_this._attachedCamera) {
  7953. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7954. }
  7955. });
  7956. };
  7957. /**
  7958. * Detaches the behavior from its current arc rotate camera.
  7959. */
  7960. AutoRotationBehavior.prototype.detach = function () {
  7961. if (!this._attachedCamera) {
  7962. return;
  7963. }
  7964. var scene = this._attachedCamera.getScene();
  7965. if (this._onPrePointerObservableObserver) {
  7966. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7967. }
  7968. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7969. this._attachedCamera = null;
  7970. };
  7971. /**
  7972. * Returns true if user is scrolling.
  7973. * @return true if user is scrolling.
  7974. */
  7975. AutoRotationBehavior.prototype._userIsZooming = function () {
  7976. if (!this._attachedCamera) {
  7977. return false;
  7978. }
  7979. return this._attachedCamera.inertialRadiusOffset !== 0;
  7980. };
  7981. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7982. if (!this._attachedCamera) {
  7983. return false;
  7984. }
  7985. var zoomHasHitLimit = false;
  7986. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7987. zoomHasHitLimit = true;
  7988. }
  7989. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7990. this._lastFrameRadius = this._attachedCamera.radius;
  7991. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7992. };
  7993. /**
  7994. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7995. */
  7996. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7997. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7998. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7999. }
  8000. };
  8001. // Tools
  8002. AutoRotationBehavior.prototype._userIsMoving = function () {
  8003. if (!this._attachedCamera) {
  8004. return false;
  8005. }
  8006. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8007. this._attachedCamera.inertialBetaOffset !== 0 ||
  8008. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8009. this._attachedCamera.inertialPanningX !== 0 ||
  8010. this._attachedCamera.inertialPanningY !== 0 ||
  8011. this._isPointerDown;
  8012. };
  8013. return AutoRotationBehavior;
  8014. }());
  8015. /***/ }),
  8016. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  8017. /*!***********************************************!*\
  8018. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  8019. \***********************************************/
  8020. /*! exports provided: BouncingBehavior */
  8021. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8022. "use strict";
  8023. __webpack_require__.r(__webpack_exports__);
  8024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  8025. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8026. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8027. /**
  8028. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  8029. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  8030. */
  8031. var BouncingBehavior = /** @class */ (function () {
  8032. function BouncingBehavior() {
  8033. /**
  8034. * The duration of the animation, in milliseconds
  8035. */
  8036. this.transitionDuration = 450;
  8037. /**
  8038. * Length of the distance animated by the transition when lower radius is reached
  8039. */
  8040. this.lowerRadiusTransitionRange = 2;
  8041. /**
  8042. * Length of the distance animated by the transition when upper radius is reached
  8043. */
  8044. this.upperRadiusTransitionRange = -2;
  8045. this._autoTransitionRange = false;
  8046. // Animations
  8047. this._radiusIsAnimating = false;
  8048. this._radiusBounceTransition = null;
  8049. this._animatables = new Array();
  8050. }
  8051. Object.defineProperty(BouncingBehavior.prototype, "name", {
  8052. /**
  8053. * Gets the name of the behavior.
  8054. */
  8055. get: function () {
  8056. return "Bouncing";
  8057. },
  8058. enumerable: true,
  8059. configurable: true
  8060. });
  8061. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  8062. /**
  8063. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  8064. */
  8065. get: function () {
  8066. return this._autoTransitionRange;
  8067. },
  8068. /**
  8069. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  8070. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  8071. */
  8072. set: function (value) {
  8073. var _this = this;
  8074. if (this._autoTransitionRange === value) {
  8075. return;
  8076. }
  8077. this._autoTransitionRange = value;
  8078. var camera = this._attachedCamera;
  8079. if (!camera) {
  8080. return;
  8081. }
  8082. if (value) {
  8083. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8084. if (!mesh) {
  8085. return;
  8086. }
  8087. mesh.computeWorldMatrix(true);
  8088. var diagonal = mesh.getBoundingInfo().diagonalLength;
  8089. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  8090. _this.upperRadiusTransitionRange = diagonal * 0.05;
  8091. });
  8092. }
  8093. else if (this._onMeshTargetChangedObserver) {
  8094. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8095. }
  8096. },
  8097. enumerable: true,
  8098. configurable: true
  8099. });
  8100. /**
  8101. * Initializes the behavior.
  8102. */
  8103. BouncingBehavior.prototype.init = function () {
  8104. // Do notihng
  8105. };
  8106. /**
  8107. * Attaches the behavior to its arc rotate camera.
  8108. * @param camera Defines the camera to attach the behavior to
  8109. */
  8110. BouncingBehavior.prototype.attach = function (camera) {
  8111. var _this = this;
  8112. this._attachedCamera = camera;
  8113. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8114. if (!_this._attachedCamera) {
  8115. return;
  8116. }
  8117. // Add the bounce animation to the lower radius limit
  8118. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8119. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8120. }
  8121. // Add the bounce animation to the upper radius limit
  8122. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8123. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8124. }
  8125. });
  8126. };
  8127. /**
  8128. * Detaches the behavior from its current arc rotate camera.
  8129. */
  8130. BouncingBehavior.prototype.detach = function () {
  8131. if (!this._attachedCamera) {
  8132. return;
  8133. }
  8134. if (this._onAfterCheckInputsObserver) {
  8135. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8136. }
  8137. if (this._onMeshTargetChangedObserver) {
  8138. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8139. }
  8140. this._attachedCamera = null;
  8141. };
  8142. /**
  8143. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8144. * @param radiusLimit The limit to check against.
  8145. * @return Bool to indicate if at limit.
  8146. */
  8147. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8148. if (!this._attachedCamera) {
  8149. return false;
  8150. }
  8151. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8152. return true;
  8153. }
  8154. return false;
  8155. };
  8156. /**
  8157. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8158. * @param radiusDelta The delta by which to animate to. Can be negative.
  8159. */
  8160. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8161. var _this = this;
  8162. if (!this._attachedCamera) {
  8163. return;
  8164. }
  8165. if (!this._radiusBounceTransition) {
  8166. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8167. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8168. }
  8169. // Prevent zoom until bounce has completed
  8170. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8171. this._attachedCamera.wheelPrecision = Infinity;
  8172. this._attachedCamera.inertialRadiusOffset = 0;
  8173. // Animate to the radius limit
  8174. this.stopAllAnimations();
  8175. this._radiusIsAnimating = true;
  8176. 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(); });
  8177. if (animatable) {
  8178. this._animatables.push(animatable);
  8179. }
  8180. };
  8181. /**
  8182. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8183. */
  8184. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8185. this._radiusIsAnimating = false;
  8186. if (this._attachedCamera) {
  8187. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8188. }
  8189. };
  8190. /**
  8191. * Stops and removes all animations that have been applied to the camera
  8192. */
  8193. BouncingBehavior.prototype.stopAllAnimations = function () {
  8194. if (this._attachedCamera) {
  8195. this._attachedCamera.animations = [];
  8196. }
  8197. while (this._animatables.length) {
  8198. this._animatables[0].onAnimationEnd = null;
  8199. this._animatables[0].stop();
  8200. this._animatables.shift();
  8201. }
  8202. };
  8203. /**
  8204. * The easing function used by animations
  8205. */
  8206. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8207. /**
  8208. * The easing mode used by animations
  8209. */
  8210. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8211. return BouncingBehavior;
  8212. }());
  8213. /***/ }),
  8214. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8215. /*!**********************************************!*\
  8216. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8217. \**********************************************/
  8218. /*! exports provided: FramingBehavior */
  8219. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8220. "use strict";
  8221. __webpack_require__.r(__webpack_exports__);
  8222. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8223. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8224. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8225. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  8226. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8227. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8228. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8229. /**
  8230. * 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.
  8231. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8232. */
  8233. var FramingBehavior = /** @class */ (function () {
  8234. function FramingBehavior() {
  8235. this._mode = FramingBehavior.FitFrustumSidesMode;
  8236. this._radiusScale = 1.0;
  8237. this._positionScale = 0.5;
  8238. this._defaultElevation = 0.3;
  8239. this._elevationReturnTime = 1500;
  8240. this._elevationReturnWaitTime = 1000;
  8241. this._zoomStopsAnimation = false;
  8242. this._framingTime = 1500;
  8243. /**
  8244. * Define if the behavior should automatically change the configured
  8245. * camera limits and sensibilities.
  8246. */
  8247. this.autoCorrectCameraLimitsAndSensibility = true;
  8248. this._isPointerDown = false;
  8249. this._lastInteractionTime = -Infinity;
  8250. // Framing control
  8251. this._animatables = new Array();
  8252. this._betaIsAnimating = false;
  8253. }
  8254. Object.defineProperty(FramingBehavior.prototype, "name", {
  8255. /**
  8256. * Gets the name of the behavior.
  8257. */
  8258. get: function () {
  8259. return "Framing";
  8260. },
  8261. enumerable: true,
  8262. configurable: true
  8263. });
  8264. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8265. /**
  8266. * Gets current mode used by the behavior.
  8267. */
  8268. get: function () {
  8269. return this._mode;
  8270. },
  8271. /**
  8272. * Sets the current mode used by the behavior
  8273. */
  8274. set: function (mode) {
  8275. this._mode = mode;
  8276. },
  8277. enumerable: true,
  8278. configurable: true
  8279. });
  8280. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8281. /**
  8282. * Gets the scale applied to the radius
  8283. */
  8284. get: function () {
  8285. return this._radiusScale;
  8286. },
  8287. /**
  8288. * Sets the scale applied to the radius (1 by default)
  8289. */
  8290. set: function (radius) {
  8291. this._radiusScale = radius;
  8292. },
  8293. enumerable: true,
  8294. configurable: true
  8295. });
  8296. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8297. /**
  8298. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8299. */
  8300. get: function () {
  8301. return this._positionScale;
  8302. },
  8303. /**
  8304. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8305. */
  8306. set: function (scale) {
  8307. this._positionScale = scale;
  8308. },
  8309. enumerable: true,
  8310. configurable: true
  8311. });
  8312. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8313. /**
  8314. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8315. * behaviour is triggered, in radians.
  8316. */
  8317. get: function () {
  8318. return this._defaultElevation;
  8319. },
  8320. /**
  8321. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8322. * behaviour is triggered, in radians.
  8323. */
  8324. set: function (elevation) {
  8325. this._defaultElevation = elevation;
  8326. },
  8327. enumerable: true,
  8328. configurable: true
  8329. });
  8330. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8331. /**
  8332. * Gets the time (in milliseconds) taken to return to the default beta position.
  8333. * Negative value indicates camera should not return to default.
  8334. */
  8335. get: function () {
  8336. return this._elevationReturnTime;
  8337. },
  8338. /**
  8339. * Sets the time (in milliseconds) taken to return to the default beta position.
  8340. * Negative value indicates camera should not return to default.
  8341. */
  8342. set: function (speed) {
  8343. this._elevationReturnTime = speed;
  8344. },
  8345. enumerable: true,
  8346. configurable: true
  8347. });
  8348. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8349. /**
  8350. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8351. */
  8352. get: function () {
  8353. return this._elevationReturnWaitTime;
  8354. },
  8355. /**
  8356. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8357. */
  8358. set: function (time) {
  8359. this._elevationReturnWaitTime = time;
  8360. },
  8361. enumerable: true,
  8362. configurable: true
  8363. });
  8364. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8365. /**
  8366. * Gets the flag that indicates if user zooming should stop animation.
  8367. */
  8368. get: function () {
  8369. return this._zoomStopsAnimation;
  8370. },
  8371. /**
  8372. * Sets the flag that indicates if user zooming should stop animation.
  8373. */
  8374. set: function (flag) {
  8375. this._zoomStopsAnimation = flag;
  8376. },
  8377. enumerable: true,
  8378. configurable: true
  8379. });
  8380. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8381. /**
  8382. * Gets the transition time when framing the mesh, in milliseconds
  8383. */
  8384. get: function () {
  8385. return this._framingTime;
  8386. },
  8387. /**
  8388. * Sets the transition time when framing the mesh, in milliseconds
  8389. */
  8390. set: function (time) {
  8391. this._framingTime = time;
  8392. },
  8393. enumerable: true,
  8394. configurable: true
  8395. });
  8396. /**
  8397. * Initializes the behavior.
  8398. */
  8399. FramingBehavior.prototype.init = function () {
  8400. // Do notihng
  8401. };
  8402. /**
  8403. * Attaches the behavior to its arc rotate camera.
  8404. * @param camera Defines the camera to attach the behavior to
  8405. */
  8406. FramingBehavior.prototype.attach = function (camera) {
  8407. var _this = this;
  8408. this._attachedCamera = camera;
  8409. var scene = this._attachedCamera.getScene();
  8410. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8411. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8412. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8413. _this._isPointerDown = true;
  8414. return;
  8415. }
  8416. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8417. _this._isPointerDown = false;
  8418. }
  8419. });
  8420. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8421. if (mesh) {
  8422. _this.zoomOnMesh(mesh);
  8423. }
  8424. });
  8425. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8426. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8427. _this._applyUserInteraction();
  8428. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8429. // back to the default position after a given timeout
  8430. _this._maintainCameraAboveGround();
  8431. });
  8432. };
  8433. /**
  8434. * Detaches the behavior from its current arc rotate camera.
  8435. */
  8436. FramingBehavior.prototype.detach = function () {
  8437. if (!this._attachedCamera) {
  8438. return;
  8439. }
  8440. var scene = this._attachedCamera.getScene();
  8441. if (this._onPrePointerObservableObserver) {
  8442. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8443. }
  8444. if (this._onAfterCheckInputsObserver) {
  8445. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8446. }
  8447. if (this._onMeshTargetChangedObserver) {
  8448. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8449. }
  8450. this._attachedCamera = null;
  8451. };
  8452. /**
  8453. * Targets the given mesh and updates zoom level accordingly.
  8454. * @param mesh The mesh to target.
  8455. * @param radius Optional. If a cached radius position already exists, overrides default.
  8456. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8457. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8458. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8459. */
  8460. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8461. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8462. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8463. mesh.computeWorldMatrix(true);
  8464. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8465. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8466. };
  8467. /**
  8468. * Targets the given mesh with its children and updates zoom level accordingly.
  8469. * @param mesh The mesh to target.
  8470. * @param radius Optional. If a cached radius position already exists, overrides default.
  8471. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8472. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8473. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8474. */
  8475. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8476. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8477. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8478. mesh.computeWorldMatrix(true);
  8479. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8480. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8481. };
  8482. /**
  8483. * Targets the given meshes with their children and updates zoom level accordingly.
  8484. * @param meshes The mesh to target.
  8485. * @param radius Optional. If a cached radius position already exists, overrides default.
  8486. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8487. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8488. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8489. */
  8490. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8491. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8492. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8493. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8494. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8495. for (var i = 0; i < meshes.length; i++) {
  8496. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8497. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8498. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8499. }
  8500. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8501. };
  8502. /**
  8503. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8504. * @param minimumWorld Determines the smaller position of the bounding box extend
  8505. * @param maximumWorld Determines the bigger position of the bounding box extend
  8506. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8507. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8508. */
  8509. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8510. var _this = this;
  8511. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8512. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8513. var zoomTarget;
  8514. if (!this._attachedCamera) {
  8515. return;
  8516. }
  8517. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8518. var bottom = minimumWorld.y;
  8519. var top = maximumWorld.y;
  8520. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8521. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8522. if (focusOnOriginXZ) {
  8523. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8524. }
  8525. else {
  8526. var centerWorld = minimumWorld.add(radiusWorld);
  8527. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8528. }
  8529. if (!this._vectorTransition) {
  8530. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8531. }
  8532. this._betaIsAnimating = true;
  8533. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8534. if (animatable) {
  8535. this._animatables.push(animatable);
  8536. }
  8537. // sets the radius and lower radius bounds
  8538. // Small delta ensures camera is not always at lower zoom limit.
  8539. var radius = 0;
  8540. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8541. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8542. if (this.autoCorrectCameraLimitsAndSensibility) {
  8543. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8544. }
  8545. radius = position;
  8546. }
  8547. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8548. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8549. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8550. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8551. }
  8552. }
  8553. // Set sensibilities
  8554. if (this.autoCorrectCameraLimitsAndSensibility) {
  8555. var extend = maximumWorld.subtract(minimumWorld).length();
  8556. this._attachedCamera.panningSensibility = 5000 / extend;
  8557. this._attachedCamera.wheelPrecision = 100 / radius;
  8558. }
  8559. // transition to new radius
  8560. if (!this._radiusTransition) {
  8561. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8562. }
  8563. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8564. _this.stopAllAnimations();
  8565. if (onAnimationEnd) {
  8566. onAnimationEnd();
  8567. }
  8568. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8569. _this._attachedCamera.storeState();
  8570. }
  8571. });
  8572. if (animatable) {
  8573. this._animatables.push(animatable);
  8574. }
  8575. };
  8576. /**
  8577. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8578. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8579. * frustum width.
  8580. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8581. * to fully enclose the mesh in the viewing frustum.
  8582. */
  8583. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8584. var size = maximumWorld.subtract(minimumWorld);
  8585. var boxVectorGlobalDiagonal = size.length();
  8586. var frustumSlope = this._getFrustumSlope();
  8587. // Formula for setting distance
  8588. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8589. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8590. // Horizon distance
  8591. var radius = radiusWithoutFraming * this._radiusScale;
  8592. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8593. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8594. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8595. var camera = this._attachedCamera;
  8596. if (!camera) {
  8597. return 0;
  8598. }
  8599. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8600. // Don't exceed the requested limit
  8601. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8602. }
  8603. // Don't exceed the upper radius limit
  8604. if (camera.upperRadiusLimit) {
  8605. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8606. }
  8607. return distance;
  8608. };
  8609. /**
  8610. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8611. * is automatically returned to its default position (expected to be above ground plane).
  8612. */
  8613. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8614. var _this = this;
  8615. if (this._elevationReturnTime < 0) {
  8616. return;
  8617. }
  8618. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8619. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8620. var limitBeta = Math.PI * 0.5;
  8621. // Bring the camera back up if below the ground plane
  8622. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8623. this._betaIsAnimating = true;
  8624. //Transition to new position
  8625. this.stopAllAnimations();
  8626. if (!this._betaTransition) {
  8627. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8628. }
  8629. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8630. _this._clearAnimationLocks();
  8631. _this.stopAllAnimations();
  8632. });
  8633. if (animatabe) {
  8634. this._animatables.push(animatabe);
  8635. }
  8636. }
  8637. };
  8638. /**
  8639. * Returns the frustum slope based on the canvas ratio and camera FOV
  8640. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8641. */
  8642. FramingBehavior.prototype._getFrustumSlope = function () {
  8643. // Calculate the viewport ratio
  8644. // Aspect Ratio is Height/Width.
  8645. var camera = this._attachedCamera;
  8646. if (!camera) {
  8647. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8648. }
  8649. var engine = camera.getScene().getEngine();
  8650. var aspectRatio = engine.getAspectRatio(camera);
  8651. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8652. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8653. var frustumSlopeY = Math.tan(camera.fov / 2);
  8654. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8655. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8656. // along the forward vector.
  8657. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8658. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8659. };
  8660. /**
  8661. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8662. */
  8663. FramingBehavior.prototype._clearAnimationLocks = function () {
  8664. this._betaIsAnimating = false;
  8665. };
  8666. /**
  8667. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8668. */
  8669. FramingBehavior.prototype._applyUserInteraction = function () {
  8670. if (this.isUserIsMoving) {
  8671. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8672. this.stopAllAnimations();
  8673. this._clearAnimationLocks();
  8674. }
  8675. };
  8676. /**
  8677. * Stops and removes all animations that have been applied to the camera
  8678. */
  8679. FramingBehavior.prototype.stopAllAnimations = function () {
  8680. if (this._attachedCamera) {
  8681. this._attachedCamera.animations = [];
  8682. }
  8683. while (this._animatables.length) {
  8684. if (this._animatables[0]) {
  8685. this._animatables[0].onAnimationEnd = null;
  8686. this._animatables[0].stop();
  8687. }
  8688. this._animatables.shift();
  8689. }
  8690. };
  8691. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8692. /**
  8693. * Gets a value indicating if the user is moving the camera
  8694. */
  8695. get: function () {
  8696. if (!this._attachedCamera) {
  8697. return false;
  8698. }
  8699. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8700. this._attachedCamera.inertialBetaOffset !== 0 ||
  8701. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8702. this._attachedCamera.inertialPanningX !== 0 ||
  8703. this._attachedCamera.inertialPanningY !== 0 ||
  8704. this._isPointerDown;
  8705. },
  8706. enumerable: true,
  8707. configurable: true
  8708. });
  8709. /**
  8710. * The easing function used by animations
  8711. */
  8712. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8713. /**
  8714. * The easing mode used by animations
  8715. */
  8716. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8717. // Statics
  8718. /**
  8719. * The camera can move all the way towards the mesh.
  8720. */
  8721. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8722. /**
  8723. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8724. */
  8725. FramingBehavior.FitFrustumSidesMode = 1;
  8726. return FramingBehavior;
  8727. }());
  8728. /***/ }),
  8729. /***/ "./Behaviors/Cameras/index.ts":
  8730. /*!************************************!*\
  8731. !*** ./Behaviors/Cameras/index.ts ***!
  8732. \************************************/
  8733. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8735. "use strict";
  8736. __webpack_require__.r(__webpack_exports__);
  8737. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8739. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8741. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8743. /***/ }),
  8744. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8745. /*!*************************************************!*\
  8746. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8747. \*************************************************/
  8748. /*! exports provided: AttachToBoxBehavior */
  8749. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8750. "use strict";
  8751. __webpack_require__.r(__webpack_exports__);
  8752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8753. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8754. /**
  8755. * @hidden
  8756. */
  8757. var FaceDirectionInfo = /** @class */ (function () {
  8758. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8759. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8760. if (diff === void 0) { diff = 0; }
  8761. if (ignore === void 0) { ignore = false; }
  8762. this.direction = direction;
  8763. this.rotatedDirection = rotatedDirection;
  8764. this.diff = diff;
  8765. this.ignore = ignore;
  8766. }
  8767. return FaceDirectionInfo;
  8768. }());
  8769. /**
  8770. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8771. */
  8772. var AttachToBoxBehavior = /** @class */ (function () {
  8773. /**
  8774. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8775. * @param ui The transform node that should be attched to the mesh
  8776. */
  8777. function AttachToBoxBehavior(ui) {
  8778. this.ui = ui;
  8779. /**
  8780. * The name of the behavior
  8781. */
  8782. this.name = "AttachToBoxBehavior";
  8783. /**
  8784. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8785. */
  8786. this.distanceAwayFromFace = 0.15;
  8787. /**
  8788. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8789. */
  8790. this.distanceAwayFromBottomOfFace = 0.15;
  8791. 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))];
  8792. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8793. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8794. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8795. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8796. /* Does nothing */
  8797. }
  8798. /**
  8799. * Initializes the behavior
  8800. */
  8801. AttachToBoxBehavior.prototype.init = function () {
  8802. /* Does nothing */
  8803. };
  8804. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8805. var _this = this;
  8806. // Go over each face and calculate the angle between the face's normal and targetDirection
  8807. this._faceVectors.forEach(function (v) {
  8808. if (!_this._target.rotationQuaternion) {
  8809. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8810. }
  8811. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8812. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8813. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8814. });
  8815. // Return the face information of the one with the normal closeset to target direction
  8816. return this._faceVectors.reduce(function (min, p) {
  8817. if (min.ignore) {
  8818. return p;
  8819. }
  8820. else if (p.ignore) {
  8821. return min;
  8822. }
  8823. else {
  8824. return min.diff < p.diff ? min : p;
  8825. }
  8826. }, this._faceVectors[0]);
  8827. };
  8828. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8829. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8830. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8831. this._lookAtTmpMatrix.invert();
  8832. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8833. };
  8834. /**
  8835. * Attaches the AttachToBoxBehavior to the passed in mesh
  8836. * @param target The mesh that the specified node will be attached to
  8837. */
  8838. AttachToBoxBehavior.prototype.attach = function (target) {
  8839. var _this = this;
  8840. this._target = target;
  8841. this._scene = this._target.getScene();
  8842. // Every frame, update the app bars position
  8843. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8844. if (!_this._scene.activeCamera) {
  8845. return;
  8846. }
  8847. // Find the face closest to the cameras position
  8848. var cameraPos = _this._scene.activeCamera.position;
  8849. if (_this._scene.activeCamera.devicePosition) {
  8850. cameraPos = _this._scene.activeCamera.devicePosition;
  8851. }
  8852. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8853. if (_this._scene.activeCamera.leftCamera) {
  8854. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8855. }
  8856. else {
  8857. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8858. }
  8859. // Get camera up direction
  8860. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8861. // Ignore faces to not select a parrelel face for the up vector of the UI
  8862. _this._faceVectors.forEach(function (v) {
  8863. if (facing.direction.x && v.direction.x) {
  8864. v.ignore = true;
  8865. }
  8866. if (facing.direction.y && v.direction.y) {
  8867. v.ignore = true;
  8868. }
  8869. if (facing.direction.z && v.direction.z) {
  8870. v.ignore = true;
  8871. }
  8872. });
  8873. var facingUp = _this._closestFace(_this._tmpVector);
  8874. // Unignore faces
  8875. _this._faceVectors.forEach(function (v) {
  8876. v.ignore = false;
  8877. });
  8878. // Position the app bar on that face
  8879. _this.ui.position.copyFrom(target.position);
  8880. if (facing.direction.x) {
  8881. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8882. _this.ui.position.addInPlace(_this._tmpVector);
  8883. }
  8884. if (facing.direction.y) {
  8885. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8886. _this.ui.position.addInPlace(_this._tmpVector);
  8887. }
  8888. if (facing.direction.z) {
  8889. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8890. _this.ui.position.addInPlace(_this._tmpVector);
  8891. }
  8892. // Rotate to be oriented properly to the camera
  8893. if (!_this.ui.rotationQuaternion) {
  8894. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8895. }
  8896. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8897. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8898. // Place ui the correct distance from the bottom of the mesh
  8899. if (facingUp.direction.x) {
  8900. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8901. }
  8902. if (facingUp.direction.y) {
  8903. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8904. }
  8905. if (facingUp.direction.z) {
  8906. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8907. }
  8908. _this.ui.position.addInPlace(_this._tmpVector);
  8909. });
  8910. };
  8911. /**
  8912. * Detaches the behavior from the mesh
  8913. */
  8914. AttachToBoxBehavior.prototype.detach = function () {
  8915. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8916. };
  8917. return AttachToBoxBehavior;
  8918. }());
  8919. /***/ }),
  8920. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8921. /*!***********************************************!*\
  8922. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8923. \***********************************************/
  8924. /*! exports provided: FadeInOutBehavior */
  8925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8926. "use strict";
  8927. __webpack_require__.r(__webpack_exports__);
  8928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8929. /**
  8930. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8931. */
  8932. var FadeInOutBehavior = /** @class */ (function () {
  8933. /**
  8934. * Instatiates the FadeInOutBehavior
  8935. */
  8936. function FadeInOutBehavior() {
  8937. var _this = this;
  8938. /**
  8939. * Time in milliseconds to delay before fading in (Default: 0)
  8940. */
  8941. this.delay = 0;
  8942. /**
  8943. * Time in milliseconds for the mesh to fade in (Default: 300)
  8944. */
  8945. this.fadeInTime = 300;
  8946. this._millisecondsPerFrame = 1000 / 60;
  8947. this._hovered = false;
  8948. this._hoverValue = 0;
  8949. this._ownerNode = null;
  8950. this._update = function () {
  8951. if (_this._ownerNode) {
  8952. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8953. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8954. if (_this._ownerNode.visibility > 1) {
  8955. _this._setAllVisibility(_this._ownerNode, 1);
  8956. _this._hoverValue = _this.fadeInTime + _this.delay;
  8957. return;
  8958. }
  8959. else if (_this._ownerNode.visibility < 0) {
  8960. _this._setAllVisibility(_this._ownerNode, 0);
  8961. if (_this._hoverValue < 0) {
  8962. _this._hoverValue = 0;
  8963. return;
  8964. }
  8965. }
  8966. setTimeout(_this._update, _this._millisecondsPerFrame);
  8967. }
  8968. };
  8969. }
  8970. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8971. /**
  8972. * The name of the behavior
  8973. */
  8974. get: function () {
  8975. return "FadeInOut";
  8976. },
  8977. enumerable: true,
  8978. configurable: true
  8979. });
  8980. /**
  8981. * Initializes the behavior
  8982. */
  8983. FadeInOutBehavior.prototype.init = function () {
  8984. };
  8985. /**
  8986. * Attaches the fade behavior on the passed in mesh
  8987. * @param ownerNode The mesh that will be faded in/out once attached
  8988. */
  8989. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8990. this._ownerNode = ownerNode;
  8991. this._setAllVisibility(this._ownerNode, 0);
  8992. };
  8993. /**
  8994. * Detaches the behavior from the mesh
  8995. */
  8996. FadeInOutBehavior.prototype.detach = function () {
  8997. this._ownerNode = null;
  8998. };
  8999. /**
  9000. * Triggers the mesh to begin fading in or out
  9001. * @param value if the object should fade in or out (true to fade in)
  9002. */
  9003. FadeInOutBehavior.prototype.fadeIn = function (value) {
  9004. this._hovered = value;
  9005. this._update();
  9006. };
  9007. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  9008. var _this = this;
  9009. mesh.visibility = value;
  9010. mesh.getChildMeshes().forEach(function (c) {
  9011. _this._setAllVisibility(c, value);
  9012. });
  9013. };
  9014. return FadeInOutBehavior;
  9015. }());
  9016. /***/ }),
  9017. /***/ "./Behaviors/Meshes/index.ts":
  9018. /*!***********************************!*\
  9019. !*** ./Behaviors/Meshes/index.ts ***!
  9020. \***********************************/
  9021. /*! exports provided: PointerDragBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, SixDofDragBehavior */
  9022. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9023. "use strict";
  9024. __webpack_require__.r(__webpack_exports__);
  9025. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  9026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  9027. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  9028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9029. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  9030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  9031. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  9032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  9033. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  9034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  9035. /***/ }),
  9036. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  9037. /*!*******************************************************!*\
  9038. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  9039. \*******************************************************/
  9040. /*! exports provided: MultiPointerScaleBehavior */
  9041. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9042. "use strict";
  9043. __webpack_require__.r(__webpack_exports__);
  9044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  9045. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  9046. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9047. /**
  9048. * A behavior that when attached to a mesh will allow the mesh to be scaled
  9049. */
  9050. var MultiPointerScaleBehavior = /** @class */ (function () {
  9051. /**
  9052. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  9053. */
  9054. function MultiPointerScaleBehavior() {
  9055. this._startDistance = 0;
  9056. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  9057. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  9058. this._sceneRenderObserver = null;
  9059. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  9060. this._dragBehaviorA.moveAttached = false;
  9061. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  9062. this._dragBehaviorB.moveAttached = false;
  9063. }
  9064. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  9065. /**
  9066. * The name of the behavior
  9067. */
  9068. get: function () {
  9069. return "MultiPointerScale";
  9070. },
  9071. enumerable: true,
  9072. configurable: true
  9073. });
  9074. /**
  9075. * Initializes the behavior
  9076. */
  9077. MultiPointerScaleBehavior.prototype.init = function () { };
  9078. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  9079. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  9080. };
  9081. /**
  9082. * Attaches the scale behavior the passed in mesh
  9083. * @param ownerNode The mesh that will be scaled around once attached
  9084. */
  9085. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  9086. var _this = this;
  9087. this._ownerNode = ownerNode;
  9088. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  9089. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  9090. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9091. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9092. _this._dragBehaviorA.releaseDrag();
  9093. }
  9094. else {
  9095. _this._initialScale.copyFrom(ownerNode.scaling);
  9096. _this._startDistance = _this._getCurrentDistance();
  9097. }
  9098. }
  9099. });
  9100. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9101. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9102. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9103. _this._dragBehaviorB.releaseDrag();
  9104. }
  9105. else {
  9106. _this._initialScale.copyFrom(ownerNode.scaling);
  9107. _this._startDistance = _this._getCurrentDistance();
  9108. }
  9109. }
  9110. });
  9111. // Once both drag behaviors are active scale based on the distance between the two pointers
  9112. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9113. behavior.onDragObservable.add(function () {
  9114. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9115. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9116. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9117. }
  9118. });
  9119. });
  9120. ownerNode.addBehavior(this._dragBehaviorA);
  9121. ownerNode.addBehavior(this._dragBehaviorB);
  9122. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9123. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9124. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9125. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9126. if (change.length() > 0.01) {
  9127. ownerNode.scaling.addInPlace(change);
  9128. }
  9129. }
  9130. });
  9131. };
  9132. /**
  9133. * Detaches the behavior from the mesh
  9134. */
  9135. MultiPointerScaleBehavior.prototype.detach = function () {
  9136. var _this = this;
  9137. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9138. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9139. behavior.onDragStartObservable.clear();
  9140. behavior.onDragObservable.clear();
  9141. _this._ownerNode.removeBehavior(behavior);
  9142. });
  9143. };
  9144. return MultiPointerScaleBehavior;
  9145. }());
  9146. /***/ }),
  9147. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9148. /*!*************************************************!*\
  9149. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9150. \*************************************************/
  9151. /*! exports provided: PointerDragBehavior */
  9152. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9153. "use strict";
  9154. __webpack_require__.r(__webpack_exports__);
  9155. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9156. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9157. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9158. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9159. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9160. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9161. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9162. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9163. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9164. /**
  9165. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9166. */
  9167. var PointerDragBehavior = /** @class */ (function () {
  9168. /**
  9169. * Creates a pointer drag behavior that can be attached to a mesh
  9170. * @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)
  9171. */
  9172. function PointerDragBehavior(options) {
  9173. this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;
  9174. /**
  9175. * 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)
  9176. */
  9177. this.maxDragAngle = 0;
  9178. /**
  9179. * @hidden
  9180. */
  9181. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9182. /**
  9183. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9184. */
  9185. this.currentDraggingPointerID = -1;
  9186. /**
  9187. * If the behavior is currently in a dragging state
  9188. */
  9189. this.dragging = false;
  9190. /**
  9191. * 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)
  9192. */
  9193. this.dragDeltaRatio = 0.2;
  9194. /**
  9195. * If the drag plane orientation should be updated during the dragging (Default: true)
  9196. */
  9197. this.updateDragPlane = true;
  9198. // Debug mode will display drag planes to help visualize behavior
  9199. this._debugMode = false;
  9200. this._moving = false;
  9201. /**
  9202. * Fires each time the attached mesh is dragged with the pointer
  9203. * * delta between last drag position and current drag position in world space
  9204. * * dragDistance along the drag axis
  9205. * * dragPlaneNormal normal of the current drag plane used during the drag
  9206. * * dragPlanePoint in world space where the drag intersects the drag plane
  9207. */
  9208. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9209. /**
  9210. * Fires each time a drag begins (eg. mouse down on mesh)
  9211. */
  9212. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9213. /**
  9214. * Fires each time a drag ends (eg. mouse release after drag)
  9215. */
  9216. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9217. /**
  9218. * If the attached mesh should be moved when dragged
  9219. */
  9220. this.moveAttached = true;
  9221. /**
  9222. * If the drag behavior will react to drag events (Default: true)
  9223. */
  9224. this.enabled = true;
  9225. /**
  9226. * If camera controls should be detached during the drag
  9227. */
  9228. this.detachCameraControls = true;
  9229. /**
  9230. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9231. */
  9232. this.useObjectOrienationForDragging = true;
  9233. /**
  9234. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9235. */
  9236. this.validateDrag = function (targetPosition) { return true; };
  9237. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9238. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9239. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9240. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9241. this._attachedElement = null;
  9242. 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"]());
  9243. this._lastPointerRay = {};
  9244. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9245. // Variables to avoid instantiation in the below method
  9246. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9247. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9248. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9249. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9250. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9251. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9252. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9253. this._options = options ? options : {};
  9254. var optionCount = 0;
  9255. if (this._options.dragAxis) {
  9256. optionCount++;
  9257. }
  9258. if (this._options.dragPlaneNormal) {
  9259. optionCount++;
  9260. }
  9261. if (optionCount > 1) {
  9262. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9263. }
  9264. }
  9265. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9266. /**
  9267. * The name of the behavior
  9268. */
  9269. get: function () {
  9270. return "PointerDrag";
  9271. },
  9272. enumerable: true,
  9273. configurable: true
  9274. });
  9275. /**
  9276. * Initializes the behavior
  9277. */
  9278. PointerDragBehavior.prototype.init = function () { };
  9279. /**
  9280. * Attaches the drag behavior the passed in mesh
  9281. * @param ownerNode The mesh that will be dragged around once attached
  9282. */
  9283. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9284. var _this = this;
  9285. this._scene = ownerNode.getScene();
  9286. this._attachedNode = ownerNode;
  9287. // Initialize drag plane to not interfere with existing scene
  9288. if (!PointerDragBehavior._planeScene) {
  9289. if (this._debugMode) {
  9290. PointerDragBehavior._planeScene = this._scene;
  9291. }
  9292. else {
  9293. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine(), { virtual: true });
  9294. PointerDragBehavior._planeScene.detachControl();
  9295. this._scene.onDisposeObservable.addOnce(function () {
  9296. PointerDragBehavior._planeScene.dispose();
  9297. PointerDragBehavior._planeScene = null;
  9298. });
  9299. }
  9300. }
  9301. 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);
  9302. // State of the drag
  9303. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9304. var pickPredicate = function (m) {
  9305. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  9306. };
  9307. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9308. if (!_this.enabled) {
  9309. return;
  9310. }
  9311. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9312. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9313. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9314. }
  9315. }
  9316. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9317. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9318. _this.releaseDrag();
  9319. }
  9320. }
  9321. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9322. var pointerId = pointerInfo.event.pointerId;
  9323. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9324. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9325. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9326. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9327. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9328. }
  9329. _this.currentDraggingPointerID = pointerId;
  9330. }
  9331. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9332. if (!_this._lastPointerRay[pointerId]) {
  9333. _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"]());
  9334. }
  9335. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9336. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9337. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9338. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9339. _this._moveDrag(pointerInfo.pickInfo.ray);
  9340. }
  9341. }
  9342. }
  9343. });
  9344. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9345. if (_this._moving && _this.moveAttached) {
  9346. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  9347. // Slowly move mesh to avoid jitter
  9348. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  9349. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9350. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9351. if (_this.validateDrag(_this._tmpVector)) {
  9352. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  9353. }
  9354. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  9355. }
  9356. });
  9357. };
  9358. /**
  9359. * Force relase the drag action by code.
  9360. */
  9361. PointerDragBehavior.prototype.releaseDrag = function () {
  9362. this.dragging = false;
  9363. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9364. this.currentDraggingPointerID = -1;
  9365. this._moving = false;
  9366. // Reattach camera controls
  9367. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9368. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9369. }
  9370. };
  9371. /**
  9372. * Simulates the start of a pointer drag event on the behavior
  9373. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9374. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9375. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9376. */
  9377. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9378. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9379. this._startDrag(pointerId, fromRay, startPickedPoint);
  9380. var lastRay = this._lastPointerRay[pointerId];
  9381. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9382. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9383. }
  9384. if (lastRay) {
  9385. // if there was a last pointer ray drag the object there
  9386. this._moveDrag(lastRay);
  9387. }
  9388. };
  9389. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9390. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  9391. return;
  9392. }
  9393. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  9394. // Create start ray from the camera to the object
  9395. if (fromRay) {
  9396. this._startDragRay.direction.copyFrom(fromRay.direction);
  9397. this._startDragRay.origin.copyFrom(fromRay.origin);
  9398. }
  9399. else {
  9400. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9401. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9402. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9403. }
  9404. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9405. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9406. if (pickedPoint) {
  9407. this.dragging = true;
  9408. this.currentDraggingPointerID = pointerId;
  9409. this.lastDragPosition.copyFrom(pickedPoint);
  9410. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9411. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  9412. // Detatch camera controls
  9413. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9414. if (this._scene.activeCamera.inputs.attachedElement) {
  9415. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9416. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9417. }
  9418. else {
  9419. this._attachedElement = null;
  9420. }
  9421. }
  9422. }
  9423. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  9424. };
  9425. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9426. this._moving = true;
  9427. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9428. if (pickedPoint) {
  9429. if (this.updateDragPlane) {
  9430. this._updateDragPlanePosition(ray, pickedPoint);
  9431. }
  9432. var dragLength = 0;
  9433. // depending on the drag mode option drag accordingly
  9434. if (this._options.dragAxis) {
  9435. // Convert local drag axis to world
  9436. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  9437. // Project delta drag from the drag plane onto the drag axis
  9438. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9439. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9440. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9441. }
  9442. else {
  9443. dragLength = this._dragDelta.length();
  9444. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9445. }
  9446. this._targetPosition.addInPlace(this._dragDelta);
  9447. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9448. this.lastDragPosition.copyFrom(pickedPoint);
  9449. }
  9450. };
  9451. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9452. var _this = this;
  9453. if (!ray) {
  9454. return null;
  9455. }
  9456. // Calculate angle between plane normal and ray
  9457. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9458. // Correct if ray is casted from oposite side
  9459. if (angle > Math.PI / 2) {
  9460. angle = Math.PI - angle;
  9461. }
  9462. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9463. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9464. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9465. // Invert ray direction along the towards object axis
  9466. this._tmpVector.copyFrom(ray.direction);
  9467. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9468. this._alternatePickedPoint.normalize();
  9469. this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9470. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9471. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9472. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9473. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9474. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9475. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9476. return this._alternatePickedPoint;
  9477. }
  9478. else {
  9479. return null;
  9480. }
  9481. }
  9482. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9483. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9484. return pickResult.pickedPoint;
  9485. }
  9486. else {
  9487. return null;
  9488. }
  9489. };
  9490. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9491. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9492. this._pointA.copyFrom(dragPlanePosition);
  9493. if (this._options.dragAxis) {
  9494. 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);
  9495. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9496. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9497. ray.origin.subtractToRef(this._pointA, this._pointC);
  9498. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9499. // Get perpendicular line from direction to camera and drag axis
  9500. this._pointB.subtractToRef(this._pointA, this._lineA);
  9501. this._pointC.subtractToRef(this._pointA, this._lineB);
  9502. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9503. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9504. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9505. this._lookAt.normalize();
  9506. this._dragPlane.position.copyFrom(this._pointA);
  9507. this._pointA.addToRef(this._lookAt, this._lookAt);
  9508. this._dragPlane.lookAt(this._lookAt);
  9509. }
  9510. else if (this._options.dragPlaneNormal) {
  9511. 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);
  9512. this._dragPlane.position.copyFrom(this._pointA);
  9513. this._pointA.addToRef(this._localAxis, this._lookAt);
  9514. this._dragPlane.lookAt(this._lookAt);
  9515. }
  9516. else {
  9517. this._dragPlane.position.copyFrom(this._pointA);
  9518. this._dragPlane.lookAt(ray.origin);
  9519. }
  9520. // 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)
  9521. this._dragPlane.position.copyFrom(this._attachedNode.absolutePosition);
  9522. this._dragPlane.computeWorldMatrix(true);
  9523. };
  9524. /**
  9525. * Detaches the behavior from the mesh
  9526. */
  9527. PointerDragBehavior.prototype.detach = function () {
  9528. if (this._pointerObserver) {
  9529. this._scene.onPointerObservable.remove(this._pointerObserver);
  9530. }
  9531. if (this._beforeRenderObserver) {
  9532. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9533. }
  9534. this.releaseDrag();
  9535. };
  9536. PointerDragBehavior._AnyMouseID = -2;
  9537. return PointerDragBehavior;
  9538. }());
  9539. /***/ }),
  9540. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9541. /*!************************************************!*\
  9542. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9543. \************************************************/
  9544. /*! exports provided: SixDofDragBehavior */
  9545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9546. "use strict";
  9547. __webpack_require__.r(__webpack_exports__);
  9548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9549. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9550. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9551. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9552. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9553. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9554. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9555. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9556. /**
  9557. * 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
  9558. */
  9559. var SixDofDragBehavior = /** @class */ (function () {
  9560. /**
  9561. * 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
  9562. */
  9563. function SixDofDragBehavior() {
  9564. this._sceneRenderObserver = null;
  9565. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9566. this._moving = false;
  9567. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9568. /**
  9569. * 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)
  9570. */
  9571. this.zDragFactor = 3;
  9572. /**
  9573. * If the object should rotate to face the drag origin
  9574. */
  9575. this.rotateDraggedObject = true;
  9576. /**
  9577. * If the behavior is currently in a dragging state
  9578. */
  9579. this.dragging = false;
  9580. /**
  9581. * 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)
  9582. */
  9583. this.dragDeltaRatio = 0.2;
  9584. /**
  9585. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9586. */
  9587. this.currentDraggingPointerID = -1;
  9588. /**
  9589. * If camera controls should be detached during the drag
  9590. */
  9591. this.detachCameraControls = true;
  9592. /**
  9593. * Fires each time a drag starts
  9594. */
  9595. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9596. /**
  9597. * Fires each time a drag ends (eg. mouse release after drag)
  9598. */
  9599. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9600. }
  9601. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9602. /**
  9603. * The name of the behavior
  9604. */
  9605. get: function () {
  9606. return "SixDofDrag";
  9607. },
  9608. enumerable: true,
  9609. configurable: true
  9610. });
  9611. /**
  9612. * Initializes the behavior
  9613. */
  9614. SixDofDragBehavior.prototype.init = function () { };
  9615. /**
  9616. * Attaches the scale behavior the passed in mesh
  9617. * @param ownerNode The mesh that will be scaled around once attached
  9618. */
  9619. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9620. var _this = this;
  9621. this._ownerNode = ownerNode;
  9622. this._scene = this._ownerNode.getScene();
  9623. if (!SixDofDragBehavior._virtualScene) {
  9624. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9625. SixDofDragBehavior._virtualScene.detachControl();
  9626. this._scene.getEngine().scenes.pop();
  9627. }
  9628. var pickedMesh = null;
  9629. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9630. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9631. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9632. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9633. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9634. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9635. var pickPredicate = function (m) {
  9636. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9637. };
  9638. var attachedElement = null;
  9639. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9640. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9641. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9642. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9643. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9644. }
  9645. pickedMesh = _this._ownerNode;
  9646. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9647. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9648. // Set position and orientation of the controller
  9649. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9650. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9651. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9652. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9653. pickedMesh.computeWorldMatrix();
  9654. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9655. if (!pickedMesh.rotationQuaternion) {
  9656. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9657. }
  9658. var oldParent = pickedMesh.parent;
  9659. pickedMesh.setParent(null);
  9660. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9661. pickedMesh.setParent(oldParent);
  9662. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9663. // Update state
  9664. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9665. _this.dragging = true;
  9666. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9667. // Detatch camera controls
  9668. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9669. if (_this._scene.activeCamera.inputs.attachedElement) {
  9670. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9671. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9672. }
  9673. else {
  9674. attachedElement = null;
  9675. }
  9676. }
  9677. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9678. _this.onDragStartObservable.notifyObservers({});
  9679. }
  9680. }
  9681. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9682. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9683. _this.dragging = false;
  9684. _this._moving = false;
  9685. _this.currentDraggingPointerID = -1;
  9686. pickedMesh = null;
  9687. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9688. // Reattach camera controls
  9689. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9690. _this._scene.activeCamera.attachControl(attachedElement, true);
  9691. }
  9692. _this.onDragEndObservable.notifyObservers({});
  9693. }
  9694. }
  9695. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9696. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9697. var zDragFactor = _this.zDragFactor;
  9698. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9699. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9700. zDragFactor = 0;
  9701. }
  9702. // Calculate controller drag distance in controller space
  9703. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9704. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9705. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9706. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9707. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9708. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9709. if (_this._virtualDragMesh.position.z < 0) {
  9710. _this._virtualDragMesh.position.z = 0;
  9711. }
  9712. // Update the controller position
  9713. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9714. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9715. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9716. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9717. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9718. if (pickedMesh.parent) {
  9719. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9720. }
  9721. if (!_this._moving) {
  9722. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9723. }
  9724. _this._moving = true;
  9725. }
  9726. }
  9727. });
  9728. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9729. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9730. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9731. if (_this.dragging && _this._moving && pickedMesh) {
  9732. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9733. // Slowly move mesh to avoid jitter
  9734. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9735. if (_this.rotateDraggedObject) {
  9736. // Get change in rotation
  9737. tmpQuaternion.copyFrom(_this._startingOrientation);
  9738. tmpQuaternion.x = -tmpQuaternion.x;
  9739. tmpQuaternion.y = -tmpQuaternion.y;
  9740. tmpQuaternion.z = -tmpQuaternion.z;
  9741. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9742. // Convert change in rotation to only y axis rotation
  9743. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9744. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9745. // Slowly move mesh to avoid jitter
  9746. var oldParent = pickedMesh.parent;
  9747. // Only rotate the mesh if it's parent has uniform scaling
  9748. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9749. pickedMesh.setParent(null);
  9750. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9751. pickedMesh.setParent(oldParent);
  9752. }
  9753. }
  9754. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9755. }
  9756. });
  9757. };
  9758. /**
  9759. * Detaches the behavior from the mesh
  9760. */
  9761. SixDofDragBehavior.prototype.detach = function () {
  9762. if (this._scene) {
  9763. this._scene.onPointerObservable.remove(this._pointerObserver);
  9764. }
  9765. if (this._ownerNode) {
  9766. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9767. }
  9768. if (this._virtualOriginMesh) {
  9769. this._virtualOriginMesh.dispose();
  9770. }
  9771. if (this._virtualDragMesh) {
  9772. this._virtualDragMesh.dispose();
  9773. }
  9774. this.onDragEndObservable.clear();
  9775. this.onDragStartObservable.clear();
  9776. };
  9777. return SixDofDragBehavior;
  9778. }());
  9779. /***/ }),
  9780. /***/ "./Behaviors/index.ts":
  9781. /*!****************************!*\
  9782. !*** ./Behaviors/index.ts ***!
  9783. \****************************/
  9784. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, PointerDragBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, SixDofDragBehavior */
  9785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9786. "use strict";
  9787. __webpack_require__.r(__webpack_exports__);
  9788. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9792. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9798. /***/ }),
  9799. /***/ "./Bones/bone.ts":
  9800. /*!***********************!*\
  9801. !*** ./Bones/bone.ts ***!
  9802. \***********************/
  9803. /*! exports provided: Bone */
  9804. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9805. "use strict";
  9806. __webpack_require__.r(__webpack_exports__);
  9807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9808. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9809. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9810. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9811. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9812. /**
  9813. * Class used to store bone information
  9814. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9815. */
  9816. var Bone = /** @class */ (function (_super) {
  9817. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9818. /**
  9819. * Create a new bone
  9820. * @param name defines the bone name
  9821. * @param skeleton defines the parent skeleton
  9822. * @param parentBone defines the parent (can be null if the bone is the root)
  9823. * @param localMatrix defines the local matrix
  9824. * @param restPose defines the rest pose matrix
  9825. * @param baseMatrix defines the base matrix
  9826. * @param index defines index of the bone in the hiearchy
  9827. */
  9828. function Bone(
  9829. /**
  9830. * defines the bone name
  9831. */
  9832. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9833. if (parentBone === void 0) { parentBone = null; }
  9834. if (localMatrix === void 0) { localMatrix = null; }
  9835. if (restPose === void 0) { restPose = null; }
  9836. if (baseMatrix === void 0) { baseMatrix = null; }
  9837. if (index === void 0) { index = null; }
  9838. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9839. _this.name = name;
  9840. /**
  9841. * Gets the list of child bones
  9842. */
  9843. _this.children = new Array();
  9844. /** Gets the animations associated with this bone */
  9845. _this.animations = new Array();
  9846. /**
  9847. * @hidden Internal only
  9848. * Set this value to map this bone to a different index in the transform matrices
  9849. * Set this value to -1 to exclude the bone from the transform matrices
  9850. */
  9851. _this._index = null;
  9852. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9853. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9854. _this._scalingDeterminant = 1;
  9855. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9856. _this._needToDecompose = true;
  9857. _this._needToCompose = false;
  9858. /** @hidden */
  9859. _this._linkedTransformNode = null;
  9860. /** @hidden */
  9861. _this._waitingTransformNodeId = null;
  9862. _this._skeleton = skeleton;
  9863. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9864. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9865. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9866. _this._index = index;
  9867. skeleton.bones.push(_this);
  9868. _this.setParent(parentBone, false);
  9869. if (baseMatrix || localMatrix) {
  9870. _this._updateDifferenceMatrix();
  9871. }
  9872. return _this;
  9873. }
  9874. Object.defineProperty(Bone.prototype, "_matrix", {
  9875. /** @hidden */
  9876. get: function () {
  9877. this._compose();
  9878. return this._localMatrix;
  9879. },
  9880. /** @hidden */
  9881. set: function (value) {
  9882. this._localMatrix.copyFrom(value);
  9883. this._needToDecompose = true;
  9884. },
  9885. enumerable: true,
  9886. configurable: true
  9887. });
  9888. /**
  9889. * Gets the current object class name.
  9890. * @return the class name
  9891. */
  9892. Bone.prototype.getClassName = function () {
  9893. return "Bone";
  9894. };
  9895. // Members
  9896. /**
  9897. * Gets the parent skeleton
  9898. * @returns a skeleton
  9899. */
  9900. Bone.prototype.getSkeleton = function () {
  9901. return this._skeleton;
  9902. };
  9903. /**
  9904. * Gets parent bone
  9905. * @returns a bone or null if the bone is the root of the bone hierarchy
  9906. */
  9907. Bone.prototype.getParent = function () {
  9908. return this._parent;
  9909. };
  9910. /**
  9911. * Returns an array containing the root bones
  9912. * @returns an array containing the root bones
  9913. */
  9914. Bone.prototype.getChildren = function () {
  9915. return this.children;
  9916. };
  9917. /**
  9918. * Sets the parent bone
  9919. * @param parent defines the parent (can be null if the bone is the root)
  9920. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9921. */
  9922. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9923. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9924. if (this._parent === parent) {
  9925. return;
  9926. }
  9927. if (this._parent) {
  9928. var index = this._parent.children.indexOf(this);
  9929. if (index !== -1) {
  9930. this._parent.children.splice(index, 1);
  9931. }
  9932. }
  9933. this._parent = parent;
  9934. if (this._parent) {
  9935. this._parent.children.push(this);
  9936. }
  9937. if (updateDifferenceMatrix) {
  9938. this._updateDifferenceMatrix();
  9939. }
  9940. this.markAsDirty();
  9941. };
  9942. /**
  9943. * Gets the local matrix
  9944. * @returns a matrix
  9945. */
  9946. Bone.prototype.getLocalMatrix = function () {
  9947. this._compose();
  9948. return this._localMatrix;
  9949. };
  9950. /**
  9951. * Gets the base matrix (initial matrix which remains unchanged)
  9952. * @returns a matrix
  9953. */
  9954. Bone.prototype.getBaseMatrix = function () {
  9955. return this._baseMatrix;
  9956. };
  9957. /**
  9958. * Gets the rest pose matrix
  9959. * @returns a matrix
  9960. */
  9961. Bone.prototype.getRestPose = function () {
  9962. return this._restPose;
  9963. };
  9964. /**
  9965. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9966. */
  9967. Bone.prototype.getWorldMatrix = function () {
  9968. return this._worldTransform;
  9969. };
  9970. /**
  9971. * Sets the local matrix to rest pose matrix
  9972. */
  9973. Bone.prototype.returnToRest = function () {
  9974. this.updateMatrix(this._restPose.clone());
  9975. };
  9976. /**
  9977. * Gets the inverse of the absolute transform matrix.
  9978. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9979. * @returns a matrix
  9980. */
  9981. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9982. return this._invertedAbsoluteTransform;
  9983. };
  9984. /**
  9985. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9986. * @returns a matrix
  9987. */
  9988. Bone.prototype.getAbsoluteTransform = function () {
  9989. return this._absoluteTransform;
  9990. };
  9991. /**
  9992. * Links with the given transform node.
  9993. * The local matrix of this bone is copied from the transform node every frame.
  9994. * @param transformNode defines the transform node to link to
  9995. */
  9996. Bone.prototype.linkTransformNode = function (transformNode) {
  9997. if (this._linkedTransformNode) {
  9998. this._skeleton._numBonesWithLinkedTransformNode--;
  9999. }
  10000. this._linkedTransformNode = transformNode;
  10001. if (this._linkedTransformNode) {
  10002. this._skeleton._numBonesWithLinkedTransformNode++;
  10003. }
  10004. };
  10005. Object.defineProperty(Bone.prototype, "position", {
  10006. // Properties (matches AbstractMesh properties)
  10007. /** Gets or sets current position (in local space) */
  10008. get: function () {
  10009. this._decompose();
  10010. return this._localPosition;
  10011. },
  10012. set: function (newPosition) {
  10013. this._decompose();
  10014. this._localPosition.copyFrom(newPosition);
  10015. this._markAsDirtyAndCompose();
  10016. },
  10017. enumerable: true,
  10018. configurable: true
  10019. });
  10020. Object.defineProperty(Bone.prototype, "rotation", {
  10021. /** Gets or sets current rotation (in local space) */
  10022. get: function () {
  10023. return this.getRotation();
  10024. },
  10025. set: function (newRotation) {
  10026. this.setRotation(newRotation);
  10027. },
  10028. enumerable: true,
  10029. configurable: true
  10030. });
  10031. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  10032. /** Gets or sets current rotation quaternion (in local space) */
  10033. get: function () {
  10034. this._decompose();
  10035. return this._localRotation;
  10036. },
  10037. set: function (newRotation) {
  10038. this.setRotationQuaternion(newRotation);
  10039. },
  10040. enumerable: true,
  10041. configurable: true
  10042. });
  10043. Object.defineProperty(Bone.prototype, "scaling", {
  10044. /** Gets or sets current scaling (in local space) */
  10045. get: function () {
  10046. return this.getScale();
  10047. },
  10048. set: function (newScaling) {
  10049. this.setScale(newScaling);
  10050. },
  10051. enumerable: true,
  10052. configurable: true
  10053. });
  10054. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  10055. /**
  10056. * Gets the animation properties override
  10057. */
  10058. get: function () {
  10059. return this._skeleton.animationPropertiesOverride;
  10060. },
  10061. enumerable: true,
  10062. configurable: true
  10063. });
  10064. // Methods
  10065. Bone.prototype._decompose = function () {
  10066. if (!this._needToDecompose) {
  10067. return;
  10068. }
  10069. this._needToDecompose = false;
  10070. if (!this._localScaling) {
  10071. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10072. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  10073. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10074. }
  10075. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  10076. };
  10077. Bone.prototype._compose = function () {
  10078. if (!this._needToCompose) {
  10079. return;
  10080. }
  10081. this._needToCompose = false;
  10082. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  10083. };
  10084. /**
  10085. * Update the base and local matrices
  10086. * @param matrix defines the new base or local matrix
  10087. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  10088. * @param updateLocalMatrix defines if the local matrix should be updated
  10089. */
  10090. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  10091. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  10092. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  10093. this._baseMatrix.copyFrom(matrix);
  10094. if (updateDifferenceMatrix) {
  10095. this._updateDifferenceMatrix();
  10096. }
  10097. if (updateLocalMatrix) {
  10098. this._localMatrix.copyFrom(matrix);
  10099. this._markAsDirtyAndDecompose();
  10100. }
  10101. else {
  10102. this.markAsDirty();
  10103. }
  10104. };
  10105. /** @hidden */
  10106. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  10107. if (updateChildren === void 0) { updateChildren = true; }
  10108. if (!rootMatrix) {
  10109. rootMatrix = this._baseMatrix;
  10110. }
  10111. if (this._parent) {
  10112. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10113. }
  10114. else {
  10115. this._absoluteTransform.copyFrom(rootMatrix);
  10116. }
  10117. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10118. if (updateChildren) {
  10119. for (var index = 0; index < this.children.length; index++) {
  10120. this.children[index]._updateDifferenceMatrix();
  10121. }
  10122. }
  10123. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10124. };
  10125. /**
  10126. * Flag the bone as dirty (Forcing it to update everything)
  10127. */
  10128. Bone.prototype.markAsDirty = function () {
  10129. this._currentRenderId++;
  10130. this._childUpdateId++;
  10131. this._skeleton._markAsDirty();
  10132. };
  10133. Bone.prototype._markAsDirtyAndCompose = function () {
  10134. this.markAsDirty();
  10135. this._needToCompose = true;
  10136. };
  10137. Bone.prototype._markAsDirtyAndDecompose = function () {
  10138. this.markAsDirty();
  10139. this._needToDecompose = true;
  10140. };
  10141. /**
  10142. * Translate the bone in local or world space
  10143. * @param vec The amount to translate the bone
  10144. * @param space The space that the translation is in
  10145. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10146. */
  10147. Bone.prototype.translate = function (vec, space, mesh) {
  10148. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10149. var lm = this.getLocalMatrix();
  10150. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10151. lm.addAtIndex(12, vec.x);
  10152. lm.addAtIndex(13, vec.y);
  10153. lm.addAtIndex(14, vec.z);
  10154. }
  10155. else {
  10156. var wm = null;
  10157. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10158. if (mesh) {
  10159. wm = mesh.getWorldMatrix();
  10160. }
  10161. this._skeleton.computeAbsoluteTransforms();
  10162. var tmat = Bone._tmpMats[0];
  10163. var tvec = Bone._tmpVecs[0];
  10164. if (this._parent) {
  10165. if (mesh && wm) {
  10166. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10167. tmat.multiplyToRef(wm, tmat);
  10168. }
  10169. else {
  10170. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10171. }
  10172. }
  10173. tmat.setTranslationFromFloats(0, 0, 0);
  10174. tmat.invert();
  10175. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10176. lm.addAtIndex(12, tvec.x);
  10177. lm.addAtIndex(13, tvec.y);
  10178. lm.addAtIndex(14, tvec.z);
  10179. }
  10180. this._markAsDirtyAndDecompose();
  10181. };
  10182. /**
  10183. * Set the postion of the bone in local or world space
  10184. * @param position The position to set the bone
  10185. * @param space The space that the position is in
  10186. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10187. */
  10188. Bone.prototype.setPosition = function (position, space, mesh) {
  10189. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10190. var lm = this.getLocalMatrix();
  10191. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10192. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10193. }
  10194. else {
  10195. var wm = null;
  10196. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10197. if (mesh) {
  10198. wm = mesh.getWorldMatrix();
  10199. }
  10200. this._skeleton.computeAbsoluteTransforms();
  10201. var tmat = Bone._tmpMats[0];
  10202. var vec = Bone._tmpVecs[0];
  10203. if (this._parent) {
  10204. if (mesh && wm) {
  10205. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10206. tmat.multiplyToRef(wm, tmat);
  10207. }
  10208. else {
  10209. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10210. }
  10211. }
  10212. tmat.invert();
  10213. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10214. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10215. }
  10216. this._markAsDirtyAndDecompose();
  10217. };
  10218. /**
  10219. * Set the absolute position of the bone (world space)
  10220. * @param position The position to set the bone
  10221. * @param mesh The mesh that this bone is attached to
  10222. */
  10223. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10224. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10225. };
  10226. /**
  10227. * Scale the bone on the x, y and z axes (in local space)
  10228. * @param x The amount to scale the bone on the x axis
  10229. * @param y The amount to scale the bone on the y axis
  10230. * @param z The amount to scale the bone on the z axis
  10231. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10232. */
  10233. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10234. if (scaleChildren === void 0) { scaleChildren = false; }
  10235. var locMat = this.getLocalMatrix();
  10236. // Apply new scaling on top of current local matrix
  10237. var scaleMat = Bone._tmpMats[0];
  10238. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10239. scaleMat.multiplyToRef(locMat, locMat);
  10240. // Invert scaling matrix and apply the inverse to all children
  10241. scaleMat.invert();
  10242. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10243. var child = _a[_i];
  10244. var cm = child.getLocalMatrix();
  10245. cm.multiplyToRef(scaleMat, cm);
  10246. cm.multiplyAtIndex(12, x);
  10247. cm.multiplyAtIndex(13, y);
  10248. cm.multiplyAtIndex(14, z);
  10249. child._markAsDirtyAndDecompose();
  10250. }
  10251. this._markAsDirtyAndDecompose();
  10252. if (scaleChildren) {
  10253. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10254. var child = _c[_b];
  10255. child.scale(x, y, z, scaleChildren);
  10256. }
  10257. }
  10258. };
  10259. /**
  10260. * Set the bone scaling in local space
  10261. * @param scale defines the scaling vector
  10262. */
  10263. Bone.prototype.setScale = function (scale) {
  10264. this._decompose();
  10265. this._localScaling.copyFrom(scale);
  10266. this._markAsDirtyAndCompose();
  10267. };
  10268. /**
  10269. * Gets the current scaling in local space
  10270. * @returns the current scaling vector
  10271. */
  10272. Bone.prototype.getScale = function () {
  10273. this._decompose();
  10274. return this._localScaling;
  10275. };
  10276. /**
  10277. * Gets the current scaling in local space and stores it in a target vector
  10278. * @param result defines the target vector
  10279. */
  10280. Bone.prototype.getScaleToRef = function (result) {
  10281. this._decompose();
  10282. result.copyFrom(this._localScaling);
  10283. };
  10284. /**
  10285. * Set the yaw, pitch, and roll of the bone in local or world space
  10286. * @param yaw The rotation of the bone on the y axis
  10287. * @param pitch The rotation of the bone on the x axis
  10288. * @param roll The rotation of the bone on the z axis
  10289. * @param space The space that the axes of rotation are in
  10290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10291. */
  10292. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10293. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10294. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10295. var quat = Bone._tmpQuat;
  10296. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10297. this.setRotationQuaternion(quat, space, mesh);
  10298. return;
  10299. }
  10300. var rotMatInv = Bone._tmpMats[0];
  10301. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10302. return;
  10303. }
  10304. var rotMat = Bone._tmpMats[1];
  10305. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10306. rotMatInv.multiplyToRef(rotMat, rotMat);
  10307. this._rotateWithMatrix(rotMat, space, mesh);
  10308. };
  10309. /**
  10310. * Add a rotation to the bone on an axis in local or world space
  10311. * @param axis The axis to rotate the bone on
  10312. * @param amount The amount to rotate the bone
  10313. * @param space The space that the axis is in
  10314. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10315. */
  10316. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10317. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10318. var rmat = Bone._tmpMats[0];
  10319. rmat.setTranslationFromFloats(0, 0, 0);
  10320. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10321. this._rotateWithMatrix(rmat, space, mesh);
  10322. };
  10323. /**
  10324. * Set the rotation of the bone to a particular axis angle in local or world space
  10325. * @param axis The axis to rotate the bone on
  10326. * @param angle The angle that the bone should be rotated to
  10327. * @param space The space that the axis is in
  10328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10329. */
  10330. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10331. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10332. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10333. var quat = Bone._tmpQuat;
  10334. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10335. this.setRotationQuaternion(quat, space, mesh);
  10336. return;
  10337. }
  10338. var rotMatInv = Bone._tmpMats[0];
  10339. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10340. return;
  10341. }
  10342. var rotMat = Bone._tmpMats[1];
  10343. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10344. rotMatInv.multiplyToRef(rotMat, rotMat);
  10345. this._rotateWithMatrix(rotMat, space, mesh);
  10346. };
  10347. /**
  10348. * Set the euler rotation of the bone in local of world space
  10349. * @param rotation The euler rotation that the bone should be set to
  10350. * @param space The space that the rotation is in
  10351. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10352. */
  10353. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10354. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10355. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10356. };
  10357. /**
  10358. * Set the quaternion rotation of the bone in local of world space
  10359. * @param quat The quaternion rotation that the bone should be set to
  10360. * @param space The space that the rotation is in
  10361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10362. */
  10363. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10364. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10365. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10366. this._decompose();
  10367. this._localRotation.copyFrom(quat);
  10368. this._markAsDirtyAndCompose();
  10369. return;
  10370. }
  10371. var rotMatInv = Bone._tmpMats[0];
  10372. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10373. return;
  10374. }
  10375. var rotMat = Bone._tmpMats[1];
  10376. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10377. rotMatInv.multiplyToRef(rotMat, rotMat);
  10378. this._rotateWithMatrix(rotMat, space, mesh);
  10379. };
  10380. /**
  10381. * Set the rotation matrix of the bone in local of world space
  10382. * @param rotMat The rotation matrix that the bone should be set to
  10383. * @param space The space that the rotation is in
  10384. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10385. */
  10386. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10387. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10388. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10389. var quat = Bone._tmpQuat;
  10390. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10391. this.setRotationQuaternion(quat, space, mesh);
  10392. return;
  10393. }
  10394. var rotMatInv = Bone._tmpMats[0];
  10395. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10396. return;
  10397. }
  10398. var rotMat2 = Bone._tmpMats[1];
  10399. rotMat2.copyFrom(rotMat);
  10400. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10401. this._rotateWithMatrix(rotMat2, space, mesh);
  10402. };
  10403. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10404. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10405. var lmat = this.getLocalMatrix();
  10406. var lx = lmat.m[12];
  10407. var ly = lmat.m[13];
  10408. var lz = lmat.m[14];
  10409. var parent = this.getParent();
  10410. var parentScale = Bone._tmpMats[3];
  10411. var parentScaleInv = Bone._tmpMats[4];
  10412. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10413. if (mesh) {
  10414. parentScale.copyFrom(mesh.getWorldMatrix());
  10415. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10416. }
  10417. else {
  10418. parentScale.copyFrom(parent.getAbsoluteTransform());
  10419. }
  10420. parentScaleInv.copyFrom(parentScale);
  10421. parentScaleInv.invert();
  10422. lmat.multiplyToRef(parentScale, lmat);
  10423. lmat.multiplyToRef(rmat, lmat);
  10424. lmat.multiplyToRef(parentScaleInv, lmat);
  10425. }
  10426. else {
  10427. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10428. parentScale.copyFrom(mesh.getWorldMatrix());
  10429. parentScaleInv.copyFrom(parentScale);
  10430. parentScaleInv.invert();
  10431. lmat.multiplyToRef(parentScale, lmat);
  10432. lmat.multiplyToRef(rmat, lmat);
  10433. lmat.multiplyToRef(parentScaleInv, lmat);
  10434. }
  10435. else {
  10436. lmat.multiplyToRef(rmat, lmat);
  10437. }
  10438. }
  10439. lmat.setTranslationFromFloats(lx, ly, lz);
  10440. this.computeAbsoluteTransforms();
  10441. this._markAsDirtyAndDecompose();
  10442. };
  10443. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10444. var scaleMatrix = Bone._tmpMats[2];
  10445. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10446. if (mesh) {
  10447. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10448. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10449. }
  10450. rotMatInv.invert();
  10451. if (isNaN(rotMatInv.m[0])) {
  10452. // Matrix failed to invert.
  10453. // This can happen if scale is zero for example.
  10454. return false;
  10455. }
  10456. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10457. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10458. return true;
  10459. };
  10460. /**
  10461. * Get the position of the bone in local or world space
  10462. * @param space The space that the returned position is in
  10463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10464. * @returns The position of the bone
  10465. */
  10466. Bone.prototype.getPosition = function (space, mesh) {
  10467. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10468. if (mesh === void 0) { mesh = null; }
  10469. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10470. this.getPositionToRef(space, mesh, pos);
  10471. return pos;
  10472. };
  10473. /**
  10474. * Copy the position of the bone to a vector3 in local or world space
  10475. * @param space The space that the returned position is in
  10476. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10477. * @param result The vector3 to copy the position to
  10478. */
  10479. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10480. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10481. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10482. var lm = this.getLocalMatrix();
  10483. result.x = lm.m[12];
  10484. result.y = lm.m[13];
  10485. result.z = lm.m[14];
  10486. }
  10487. else {
  10488. var wm = null;
  10489. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10490. if (mesh) {
  10491. wm = mesh.getWorldMatrix();
  10492. }
  10493. this._skeleton.computeAbsoluteTransforms();
  10494. var tmat = Bone._tmpMats[0];
  10495. if (mesh && wm) {
  10496. tmat.copyFrom(this.getAbsoluteTransform());
  10497. tmat.multiplyToRef(wm, tmat);
  10498. }
  10499. else {
  10500. tmat = this.getAbsoluteTransform();
  10501. }
  10502. result.x = tmat.m[12];
  10503. result.y = tmat.m[13];
  10504. result.z = tmat.m[14];
  10505. }
  10506. };
  10507. /**
  10508. * Get the absolute position of the bone (world space)
  10509. * @param mesh The mesh that this bone is attached to
  10510. * @returns The absolute position of the bone
  10511. */
  10512. Bone.prototype.getAbsolutePosition = function (mesh) {
  10513. if (mesh === void 0) { mesh = null; }
  10514. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10515. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10516. return pos;
  10517. };
  10518. /**
  10519. * Copy the absolute position of the bone (world space) to the result param
  10520. * @param mesh The mesh that this bone is attached to
  10521. * @param result The vector3 to copy the absolute position to
  10522. */
  10523. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10524. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10525. };
  10526. /**
  10527. * Compute the absolute transforms of this bone and its children
  10528. */
  10529. Bone.prototype.computeAbsoluteTransforms = function () {
  10530. this._compose();
  10531. if (this._parent) {
  10532. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10533. }
  10534. else {
  10535. this._absoluteTransform.copyFrom(this._localMatrix);
  10536. var poseMatrix = this._skeleton.getPoseMatrix();
  10537. if (poseMatrix) {
  10538. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10539. }
  10540. }
  10541. var children = this.children;
  10542. var len = children.length;
  10543. for (var i = 0; i < len; i++) {
  10544. children[i].computeAbsoluteTransforms();
  10545. }
  10546. };
  10547. /**
  10548. * Get the world direction from an axis that is in the local space of the bone
  10549. * @param localAxis The local direction that is used to compute the world direction
  10550. * @param mesh The mesh that this bone is attached to
  10551. * @returns The world direction
  10552. */
  10553. Bone.prototype.getDirection = function (localAxis, mesh) {
  10554. if (mesh === void 0) { mesh = null; }
  10555. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10556. this.getDirectionToRef(localAxis, mesh, result);
  10557. return result;
  10558. };
  10559. /**
  10560. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10561. * @param localAxis The local direction that is used to compute the world direction
  10562. * @param mesh The mesh that this bone is attached to
  10563. * @param result The vector3 that the world direction will be copied to
  10564. */
  10565. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10566. if (mesh === void 0) { mesh = null; }
  10567. var wm = null;
  10568. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10569. if (mesh) {
  10570. wm = mesh.getWorldMatrix();
  10571. }
  10572. this._skeleton.computeAbsoluteTransforms();
  10573. var mat = Bone._tmpMats[0];
  10574. mat.copyFrom(this.getAbsoluteTransform());
  10575. if (mesh && wm) {
  10576. mat.multiplyToRef(wm, mat);
  10577. }
  10578. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10579. result.normalize();
  10580. };
  10581. /**
  10582. * Get the euler rotation of the bone in local or world space
  10583. * @param space The space that the rotation should be in
  10584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10585. * @returns The euler rotation
  10586. */
  10587. Bone.prototype.getRotation = function (space, mesh) {
  10588. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10589. if (mesh === void 0) { mesh = null; }
  10590. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10591. this.getRotationToRef(space, mesh, result);
  10592. return result;
  10593. };
  10594. /**
  10595. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10596. * @param space The space that the rotation should be in
  10597. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10598. * @param result The vector3 that the rotation should be copied to
  10599. */
  10600. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10601. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10602. if (mesh === void 0) { mesh = null; }
  10603. var quat = Bone._tmpQuat;
  10604. this.getRotationQuaternionToRef(space, mesh, quat);
  10605. quat.toEulerAnglesToRef(result);
  10606. };
  10607. /**
  10608. * Get the quaternion rotation of the bone in either local or world space
  10609. * @param space The space that the rotation should be in
  10610. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10611. * @returns The quaternion rotation
  10612. */
  10613. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10614. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10615. if (mesh === void 0) { mesh = null; }
  10616. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10617. this.getRotationQuaternionToRef(space, mesh, result);
  10618. return result;
  10619. };
  10620. /**
  10621. * Copy the quaternion rotation of the bone to a quaternion. 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.getRotationQuaternionToRef = function (space, mesh, result) {
  10627. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10628. if (mesh === void 0) { mesh = null; }
  10629. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10630. this._decompose();
  10631. result.copyFrom(this._localRotation);
  10632. }
  10633. else {
  10634. var mat = Bone._tmpMats[0];
  10635. var amat = this.getAbsoluteTransform();
  10636. if (mesh) {
  10637. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10638. }
  10639. else {
  10640. mat.copyFrom(amat);
  10641. }
  10642. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10643. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10644. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10645. mat.decompose(undefined, result, undefined);
  10646. }
  10647. };
  10648. /**
  10649. * Get the rotation matrix of the bone in local or world space
  10650. * @param space The space that the rotation should be in
  10651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10652. * @returns The rotation matrix
  10653. */
  10654. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10655. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10656. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10657. this.getRotationMatrixToRef(space, mesh, result);
  10658. return result;
  10659. };
  10660. /**
  10661. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10662. * @param space The space that the rotation should be in
  10663. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10664. * @param result The quaternion that the rotation should be copied to
  10665. */
  10666. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10667. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10668. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10669. this.getLocalMatrix().getRotationMatrixToRef(result);
  10670. }
  10671. else {
  10672. var mat = Bone._tmpMats[0];
  10673. var amat = this.getAbsoluteTransform();
  10674. if (mesh) {
  10675. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10676. }
  10677. else {
  10678. mat.copyFrom(amat);
  10679. }
  10680. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10681. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10682. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10683. mat.getRotationMatrixToRef(result);
  10684. }
  10685. };
  10686. /**
  10687. * Get the world position of a point that is in the local space of the bone
  10688. * @param position The local position
  10689. * @param mesh The mesh that this bone is attached to
  10690. * @returns The world position
  10691. */
  10692. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10693. if (mesh === void 0) { mesh = null; }
  10694. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10695. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10696. return result;
  10697. };
  10698. /**
  10699. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10700. * @param position The local position
  10701. * @param mesh The mesh that this bone is attached to
  10702. * @param result The vector3 that the world position should be copied to
  10703. */
  10704. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10705. if (mesh === void 0) { mesh = null; }
  10706. var wm = null;
  10707. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10708. if (mesh) {
  10709. wm = mesh.getWorldMatrix();
  10710. }
  10711. this._skeleton.computeAbsoluteTransforms();
  10712. var tmat = Bone._tmpMats[0];
  10713. if (mesh && wm) {
  10714. tmat.copyFrom(this.getAbsoluteTransform());
  10715. tmat.multiplyToRef(wm, tmat);
  10716. }
  10717. else {
  10718. tmat = this.getAbsoluteTransform();
  10719. }
  10720. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10721. };
  10722. /**
  10723. * Get the local position of a point that is in world space
  10724. * @param position The world position
  10725. * @param mesh The mesh that this bone is attached to
  10726. * @returns The local position
  10727. */
  10728. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10729. if (mesh === void 0) { mesh = null; }
  10730. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10731. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10732. return result;
  10733. };
  10734. /**
  10735. * Get the local position of a point that is in world space and copy it to the result param
  10736. * @param position The world position
  10737. * @param mesh The mesh that this bone is attached to
  10738. * @param result The vector3 that the local position should be copied to
  10739. */
  10740. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10741. if (mesh === void 0) { mesh = null; }
  10742. var wm = null;
  10743. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10744. if (mesh) {
  10745. wm = mesh.getWorldMatrix();
  10746. }
  10747. this._skeleton.computeAbsoluteTransforms();
  10748. var tmat = Bone._tmpMats[0];
  10749. tmat.copyFrom(this.getAbsoluteTransform());
  10750. if (mesh && wm) {
  10751. tmat.multiplyToRef(wm, tmat);
  10752. }
  10753. tmat.invert();
  10754. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10755. };
  10756. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10757. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10758. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10759. return Bone;
  10760. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10761. /***/ }),
  10762. /***/ "./Bones/boneIKController.ts":
  10763. /*!***********************************!*\
  10764. !*** ./Bones/boneIKController.ts ***!
  10765. \***********************************/
  10766. /*! exports provided: BoneIKController */
  10767. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10768. "use strict";
  10769. __webpack_require__.r(__webpack_exports__);
  10770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10771. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10772. /**
  10773. * Class used to apply inverse kinematics to bones
  10774. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10775. */
  10776. var BoneIKController = /** @class */ (function () {
  10777. /**
  10778. * Creates a new BoneIKController
  10779. * @param mesh defines the mesh to control
  10780. * @param bone defines the bone to control
  10781. * @param options defines options to set up the controller
  10782. */
  10783. function BoneIKController(mesh, bone, options) {
  10784. /**
  10785. * Gets or sets the target position
  10786. */
  10787. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10788. /**
  10789. * Gets or sets the pole target position
  10790. */
  10791. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10792. /**
  10793. * Gets or sets the pole target local offset
  10794. */
  10795. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10796. /**
  10797. * Gets or sets the pole angle
  10798. */
  10799. this.poleAngle = 0;
  10800. /**
  10801. * 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)
  10802. */
  10803. this.slerpAmount = 1;
  10804. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10805. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10806. this._bone2Ang = Math.PI;
  10807. this._maxAngle = Math.PI;
  10808. this._rightHandedSystem = false;
  10809. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10810. this._slerping = false;
  10811. this._adjustRoll = 0;
  10812. this._bone2 = bone;
  10813. this._bone1 = bone.getParent();
  10814. if (!this._bone1) {
  10815. return;
  10816. }
  10817. this.mesh = mesh;
  10818. var bonePos = bone.getPosition();
  10819. if (bone.getAbsoluteTransform().determinant() > 0) {
  10820. this._rightHandedSystem = true;
  10821. this._bendAxis.x = 0;
  10822. this._bendAxis.y = 0;
  10823. this._bendAxis.z = -1;
  10824. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10825. this._adjustRoll = Math.PI * .5;
  10826. this._bendAxis.z = 1;
  10827. }
  10828. }
  10829. if (this._bone1.length) {
  10830. var boneScale1 = this._bone1.getScale();
  10831. var boneScale2 = this._bone2.getScale();
  10832. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10833. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10834. }
  10835. else if (this._bone1.children[0]) {
  10836. mesh.computeWorldMatrix(true);
  10837. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10838. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10839. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10840. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10841. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10842. }
  10843. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10844. this.maxAngle = Math.PI;
  10845. if (options) {
  10846. if (options.targetMesh) {
  10847. this.targetMesh = options.targetMesh;
  10848. this.targetMesh.computeWorldMatrix(true);
  10849. }
  10850. if (options.poleTargetMesh) {
  10851. this.poleTargetMesh = options.poleTargetMesh;
  10852. this.poleTargetMesh.computeWorldMatrix(true);
  10853. }
  10854. else if (options.poleTargetBone) {
  10855. this.poleTargetBone = options.poleTargetBone;
  10856. }
  10857. else if (this._bone1.getParent()) {
  10858. this.poleTargetBone = this._bone1.getParent();
  10859. }
  10860. if (options.poleTargetLocalOffset) {
  10861. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10862. }
  10863. if (options.poleAngle) {
  10864. this.poleAngle = options.poleAngle;
  10865. }
  10866. if (options.bendAxis) {
  10867. this._bendAxis.copyFrom(options.bendAxis);
  10868. }
  10869. if (options.maxAngle) {
  10870. this.maxAngle = options.maxAngle;
  10871. }
  10872. if (options.slerpAmount) {
  10873. this.slerpAmount = options.slerpAmount;
  10874. }
  10875. }
  10876. }
  10877. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10878. /**
  10879. * Gets or sets maximum allowed angle
  10880. */
  10881. get: function () {
  10882. return this._maxAngle;
  10883. },
  10884. set: function (value) {
  10885. this._setMaxAngle(value);
  10886. },
  10887. enumerable: true,
  10888. configurable: true
  10889. });
  10890. BoneIKController.prototype._setMaxAngle = function (ang) {
  10891. if (ang < 0) {
  10892. ang = 0;
  10893. }
  10894. if (ang > Math.PI || ang == undefined) {
  10895. ang = Math.PI;
  10896. }
  10897. this._maxAngle = ang;
  10898. var a = this._bone1Length;
  10899. var b = this._bone2Length;
  10900. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10901. };
  10902. /**
  10903. * Force the controller to update the bones
  10904. */
  10905. BoneIKController.prototype.update = function () {
  10906. var bone1 = this._bone1;
  10907. if (!bone1) {
  10908. return;
  10909. }
  10910. var target = this.targetPosition;
  10911. var poleTarget = this.poleTargetPosition;
  10912. var mat1 = BoneIKController._tmpMats[0];
  10913. var mat2 = BoneIKController._tmpMats[1];
  10914. if (this.targetMesh) {
  10915. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10916. }
  10917. if (this.poleTargetBone) {
  10918. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10919. }
  10920. else if (this.poleTargetMesh) {
  10921. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10922. }
  10923. var bonePos = BoneIKController._tmpVecs[0];
  10924. var zaxis = BoneIKController._tmpVecs[1];
  10925. var xaxis = BoneIKController._tmpVecs[2];
  10926. var yaxis = BoneIKController._tmpVecs[3];
  10927. var upAxis = BoneIKController._tmpVecs[4];
  10928. var _tmpQuat = BoneIKController._tmpQuat;
  10929. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10930. poleTarget.subtractToRef(bonePos, upAxis);
  10931. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10932. upAxis.y = 1;
  10933. }
  10934. else {
  10935. upAxis.normalize();
  10936. }
  10937. target.subtractToRef(bonePos, yaxis);
  10938. yaxis.normalize();
  10939. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10940. zaxis.normalize();
  10941. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10942. xaxis.normalize();
  10943. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10944. var a = this._bone1Length;
  10945. var b = this._bone2Length;
  10946. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10947. if (this._maxReach > 0) {
  10948. c = Math.min(this._maxReach, c);
  10949. }
  10950. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10951. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10952. if (acosa > 1) {
  10953. acosa = 1;
  10954. }
  10955. if (acosb > 1) {
  10956. acosb = 1;
  10957. }
  10958. if (acosa < -1) {
  10959. acosa = -1;
  10960. }
  10961. if (acosb < -1) {
  10962. acosb = -1;
  10963. }
  10964. var angA = Math.acos(acosa);
  10965. var angB = Math.acos(acosb);
  10966. var angC = -angA - angB;
  10967. if (this._rightHandedSystem) {
  10968. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10969. mat2.multiplyToRef(mat1, mat1);
  10970. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10971. mat2.multiplyToRef(mat1, mat1);
  10972. }
  10973. else {
  10974. var _tmpVec = BoneIKController._tmpVecs[5];
  10975. _tmpVec.copyFrom(this._bendAxis);
  10976. _tmpVec.x *= -1;
  10977. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10978. mat2.multiplyToRef(mat1, mat1);
  10979. }
  10980. if (this.poleAngle) {
  10981. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10982. mat1.multiplyToRef(mat2, mat1);
  10983. }
  10984. if (this._bone1) {
  10985. if (this.slerpAmount < 1) {
  10986. if (!this._slerping) {
  10987. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10988. }
  10989. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10990. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10991. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10992. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10993. this._slerping = true;
  10994. }
  10995. else {
  10996. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10997. this._bone1Mat.copyFrom(mat1);
  10998. this._slerping = false;
  10999. }
  11000. }
  11001. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  11002. this._bone2Ang = angC;
  11003. };
  11004. 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()];
  11005. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  11006. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  11007. return BoneIKController;
  11008. }());
  11009. /***/ }),
  11010. /***/ "./Bones/boneLookController.ts":
  11011. /*!*************************************!*\
  11012. !*** ./Bones/boneLookController.ts ***!
  11013. \*************************************/
  11014. /*! exports provided: BoneLookController */
  11015. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11016. "use strict";
  11017. __webpack_require__.r(__webpack_exports__);
  11018. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  11019. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  11020. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11021. /**
  11022. * Class used to make a bone look toward a point in space
  11023. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  11024. */
  11025. var BoneLookController = /** @class */ (function () {
  11026. /**
  11027. * Create a BoneLookController
  11028. * @param mesh the mesh that the bone belongs to
  11029. * @param bone the bone that will be looking to the target
  11030. * @param target the target Vector3 to look at
  11031. * @param options optional settings:
  11032. * * maxYaw: the maximum angle the bone will yaw to
  11033. * * minYaw: the minimum angle the bone will yaw to
  11034. * * maxPitch: the maximum angle the bone will pitch to
  11035. * * minPitch: the minimum angle the bone will yaw to
  11036. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  11037. * * upAxis: the up axis of the coordinate system
  11038. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  11039. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  11040. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  11041. * * adjustYaw: used to make an adjustment to the yaw of the bone
  11042. * * adjustPitch: used to make an adjustment to the pitch of the bone
  11043. * * adjustRoll: used to make an adjustment to the roll of the bone
  11044. **/
  11045. function BoneLookController(mesh, bone, target, options) {
  11046. /**
  11047. * The up axis of the coordinate system that is used when the bone is rotated
  11048. */
  11049. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  11050. /**
  11051. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  11052. */
  11053. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11054. /**
  11055. * Used to make an adjustment to the yaw of the bone
  11056. */
  11057. this.adjustYaw = 0;
  11058. /**
  11059. * Used to make an adjustment to the pitch of the bone
  11060. */
  11061. this.adjustPitch = 0;
  11062. /**
  11063. * Used to make an adjustment to the roll of the bone
  11064. */
  11065. this.adjustRoll = 0;
  11066. /**
  11067. * 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)
  11068. */
  11069. this.slerpAmount = 1;
  11070. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11071. this._slerping = false;
  11072. this._firstFrameSkipped = false;
  11073. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  11074. this.mesh = mesh;
  11075. this.bone = bone;
  11076. this.target = target;
  11077. if (options) {
  11078. if (options.adjustYaw) {
  11079. this.adjustYaw = options.adjustYaw;
  11080. }
  11081. if (options.adjustPitch) {
  11082. this.adjustPitch = options.adjustPitch;
  11083. }
  11084. if (options.adjustRoll) {
  11085. this.adjustRoll = options.adjustRoll;
  11086. }
  11087. if (options.maxYaw != null) {
  11088. this.maxYaw = options.maxYaw;
  11089. }
  11090. else {
  11091. this.maxYaw = Math.PI;
  11092. }
  11093. if (options.minYaw != null) {
  11094. this.minYaw = options.minYaw;
  11095. }
  11096. else {
  11097. this.minYaw = -Math.PI;
  11098. }
  11099. if (options.maxPitch != null) {
  11100. this.maxPitch = options.maxPitch;
  11101. }
  11102. else {
  11103. this.maxPitch = Math.PI;
  11104. }
  11105. if (options.minPitch != null) {
  11106. this.minPitch = options.minPitch;
  11107. }
  11108. else {
  11109. this.minPitch = -Math.PI;
  11110. }
  11111. if (options.slerpAmount != null) {
  11112. this.slerpAmount = options.slerpAmount;
  11113. }
  11114. if (options.upAxis != null) {
  11115. this.upAxis = options.upAxis;
  11116. }
  11117. if (options.upAxisSpace != null) {
  11118. this.upAxisSpace = options.upAxisSpace;
  11119. }
  11120. if (options.yawAxis != null || options.pitchAxis != null) {
  11121. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11122. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11123. if (options.yawAxis != null) {
  11124. newYawAxis = options.yawAxis.clone();
  11125. newYawAxis.normalize();
  11126. }
  11127. if (options.pitchAxis != null) {
  11128. newPitchAxis = options.pitchAxis.clone();
  11129. newPitchAxis.normalize();
  11130. }
  11131. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11132. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11133. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11134. this._transformYawPitchInv = this._transformYawPitch.clone();
  11135. this._transformYawPitch.invert();
  11136. }
  11137. }
  11138. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11139. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11140. }
  11141. }
  11142. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11143. /**
  11144. * Gets or sets the minimum yaw angle that the bone can look to
  11145. */
  11146. get: function () {
  11147. return this._minYaw;
  11148. },
  11149. set: function (value) {
  11150. this._minYaw = value;
  11151. this._minYawSin = Math.sin(value);
  11152. this._minYawCos = Math.cos(value);
  11153. if (this._maxYaw != null) {
  11154. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11155. this._yawRange = this._maxYaw - this._minYaw;
  11156. }
  11157. },
  11158. enumerable: true,
  11159. configurable: true
  11160. });
  11161. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11162. /**
  11163. * Gets or sets the maximum yaw angle that the bone can look to
  11164. */
  11165. get: function () {
  11166. return this._maxYaw;
  11167. },
  11168. set: function (value) {
  11169. this._maxYaw = value;
  11170. this._maxYawSin = Math.sin(value);
  11171. this._maxYawCos = Math.cos(value);
  11172. if (this._minYaw != null) {
  11173. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11174. this._yawRange = this._maxYaw - this._minYaw;
  11175. }
  11176. },
  11177. enumerable: true,
  11178. configurable: true
  11179. });
  11180. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11181. /**
  11182. * Gets or sets the minimum pitch angle that the bone can look to
  11183. */
  11184. get: function () {
  11185. return this._minPitch;
  11186. },
  11187. set: function (value) {
  11188. this._minPitch = value;
  11189. this._minPitchTan = Math.tan(value);
  11190. },
  11191. enumerable: true,
  11192. configurable: true
  11193. });
  11194. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11195. /**
  11196. * Gets or sets the maximum pitch angle that the bone can look to
  11197. */
  11198. get: function () {
  11199. return this._maxPitch;
  11200. },
  11201. set: function (value) {
  11202. this._maxPitch = value;
  11203. this._maxPitchTan = Math.tan(value);
  11204. },
  11205. enumerable: true,
  11206. configurable: true
  11207. });
  11208. /**
  11209. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11210. */
  11211. BoneLookController.prototype.update = function () {
  11212. //skip the first frame when slerping so that the mesh rotation is correct
  11213. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11214. this._firstFrameSkipped = true;
  11215. return;
  11216. }
  11217. var bone = this.bone;
  11218. var bonePos = BoneLookController._tmpVecs[0];
  11219. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11220. var target = this.target;
  11221. var _tmpMat1 = BoneLookController._tmpMats[0];
  11222. var _tmpMat2 = BoneLookController._tmpMats[1];
  11223. var mesh = this.mesh;
  11224. var parentBone = bone.getParent();
  11225. var upAxis = BoneLookController._tmpVecs[1];
  11226. upAxis.copyFrom(this.upAxis);
  11227. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11228. if (this._transformYawPitch) {
  11229. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11230. }
  11231. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11232. }
  11233. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11234. mesh.getDirectionToRef(upAxis, upAxis);
  11235. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11236. upAxis.normalize();
  11237. }
  11238. }
  11239. var checkYaw = false;
  11240. var checkPitch = false;
  11241. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11242. checkYaw = true;
  11243. }
  11244. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11245. checkPitch = true;
  11246. }
  11247. if (checkYaw || checkPitch) {
  11248. var spaceMat = BoneLookController._tmpMats[2];
  11249. var spaceMatInv = BoneLookController._tmpMats[3];
  11250. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11251. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11252. }
  11253. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11254. spaceMat.copyFrom(mesh.getWorldMatrix());
  11255. }
  11256. else {
  11257. var forwardAxis = BoneLookController._tmpVecs[2];
  11258. forwardAxis.copyFrom(this._fowardAxis);
  11259. if (this._transformYawPitch) {
  11260. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11261. }
  11262. if (parentBone) {
  11263. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11264. }
  11265. else {
  11266. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11267. }
  11268. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11269. rightAxis.normalize();
  11270. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11271. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11272. }
  11273. spaceMat.invertToRef(spaceMatInv);
  11274. var xzlen = null;
  11275. if (checkPitch) {
  11276. var localTarget = BoneLookController._tmpVecs[3];
  11277. target.subtractToRef(bonePos, localTarget);
  11278. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11279. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11280. var pitch = Math.atan2(localTarget.y, xzlen);
  11281. var newPitch = pitch;
  11282. if (pitch > this._maxPitch) {
  11283. localTarget.y = this._maxPitchTan * xzlen;
  11284. newPitch = this._maxPitch;
  11285. }
  11286. else if (pitch < this._minPitch) {
  11287. localTarget.y = this._minPitchTan * xzlen;
  11288. newPitch = this._minPitch;
  11289. }
  11290. if (pitch != newPitch) {
  11291. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11292. localTarget.addInPlace(bonePos);
  11293. target = localTarget;
  11294. }
  11295. }
  11296. if (checkYaw) {
  11297. var localTarget = BoneLookController._tmpVecs[4];
  11298. target.subtractToRef(bonePos, localTarget);
  11299. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11300. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11301. var newYaw = yaw;
  11302. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11303. if (xzlen == null) {
  11304. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11305. }
  11306. if (this._yawRange > Math.PI) {
  11307. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11308. localTarget.z = this._maxYawCos * xzlen;
  11309. localTarget.x = this._maxYawSin * xzlen;
  11310. newYaw = this._maxYaw;
  11311. }
  11312. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11313. localTarget.z = this._minYawCos * xzlen;
  11314. localTarget.x = this._minYawSin * xzlen;
  11315. newYaw = this._minYaw;
  11316. }
  11317. }
  11318. else {
  11319. if (yaw > this._maxYaw) {
  11320. localTarget.z = this._maxYawCos * xzlen;
  11321. localTarget.x = this._maxYawSin * xzlen;
  11322. newYaw = this._maxYaw;
  11323. }
  11324. else if (yaw < this._minYaw) {
  11325. localTarget.z = this._minYawCos * xzlen;
  11326. localTarget.x = this._minYawSin * xzlen;
  11327. newYaw = this._minYaw;
  11328. }
  11329. }
  11330. }
  11331. if (this._slerping && this._yawRange > Math.PI) {
  11332. //are we going to be crossing into the min/max region?
  11333. var boneFwd = BoneLookController._tmpVecs[8];
  11334. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11335. if (this._transformYawPitch) {
  11336. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11337. }
  11338. var boneRotMat = BoneLookController._tmpMats[4];
  11339. this._boneQuat.toRotationMatrix(boneRotMat);
  11340. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11341. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11342. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11343. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11344. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11345. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11346. if (angBtwTar > angBtwMidYaw) {
  11347. if (xzlen == null) {
  11348. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11349. }
  11350. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11351. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11352. if (angBtwMin < angBtwMax) {
  11353. newYaw = boneYaw + Math.PI * .75;
  11354. localTarget.z = Math.cos(newYaw) * xzlen;
  11355. localTarget.x = Math.sin(newYaw) * xzlen;
  11356. }
  11357. else {
  11358. newYaw = boneYaw - Math.PI * .75;
  11359. localTarget.z = Math.cos(newYaw) * xzlen;
  11360. localTarget.x = Math.sin(newYaw) * xzlen;
  11361. }
  11362. }
  11363. }
  11364. if (yaw != newYaw) {
  11365. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11366. localTarget.addInPlace(bonePos);
  11367. target = localTarget;
  11368. }
  11369. }
  11370. }
  11371. var zaxis = BoneLookController._tmpVecs[5];
  11372. var xaxis = BoneLookController._tmpVecs[6];
  11373. var yaxis = BoneLookController._tmpVecs[7];
  11374. var _tmpQuat = BoneLookController._tmpQuat;
  11375. target.subtractToRef(bonePos, zaxis);
  11376. zaxis.normalize();
  11377. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11378. xaxis.normalize();
  11379. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11380. yaxis.normalize();
  11381. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11382. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11383. return;
  11384. }
  11385. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11386. return;
  11387. }
  11388. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11389. return;
  11390. }
  11391. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11392. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11393. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11394. }
  11395. if (this.slerpAmount < 1) {
  11396. if (!this._slerping) {
  11397. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11398. }
  11399. if (this._transformYawPitch) {
  11400. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11401. }
  11402. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11403. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11404. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11405. this._slerping = true;
  11406. }
  11407. else {
  11408. if (this._transformYawPitch) {
  11409. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11410. }
  11411. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11412. this._slerping = false;
  11413. }
  11414. };
  11415. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11416. var angDiff = ang2 - ang1;
  11417. angDiff %= Math.PI * 2;
  11418. if (angDiff > Math.PI) {
  11419. angDiff -= Math.PI * 2;
  11420. }
  11421. else if (angDiff < -Math.PI) {
  11422. angDiff += Math.PI * 2;
  11423. }
  11424. return angDiff;
  11425. };
  11426. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11427. ang1 %= (2 * Math.PI);
  11428. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11429. ang2 %= (2 * Math.PI);
  11430. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11431. var ab = 0;
  11432. if (ang1 < ang2) {
  11433. ab = ang2 - ang1;
  11434. }
  11435. else {
  11436. ab = ang1 - ang2;
  11437. }
  11438. if (ab > Math.PI) {
  11439. ab = Math.PI * 2 - ab;
  11440. }
  11441. return ab;
  11442. };
  11443. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11444. ang %= (2 * Math.PI);
  11445. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11446. ang1 %= (2 * Math.PI);
  11447. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11448. ang2 %= (2 * Math.PI);
  11449. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11450. if (ang1 < ang2) {
  11451. if (ang > ang1 && ang < ang2) {
  11452. return true;
  11453. }
  11454. }
  11455. else {
  11456. if (ang > ang2 && ang < ang1) {
  11457. return true;
  11458. }
  11459. }
  11460. return false;
  11461. };
  11462. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11463. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11464. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11465. return BoneLookController;
  11466. }());
  11467. /***/ }),
  11468. /***/ "./Bones/index.ts":
  11469. /*!************************!*\
  11470. !*** ./Bones/index.ts ***!
  11471. \************************/
  11472. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11474. "use strict";
  11475. __webpack_require__.r(__webpack_exports__);
  11476. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11478. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11480. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11482. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11484. /***/ }),
  11485. /***/ "./Bones/skeleton.ts":
  11486. /*!***************************!*\
  11487. !*** ./Bones/skeleton.ts ***!
  11488. \***************************/
  11489. /*! exports provided: Skeleton */
  11490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11491. "use strict";
  11492. __webpack_require__.r(__webpack_exports__);
  11493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11494. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11495. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11496. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11497. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11498. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11499. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11500. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11501. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11502. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11503. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11504. /**
  11505. * Class used to handle skinning animations
  11506. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11507. */
  11508. var Skeleton = /** @class */ (function () {
  11509. /**
  11510. * Creates a new skeleton
  11511. * @param name defines the skeleton name
  11512. * @param id defines the skeleton Id
  11513. * @param scene defines the hosting scene
  11514. */
  11515. function Skeleton(
  11516. /** defines the skeleton name */
  11517. name,
  11518. /** defines the skeleton Id */
  11519. id, scene) {
  11520. this.name = name;
  11521. this.id = id;
  11522. /**
  11523. * Defines the list of child bones
  11524. */
  11525. this.bones = new Array();
  11526. /**
  11527. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11528. */
  11529. this.needInitialSkinMatrix = false;
  11530. /**
  11531. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11532. */
  11533. this.overrideMesh = null;
  11534. this._isDirty = true;
  11535. this._meshesWithPoseMatrix = new Array();
  11536. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11537. this._ranges = {};
  11538. this._lastAbsoluteTransformsUpdateId = -1;
  11539. this._canUseTextureForBones = false;
  11540. this._uniqueId = 0;
  11541. /** @hidden */
  11542. this._numBonesWithLinkedTransformNode = 0;
  11543. /** @hidden */
  11544. this._hasWaitingData = null;
  11545. /**
  11546. * Specifies if the skeleton should be serialized
  11547. */
  11548. this.doNotSerialize = false;
  11549. this._useTextureToStoreBoneMatrices = true;
  11550. this._animationPropertiesOverride = null;
  11551. // Events
  11552. /**
  11553. * An observable triggered before computing the skeleton's matrices
  11554. */
  11555. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11556. this.bones = [];
  11557. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11558. this._uniqueId = this._scene.getUniqueId();
  11559. this._scene.addSkeleton(this);
  11560. //make sure it will recalculate the matrix next time prepare is called.
  11561. this._isDirty = true;
  11562. var engineCaps = this._scene.getEngine().getCaps();
  11563. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11564. }
  11565. Object.defineProperty(Skeleton.prototype, "useTextureToStoreBoneMatrices", {
  11566. /**
  11567. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11568. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11569. */
  11570. get: function () {
  11571. return this._useTextureToStoreBoneMatrices;
  11572. },
  11573. set: function (value) {
  11574. this._useTextureToStoreBoneMatrices = value;
  11575. this._markAsDirty();
  11576. },
  11577. enumerable: true,
  11578. configurable: true
  11579. });
  11580. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11581. /**
  11582. * Gets or sets the animation properties override
  11583. */
  11584. get: function () {
  11585. if (!this._animationPropertiesOverride) {
  11586. return this._scene.animationPropertiesOverride;
  11587. }
  11588. return this._animationPropertiesOverride;
  11589. },
  11590. set: function (value) {
  11591. this._animationPropertiesOverride = value;
  11592. },
  11593. enumerable: true,
  11594. configurable: true
  11595. });
  11596. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11597. /**
  11598. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11599. */
  11600. get: function () {
  11601. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11602. },
  11603. enumerable: true,
  11604. configurable: true
  11605. });
  11606. Object.defineProperty(Skeleton.prototype, "uniqueId", {
  11607. /**
  11608. * Gets the unique ID of this skeleton
  11609. */
  11610. get: function () {
  11611. return this._uniqueId;
  11612. },
  11613. enumerable: true,
  11614. configurable: true
  11615. });
  11616. /**
  11617. * Gets the current object class name.
  11618. * @return the class name
  11619. */
  11620. Skeleton.prototype.getClassName = function () {
  11621. return "Skeleton";
  11622. };
  11623. /**
  11624. * Returns an array containing the root bones
  11625. * @returns an array containing the root bones
  11626. */
  11627. Skeleton.prototype.getChildren = function () {
  11628. return this.bones.filter(function (b) { return !b.getParent(); });
  11629. };
  11630. // Members
  11631. /**
  11632. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11633. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11634. * @returns a Float32Array containing matrices data
  11635. */
  11636. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11637. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11638. return mesh._bonesTransformMatrices;
  11639. }
  11640. if (!this._transformMatrices) {
  11641. this.prepare();
  11642. }
  11643. return this._transformMatrices;
  11644. };
  11645. /**
  11646. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11647. * @returns a raw texture containing the data
  11648. */
  11649. Skeleton.prototype.getTransformMatrixTexture = function () {
  11650. return this._transformMatrixTexture;
  11651. };
  11652. /**
  11653. * Gets the current hosting scene
  11654. * @returns a scene object
  11655. */
  11656. Skeleton.prototype.getScene = function () {
  11657. return this._scene;
  11658. };
  11659. // Methods
  11660. /**
  11661. * Gets a string representing the current skeleton data
  11662. * @param fullDetails defines a boolean indicating if we want a verbose version
  11663. * @returns a string representing the current skeleton data
  11664. */
  11665. Skeleton.prototype.toString = function (fullDetails) {
  11666. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11667. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11668. if (fullDetails) {
  11669. ret += ", Ranges: {";
  11670. var first = true;
  11671. for (var name_1 in this._ranges) {
  11672. if (first) {
  11673. ret += ", ";
  11674. first = false;
  11675. }
  11676. ret += name_1;
  11677. }
  11678. ret += "}";
  11679. }
  11680. return ret;
  11681. };
  11682. /**
  11683. * Get bone's index searching by name
  11684. * @param name defines bone's name to search for
  11685. * @return the indice of the bone. Returns -1 if not found
  11686. */
  11687. Skeleton.prototype.getBoneIndexByName = function (name) {
  11688. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11689. if (this.bones[boneIndex].name === name) {
  11690. return boneIndex;
  11691. }
  11692. }
  11693. return -1;
  11694. };
  11695. /**
  11696. * Creater a new animation range
  11697. * @param name defines the name of the range
  11698. * @param from defines the start key
  11699. * @param to defines the end key
  11700. */
  11701. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11702. // check name not already in use
  11703. if (!this._ranges[name]) {
  11704. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11705. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11706. if (this.bones[i].animations[0]) {
  11707. this.bones[i].animations[0].createRange(name, from, to);
  11708. }
  11709. }
  11710. }
  11711. };
  11712. /**
  11713. * Delete a specific animation range
  11714. * @param name defines the name of the range
  11715. * @param deleteFrames defines if frames must be removed as well
  11716. */
  11717. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11718. if (deleteFrames === void 0) { deleteFrames = true; }
  11719. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11720. if (this.bones[i].animations[0]) {
  11721. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11722. }
  11723. }
  11724. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11725. };
  11726. /**
  11727. * Gets a specific animation range
  11728. * @param name defines the name of the range to look for
  11729. * @returns the requested animation range or null if not found
  11730. */
  11731. Skeleton.prototype.getAnimationRange = function (name) {
  11732. return this._ranges[name];
  11733. };
  11734. /**
  11735. * Gets the list of all animation ranges defined on this skeleton
  11736. * @returns an array
  11737. */
  11738. Skeleton.prototype.getAnimationRanges = function () {
  11739. var animationRanges = [];
  11740. var name;
  11741. for (name in this._ranges) {
  11742. animationRanges.push(this._ranges[name]);
  11743. }
  11744. return animationRanges;
  11745. };
  11746. /**
  11747. * Copy animation range from a source skeleton.
  11748. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11749. * @param source defines the source skeleton
  11750. * @param name defines the name of the range to copy
  11751. * @param rescaleAsRequired defines if rescaling must be applied if required
  11752. * @returns true if operation was successful
  11753. */
  11754. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11755. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11756. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11757. return false;
  11758. }
  11759. var ret = true;
  11760. var frameOffset = this._getHighestAnimationFrame() + 1;
  11761. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11762. var boneDict = {};
  11763. var sourceBones = source.bones;
  11764. var nBones;
  11765. var i;
  11766. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11767. boneDict[sourceBones[i].name] = sourceBones[i];
  11768. }
  11769. if (this.bones.length !== sourceBones.length) {
  11770. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11771. ret = false;
  11772. }
  11773. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11774. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11775. var boneName = this.bones[i].name;
  11776. var sourceBone = boneDict[boneName];
  11777. if (sourceBone) {
  11778. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11779. }
  11780. else {
  11781. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11782. ret = false;
  11783. }
  11784. }
  11785. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11786. var range = source.getAnimationRange(name);
  11787. if (range) {
  11788. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11789. }
  11790. return ret;
  11791. };
  11792. /**
  11793. * Forces the skeleton to go to rest pose
  11794. */
  11795. Skeleton.prototype.returnToRest = function () {
  11796. for (var index = 0; index < this.bones.length; index++) {
  11797. this.bones[index].returnToRest();
  11798. }
  11799. };
  11800. Skeleton.prototype._getHighestAnimationFrame = function () {
  11801. var ret = 0;
  11802. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11803. if (this.bones[i].animations[0]) {
  11804. var highest = this.bones[i].animations[0].getHighestFrame();
  11805. if (ret < highest) {
  11806. ret = highest;
  11807. }
  11808. }
  11809. }
  11810. return ret;
  11811. };
  11812. /**
  11813. * Begin a specific animation range
  11814. * @param name defines the name of the range to start
  11815. * @param loop defines if looping must be turned on (false by default)
  11816. * @param speedRatio defines the speed ratio to apply (1 by default)
  11817. * @param onAnimationEnd defines a callback which will be called when animation will end
  11818. * @returns a new animatable
  11819. */
  11820. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11821. var range = this.getAnimationRange(name);
  11822. if (!range) {
  11823. return null;
  11824. }
  11825. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11826. };
  11827. /** @hidden */
  11828. Skeleton.prototype._markAsDirty = function () {
  11829. this._isDirty = true;
  11830. };
  11831. /** @hidden */
  11832. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11833. this._meshesWithPoseMatrix.push(mesh);
  11834. };
  11835. /** @hidden */
  11836. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11837. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11838. if (index > -1) {
  11839. this._meshesWithPoseMatrix.splice(index, 1);
  11840. }
  11841. };
  11842. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11843. this.onBeforeComputeObservable.notifyObservers(this);
  11844. for (var index = 0; index < this.bones.length; index++) {
  11845. var bone = this.bones[index];
  11846. bone._childUpdateId++;
  11847. var parentBone = bone.getParent();
  11848. if (parentBone) {
  11849. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11850. }
  11851. else {
  11852. if (initialSkinMatrix) {
  11853. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11854. }
  11855. else {
  11856. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11857. }
  11858. }
  11859. if (bone._index !== -1) {
  11860. var mappedIndex = bone._index === null ? index : bone._index;
  11861. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11862. }
  11863. }
  11864. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11865. };
  11866. /**
  11867. * Build all resources required to render a skeleton
  11868. */
  11869. Skeleton.prototype.prepare = function () {
  11870. // Update the local matrix of bones with linked transform nodes.
  11871. if (this._numBonesWithLinkedTransformNode > 0) {
  11872. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11873. var bone_1 = _a[_i];
  11874. if (bone_1._linkedTransformNode) {
  11875. // Computing the world matrix also computes the local matrix.
  11876. bone_1._linkedTransformNode.computeWorldMatrix();
  11877. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11878. bone_1.markAsDirty();
  11879. }
  11880. }
  11881. }
  11882. if (!this._isDirty) {
  11883. return;
  11884. }
  11885. if (this.needInitialSkinMatrix) {
  11886. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11887. var mesh = this._meshesWithPoseMatrix[index];
  11888. var poseMatrix = mesh.getPoseMatrix();
  11889. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11890. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11891. }
  11892. if (this._synchronizedWithMesh !== mesh) {
  11893. this._synchronizedWithMesh = mesh;
  11894. // Prepare bones
  11895. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11896. var bone = this.bones[boneIndex];
  11897. if (!bone.getParent()) {
  11898. var matrix = bone.getBaseMatrix();
  11899. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11900. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11901. }
  11902. }
  11903. }
  11904. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11905. }
  11906. }
  11907. else {
  11908. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11909. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11910. if (this.isUsingTextureForMatrices) {
  11911. if (this._transformMatrixTexture) {
  11912. this._transformMatrixTexture.dispose();
  11913. }
  11914. 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);
  11915. }
  11916. }
  11917. this._computeTransformMatrices(this._transformMatrices, null);
  11918. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11919. this._transformMatrixTexture.update(this._transformMatrices);
  11920. }
  11921. }
  11922. this._isDirty = false;
  11923. this._scene._activeBones.addCount(this.bones.length, false);
  11924. };
  11925. /**
  11926. * Gets the list of animatables currently running for this skeleton
  11927. * @returns an array of animatables
  11928. */
  11929. Skeleton.prototype.getAnimatables = function () {
  11930. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11931. this._animatables = [];
  11932. for (var index = 0; index < this.bones.length; index++) {
  11933. this._animatables.push(this.bones[index]);
  11934. }
  11935. }
  11936. return this._animatables;
  11937. };
  11938. /**
  11939. * Clone the current skeleton
  11940. * @param name defines the name of the new skeleton
  11941. * @param id defines the id of the new skeleton
  11942. * @returns the new skeleton
  11943. */
  11944. Skeleton.prototype.clone = function (name, id) {
  11945. var result = new Skeleton(name, id || name, this._scene);
  11946. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11947. for (var index = 0; index < this.bones.length; index++) {
  11948. var source = this.bones[index];
  11949. var parentBone = null;
  11950. var parent_1 = source.getParent();
  11951. if (parent_1) {
  11952. var parentIndex = this.bones.indexOf(parent_1);
  11953. parentBone = result.bones[parentIndex];
  11954. }
  11955. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11956. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11957. }
  11958. if (this._ranges) {
  11959. result._ranges = {};
  11960. for (var rangeName in this._ranges) {
  11961. var range = this._ranges[rangeName];
  11962. if (range) {
  11963. result._ranges[rangeName] = range.clone();
  11964. }
  11965. }
  11966. }
  11967. this._isDirty = true;
  11968. return result;
  11969. };
  11970. /**
  11971. * Enable animation blending for this skeleton
  11972. * @param blendingSpeed defines the blending speed to apply
  11973. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11974. */
  11975. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11976. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11977. this.bones.forEach(function (bone) {
  11978. bone.animations.forEach(function (animation) {
  11979. animation.enableBlending = true;
  11980. animation.blendingSpeed = blendingSpeed;
  11981. });
  11982. });
  11983. };
  11984. /**
  11985. * Releases all resources associated with the current skeleton
  11986. */
  11987. Skeleton.prototype.dispose = function () {
  11988. this._meshesWithPoseMatrix = [];
  11989. // Animations
  11990. this.getScene().stopAnimation(this);
  11991. // Remove from scene
  11992. this.getScene().removeSkeleton(this);
  11993. if (this._transformMatrixTexture) {
  11994. this._transformMatrixTexture.dispose();
  11995. this._transformMatrixTexture = null;
  11996. }
  11997. };
  11998. /**
  11999. * Serialize the skeleton in a JSON object
  12000. * @returns a JSON object
  12001. */
  12002. Skeleton.prototype.serialize = function () {
  12003. var serializationObject = {};
  12004. serializationObject.name = this.name;
  12005. serializationObject.id = this.id;
  12006. if (this.dimensionsAtRest) {
  12007. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  12008. }
  12009. serializationObject.bones = [];
  12010. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  12011. for (var index = 0; index < this.bones.length; index++) {
  12012. var bone = this.bones[index];
  12013. var parent_2 = bone.getParent();
  12014. var serializedBone = {
  12015. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  12016. name: bone.name,
  12017. matrix: bone.getBaseMatrix().toArray(),
  12018. rest: bone.getRestPose().toArray()
  12019. };
  12020. serializationObject.bones.push(serializedBone);
  12021. if (bone.length) {
  12022. serializedBone.length = bone.length;
  12023. }
  12024. if (bone.metadata) {
  12025. serializedBone.metadata = bone.metadata;
  12026. }
  12027. if (bone.animations && bone.animations.length > 0) {
  12028. serializedBone.animation = bone.animations[0].serialize();
  12029. }
  12030. serializationObject.ranges = [];
  12031. for (var name in this._ranges) {
  12032. var source = this._ranges[name];
  12033. if (!source) {
  12034. continue;
  12035. }
  12036. var range = {};
  12037. range.name = name;
  12038. range.from = source.from;
  12039. range.to = source.to;
  12040. serializationObject.ranges.push(range);
  12041. }
  12042. }
  12043. return serializationObject;
  12044. };
  12045. /**
  12046. * Creates a new skeleton from serialized data
  12047. * @param parsedSkeleton defines the serialized data
  12048. * @param scene defines the hosting scene
  12049. * @returns a new skeleton
  12050. */
  12051. Skeleton.Parse = function (parsedSkeleton, scene) {
  12052. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  12053. if (parsedSkeleton.dimensionsAtRest) {
  12054. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  12055. }
  12056. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  12057. var index;
  12058. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  12059. var parsedBone = parsedSkeleton.bones[index];
  12060. var parentBone = null;
  12061. if (parsedBone.parentBoneIndex > -1) {
  12062. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  12063. }
  12064. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  12065. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  12066. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  12067. bone.id = parsedBone.id;
  12068. }
  12069. if (parsedBone.length) {
  12070. bone.length = parsedBone.length;
  12071. }
  12072. if (parsedBone.metadata) {
  12073. bone.metadata = parsedBone.metadata;
  12074. }
  12075. if (parsedBone.animation) {
  12076. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  12077. }
  12078. if (parsedBone.linkedTransformNodeId !== undefined && parsedBone.linkedTransformNodeId !== null) {
  12079. skeleton._hasWaitingData = true;
  12080. bone._waitingTransformNodeId = parsedBone.linkedTransformNodeId;
  12081. }
  12082. }
  12083. // placed after bones, so createAnimationRange can cascade down
  12084. if (parsedSkeleton.ranges) {
  12085. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  12086. var data = parsedSkeleton.ranges[index];
  12087. skeleton.createAnimationRange(data.name, data.from, data.to);
  12088. }
  12089. }
  12090. return skeleton;
  12091. };
  12092. /**
  12093. * Compute all node absolute transforms
  12094. * @param forceUpdate defines if computation must be done even if cache is up to date
  12095. */
  12096. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  12097. if (forceUpdate === void 0) { forceUpdate = false; }
  12098. var renderId = this._scene.getRenderId();
  12099. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  12100. this.bones[0].computeAbsoluteTransforms();
  12101. this._lastAbsoluteTransformsUpdateId = renderId;
  12102. }
  12103. };
  12104. /**
  12105. * Gets the root pose matrix
  12106. * @returns a matrix
  12107. */
  12108. Skeleton.prototype.getPoseMatrix = function () {
  12109. var poseMatrix = null;
  12110. if (this._meshesWithPoseMatrix.length > 0) {
  12111. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  12112. }
  12113. return poseMatrix;
  12114. };
  12115. /**
  12116. * Sorts bones per internal index
  12117. */
  12118. Skeleton.prototype.sortBones = function () {
  12119. var bones = new Array();
  12120. var visited = new Array(this.bones.length);
  12121. for (var index = 0; index < this.bones.length; index++) {
  12122. this._sortBones(index, bones, visited);
  12123. }
  12124. this.bones = bones;
  12125. };
  12126. Skeleton.prototype._sortBones = function (index, bones, visited) {
  12127. if (visited[index]) {
  12128. return;
  12129. }
  12130. visited[index] = true;
  12131. var bone = this.bones[index];
  12132. if (bone._index === undefined) {
  12133. bone._index = index;
  12134. }
  12135. var parentBone = bone.getParent();
  12136. if (parentBone) {
  12137. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  12138. }
  12139. bones.push(bone);
  12140. };
  12141. return Skeleton;
  12142. }());
  12143. /***/ }),
  12144. /***/ "./Cameras/Inputs/BaseCameraPointersInput.ts":
  12145. /*!***************************************************!*\
  12146. !*** ./Cameras/Inputs/BaseCameraPointersInput.ts ***!
  12147. \***************************************************/
  12148. /*! exports provided: BaseCameraPointersInput */
  12149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12150. "use strict";
  12151. __webpack_require__.r(__webpack_exports__);
  12152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseCameraPointersInput", function() { return BaseCameraPointersInput; });
  12153. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12154. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12155. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12156. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12157. /**
  12158. * Base class for Camera Pointer Inputs.
  12159. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  12160. * for example usage.
  12161. */
  12162. var BaseCameraPointersInput = /** @class */ (function () {
  12163. function BaseCameraPointersInput() {
  12164. /**
  12165. * Defines the buttons associated with the input to handle camera move.
  12166. */
  12167. this.buttons = [0, 1, 2];
  12168. }
  12169. /**
  12170. * Attach the input controls to a specific dom element to get the input from.
  12171. * @param element Defines the element the controls should be listened from
  12172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12173. */
  12174. BaseCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12175. var _this = this;
  12176. var engine = this.camera.getEngine();
  12177. var previousPinchSquaredDistance = 0;
  12178. var previousMultiTouchPanPosition = null;
  12179. this.pointA = null;
  12180. this.pointB = null;
  12181. this._altKey = false;
  12182. this._ctrlKey = false;
  12183. this._metaKey = false;
  12184. this._shiftKey = false;
  12185. this._buttonsPressed = 0;
  12186. this._pointerInput = function (p, s) {
  12187. var evt = p.event;
  12188. var isTouch = evt.pointerType === "touch";
  12189. if (engine.isInVRExclusivePointerMode) {
  12190. return;
  12191. }
  12192. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE &&
  12193. _this.buttons.indexOf(evt.button) === -1) {
  12194. return;
  12195. }
  12196. var srcElement = (evt.srcElement || evt.target);
  12197. _this._altKey = evt.altKey;
  12198. _this._ctrlKey = evt.ctrlKey;
  12199. _this._metaKey = evt.metaKey;
  12200. _this._shiftKey = evt.shiftKey;
  12201. _this._buttonsPressed = evt.buttons;
  12202. if (engine.isPointerLock) {
  12203. var offsetX = evt.movementX ||
  12204. evt.mozMovementX ||
  12205. evt.webkitMovementX ||
  12206. evt.msMovementX ||
  12207. 0;
  12208. var offsetY = evt.movementY ||
  12209. evt.mozMovementY ||
  12210. evt.webkitMovementY ||
  12211. evt.msMovementY ||
  12212. 0;
  12213. _this.onTouch(null, offsetX, offsetY);
  12214. _this.pointA = null;
  12215. _this.pointB = null;
  12216. }
  12217. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12218. try {
  12219. srcElement.setPointerCapture(evt.pointerId);
  12220. }
  12221. catch (e) {
  12222. //Nothing to do with the error. Execution will continue.
  12223. }
  12224. if (_this.pointA === null) {
  12225. _this.pointA = { x: evt.clientX,
  12226. y: evt.clientY,
  12227. pointerId: evt.pointerId,
  12228. type: evt.pointerType };
  12229. }
  12230. else if (_this.pointB === null) {
  12231. _this.pointB = { x: evt.clientX,
  12232. y: evt.clientY,
  12233. pointerId: evt.pointerId,
  12234. type: evt.pointerType };
  12235. }
  12236. _this.onButtonDown(evt);
  12237. if (!noPreventDefault) {
  12238. evt.preventDefault();
  12239. element.focus();
  12240. }
  12241. }
  12242. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOUBLETAP) {
  12243. _this.onDoubleTap(evt.pointerType);
  12244. }
  12245. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  12246. try {
  12247. srcElement.releasePointerCapture(evt.pointerId);
  12248. }
  12249. catch (e) {
  12250. //Nothing to do with the error.
  12251. }
  12252. if (!isTouch) {
  12253. _this.pointB = null; // Mouse and pen are mono pointer
  12254. }
  12255. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12256. //but emptying completely pointers collection is required to fix a bug on iPhone :
  12257. //when changing orientation while pinching camera,
  12258. //one pointer stay pressed forever if we don't release all pointers
  12259. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12260. if (engine._badOS) {
  12261. _this.pointA = _this.pointB = null;
  12262. }
  12263. else {
  12264. //only remove the impacted pointer in case of multitouch allowing on most
  12265. //platforms switching from rotate to zoom and pan seamlessly.
  12266. if (_this.pointB && _this.pointA && _this.pointA.pointerId == evt.pointerId) {
  12267. _this.pointA = _this.pointB;
  12268. _this.pointB = null;
  12269. }
  12270. else if (_this.pointA && _this.pointB &&
  12271. _this.pointB.pointerId == evt.pointerId) {
  12272. _this.pointB = null;
  12273. }
  12274. else {
  12275. _this.pointA = _this.pointB = null;
  12276. }
  12277. }
  12278. if (previousPinchSquaredDistance !== 0 || previousMultiTouchPanPosition) {
  12279. // Previous pinch data is populated but a button has been lifted
  12280. // so pinch has ended.
  12281. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, 0, // pinchSquaredDistance
  12282. previousMultiTouchPanPosition, null // multiTouchPanPosition
  12283. );
  12284. previousPinchSquaredDistance = 0;
  12285. previousMultiTouchPanPosition = null;
  12286. }
  12287. _this.onButtonUp(evt);
  12288. if (!noPreventDefault) {
  12289. evt.preventDefault();
  12290. }
  12291. }
  12292. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  12293. if (!noPreventDefault) {
  12294. evt.preventDefault();
  12295. }
  12296. // One button down
  12297. if (_this.pointA && _this.pointB === null) {
  12298. var offsetX = evt.clientX - _this.pointA.x;
  12299. var offsetY = evt.clientY - _this.pointA.y;
  12300. _this.onTouch(_this.pointA, offsetX, offsetY);
  12301. _this.pointA.x = evt.clientX;
  12302. _this.pointA.y = evt.clientY;
  12303. }
  12304. // Two buttons down: pinch
  12305. else if (_this.pointA && _this.pointB) {
  12306. var ed = (_this.pointA.pointerId === evt.pointerId) ?
  12307. _this.pointA : _this.pointB;
  12308. ed.x = evt.clientX;
  12309. ed.y = evt.clientY;
  12310. var distX = _this.pointA.x - _this.pointB.x;
  12311. var distY = _this.pointA.y - _this.pointB.y;
  12312. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12313. var multiTouchPanPosition = { x: (_this.pointA.x + _this.pointB.x) / 2,
  12314. y: (_this.pointA.y + _this.pointB.y) / 2,
  12315. pointerId: evt.pointerId,
  12316. type: p.type };
  12317. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);
  12318. previousMultiTouchPanPosition = multiTouchPanPosition;
  12319. previousPinchSquaredDistance = pinchSquaredDistance;
  12320. }
  12321. }
  12322. };
  12323. 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 |
  12324. _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  12325. this._onLostFocus = function () {
  12326. _this.pointA = _this.pointB = null;
  12327. previousPinchSquaredDistance = 0;
  12328. previousMultiTouchPanPosition = null;
  12329. _this.onLostFocus();
  12330. };
  12331. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  12332. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12333. { name: "blur", handler: this._onLostFocus }
  12334. ]);
  12335. };
  12336. /**
  12337. * Detach the current controls from the specified dom element.
  12338. * @param element Defines the element to stop listening the inputs from
  12339. */
  12340. BaseCameraPointersInput.prototype.detachControl = function (element) {
  12341. if (this._onLostFocus) {
  12342. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12343. { name: "blur", handler: this._onLostFocus }
  12344. ]);
  12345. }
  12346. if (element && this._observer) {
  12347. this.camera.getScene().onPointerObservable.remove(this._observer);
  12348. this._observer = null;
  12349. if (this.onContextMenu) {
  12350. element.removeEventListener("contextmenu", this.onContextMenu);
  12351. }
  12352. this._onLostFocus = null;
  12353. }
  12354. this._altKey = false;
  12355. this._ctrlKey = false;
  12356. this._metaKey = false;
  12357. this._shiftKey = false;
  12358. this._buttonsPressed = 0;
  12359. };
  12360. /**
  12361. * Gets the class name of the current input.
  12362. * @returns the class name
  12363. */
  12364. BaseCameraPointersInput.prototype.getClassName = function () {
  12365. return "BaseCameraPointersInput";
  12366. };
  12367. /**
  12368. * Get the friendly name associated with the input class.
  12369. * @returns the input friendly name
  12370. */
  12371. BaseCameraPointersInput.prototype.getSimpleName = function () {
  12372. return "pointers";
  12373. };
  12374. /**
  12375. * Called on pointer POINTERDOUBLETAP event.
  12376. * Override this method to provide functionality on POINTERDOUBLETAP event.
  12377. */
  12378. BaseCameraPointersInput.prototype.onDoubleTap = function (type) {
  12379. };
  12380. /**
  12381. * Called on pointer POINTERMOVE event if only a single touch is active.
  12382. * Override this method to provide functionality.
  12383. */
  12384. BaseCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12385. };
  12386. /**
  12387. * Called on pointer POINTERMOVE event if multiple touches are active.
  12388. * Override this method to provide functionality.
  12389. */
  12390. BaseCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12391. };
  12392. /**
  12393. * Called on JS contextmenu event.
  12394. * Override this method to provide functionality.
  12395. */
  12396. BaseCameraPointersInput.prototype.onContextMenu = function (evt) {
  12397. evt.preventDefault();
  12398. };
  12399. /**
  12400. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12401. * press.
  12402. * Override this method to provide functionality.
  12403. */
  12404. BaseCameraPointersInput.prototype.onButtonDown = function (evt) {
  12405. };
  12406. /**
  12407. * Called each time a new POINTERUP event occurs. Ie, for each button
  12408. * release.
  12409. * Override this method to provide functionality.
  12410. */
  12411. BaseCameraPointersInput.prototype.onButtonUp = function (evt) {
  12412. };
  12413. /**
  12414. * Called when window becomes inactive.
  12415. * Override this method to provide functionality.
  12416. */
  12417. BaseCameraPointersInput.prototype.onLostFocus = function () {
  12418. };
  12419. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12420. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12421. ], BaseCameraPointersInput.prototype, "buttons", void 0);
  12422. return BaseCameraPointersInput;
  12423. }());
  12424. /***/ }),
  12425. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  12426. /*!*******************************************************!*\
  12427. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  12428. \*******************************************************/
  12429. /*! exports provided: ArcRotateCameraGamepadInput */
  12430. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12431. "use strict";
  12432. __webpack_require__.r(__webpack_exports__);
  12433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  12434. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12435. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12436. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12437. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12438. /**
  12439. * Manage the gamepad inputs to control an arc rotate camera.
  12440. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12441. */
  12442. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12443. function ArcRotateCameraGamepadInput() {
  12444. /**
  12445. * Defines the gamepad rotation sensiblity.
  12446. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12447. */
  12448. this.gamepadRotationSensibility = 80;
  12449. /**
  12450. * Defines the gamepad move sensiblity.
  12451. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12452. */
  12453. this.gamepadMoveSensibility = 40;
  12454. }
  12455. /**
  12456. * Attach the input controls to a specific dom element to get the input from.
  12457. * @param element Defines the element the controls should be listened from
  12458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12459. */
  12460. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12461. var _this = this;
  12462. var manager = this.camera.getScene().gamepadManager;
  12463. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12464. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12465. // prioritize XBOX gamepads.
  12466. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12467. _this.gamepad = gamepad;
  12468. }
  12469. }
  12470. });
  12471. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12472. if (_this.gamepad === gamepad) {
  12473. _this.gamepad = null;
  12474. }
  12475. });
  12476. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12477. };
  12478. /**
  12479. * Detach the current controls from the specified dom element.
  12480. * @param element Defines the element to stop listening the inputs from
  12481. */
  12482. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12483. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12484. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12485. this.gamepad = null;
  12486. };
  12487. /**
  12488. * Update the current camera state depending on the inputs that have been used this frame.
  12489. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12490. */
  12491. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12492. if (this.gamepad) {
  12493. var camera = this.camera;
  12494. var RSValues = this.gamepad.rightStick;
  12495. if (RSValues) {
  12496. if (RSValues.x != 0) {
  12497. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12498. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12499. camera.inertialAlphaOffset += normalizedRX;
  12500. }
  12501. }
  12502. if (RSValues.y != 0) {
  12503. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12504. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12505. camera.inertialBetaOffset += normalizedRY;
  12506. }
  12507. }
  12508. }
  12509. var LSValues = this.gamepad.leftStick;
  12510. if (LSValues && LSValues.y != 0) {
  12511. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12512. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12513. this.camera.inertialRadiusOffset -= normalizedLY;
  12514. }
  12515. }
  12516. }
  12517. };
  12518. /**
  12519. * Gets the class name of the current intput.
  12520. * @returns the class name
  12521. */
  12522. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12523. return "ArcRotateCameraGamepadInput";
  12524. };
  12525. /**
  12526. * Get the friendly name associated with the input class.
  12527. * @returns the input friendly name
  12528. */
  12529. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12530. return "gamepad";
  12531. };
  12532. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12533. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12534. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12535. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12536. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12537. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12538. return ArcRotateCameraGamepadInput;
  12539. }());
  12540. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12541. /***/ }),
  12542. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12543. /*!************************************************************!*\
  12544. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12545. \************************************************************/
  12546. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12548. "use strict";
  12549. __webpack_require__.r(__webpack_exports__);
  12550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12551. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12552. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12553. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12554. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12555. /**
  12556. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12557. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12558. */
  12559. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12560. function ArcRotateCameraKeyboardMoveInput() {
  12561. /**
  12562. * Defines the list of key codes associated with the up action (increase alpha)
  12563. */
  12564. this.keysUp = [38];
  12565. /**
  12566. * Defines the list of key codes associated with the down action (decrease alpha)
  12567. */
  12568. this.keysDown = [40];
  12569. /**
  12570. * Defines the list of key codes associated with the left action (increase beta)
  12571. */
  12572. this.keysLeft = [37];
  12573. /**
  12574. * Defines the list of key codes associated with the right action (decrease beta)
  12575. */
  12576. this.keysRight = [39];
  12577. /**
  12578. * Defines the list of key codes associated with the reset action.
  12579. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12580. */
  12581. this.keysReset = [220];
  12582. /**
  12583. * Defines the panning sensibility of the inputs.
  12584. * (How fast is the camera paning)
  12585. */
  12586. this.panningSensibility = 50.0;
  12587. /**
  12588. * Defines the zooming sensibility of the inputs.
  12589. * (How fast is the camera zooming)
  12590. */
  12591. this.zoomingSensibility = 25.0;
  12592. /**
  12593. * Defines wether maintaining the alt key down switch the movement mode from
  12594. * orientation to zoom.
  12595. */
  12596. this.useAltToZoom = true;
  12597. /**
  12598. * Rotation speed of the camera
  12599. */
  12600. this.angularSpeed = 0.01;
  12601. this._keys = new Array();
  12602. }
  12603. /**
  12604. * Attach the input controls to a specific dom element to get the input from.
  12605. * @param element Defines the element the controls should be listened from
  12606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12607. */
  12608. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12609. var _this = this;
  12610. if (this._onCanvasBlurObserver) {
  12611. return;
  12612. }
  12613. this._scene = this.camera.getScene();
  12614. this._engine = this._scene.getEngine();
  12615. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12616. _this._keys = [];
  12617. });
  12618. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12619. var evt = info.event;
  12620. if (!evt.metaKey) {
  12621. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12622. _this._ctrlPressed = evt.ctrlKey;
  12623. _this._altPressed = evt.altKey;
  12624. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12625. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12626. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12627. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12628. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12629. var index = _this._keys.indexOf(evt.keyCode);
  12630. if (index === -1) {
  12631. _this._keys.push(evt.keyCode);
  12632. }
  12633. if (evt.preventDefault) {
  12634. if (!noPreventDefault) {
  12635. evt.preventDefault();
  12636. }
  12637. }
  12638. }
  12639. }
  12640. else {
  12641. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12642. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12643. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12644. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12645. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12646. var index = _this._keys.indexOf(evt.keyCode);
  12647. if (index >= 0) {
  12648. _this._keys.splice(index, 1);
  12649. }
  12650. if (evt.preventDefault) {
  12651. if (!noPreventDefault) {
  12652. evt.preventDefault();
  12653. }
  12654. }
  12655. }
  12656. }
  12657. }
  12658. });
  12659. };
  12660. /**
  12661. * Detach the current controls from the specified dom element.
  12662. * @param element Defines the element to stop listening the inputs from
  12663. */
  12664. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12665. if (this._scene) {
  12666. if (this._onKeyboardObserver) {
  12667. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12668. }
  12669. if (this._onCanvasBlurObserver) {
  12670. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12671. }
  12672. this._onKeyboardObserver = null;
  12673. this._onCanvasBlurObserver = null;
  12674. }
  12675. this._keys = [];
  12676. };
  12677. /**
  12678. * Update the current camera state depending on the inputs that have been used this frame.
  12679. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12680. */
  12681. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12682. if (this._onKeyboardObserver) {
  12683. var camera = this.camera;
  12684. for (var index = 0; index < this._keys.length; index++) {
  12685. var keyCode = this._keys[index];
  12686. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12687. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12688. camera.inertialPanningX -= 1 / this.panningSensibility;
  12689. }
  12690. else {
  12691. camera.inertialAlphaOffset -= this.angularSpeed;
  12692. }
  12693. }
  12694. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12695. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12696. camera.inertialPanningY += 1 / this.panningSensibility;
  12697. }
  12698. else if (this._altPressed && this.useAltToZoom) {
  12699. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12700. }
  12701. else {
  12702. camera.inertialBetaOffset -= this.angularSpeed;
  12703. }
  12704. }
  12705. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12706. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12707. camera.inertialPanningX += 1 / this.panningSensibility;
  12708. }
  12709. else {
  12710. camera.inertialAlphaOffset += this.angularSpeed;
  12711. }
  12712. }
  12713. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12714. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12715. camera.inertialPanningY -= 1 / this.panningSensibility;
  12716. }
  12717. else if (this._altPressed && this.useAltToZoom) {
  12718. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12719. }
  12720. else {
  12721. camera.inertialBetaOffset += this.angularSpeed;
  12722. }
  12723. }
  12724. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12725. if (camera.useInputToRestoreState) {
  12726. camera.restoreState();
  12727. }
  12728. }
  12729. }
  12730. }
  12731. };
  12732. /**
  12733. * Gets the class name of the current intput.
  12734. * @returns the class name
  12735. */
  12736. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12737. return "ArcRotateCameraKeyboardMoveInput";
  12738. };
  12739. /**
  12740. * Get the friendly name associated with the input class.
  12741. * @returns the input friendly name
  12742. */
  12743. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12744. return "keyboard";
  12745. };
  12746. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12747. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12748. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12749. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12750. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12751. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12752. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12753. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12754. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12755. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12756. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12757. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12758. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12759. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12760. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12761. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12762. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12763. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12764. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12765. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12766. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12767. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12768. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12769. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12770. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12771. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12772. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12773. return ArcRotateCameraKeyboardMoveInput;
  12774. }());
  12775. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12776. /***/ }),
  12777. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12778. /*!**********************************************************!*\
  12779. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12780. \**********************************************************/
  12781. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12783. "use strict";
  12784. __webpack_require__.r(__webpack_exports__);
  12785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12786. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12787. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12788. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12789. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12790. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  12791. /**
  12792. * Manage the mouse wheel inputs to control an arc rotate camera.
  12793. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12794. */
  12795. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12796. function ArcRotateCameraMouseWheelInput() {
  12797. /**
  12798. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12799. */
  12800. this.wheelPrecision = 3.0;
  12801. /**
  12802. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12803. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12804. */
  12805. this.wheelDeltaPercentage = 0;
  12806. }
  12807. ArcRotateCameraMouseWheelInput.prototype.computeDeltaFromMouseWheelLegacyEvent = function (mouseWheelLegacyEvent, radius) {
  12808. var delta = 0;
  12809. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * this.wheelDeltaPercentage) * radius;
  12810. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12811. delta = wheelDelta / (1.0 + this.wheelDeltaPercentage);
  12812. }
  12813. else {
  12814. delta = wheelDelta * (1.0 + this.wheelDeltaPercentage);
  12815. }
  12816. return delta;
  12817. };
  12818. /**
  12819. * Attach the input controls to a specific dom element to get the input from.
  12820. * @param element Defines the element the controls should be listened from
  12821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12822. */
  12823. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12824. var _this = this;
  12825. this._wheel = function (p, s) {
  12826. //sanity check - this should be a PointerWheel event.
  12827. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12828. return;
  12829. }
  12830. var event = p.event;
  12831. var delta = 0;
  12832. var mouseWheelLegacyEvent = event;
  12833. if (mouseWheelLegacyEvent.wheelDelta) {
  12834. if (_this.wheelDeltaPercentage) {
  12835. delta = _this.computeDeltaFromMouseWheelLegacyEvent(mouseWheelLegacyEvent, _this.camera.radius);
  12836. // If zooming in, estimate the target radius and use that to compute the delta for inertia
  12837. // this will stop multiple scroll events zooming in from adding too much inertia
  12838. if (delta > 0) {
  12839. var estimatedTargetRadius = _this.camera.radius;
  12840. var targetInertia = _this.camera.inertialRadiusOffset + delta;
  12841. for (var i = 0; i < 20 && Math.abs(targetInertia) > 0.001; i++) {
  12842. estimatedTargetRadius -= targetInertia;
  12843. targetInertia *= _this.camera.inertia;
  12844. }
  12845. estimatedTargetRadius = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(estimatedTargetRadius, 0, Number.MAX_VALUE);
  12846. delta = _this.computeDeltaFromMouseWheelLegacyEvent(mouseWheelLegacyEvent, estimatedTargetRadius);
  12847. }
  12848. }
  12849. else {
  12850. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12851. }
  12852. }
  12853. else {
  12854. var deltaValue = event.deltaY || event.detail;
  12855. delta = -deltaValue / _this.wheelPrecision;
  12856. }
  12857. if (delta) {
  12858. _this.camera.inertialRadiusOffset += delta;
  12859. }
  12860. if (event.preventDefault) {
  12861. if (!noPreventDefault) {
  12862. event.preventDefault();
  12863. }
  12864. }
  12865. };
  12866. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12867. };
  12868. /**
  12869. * Detach the current controls from the specified dom element.
  12870. * @param element Defines the element to stop listening the inputs from
  12871. */
  12872. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12873. if (this._observer && element) {
  12874. this.camera.getScene().onPointerObservable.remove(this._observer);
  12875. this._observer = null;
  12876. this._wheel = null;
  12877. }
  12878. };
  12879. /**
  12880. * Gets the class name of the current intput.
  12881. * @returns the class name
  12882. */
  12883. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12884. return "ArcRotateCameraMouseWheelInput";
  12885. };
  12886. /**
  12887. * Get the friendly name associated with the input class.
  12888. * @returns the input friendly name
  12889. */
  12890. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12891. return "mousewheel";
  12892. };
  12893. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12894. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12895. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12896. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12897. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12898. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12899. return ArcRotateCameraMouseWheelInput;
  12900. }());
  12901. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12902. /***/ }),
  12903. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12904. /*!********************************************************!*\
  12905. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12906. \********************************************************/
  12907. /*! exports provided: ArcRotateCameraPointersInput */
  12908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12909. "use strict";
  12910. __webpack_require__.r(__webpack_exports__);
  12911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12912. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12913. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12914. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12915. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  12916. /**
  12917. * Manage the pointers inputs to control an arc rotate camera.
  12918. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12919. */
  12920. var ArcRotateCameraPointersInput = /** @class */ (function (_super) {
  12921. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraPointersInput, _super);
  12922. function ArcRotateCameraPointersInput() {
  12923. var _this = _super !== null && _super.apply(this, arguments) || this;
  12924. /**
  12925. * Defines the buttons associated with the input to handle camera move.
  12926. */
  12927. _this.buttons = [0, 1, 2];
  12928. /**
  12929. * Defines the pointer angular sensibility along the X axis or how fast is
  12930. * the camera rotating.
  12931. */
  12932. _this.angularSensibilityX = 1000.0;
  12933. /**
  12934. * Defines the pointer angular sensibility along the Y axis or how fast is
  12935. * the camera rotating.
  12936. */
  12937. _this.angularSensibilityY = 1000.0;
  12938. /**
  12939. * Defines the pointer pinch precision or how fast is the camera zooming.
  12940. */
  12941. _this.pinchPrecision = 12.0;
  12942. /**
  12943. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  12944. * from 0.
  12945. * It defines the percentage of current camera.radius to use as delta when
  12946. * pinch zoom is used.
  12947. */
  12948. _this.pinchDeltaPercentage = 0;
  12949. /**
  12950. * Defines the pointer panning sensibility or how fast is the camera moving.
  12951. */
  12952. _this.panningSensibility = 1000.0;
  12953. /**
  12954. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12955. */
  12956. _this.multiTouchPanning = true;
  12957. /**
  12958. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  12959. * zoom (pinch) through multitouch.
  12960. */
  12961. _this.multiTouchPanAndZoom = true;
  12962. /**
  12963. * Revers pinch action direction.
  12964. */
  12965. _this.pinchInwards = true;
  12966. _this._isPanClick = false;
  12967. _this._twoFingerActivityCount = 0;
  12968. _this._isPinching = false;
  12969. return _this;
  12970. }
  12971. /**
  12972. * Gets the class name of the current input.
  12973. * @returns the class name
  12974. */
  12975. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12976. return "ArcRotateCameraPointersInput";
  12977. };
  12978. /**
  12979. * Called on pointer POINTERMOVE event if only a single touch is active.
  12980. */
  12981. ArcRotateCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12982. if (this.panningSensibility !== 0 &&
  12983. ((this._ctrlKey && this.camera._useCtrlForPanning) || this._isPanClick)) {
  12984. this.camera.inertialPanningX += -offsetX / this.panningSensibility;
  12985. this.camera.inertialPanningY += offsetY / this.panningSensibility;
  12986. }
  12987. else {
  12988. this.camera.inertialAlphaOffset -= offsetX / this.angularSensibilityX;
  12989. this.camera.inertialBetaOffset -= offsetY / this.angularSensibilityY;
  12990. }
  12991. };
  12992. /**
  12993. * Called on pointer POINTERDOUBLETAP event.
  12994. */
  12995. ArcRotateCameraPointersInput.prototype.onDoubleTap = function (type) {
  12996. if (this.camera.useInputToRestoreState) {
  12997. this.camera.restoreState();
  12998. }
  12999. };
  13000. /**
  13001. * Called on pointer POINTERMOVE event if multiple touches are active.
  13002. */
  13003. ArcRotateCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  13004. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  13005. // First time this method is called for new pinch.
  13006. // Next time this is called there will be a
  13007. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  13008. return;
  13009. }
  13010. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  13011. // Last time this method is called at the end of a pinch.
  13012. return;
  13013. }
  13014. var direction = this.pinchInwards ? 1 : -1;
  13015. if (this.multiTouchPanAndZoom) {
  13016. if (this.pinchDeltaPercentage) {
  13017. this.camera.inertialRadiusOffset +=
  13018. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  13019. this.camera.radius * this.pinchDeltaPercentage;
  13020. }
  13021. else {
  13022. this.camera.inertialRadiusOffset +=
  13023. (pinchSquaredDistance - previousPinchSquaredDistance) /
  13024. (this.pinchPrecision * direction *
  13025. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  13026. }
  13027. if (this.panningSensibility !== 0 &&
  13028. previousMultiTouchPanPosition && multiTouchPanPosition) {
  13029. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  13030. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  13031. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  13032. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  13033. }
  13034. }
  13035. else {
  13036. this._twoFingerActivityCount++;
  13037. var previousPinchDistance = Math.sqrt(previousPinchSquaredDistance);
  13038. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  13039. if (this._isPinching ||
  13040. (this._twoFingerActivityCount < 20 &&
  13041. Math.abs(pinchDistance - previousPinchDistance) >
  13042. this.camera.pinchToPanMaxDistance)) {
  13043. // Since pinch has not been active long, assume we intend to zoom.
  13044. if (this.pinchDeltaPercentage) {
  13045. this.camera.inertialRadiusOffset +=
  13046. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  13047. this.camera.radius * this.pinchDeltaPercentage;
  13048. }
  13049. else {
  13050. this.camera.inertialRadiusOffset +=
  13051. (pinchSquaredDistance - previousPinchSquaredDistance) /
  13052. (this.pinchPrecision * direction *
  13053. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  13054. }
  13055. // Since we are pinching, remain pinching on next iteration.
  13056. this._isPinching = true;
  13057. }
  13058. else {
  13059. // Pause between pinch starting and moving implies not a zoom event.
  13060. // Pan instead.
  13061. if (this.panningSensibility !== 0 && this.multiTouchPanning &&
  13062. multiTouchPanPosition && previousMultiTouchPanPosition) {
  13063. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  13064. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  13065. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  13066. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  13067. }
  13068. }
  13069. }
  13070. };
  13071. /**
  13072. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  13073. * press.
  13074. */
  13075. ArcRotateCameraPointersInput.prototype.onButtonDown = function (evt) {
  13076. this._isPanClick = evt.button === this.camera._panningMouseButton;
  13077. };
  13078. /**
  13079. * Called each time a new POINTERUP event occurs. Ie, for each button
  13080. * release.
  13081. */
  13082. ArcRotateCameraPointersInput.prototype.onButtonUp = function (evt) {
  13083. this._twoFingerActivityCount = 0;
  13084. this._isPinching = false;
  13085. };
  13086. /**
  13087. * Called when window becomes inactive.
  13088. */
  13089. ArcRotateCameraPointersInput.prototype.onLostFocus = function () {
  13090. this._isPanClick = false;
  13091. this._twoFingerActivityCount = 0;
  13092. this._isPinching = false;
  13093. };
  13094. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13095. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13096. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  13097. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13098. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13099. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  13100. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13101. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13102. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  13103. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13104. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13105. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  13106. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13107. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13108. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  13109. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13110. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13111. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  13112. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13113. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13114. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  13115. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13117. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  13118. return ArcRotateCameraPointersInput;
  13119. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  13120. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraPointersInput"] =
  13121. ArcRotateCameraPointersInput;
  13122. /***/ }),
  13123. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  13124. /*!*******************************************************************!*\
  13125. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  13126. \*******************************************************************/
  13127. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  13128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13129. "use strict";
  13130. __webpack_require__.r(__webpack_exports__);
  13131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  13132. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13133. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  13134. /**
  13135. * Add orientation input support to the input manager.
  13136. * @returns the current input manager
  13137. */
  13138. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  13139. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  13140. return this;
  13141. };
  13142. /**
  13143. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  13144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13145. */
  13146. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  13147. /**
  13148. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  13149. */
  13150. function ArcRotateCameraVRDeviceOrientationInput() {
  13151. /**
  13152. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  13153. */
  13154. this.alphaCorrection = 1;
  13155. /**
  13156. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  13157. */
  13158. this.gammaCorrection = 1;
  13159. this._alpha = 0;
  13160. this._gamma = 0;
  13161. this._dirty = false;
  13162. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  13163. }
  13164. /**
  13165. * Attach the input controls to a specific dom element to get the input from.
  13166. * @param element Defines the element the controls should be listened from
  13167. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13168. */
  13169. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13170. this.camera.attachControl(element, noPreventDefault);
  13171. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  13172. };
  13173. /** @hidden */
  13174. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  13175. if (evt.alpha !== null) {
  13176. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  13177. }
  13178. if (evt.gamma !== null) {
  13179. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  13180. }
  13181. this._dirty = true;
  13182. };
  13183. /**
  13184. * Update the current camera state depending on the inputs that have been used this frame.
  13185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13186. */
  13187. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  13188. if (this._dirty) {
  13189. this._dirty = false;
  13190. if (this._gamma < 0) {
  13191. this._gamma = 180 + this._gamma;
  13192. }
  13193. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  13194. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  13195. }
  13196. };
  13197. /**
  13198. * Detach the current controls from the specified dom element.
  13199. * @param element Defines the element to stop listening the inputs from
  13200. */
  13201. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  13202. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  13203. };
  13204. /**
  13205. * Gets the class name of the current intput.
  13206. * @returns the class name
  13207. */
  13208. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  13209. return "ArcRotateCameraVRDeviceOrientationInput";
  13210. };
  13211. /**
  13212. * Get the friendly name associated with the input class.
  13213. * @returns the input friendly name
  13214. */
  13215. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  13216. return "VRDeviceOrientation";
  13217. };
  13218. return ArcRotateCameraVRDeviceOrientationInput;
  13219. }());
  13220. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  13221. /***/ }),
  13222. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  13223. /*!**************************************************!*\
  13224. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  13225. \**************************************************/
  13226. /*! exports provided: FlyCameraKeyboardInput */
  13227. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13228. "use strict";
  13229. __webpack_require__.r(__webpack_exports__);
  13230. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  13231. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13232. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13233. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13234. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13235. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13236. /**
  13237. * Listen to keyboard events to control the camera.
  13238. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13239. */
  13240. var FlyCameraKeyboardInput = /** @class */ (function () {
  13241. function FlyCameraKeyboardInput() {
  13242. /**
  13243. * The list of keyboard keys used to control the forward move of the camera.
  13244. */
  13245. this.keysForward = [87];
  13246. /**
  13247. * The list of keyboard keys used to control the backward move of the camera.
  13248. */
  13249. this.keysBackward = [83];
  13250. /**
  13251. * The list of keyboard keys used to control the forward move of the camera.
  13252. */
  13253. this.keysUp = [69];
  13254. /**
  13255. * The list of keyboard keys used to control the backward move of the camera.
  13256. */
  13257. this.keysDown = [81];
  13258. /**
  13259. * The list of keyboard keys used to control the right strafe move of the camera.
  13260. */
  13261. this.keysRight = [68];
  13262. /**
  13263. * The list of keyboard keys used to control the left strafe move of the camera.
  13264. */
  13265. this.keysLeft = [65];
  13266. this._keys = new Array();
  13267. }
  13268. /**
  13269. * Attach the input controls to a specific dom element to get the input from.
  13270. * @param element Defines the element the controls should be listened from
  13271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13272. */
  13273. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  13274. var _this = this;
  13275. if (this._onCanvasBlurObserver) {
  13276. return;
  13277. }
  13278. this._scene = this.camera.getScene();
  13279. this._engine = this._scene.getEngine();
  13280. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13281. _this._keys = [];
  13282. });
  13283. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13284. var evt = info.event;
  13285. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13286. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13287. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13288. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13289. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13290. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13291. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13292. var index = _this._keys.indexOf(evt.keyCode);
  13293. if (index === -1) {
  13294. _this._keys.push(evt.keyCode);
  13295. }
  13296. if (!noPreventDefault) {
  13297. evt.preventDefault();
  13298. }
  13299. }
  13300. }
  13301. else {
  13302. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13303. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13304. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13305. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13306. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13307. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13308. var index = _this._keys.indexOf(evt.keyCode);
  13309. if (index >= 0) {
  13310. _this._keys.splice(index, 1);
  13311. }
  13312. if (!noPreventDefault) {
  13313. evt.preventDefault();
  13314. }
  13315. }
  13316. }
  13317. });
  13318. };
  13319. /**
  13320. * Detach the current controls from the specified dom element.
  13321. * @param element Defines the element to stop listening the inputs from
  13322. */
  13323. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13324. if (this._scene) {
  13325. if (this._onKeyboardObserver) {
  13326. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13327. }
  13328. if (this._onCanvasBlurObserver) {
  13329. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13330. }
  13331. this._onKeyboardObserver = null;
  13332. this._onCanvasBlurObserver = null;
  13333. }
  13334. this._keys = [];
  13335. };
  13336. /**
  13337. * Gets the class name of the current intput.
  13338. * @returns the class name
  13339. */
  13340. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13341. return "FlyCameraKeyboardInput";
  13342. };
  13343. /** @hidden */
  13344. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13345. this._keys = [];
  13346. };
  13347. /**
  13348. * Get the friendly name associated with the input class.
  13349. * @returns the input friendly name
  13350. */
  13351. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13352. return "keyboard";
  13353. };
  13354. /**
  13355. * Update the current camera state depending on the inputs that have been used this frame.
  13356. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13357. */
  13358. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13359. if (this._onKeyboardObserver) {
  13360. var camera = this.camera;
  13361. // Keyboard
  13362. for (var index = 0; index < this._keys.length; index++) {
  13363. var keyCode = this._keys[index];
  13364. var speed = camera._computeLocalCameraSpeed();
  13365. if (this.keysForward.indexOf(keyCode) !== -1) {
  13366. camera._localDirection.copyFromFloats(0, 0, speed);
  13367. }
  13368. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13369. camera._localDirection.copyFromFloats(0, 0, -speed);
  13370. }
  13371. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13372. camera._localDirection.copyFromFloats(0, speed, 0);
  13373. }
  13374. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13375. camera._localDirection.copyFromFloats(0, -speed, 0);
  13376. }
  13377. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13378. camera._localDirection.copyFromFloats(speed, 0, 0);
  13379. }
  13380. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13381. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13382. }
  13383. if (camera.getScene().useRightHandedSystem) {
  13384. camera._localDirection.z *= -1;
  13385. }
  13386. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13387. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13388. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13389. }
  13390. }
  13391. };
  13392. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13393. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13394. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13395. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13396. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13397. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13398. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13399. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13400. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13401. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13402. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13403. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13404. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13406. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13407. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13408. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13409. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13410. return FlyCameraKeyboardInput;
  13411. }());
  13412. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13413. /***/ }),
  13414. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13415. /*!***********************************************!*\
  13416. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13417. \***********************************************/
  13418. /*! exports provided: FlyCameraMouseInput */
  13419. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13420. "use strict";
  13421. __webpack_require__.r(__webpack_exports__);
  13422. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13423. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13424. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13425. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13426. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13427. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13428. /**
  13429. * Listen to mouse events to control the camera.
  13430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13431. */
  13432. var FlyCameraMouseInput = /** @class */ (function () {
  13433. /**
  13434. * Listen to mouse events to control the camera.
  13435. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13436. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13437. */
  13438. function FlyCameraMouseInput(touchEnabled) {
  13439. if (touchEnabled === void 0) { touchEnabled = true; }
  13440. /**
  13441. * Defines the buttons associated with the input to handle camera rotation.
  13442. */
  13443. this.buttons = [0, 1, 2];
  13444. /**
  13445. * Assign buttons for Yaw control.
  13446. */
  13447. this.buttonsYaw = [-1, 0, 1];
  13448. /**
  13449. * Assign buttons for Pitch control.
  13450. */
  13451. this.buttonsPitch = [-1, 0, 1];
  13452. /**
  13453. * Assign buttons for Roll control.
  13454. */
  13455. this.buttonsRoll = [2];
  13456. /**
  13457. * Detect if any button is being pressed while mouse is moved.
  13458. * -1 = Mouse locked.
  13459. * 0 = Left button.
  13460. * 1 = Middle Button.
  13461. * 2 = Right Button.
  13462. */
  13463. this.activeButton = -1;
  13464. /**
  13465. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13466. * Higher values reduce its sensitivity.
  13467. */
  13468. this.angularSensibility = 1000.0;
  13469. this.previousPosition = null;
  13470. }
  13471. /**
  13472. * Attach the mouse control to the HTML DOM element.
  13473. * @param element Defines the element that listens to the input events.
  13474. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13475. */
  13476. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13477. var _this = this;
  13478. this.element = element;
  13479. this.noPreventDefault = noPreventDefault;
  13480. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13481. _this._pointerInput(p, s);
  13482. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13483. // Correct Roll by rate, if enabled.
  13484. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13485. if (_this.camera.rollCorrect) {
  13486. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13487. }
  13488. });
  13489. // Helper function to keep 'this'.
  13490. this._mousemoveCallback = function (e) {
  13491. _this._onMouseMove(e);
  13492. };
  13493. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13494. };
  13495. /**
  13496. * Detach the current controls from the specified dom element.
  13497. * @param element Defines the element to stop listening the inputs from
  13498. */
  13499. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13500. if (this._observer && element) {
  13501. this.camera.getScene().onPointerObservable.remove(this._observer);
  13502. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13503. if (this._mousemoveCallback) {
  13504. element.removeEventListener("mousemove", this._mousemoveCallback);
  13505. }
  13506. this._observer = null;
  13507. this._rollObserver = null;
  13508. this.previousPosition = null;
  13509. this.noPreventDefault = undefined;
  13510. }
  13511. };
  13512. /**
  13513. * Gets the class name of the current input.
  13514. * @returns the class name.
  13515. */
  13516. FlyCameraMouseInput.prototype.getClassName = function () {
  13517. return "FlyCameraMouseInput";
  13518. };
  13519. /**
  13520. * Get the friendly name associated with the input class.
  13521. * @returns the input's friendly name.
  13522. */
  13523. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13524. return "mouse";
  13525. };
  13526. // Track mouse movement, when the pointer is not locked.
  13527. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13528. var e = p.event;
  13529. var camera = this.camera;
  13530. var engine = camera.getEngine();
  13531. if (engine.isInVRExclusivePointerMode) {
  13532. return;
  13533. }
  13534. if (!this.touchEnabled && e.pointerType === "touch") {
  13535. return;
  13536. }
  13537. // Mouse is moved but an unknown mouse button is pressed.
  13538. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13539. return;
  13540. }
  13541. var srcElement = (e.srcElement || e.target);
  13542. // Mouse down.
  13543. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13544. try {
  13545. srcElement.setPointerCapture(e.pointerId);
  13546. }
  13547. catch (e) {
  13548. // Nothing to do with the error. Execution continues.
  13549. }
  13550. this.previousPosition = {
  13551. x: e.clientX,
  13552. y: e.clientY
  13553. };
  13554. this.activeButton = e.button;
  13555. if (!this.noPreventDefault) {
  13556. e.preventDefault();
  13557. this.element.focus();
  13558. }
  13559. }
  13560. else
  13561. // Mouse up.
  13562. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13563. try {
  13564. srcElement.releasePointerCapture(e.pointerId);
  13565. }
  13566. catch (e) {
  13567. // Nothing to do with the error. Execution continues.
  13568. }
  13569. this.activeButton = -1;
  13570. this.previousPosition = null;
  13571. if (!this.noPreventDefault) {
  13572. e.preventDefault();
  13573. }
  13574. }
  13575. else
  13576. // Mouse move.
  13577. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13578. if (!this.previousPosition || engine.isPointerLock) {
  13579. return;
  13580. }
  13581. var offsetX = e.clientX - this.previousPosition.x;
  13582. var offsetY = e.clientY - this.previousPosition.y;
  13583. this.rotateCamera(offsetX, offsetY);
  13584. this.previousPosition = {
  13585. x: e.clientX,
  13586. y: e.clientY
  13587. };
  13588. if (!this.noPreventDefault) {
  13589. e.preventDefault();
  13590. }
  13591. }
  13592. };
  13593. // Track mouse movement, when pointer is locked.
  13594. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13595. var camera = this.camera;
  13596. var engine = camera.getEngine();
  13597. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13598. return;
  13599. }
  13600. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13601. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13602. this.rotateCamera(offsetX, offsetY);
  13603. this.previousPosition = null;
  13604. if (!this.noPreventDefault) {
  13605. e.preventDefault();
  13606. }
  13607. };
  13608. /**
  13609. * Rotate camera by mouse offset.
  13610. */
  13611. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13612. var _this = this;
  13613. var camera = this.camera;
  13614. var scene = this.camera.getScene();
  13615. if (scene.useRightHandedSystem) {
  13616. offsetX *= -1;
  13617. }
  13618. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13619. offsetX *= -1;
  13620. }
  13621. var x = offsetX / this.angularSensibility;
  13622. var y = offsetY / this.angularSensibility;
  13623. // Initialize to current rotation.
  13624. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13625. var rotationChange;
  13626. // Pitch.
  13627. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13628. // Apply change in Radians to vector Angle.
  13629. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13630. // Apply Pitch to quaternion.
  13631. currentRotation.multiplyInPlace(rotationChange);
  13632. }
  13633. // Yaw.
  13634. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13635. // Apply change in Radians to vector Angle.
  13636. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13637. // Apply Yaw to quaternion.
  13638. currentRotation.multiplyInPlace(rotationChange);
  13639. // Add Roll, if banked turning is enabled, within Roll limit.
  13640. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13641. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13642. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13643. // Apply change in Radians to vector Angle.
  13644. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13645. // Apply Yaw to quaternion.
  13646. currentRotation.multiplyInPlace(rotationChange);
  13647. }
  13648. }
  13649. // Roll.
  13650. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13651. // Apply change in Radians to vector Angle.
  13652. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13653. // Track Rolling.
  13654. camera._trackRoll -= x;
  13655. // Apply Pitch to quaternion.
  13656. currentRotation.multiplyInPlace(rotationChange);
  13657. }
  13658. // Apply rotationQuaternion to Euler camera.rotation.
  13659. currentRotation.toEulerAnglesToRef(camera.rotation);
  13660. };
  13661. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13662. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13663. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13664. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13666. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13667. return FlyCameraMouseInput;
  13668. }());
  13669. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13670. /***/ }),
  13671. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13672. /*!*********************************************************!*\
  13673. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13674. \*********************************************************/
  13675. /*! exports provided: FollowCameraKeyboardMoveInput */
  13676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13677. "use strict";
  13678. __webpack_require__.r(__webpack_exports__);
  13679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13680. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13681. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13682. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13683. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13684. /**
  13685. * Manage the keyboard inputs to control the movement of a follow camera.
  13686. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13687. */
  13688. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13689. function FollowCameraKeyboardMoveInput() {
  13690. /**
  13691. * Defines the list of key codes associated with the up action (increase heightOffset)
  13692. */
  13693. this.keysHeightOffsetIncr = [38];
  13694. /**
  13695. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13696. */
  13697. this.keysHeightOffsetDecr = [40];
  13698. /**
  13699. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13700. */
  13701. this.keysHeightOffsetModifierAlt = false;
  13702. /**
  13703. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13704. */
  13705. this.keysHeightOffsetModifierCtrl = false;
  13706. /**
  13707. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13708. */
  13709. this.keysHeightOffsetModifierShift = false;
  13710. /**
  13711. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13712. */
  13713. this.keysRotationOffsetIncr = [37];
  13714. /**
  13715. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13716. */
  13717. this.keysRotationOffsetDecr = [39];
  13718. /**
  13719. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13720. */
  13721. this.keysRotationOffsetModifierAlt = false;
  13722. /**
  13723. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13724. */
  13725. this.keysRotationOffsetModifierCtrl = false;
  13726. /**
  13727. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13728. */
  13729. this.keysRotationOffsetModifierShift = false;
  13730. /**
  13731. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13732. */
  13733. this.keysRadiusIncr = [40];
  13734. /**
  13735. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13736. */
  13737. this.keysRadiusDecr = [38];
  13738. /**
  13739. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13740. */
  13741. this.keysRadiusModifierAlt = true;
  13742. /**
  13743. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13744. */
  13745. this.keysRadiusModifierCtrl = false;
  13746. /**
  13747. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13748. */
  13749. this.keysRadiusModifierShift = false;
  13750. /**
  13751. * Defines the rate of change of heightOffset.
  13752. */
  13753. this.heightSensibility = 1;
  13754. /**
  13755. * Defines the rate of change of rotationOffset.
  13756. */
  13757. this.rotationSensibility = 1;
  13758. /**
  13759. * Defines the rate of change of radius.
  13760. */
  13761. this.radiusSensibility = 1;
  13762. this._keys = new Array();
  13763. }
  13764. /**
  13765. * Attach the input controls to a specific dom element to get the input from.
  13766. * @param element Defines the element the controls should be listened from
  13767. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13768. */
  13769. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13770. var _this = this;
  13771. if (this._onCanvasBlurObserver) {
  13772. return;
  13773. }
  13774. this._scene = this.camera.getScene();
  13775. this._engine = this._scene.getEngine();
  13776. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13777. _this._keys = [];
  13778. });
  13779. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13780. var evt = info.event;
  13781. if (!evt.metaKey) {
  13782. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13783. _this._ctrlPressed = evt.ctrlKey;
  13784. _this._altPressed = evt.altKey;
  13785. _this._shiftPressed = evt.shiftKey;
  13786. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13787. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13788. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13789. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13790. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13791. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13792. var index = _this._keys.indexOf(evt.keyCode);
  13793. if (index === -1) {
  13794. _this._keys.push(evt.keyCode);
  13795. }
  13796. if (evt.preventDefault) {
  13797. if (!noPreventDefault) {
  13798. evt.preventDefault();
  13799. }
  13800. }
  13801. }
  13802. }
  13803. else {
  13804. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13805. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13806. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13807. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13808. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13809. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13810. var index = _this._keys.indexOf(evt.keyCode);
  13811. if (index >= 0) {
  13812. _this._keys.splice(index, 1);
  13813. }
  13814. if (evt.preventDefault) {
  13815. if (!noPreventDefault) {
  13816. evt.preventDefault();
  13817. }
  13818. }
  13819. }
  13820. }
  13821. }
  13822. });
  13823. };
  13824. /**
  13825. * Detach the current controls from the specified dom element.
  13826. * @param element Defines the element to stop listening the inputs from
  13827. */
  13828. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13829. if (this._scene) {
  13830. if (this._onKeyboardObserver) {
  13831. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13832. }
  13833. if (this._onCanvasBlurObserver) {
  13834. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13835. }
  13836. this._onKeyboardObserver = null;
  13837. this._onCanvasBlurObserver = null;
  13838. }
  13839. this._keys = [];
  13840. };
  13841. /**
  13842. * Update the current camera state depending on the inputs that have been used this frame.
  13843. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13844. */
  13845. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13846. var _this = this;
  13847. if (this._onKeyboardObserver) {
  13848. this._keys.forEach(function (keyCode) {
  13849. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13850. _this._modifierHeightOffset()) {
  13851. _this.camera.heightOffset += _this.heightSensibility;
  13852. }
  13853. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13854. _this._modifierHeightOffset()) {
  13855. _this.camera.heightOffset -= _this.heightSensibility;
  13856. }
  13857. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13858. _this._modifierRotationOffset()) {
  13859. _this.camera.rotationOffset += _this.rotationSensibility;
  13860. _this.camera.rotationOffset %= 360;
  13861. }
  13862. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13863. _this._modifierRotationOffset()) {
  13864. _this.camera.rotationOffset -= _this.rotationSensibility;
  13865. _this.camera.rotationOffset %= 360;
  13866. }
  13867. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13868. _this._modifierRadius()) {
  13869. _this.camera.radius += _this.radiusSensibility;
  13870. }
  13871. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13872. _this._modifierRadius()) {
  13873. _this.camera.radius -= _this.radiusSensibility;
  13874. }
  13875. });
  13876. }
  13877. };
  13878. /**
  13879. * Gets the class name of the current input.
  13880. * @returns the class name
  13881. */
  13882. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13883. return "FollowCameraKeyboardMoveInput";
  13884. };
  13885. /**
  13886. * Get the friendly name associated with the input class.
  13887. * @returns the input friendly name
  13888. */
  13889. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13890. return "keyboard";
  13891. };
  13892. /**
  13893. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13894. * allow modification of the heightOffset value.
  13895. */
  13896. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13897. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13898. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13899. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13900. };
  13901. /**
  13902. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13903. * allow modification of the rotationOffset value.
  13904. */
  13905. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13906. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13907. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13908. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13909. };
  13910. /**
  13911. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13912. * allow modification of the radius value.
  13913. */
  13914. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13915. return (this.keysRadiusModifierAlt === this._altPressed &&
  13916. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13917. this.keysRadiusModifierShift === this._shiftPressed);
  13918. };
  13919. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13920. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13921. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13922. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13923. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13924. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13925. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13926. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13927. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13928. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13929. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13930. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13931. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13932. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13933. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13934. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13935. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13936. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13937. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13938. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13939. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13940. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13941. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13942. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13943. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13945. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13946. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13948. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13951. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13952. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13953. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13954. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13955. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13957. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13960. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13963. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13964. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13965. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13966. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13967. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13968. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13969. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13972. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13973. return FollowCameraKeyboardMoveInput;
  13974. }());
  13975. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13976. /***/ }),
  13977. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13978. /*!*******************************************************!*\
  13979. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13980. \*******************************************************/
  13981. /*! exports provided: FollowCameraMouseWheelInput */
  13982. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13983. "use strict";
  13984. __webpack_require__.r(__webpack_exports__);
  13985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13986. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13987. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13988. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13989. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13990. /**
  13991. * Manage the mouse wheel inputs to control a follow camera.
  13992. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13993. */
  13994. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13995. function FollowCameraMouseWheelInput() {
  13996. /**
  13997. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  13998. */
  13999. this.axisControlRadius = true;
  14000. /**
  14001. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  14002. */
  14003. this.axisControlHeight = false;
  14004. /**
  14005. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  14006. */
  14007. this.axisControlRotation = false;
  14008. /**
  14009. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  14010. * relation to mouseWheel events.
  14011. */
  14012. this.wheelPrecision = 3.0;
  14013. /**
  14014. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  14015. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  14016. */
  14017. this.wheelDeltaPercentage = 0;
  14018. }
  14019. /**
  14020. * Attach the input controls to a specific dom element to get the input from.
  14021. * @param element Defines the element the controls should be listened from
  14022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14023. */
  14024. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  14025. var _this = this;
  14026. this._wheel = function (p, s) {
  14027. // sanity check - this should be a PointerWheel event.
  14028. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  14029. return;
  14030. }
  14031. var event = p.event;
  14032. var delta = 0;
  14033. // Chrome, Safari: event.deltaY
  14034. // IE: event.wheelDelta
  14035. // Firefox: event.detail (inverted)
  14036. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  14037. if (_this.wheelDeltaPercentage) {
  14038. console.assert((_this.axisControlRadius +
  14039. _this.axisControlHeight +
  14040. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  14041. "controlls ONE axis. " +
  14042. "Currently enabled: " +
  14043. "axisControlRadius: " + _this.axisControlRadius +
  14044. ", axisControlHeightOffset: " + _this.axisControlHeight +
  14045. ", axisControlRotationOffset: " + _this.axisControlRotation);
  14046. if (_this.axisControlRadius) {
  14047. delta =
  14048. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  14049. _this.camera.radius;
  14050. }
  14051. else if (_this.axisControlHeight) {
  14052. delta =
  14053. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  14054. _this.camera.heightOffset;
  14055. }
  14056. else if (_this.axisControlRotation) {
  14057. delta =
  14058. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  14059. _this.camera.rotationOffset;
  14060. }
  14061. }
  14062. else {
  14063. delta = wheelDelta * _this.wheelPrecision;
  14064. }
  14065. if (delta) {
  14066. if (_this.axisControlRadius) {
  14067. _this.camera.radius += delta;
  14068. }
  14069. else if (_this.axisControlHeight) {
  14070. _this.camera.heightOffset -= delta;
  14071. }
  14072. else if (_this.axisControlRotation) {
  14073. _this.camera.rotationOffset -= delta;
  14074. }
  14075. }
  14076. if (event.preventDefault) {
  14077. if (!noPreventDefault) {
  14078. event.preventDefault();
  14079. }
  14080. }
  14081. };
  14082. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  14083. };
  14084. /**
  14085. * Detach the current controls from the specified dom element.
  14086. * @param element Defines the element to stop listening the inputs from
  14087. */
  14088. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  14089. if (this._observer && element) {
  14090. this.camera.getScene().onPointerObservable.remove(this._observer);
  14091. this._observer = null;
  14092. this._wheel = null;
  14093. }
  14094. };
  14095. /**
  14096. * Gets the class name of the current intput.
  14097. * @returns the class name
  14098. */
  14099. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  14100. return "ArcRotateCameraMouseWheelInput";
  14101. };
  14102. /**
  14103. * Get the friendly name associated with the input class.
  14104. * @returns the input friendly name
  14105. */
  14106. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  14107. return "mousewheel";
  14108. };
  14109. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14110. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14111. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  14112. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14113. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14114. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  14115. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14117. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  14118. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14120. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  14121. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14122. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14123. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  14124. return FollowCameraMouseWheelInput;
  14125. }());
  14126. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  14127. /***/ }),
  14128. /***/ "./Cameras/Inputs/followCameraPointersInput.ts":
  14129. /*!*****************************************************!*\
  14130. !*** ./Cameras/Inputs/followCameraPointersInput.ts ***!
  14131. \*****************************************************/
  14132. /*! exports provided: FollowCameraPointersInput */
  14133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14134. "use strict";
  14135. __webpack_require__.r(__webpack_exports__);
  14136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return FollowCameraPointersInput; });
  14137. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14138. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14139. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14140. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  14141. /**
  14142. * Manage the pointers inputs to control an follow camera.
  14143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14144. */
  14145. var FollowCameraPointersInput = /** @class */ (function (_super) {
  14146. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraPointersInput, _super);
  14147. function FollowCameraPointersInput() {
  14148. var _this = _super !== null && _super.apply(this, arguments) || this;
  14149. /**
  14150. * Defines the pointer angular sensibility along the X axis or how fast is
  14151. * the camera rotating.
  14152. * A negative number will reverse the axis direction.
  14153. */
  14154. _this.angularSensibilityX = 1;
  14155. /**
  14156. * Defines the pointer angular sensibility along the Y axis or how fast is
  14157. * the camera rotating.
  14158. * A negative number will reverse the axis direction.
  14159. */
  14160. _this.angularSensibilityY = 1;
  14161. /**
  14162. * Defines the pointer pinch precision or how fast is the camera zooming.
  14163. * A negative number will reverse the axis direction.
  14164. */
  14165. _this.pinchPrecision = 10000.0;
  14166. /**
  14167. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  14168. * from 0.
  14169. * It defines the percentage of current camera.radius to use as delta when
  14170. * pinch zoom is used.
  14171. */
  14172. _this.pinchDeltaPercentage = 0;
  14173. /**
  14174. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  14175. */
  14176. _this.axisXControlRadius = false;
  14177. /**
  14178. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  14179. */
  14180. _this.axisXControlHeight = false;
  14181. /**
  14182. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  14183. */
  14184. _this.axisXControlRotation = true;
  14185. /**
  14186. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  14187. */
  14188. _this.axisYControlRadius = false;
  14189. /**
  14190. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  14191. */
  14192. _this.axisYControlHeight = true;
  14193. /**
  14194. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  14195. */
  14196. _this.axisYControlRotation = false;
  14197. /**
  14198. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  14199. */
  14200. _this.axisPinchControlRadius = true;
  14201. /**
  14202. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  14203. */
  14204. _this.axisPinchControlHeight = false;
  14205. /**
  14206. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  14207. */
  14208. _this.axisPinchControlRotation = false;
  14209. /**
  14210. * Log error messages if basic misconfiguration has occurred.
  14211. */
  14212. _this.warningEnable = true;
  14213. /* Check for obvious misconfiguration. */
  14214. _this._warningCounter = 0;
  14215. return _this;
  14216. }
  14217. /**
  14218. * Gets the class name of the current input.
  14219. * @returns the class name
  14220. */
  14221. FollowCameraPointersInput.prototype.getClassName = function () {
  14222. return "FollowCameraPointersInput";
  14223. };
  14224. FollowCameraPointersInput.prototype.onTouch = function (pointA, offsetX, offsetY) {
  14225. this._warning();
  14226. if (this.axisXControlRotation) {
  14227. this.camera.rotationOffset += offsetX / this.angularSensibilityX;
  14228. }
  14229. else if (this.axisYControlRotation) {
  14230. this.camera.rotationOffset += offsetY / this.angularSensibilityX;
  14231. }
  14232. if (this.axisXControlHeight) {
  14233. this.camera.heightOffset += offsetX / this.angularSensibilityY;
  14234. }
  14235. else if (this.axisYControlHeight) {
  14236. this.camera.heightOffset += offsetY / this.angularSensibilityY;
  14237. }
  14238. if (this.axisXControlRadius) {
  14239. this.camera.radius -= offsetX / this.angularSensibilityY;
  14240. }
  14241. else if (this.axisYControlRadius) {
  14242. this.camera.radius -= offsetY / this.angularSensibilityY;
  14243. }
  14244. };
  14245. FollowCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  14246. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  14247. // First time this method is called for new pinch.
  14248. // Next time this is called there will be a
  14249. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  14250. return;
  14251. }
  14252. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  14253. // Last time this method is called at the end of a pinch.
  14254. return;
  14255. }
  14256. var pinchDelta = (pinchSquaredDistance - previousPinchSquaredDistance) /
  14257. (this.pinchPrecision * (this.angularSensibilityX + this.angularSensibilityY) / 2);
  14258. if (this.pinchDeltaPercentage) {
  14259. pinchDelta *= 0.01 * this.pinchDeltaPercentage;
  14260. if (this.axisPinchControlRotation) {
  14261. this.camera.rotationOffset += pinchDelta * this.camera.rotationOffset;
  14262. }
  14263. if (this.axisPinchControlHeight) {
  14264. this.camera.heightOffset += pinchDelta * this.camera.heightOffset;
  14265. }
  14266. if (this.axisPinchControlRadius) {
  14267. this.camera.radius -= pinchDelta * this.camera.radius;
  14268. }
  14269. }
  14270. else {
  14271. if (this.axisPinchControlRotation) {
  14272. this.camera.rotationOffset += pinchDelta;
  14273. }
  14274. if (this.axisPinchControlHeight) {
  14275. this.camera.heightOffset += pinchDelta;
  14276. }
  14277. if (this.axisPinchControlRadius) {
  14278. this.camera.radius -= pinchDelta;
  14279. }
  14280. }
  14281. };
  14282. FollowCameraPointersInput.prototype._warning = function () {
  14283. if (!this.warningEnable || this._warningCounter++ % 100 !== 0) {
  14284. return;
  14285. }
  14286. var warn = "It probably only makes sense to control ONE camera " +
  14287. "property with each pointer axis. Set 'warningEnable = false' " +
  14288. "if you are sure. Currently enabled: ";
  14289. console.assert((this.axisXControlRotation +
  14290. this.axisXControlHeight +
  14291. this.axisXControlRadius) <= 1, warn +
  14292. "axisXControlRotation: " + this.axisXControlRotation +
  14293. ", axisXControlHeight: " + this.axisXControlHeight +
  14294. ", axisXControlRadius: " + this.axisXControlRadius);
  14295. console.assert((this.axisYControlRotation +
  14296. this.axisYControlHeight +
  14297. this.axisYControlRadius) <= 1, warn +
  14298. "axisYControlRotation: " + this.axisYControlRotation +
  14299. ", axisYControlHeight: " + this.axisYControlHeight +
  14300. ", axisYControlRadius: " + this.axisYControlRadius);
  14301. console.assert((this.axisPinchControlRotation +
  14302. this.axisPinchControlHeight +
  14303. this.axisPinchControlRadius) <= 1, warn +
  14304. "axisPinchControlRotation: " + this.axisPinchControlRotation +
  14305. ", axisPinchControlHeight: " + this.axisPinchControlHeight +
  14306. ", axisPinchControlRadius: " + this.axisPinchControlRadius);
  14307. };
  14308. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14309. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14310. ], FollowCameraPointersInput.prototype, "angularSensibilityX", void 0);
  14311. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14312. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14313. ], FollowCameraPointersInput.prototype, "angularSensibilityY", void 0);
  14314. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14316. ], FollowCameraPointersInput.prototype, "pinchPrecision", void 0);
  14317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14319. ], FollowCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  14320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14322. ], FollowCameraPointersInput.prototype, "axisXControlRadius", void 0);
  14323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14325. ], FollowCameraPointersInput.prototype, "axisXControlHeight", void 0);
  14326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14328. ], FollowCameraPointersInput.prototype, "axisXControlRotation", void 0);
  14329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14331. ], FollowCameraPointersInput.prototype, "axisYControlRadius", void 0);
  14332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14334. ], FollowCameraPointersInput.prototype, "axisYControlHeight", void 0);
  14335. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14336. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14337. ], FollowCameraPointersInput.prototype, "axisYControlRotation", void 0);
  14338. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14339. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14340. ], FollowCameraPointersInput.prototype, "axisPinchControlRadius", void 0);
  14341. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14343. ], FollowCameraPointersInput.prototype, "axisPinchControlHeight", void 0);
  14344. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14345. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14346. ], FollowCameraPointersInput.prototype, "axisPinchControlRotation", void 0);
  14347. return FollowCameraPointersInput;
  14348. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  14349. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraPointersInput"] = FollowCameraPointersInput;
  14350. /***/ }),
  14351. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  14352. /*!************************************************************!*\
  14353. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  14354. \************************************************************/
  14355. /*! exports provided: FreeCameraDeviceOrientationInput */
  14356. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14357. "use strict";
  14358. __webpack_require__.r(__webpack_exports__);
  14359. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  14360. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14361. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14362. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  14363. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14364. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  14365. /**
  14366. * Add orientation input support to the input manager.
  14367. * @returns the current input manager
  14368. */
  14369. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  14370. if (!this._deviceOrientationInput) {
  14371. this._deviceOrientationInput = new FreeCameraDeviceOrientationInput();
  14372. this.add(this._deviceOrientationInput);
  14373. }
  14374. return this;
  14375. };
  14376. /**
  14377. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  14378. * Screen rotation is taken into account.
  14379. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14380. */
  14381. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  14382. /**
  14383. * Instantiates a new input
  14384. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14385. */
  14386. function FreeCameraDeviceOrientationInput() {
  14387. var _this = this;
  14388. this._screenOrientationAngle = 0;
  14389. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14390. this._alpha = 0;
  14391. this._beta = 0;
  14392. this._gamma = 0;
  14393. /**
  14394. * @hidden
  14395. */
  14396. this._onDeviceOrientationChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  14397. this._orientationChanged = function () {
  14398. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  14399. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  14400. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  14401. };
  14402. this._deviceOrientation = function (evt) {
  14403. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  14404. _this._beta = evt.beta !== null ? evt.beta : 0;
  14405. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  14406. if (evt.alpha !== null) {
  14407. _this._onDeviceOrientationChangedObservable.notifyObservers();
  14408. }
  14409. };
  14410. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  14411. this._orientationChanged();
  14412. }
  14413. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  14414. /**
  14415. * Define the camera controlled by the input.
  14416. */
  14417. get: function () {
  14418. return this._camera;
  14419. },
  14420. set: function (camera) {
  14421. var _this = this;
  14422. this._camera = camera;
  14423. if (this._camera != null && !this._camera.rotationQuaternion) {
  14424. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14425. }
  14426. if (this._camera) {
  14427. this._camera.onDisposeObservable.add(function () {
  14428. _this._onDeviceOrientationChangedObservable.clear();
  14429. });
  14430. }
  14431. },
  14432. enumerable: true,
  14433. configurable: true
  14434. });
  14435. /**
  14436. * Attach the input controls to a specific dom element to get the input from.
  14437. * @param element Defines the element the controls should be listened from
  14438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14439. */
  14440. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  14441. window.addEventListener("orientationchange", this._orientationChanged);
  14442. window.addEventListener("deviceorientation", this._deviceOrientation);
  14443. //In certain cases, the attach control is called AFTER orientation was changed,
  14444. //So this is needed.
  14445. this._orientationChanged();
  14446. };
  14447. /**
  14448. * Detach the current controls from the specified dom element.
  14449. * @param element Defines the element to stop listening the inputs from
  14450. */
  14451. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  14452. window.removeEventListener("orientationchange", this._orientationChanged);
  14453. window.removeEventListener("deviceorientation", this._deviceOrientation);
  14454. this._alpha = 0;
  14455. };
  14456. /**
  14457. * Update the current camera state depending on the inputs that have been used this frame.
  14458. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14459. */
  14460. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  14461. //if no device orientation provided, don't update the rotation.
  14462. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  14463. if (!this._alpha) {
  14464. return;
  14465. }
  14466. _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);
  14467. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  14468. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  14469. //Mirror on XY Plane
  14470. this._camera.rotationQuaternion.z *= -1;
  14471. this._camera.rotationQuaternion.w *= -1;
  14472. };
  14473. /**
  14474. * Gets the class name of the current intput.
  14475. * @returns the class name
  14476. */
  14477. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  14478. return "FreeCameraDeviceOrientationInput";
  14479. };
  14480. /**
  14481. * Get the friendly name associated with the input class.
  14482. * @returns the input friendly name
  14483. */
  14484. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  14485. return "deviceOrientation";
  14486. };
  14487. return FreeCameraDeviceOrientationInput;
  14488. }());
  14489. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  14490. /***/ }),
  14491. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  14492. /*!**************************************************!*\
  14493. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  14494. \**************************************************/
  14495. /*! exports provided: FreeCameraGamepadInput */
  14496. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14497. "use strict";
  14498. __webpack_require__.r(__webpack_exports__);
  14499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  14500. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14501. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14502. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14503. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14504. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  14505. /**
  14506. * Manage the gamepad inputs to control a free camera.
  14507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14508. */
  14509. var FreeCameraGamepadInput = /** @class */ (function () {
  14510. function FreeCameraGamepadInput() {
  14511. /**
  14512. * Defines the gamepad rotation sensiblity.
  14513. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  14514. */
  14515. this.gamepadAngularSensibility = 200;
  14516. /**
  14517. * Defines the gamepad move sensiblity.
  14518. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  14519. */
  14520. this.gamepadMoveSensibility = 40;
  14521. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  14522. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14523. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14524. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  14525. }
  14526. /**
  14527. * Attach the input controls to a specific dom element to get the input from.
  14528. * @param element Defines the element the controls should be listened from
  14529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14530. */
  14531. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14532. var _this = this;
  14533. var manager = this.camera.getScene().gamepadManager;
  14534. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14535. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14536. // prioritize XBOX gamepads.
  14537. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14538. _this.gamepad = gamepad;
  14539. }
  14540. }
  14541. });
  14542. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14543. if (_this.gamepad === gamepad) {
  14544. _this.gamepad = null;
  14545. }
  14546. });
  14547. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14548. };
  14549. /**
  14550. * Detach the current controls from the specified dom element.
  14551. * @param element Defines the element to stop listening the inputs from
  14552. */
  14553. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14554. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14555. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14556. this.gamepad = null;
  14557. };
  14558. /**
  14559. * Update the current camera state depending on the inputs that have been used this frame.
  14560. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14561. */
  14562. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14563. if (this.gamepad && this.gamepad.leftStick) {
  14564. var camera = this.camera;
  14565. var LSValues = this.gamepad.leftStick;
  14566. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14567. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14568. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14569. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14570. var RSValues = this.gamepad.rightStick;
  14571. if (RSValues) {
  14572. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14573. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14574. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14575. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14576. }
  14577. else {
  14578. RSValues = { x: 0, y: 0 };
  14579. }
  14580. if (!camera.rotationQuaternion) {
  14581. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14582. }
  14583. else {
  14584. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14585. }
  14586. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14587. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14588. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14589. camera.cameraDirection.addInPlace(this._deltaTransform);
  14590. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14591. camera.cameraRotation.addInPlace(this._vector2);
  14592. }
  14593. };
  14594. /**
  14595. * Gets the class name of the current intput.
  14596. * @returns the class name
  14597. */
  14598. FreeCameraGamepadInput.prototype.getClassName = function () {
  14599. return "FreeCameraGamepadInput";
  14600. };
  14601. /**
  14602. * Get the friendly name associated with the input class.
  14603. * @returns the input friendly name
  14604. */
  14605. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14606. return "gamepad";
  14607. };
  14608. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14609. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14610. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14611. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14612. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14613. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14614. return FreeCameraGamepadInput;
  14615. }());
  14616. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14617. /***/ }),
  14618. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14619. /*!*******************************************************!*\
  14620. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14621. \*******************************************************/
  14622. /*! exports provided: FreeCameraKeyboardMoveInput */
  14623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14624. "use strict";
  14625. __webpack_require__.r(__webpack_exports__);
  14626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14627. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14628. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14629. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14630. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14631. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14632. /**
  14633. * Manage the keyboard inputs to control the movement of a free camera.
  14634. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14635. */
  14636. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14637. function FreeCameraKeyboardMoveInput() {
  14638. /**
  14639. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14640. */
  14641. this.keysUp = [38];
  14642. /**
  14643. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14644. */
  14645. this.keysDown = [40];
  14646. /**
  14647. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14648. */
  14649. this.keysLeft = [37];
  14650. /**
  14651. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14652. */
  14653. this.keysRight = [39];
  14654. this._keys = new Array();
  14655. }
  14656. /**
  14657. * Attach the input controls to a specific dom element to get the input from.
  14658. * @param element Defines the element the controls should be listened from
  14659. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14660. */
  14661. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14662. var _this = this;
  14663. if (this._onCanvasBlurObserver) {
  14664. return;
  14665. }
  14666. this._scene = this.camera.getScene();
  14667. this._engine = this._scene.getEngine();
  14668. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14669. _this._keys = [];
  14670. });
  14671. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14672. var evt = info.event;
  14673. if (!evt.metaKey) {
  14674. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14675. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14676. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14677. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14678. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14679. var index = _this._keys.indexOf(evt.keyCode);
  14680. if (index === -1) {
  14681. _this._keys.push(evt.keyCode);
  14682. }
  14683. if (!noPreventDefault) {
  14684. evt.preventDefault();
  14685. }
  14686. }
  14687. }
  14688. else {
  14689. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14690. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14691. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14692. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14693. var index = _this._keys.indexOf(evt.keyCode);
  14694. if (index >= 0) {
  14695. _this._keys.splice(index, 1);
  14696. }
  14697. if (!noPreventDefault) {
  14698. evt.preventDefault();
  14699. }
  14700. }
  14701. }
  14702. }
  14703. });
  14704. };
  14705. /**
  14706. * Detach the current controls from the specified dom element.
  14707. * @param element Defines the element to stop listening the inputs from
  14708. */
  14709. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14710. if (this._scene) {
  14711. if (this._onKeyboardObserver) {
  14712. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14713. }
  14714. if (this._onCanvasBlurObserver) {
  14715. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14716. }
  14717. this._onKeyboardObserver = null;
  14718. this._onCanvasBlurObserver = null;
  14719. }
  14720. this._keys = [];
  14721. };
  14722. /**
  14723. * Update the current camera state depending on the inputs that have been used this frame.
  14724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14725. */
  14726. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14727. if (this._onKeyboardObserver) {
  14728. var camera = this.camera;
  14729. // Keyboard
  14730. for (var index = 0; index < this._keys.length; index++) {
  14731. var keyCode = this._keys[index];
  14732. var speed = camera._computeLocalCameraSpeed();
  14733. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14734. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14735. }
  14736. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14737. camera._localDirection.copyFromFloats(0, 0, speed);
  14738. }
  14739. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14740. camera._localDirection.copyFromFloats(speed, 0, 0);
  14741. }
  14742. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14743. camera._localDirection.copyFromFloats(0, 0, -speed);
  14744. }
  14745. if (camera.getScene().useRightHandedSystem) {
  14746. camera._localDirection.z *= -1;
  14747. }
  14748. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14749. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14750. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14751. }
  14752. }
  14753. };
  14754. /**
  14755. * Gets the class name of the current intput.
  14756. * @returns the class name
  14757. */
  14758. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14759. return "FreeCameraKeyboardMoveInput";
  14760. };
  14761. /** @hidden */
  14762. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14763. this._keys = [];
  14764. };
  14765. /**
  14766. * Get the friendly name associated with the input class.
  14767. * @returns the input friendly name
  14768. */
  14769. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14770. return "keyboard";
  14771. };
  14772. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14773. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14774. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14775. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14776. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14777. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14778. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14779. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14780. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14781. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14782. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14783. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14784. return FreeCameraKeyboardMoveInput;
  14785. }());
  14786. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14787. /***/ }),
  14788. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14789. /*!************************************************!*\
  14790. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14791. \************************************************/
  14792. /*! exports provided: FreeCameraMouseInput */
  14793. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14794. "use strict";
  14795. __webpack_require__.r(__webpack_exports__);
  14796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14797. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14798. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  14799. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14800. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14801. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14802. /**
  14803. * Manage the mouse inputs to control the movement of a free camera.
  14804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14805. */
  14806. var FreeCameraMouseInput = /** @class */ (function () {
  14807. /**
  14808. * Manage the mouse inputs to control the movement of a free camera.
  14809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14810. * @param touchEnabled Defines if touch is enabled or not
  14811. */
  14812. function FreeCameraMouseInput(
  14813. /**
  14814. * Define if touch is enabled in the mouse input
  14815. */
  14816. touchEnabled) {
  14817. if (touchEnabled === void 0) { touchEnabled = true; }
  14818. this.touchEnabled = touchEnabled;
  14819. /**
  14820. * Defines the buttons associated with the input to handle camera move.
  14821. */
  14822. this.buttons = [0, 1, 2];
  14823. /**
  14824. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14825. */
  14826. this.angularSensibility = 2000.0;
  14827. this.previousPosition = null;
  14828. /**
  14829. * Observable for when a pointer move event occurs containing the move offset
  14830. */
  14831. this.onPointerMovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  14832. /**
  14833. * @hidden
  14834. * If the camera should be rotated automatically based on pointer movement
  14835. */
  14836. this._allowCameraRotation = true;
  14837. }
  14838. /**
  14839. * Attach the input controls to a specific dom element to get the input from.
  14840. * @param element Defines the element the controls should be listened from
  14841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14842. */
  14843. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14844. var _this = this;
  14845. var engine = this.camera.getEngine();
  14846. if (!this._pointerInput) {
  14847. this._pointerInput = function (p) {
  14848. var evt = p.event;
  14849. if (engine.isInVRExclusivePointerMode) {
  14850. return;
  14851. }
  14852. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14853. return;
  14854. }
  14855. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14856. return;
  14857. }
  14858. var srcElement = (evt.srcElement || evt.target);
  14859. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14860. try {
  14861. srcElement.setPointerCapture(evt.pointerId);
  14862. }
  14863. catch (e) {
  14864. //Nothing to do with the error. Execution will continue.
  14865. }
  14866. _this.previousPosition = {
  14867. x: evt.clientX,
  14868. y: evt.clientY
  14869. };
  14870. if (!noPreventDefault) {
  14871. evt.preventDefault();
  14872. element.focus();
  14873. }
  14874. }
  14875. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  14876. try {
  14877. srcElement.releasePointerCapture(evt.pointerId);
  14878. }
  14879. catch (e) {
  14880. //Nothing to do with the error.
  14881. }
  14882. _this.previousPosition = null;
  14883. if (!noPreventDefault) {
  14884. evt.preventDefault();
  14885. }
  14886. }
  14887. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  14888. if (!_this.previousPosition || engine.isPointerLock) {
  14889. return;
  14890. }
  14891. var offsetX = evt.clientX - _this.previousPosition.x;
  14892. var offsetY = evt.clientY - _this.previousPosition.y;
  14893. if (_this.camera.getScene().useRightHandedSystem) {
  14894. offsetX *= -1;
  14895. }
  14896. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14897. offsetX *= -1;
  14898. }
  14899. if (_this._allowCameraRotation) {
  14900. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14901. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14902. }
  14903. _this.onPointerMovedObservable.notifyObservers({ offsetX: offsetX, offsetY: offsetY });
  14904. _this.previousPosition = {
  14905. x: evt.clientX,
  14906. y: evt.clientY
  14907. };
  14908. if (!noPreventDefault) {
  14909. evt.preventDefault();
  14910. }
  14911. }
  14912. };
  14913. }
  14914. this._onMouseMove = function (evt) {
  14915. if (!engine.isPointerLock) {
  14916. return;
  14917. }
  14918. if (engine.isInVRExclusivePointerMode) {
  14919. return;
  14920. }
  14921. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14922. if (_this.camera.getScene().useRightHandedSystem) {
  14923. offsetX *= -1;
  14924. }
  14925. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14926. offsetX *= -1;
  14927. }
  14928. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14929. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14930. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14931. _this.previousPosition = null;
  14932. if (!noPreventDefault) {
  14933. evt.preventDefault();
  14934. }
  14935. };
  14936. 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);
  14937. element.addEventListener("mousemove", this._onMouseMove, false);
  14938. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  14939. };
  14940. /**
  14941. * Called on JS contextmenu event.
  14942. * Override this method to provide functionality.
  14943. */
  14944. FreeCameraMouseInput.prototype.onContextMenu = function (evt) {
  14945. evt.preventDefault();
  14946. };
  14947. /**
  14948. * Detach the current controls from the specified dom element.
  14949. * @param element Defines the element to stop listening the inputs from
  14950. */
  14951. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14952. if (this._observer && element) {
  14953. this.camera.getScene().onPointerObservable.remove(this._observer);
  14954. if (this._onMouseMove) {
  14955. element.removeEventListener("mousemove", this._onMouseMove);
  14956. }
  14957. if (this.onContextMenu) {
  14958. element.removeEventListener("contextmenu", this.onContextMenu);
  14959. }
  14960. if (this.onPointerMovedObservable) {
  14961. this.onPointerMovedObservable.clear();
  14962. }
  14963. this._observer = null;
  14964. this._onMouseMove = null;
  14965. this.previousPosition = null;
  14966. }
  14967. };
  14968. /**
  14969. * Gets the class name of the current intput.
  14970. * @returns the class name
  14971. */
  14972. FreeCameraMouseInput.prototype.getClassName = function () {
  14973. return "FreeCameraMouseInput";
  14974. };
  14975. /**
  14976. * Get the friendly name associated with the input class.
  14977. * @returns the input friendly name
  14978. */
  14979. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14980. return "mouse";
  14981. };
  14982. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14984. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14985. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14986. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14987. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14988. return FreeCameraMouseInput;
  14989. }());
  14990. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14991. /***/ }),
  14992. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14993. /*!************************************************!*\
  14994. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14995. \************************************************/
  14996. /*! exports provided: FreeCameraTouchInput */
  14997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14998. "use strict";
  14999. __webpack_require__.r(__webpack_exports__);
  15000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  15001. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15002. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  15003. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  15004. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  15005. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15006. /**
  15007. * Manage the touch inputs to control the movement of a free camera.
  15008. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  15009. */
  15010. var FreeCameraTouchInput = /** @class */ (function () {
  15011. function FreeCameraTouchInput() {
  15012. /**
  15013. * Defines the touch sensibility for rotation.
  15014. * The higher the faster.
  15015. */
  15016. this.touchAngularSensibility = 200000.0;
  15017. /**
  15018. * Defines the touch sensibility for move.
  15019. * The higher the faster.
  15020. */
  15021. this.touchMoveSensibility = 250.0;
  15022. this._offsetX = null;
  15023. this._offsetY = null;
  15024. this._pointerPressed = new Array();
  15025. }
  15026. /**
  15027. * Attach the input controls to a specific dom element to get the input from.
  15028. * @param element Defines the element the controls should be listened from
  15029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  15030. */
  15031. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  15032. var _this = this;
  15033. var previousPosition = null;
  15034. if (this._pointerInput === undefined) {
  15035. this._onLostFocus = function () {
  15036. _this._offsetX = null;
  15037. _this._offsetY = null;
  15038. };
  15039. this._pointerInput = function (p) {
  15040. var evt = p.event;
  15041. if (evt.pointerType === "mouse") {
  15042. return;
  15043. }
  15044. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  15045. if (!noPreventDefault) {
  15046. evt.preventDefault();
  15047. }
  15048. _this._pointerPressed.push(evt.pointerId);
  15049. if (_this._pointerPressed.length !== 1) {
  15050. return;
  15051. }
  15052. previousPosition = {
  15053. x: evt.clientX,
  15054. y: evt.clientY
  15055. };
  15056. }
  15057. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  15058. if (!noPreventDefault) {
  15059. evt.preventDefault();
  15060. }
  15061. var index = _this._pointerPressed.indexOf(evt.pointerId);
  15062. if (index === -1) {
  15063. return;
  15064. }
  15065. _this._pointerPressed.splice(index, 1);
  15066. if (index != 0) {
  15067. return;
  15068. }
  15069. previousPosition = null;
  15070. _this._offsetX = null;
  15071. _this._offsetY = null;
  15072. }
  15073. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  15074. if (!noPreventDefault) {
  15075. evt.preventDefault();
  15076. }
  15077. if (!previousPosition) {
  15078. return;
  15079. }
  15080. var index = _this._pointerPressed.indexOf(evt.pointerId);
  15081. if (index != 0) {
  15082. return;
  15083. }
  15084. _this._offsetX = evt.clientX - previousPosition.x;
  15085. _this._offsetY = -(evt.clientY - previousPosition.y);
  15086. }
  15087. };
  15088. }
  15089. 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);
  15090. if (this._onLostFocus) {
  15091. element.addEventListener("blur", this._onLostFocus);
  15092. }
  15093. };
  15094. /**
  15095. * Detach the current controls from the specified dom element.
  15096. * @param element Defines the element to stop listening the inputs from
  15097. */
  15098. FreeCameraTouchInput.prototype.detachControl = function (element) {
  15099. if (this._pointerInput && element) {
  15100. if (this._observer) {
  15101. this.camera.getScene().onPointerObservable.remove(this._observer);
  15102. this._observer = null;
  15103. }
  15104. if (this._onLostFocus) {
  15105. element.removeEventListener("blur", this._onLostFocus);
  15106. this._onLostFocus = null;
  15107. }
  15108. this._pointerPressed = [];
  15109. this._offsetX = null;
  15110. this._offsetY = null;
  15111. }
  15112. };
  15113. /**
  15114. * Update the current camera state depending on the inputs that have been used this frame.
  15115. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15116. */
  15117. FreeCameraTouchInput.prototype.checkInputs = function () {
  15118. if (this._offsetX && this._offsetY) {
  15119. var camera = this.camera;
  15120. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  15121. if (this._pointerPressed.length > 1) {
  15122. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  15123. }
  15124. else {
  15125. var speed = camera._computeLocalCameraSpeed();
  15126. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  15127. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  15128. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  15129. }
  15130. }
  15131. };
  15132. /**
  15133. * Gets the class name of the current intput.
  15134. * @returns the class name
  15135. */
  15136. FreeCameraTouchInput.prototype.getClassName = function () {
  15137. return "FreeCameraTouchInput";
  15138. };
  15139. /**
  15140. * Get the friendly name associated with the input class.
  15141. * @returns the input friendly name
  15142. */
  15143. FreeCameraTouchInput.prototype.getSimpleName = function () {
  15144. return "touch";
  15145. };
  15146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15148. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  15149. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15151. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  15152. return FreeCameraTouchInput;
  15153. }());
  15154. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  15155. /***/ }),
  15156. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  15157. /*!**********************************************************!*\
  15158. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  15159. \**********************************************************/
  15160. /*! exports provided: FreeCameraVirtualJoystickInput */
  15161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15162. "use strict";
  15163. __webpack_require__.r(__webpack_exports__);
  15164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  15165. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  15166. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  15167. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15168. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  15169. /**
  15170. * Add virtual joystick input support to the input manager.
  15171. * @returns the current input manager
  15172. */
  15173. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  15174. this.add(new FreeCameraVirtualJoystickInput());
  15175. return this;
  15176. };
  15177. /**
  15178. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  15179. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  15180. */
  15181. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  15182. function FreeCameraVirtualJoystickInput() {
  15183. }
  15184. /**
  15185. * Gets the left stick of the virtual joystick.
  15186. * @returns The virtual Joystick
  15187. */
  15188. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  15189. return this._leftjoystick;
  15190. };
  15191. /**
  15192. * Gets the right stick of the virtual joystick.
  15193. * @returns The virtual Joystick
  15194. */
  15195. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  15196. return this._rightjoystick;
  15197. };
  15198. /**
  15199. * Update the current camera state depending on the inputs that have been used this frame.
  15200. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15201. */
  15202. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  15203. if (this._leftjoystick) {
  15204. var camera = this.camera;
  15205. var speed = camera._computeLocalCameraSpeed() * 50;
  15206. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  15207. 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);
  15208. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  15209. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  15210. if (!this._leftjoystick.pressed) {
  15211. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  15212. }
  15213. if (!this._rightjoystick.pressed) {
  15214. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  15215. }
  15216. }
  15217. };
  15218. /**
  15219. * Attach the input controls to a specific dom element to get the input from.
  15220. * @param element Defines the element the controls should be listened from
  15221. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  15222. */
  15223. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  15224. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  15225. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  15226. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15227. this._leftjoystick.setJoystickSensibility(0.15);
  15228. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  15229. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15230. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  15231. this._rightjoystick.reverseUpDown = true;
  15232. this._rightjoystick.setJoystickSensibility(0.05);
  15233. this._rightjoystick.setJoystickColor("yellow");
  15234. };
  15235. /**
  15236. * Detach the current controls from the specified dom element.
  15237. * @param element Defines the element to stop listening the inputs from
  15238. */
  15239. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  15240. this._leftjoystick.releaseCanvas();
  15241. this._rightjoystick.releaseCanvas();
  15242. };
  15243. /**
  15244. * Gets the class name of the current intput.
  15245. * @returns the class name
  15246. */
  15247. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  15248. return "FreeCameraVirtualJoystickInput";
  15249. };
  15250. /**
  15251. * Get the friendly name associated with the input class.
  15252. * @returns the input friendly name
  15253. */
  15254. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  15255. return "virtualJoystick";
  15256. };
  15257. return FreeCameraVirtualJoystickInput;
  15258. }());
  15259. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  15260. /***/ }),
  15261. /***/ "./Cameras/Inputs/index.ts":
  15262. /*!*********************************!*\
  15263. !*** ./Cameras/Inputs/index.ts ***!
  15264. \*********************************/
  15265. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  15266. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15267. "use strict";
  15268. __webpack_require__.r(__webpack_exports__);
  15269. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  15270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  15271. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  15272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  15273. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  15274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  15275. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  15276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  15277. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  15279. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  15280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  15281. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  15282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  15283. /* harmony import */ var _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  15284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  15285. /* harmony import */ var _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  15286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__["FollowCameraMouseWheelInput"]; });
  15287. /* harmony import */ var _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  15288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__["FollowCameraPointersInput"]; });
  15289. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  15290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraDeviceOrientationInput"]; });
  15291. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  15292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraGamepadInput"]; });
  15293. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  15294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraKeyboardMoveInput"]; });
  15295. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  15296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__["FreeCameraMouseInput"]; });
  15297. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  15298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__["FreeCameraTouchInput"]; });
  15299. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  15300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__["FreeCameraVirtualJoystickInput"]; });
  15301. /***/ }),
  15302. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  15303. /*!*********************************************************!*\
  15304. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  15305. \*********************************************************/
  15306. /*! no exports provided */
  15307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15308. "use strict";
  15309. __webpack_require__.r(__webpack_exports__);
  15310. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15311. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15312. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  15313. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  15314. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15315. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  15316. };
  15317. /***/ }),
  15318. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  15319. /*!*************************************************!*\
  15320. !*** ./Cameras/RigModes/stereoscopicRigMode.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 _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15328. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  15329. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  15330. 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;
  15331. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15332. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  15333. };
  15334. /***/ }),
  15335. /***/ "./Cameras/RigModes/vrRigMode.ts":
  15336. /*!***************************************!*\
  15337. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  15338. \***************************************/
  15339. /*! no exports provided */
  15340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15341. "use strict";
  15342. __webpack_require__.r(__webpack_exports__);
  15343. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15344. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15345. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  15346. /* harmony import */ var _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../PostProcesses/vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  15347. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15348. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15349. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  15350. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_4__["VRCameraMetrics"].GetDefault();
  15351. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  15352. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15353. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15354. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  15355. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  15356. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  15357. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  15358. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15359. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15360. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  15361. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  15362. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  15363. // For multiview on a webVR camera
  15364. // First multiview will be rendered to camera._multiviewTexture
  15365. // Then this postprocess will run on each eye to copy the right texture to each eye
  15366. if (metrics.multiviewEnabled) {
  15367. if (!camera.getScene().getEngine().getCaps().multiview) {
  15368. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("Multiview is not supported, falling back to standard rendering");
  15369. metrics.multiviewEnabled = false;
  15370. }
  15371. else {
  15372. camera._useMultiviewToSingleView = true;
  15373. camera._rigPostProcess = new _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_3__["VRMultiviewToSingleviewPostProcess"]("VRMultiviewToSingleview", camera, metrics.postProcessScaleFactor);
  15374. }
  15375. }
  15376. if (metrics.compensateDistortion) {
  15377. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  15378. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  15379. }
  15380. };
  15381. /***/ }),
  15382. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  15383. /*!******************************************!*\
  15384. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  15385. \******************************************/
  15386. /*! no exports provided */
  15387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15388. "use strict";
  15389. __webpack_require__.r(__webpack_exports__);
  15390. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15391. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15392. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  15393. if (rigParams.vrDisplay) {
  15394. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  15395. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  15396. //Left eye
  15397. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15398. camera._rigCameras[0].setCameraRigParameter("left", true);
  15399. //leaving this for future reference
  15400. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  15401. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  15402. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  15403. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15404. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15405. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15406. camera._rigCameras[0].parent = camera;
  15407. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  15408. //Right eye
  15409. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15410. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  15411. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  15412. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  15413. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15414. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15415. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15416. camera._rigCameras[1].parent = camera;
  15417. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  15418. }
  15419. };
  15420. /***/ }),
  15421. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  15422. /*!*********************************************************!*\
  15423. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  15424. \*********************************************************/
  15425. /*! exports provided: AnaglyphArcRotateCamera */
  15426. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15427. "use strict";
  15428. __webpack_require__.r(__webpack_exports__);
  15429. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  15430. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15431. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15432. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15433. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15434. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15435. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15436. // Side effect import to define the stereoscopic mode.
  15437. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  15438. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15439. });
  15440. /**
  15441. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  15442. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15443. */
  15444. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  15445. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  15446. /**
  15447. * Creates a new AnaglyphArcRotateCamera
  15448. * @param name defines camera name
  15449. * @param alpha defines alpha angle (in radians)
  15450. * @param beta defines beta angle (in radians)
  15451. * @param radius defines radius
  15452. * @param target defines camera target
  15453. * @param interaxialDistance defines distance between each color axis
  15454. * @param scene defines the hosting scene
  15455. */
  15456. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  15457. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15458. _this.interaxialDistance = interaxialDistance;
  15459. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15460. return _this;
  15461. }
  15462. /**
  15463. * Gets camera class name
  15464. * @returns AnaglyphArcRotateCamera
  15465. */
  15466. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  15467. return "AnaglyphArcRotateCamera";
  15468. };
  15469. return AnaglyphArcRotateCamera;
  15470. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15471. /***/ }),
  15472. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  15473. /*!****************************************************!*\
  15474. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  15475. \****************************************************/
  15476. /*! exports provided: AnaglyphFreeCamera */
  15477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15478. "use strict";
  15479. __webpack_require__.r(__webpack_exports__);
  15480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  15481. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15482. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15483. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15484. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15485. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15486. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15487. // Side effect import to define the stereoscopic mode.
  15488. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  15489. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15490. });
  15491. /**
  15492. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  15493. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15494. */
  15495. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  15496. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  15497. /**
  15498. * Creates a new AnaglyphFreeCamera
  15499. * @param name defines camera name
  15500. * @param position defines initial position
  15501. * @param interaxialDistance defines distance between each color axis
  15502. * @param scene defines the hosting scene
  15503. */
  15504. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  15505. var _this = _super.call(this, name, position, scene) || this;
  15506. _this.interaxialDistance = interaxialDistance;
  15507. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15508. return _this;
  15509. }
  15510. /**
  15511. * Gets camera class name
  15512. * @returns AnaglyphFreeCamera
  15513. */
  15514. AnaglyphFreeCamera.prototype.getClassName = function () {
  15515. return "AnaglyphFreeCamera";
  15516. };
  15517. return AnaglyphFreeCamera;
  15518. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15519. /***/ }),
  15520. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  15521. /*!*******************************************************!*\
  15522. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  15523. \*******************************************************/
  15524. /*! exports provided: AnaglyphGamepadCamera */
  15525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15526. "use strict";
  15527. __webpack_require__.r(__webpack_exports__);
  15528. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  15529. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15530. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15531. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15532. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15533. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15534. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15535. // Side effect import to define the stereoscopic mode.
  15536. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  15537. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15538. });
  15539. /**
  15540. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  15541. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15542. */
  15543. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  15544. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  15545. /**
  15546. * Creates a new AnaglyphGamepadCamera
  15547. * @param name defines camera name
  15548. * @param position defines initial position
  15549. * @param interaxialDistance defines distance between each color axis
  15550. * @param scene defines the hosting scene
  15551. */
  15552. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  15553. var _this = _super.call(this, name, position, scene) || this;
  15554. _this.interaxialDistance = interaxialDistance;
  15555. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15556. return _this;
  15557. }
  15558. /**
  15559. * Gets camera class name
  15560. * @returns AnaglyphGamepadCamera
  15561. */
  15562. AnaglyphGamepadCamera.prototype.getClassName = function () {
  15563. return "AnaglyphGamepadCamera";
  15564. };
  15565. return AnaglyphGamepadCamera;
  15566. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15567. /***/ }),
  15568. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  15569. /*!*********************************************************!*\
  15570. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  15571. \*********************************************************/
  15572. /*! exports provided: AnaglyphUniversalCamera */
  15573. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15574. "use strict";
  15575. __webpack_require__.r(__webpack_exports__);
  15576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15577. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15578. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15579. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15580. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15581. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15582. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15583. // Side effect import to define the stereoscopic mode.
  15584. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15585. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15586. });
  15587. /**
  15588. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15589. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15590. */
  15591. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15592. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15593. /**
  15594. * Creates a new AnaglyphUniversalCamera
  15595. * @param name defines camera name
  15596. * @param position defines initial position
  15597. * @param interaxialDistance defines distance between each color axis
  15598. * @param scene defines the hosting scene
  15599. */
  15600. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15601. var _this = _super.call(this, name, position, scene) || this;
  15602. _this.interaxialDistance = interaxialDistance;
  15603. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15604. return _this;
  15605. }
  15606. /**
  15607. * Gets camera class name
  15608. * @returns AnaglyphUniversalCamera
  15609. */
  15610. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15611. return "AnaglyphUniversalCamera";
  15612. };
  15613. return AnaglyphUniversalCamera;
  15614. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15615. /***/ }),
  15616. /***/ "./Cameras/Stereoscopic/index.ts":
  15617. /*!***************************************!*\
  15618. !*** ./Cameras/Stereoscopic/index.ts ***!
  15619. \***************************************/
  15620. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15621. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15622. "use strict";
  15623. __webpack_require__.r(__webpack_exports__);
  15624. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15626. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15628. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15630. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15632. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15634. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15636. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15638. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15640. /***/ }),
  15641. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15642. /*!*************************************************************!*\
  15643. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15644. \*************************************************************/
  15645. /*! exports provided: StereoscopicArcRotateCamera */
  15646. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15647. "use strict";
  15648. __webpack_require__.r(__webpack_exports__);
  15649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15650. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15651. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15652. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15653. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15654. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15655. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15656. // Side effect import to define the stereoscopic mode.
  15657. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15658. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15659. });
  15660. /**
  15661. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15662. * @see http://doc.babylonjs.com/features/cameras
  15663. */
  15664. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15665. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15666. /**
  15667. * Creates a new StereoscopicArcRotateCamera
  15668. * @param name defines camera name
  15669. * @param alpha defines alpha angle (in radians)
  15670. * @param beta defines beta angle (in radians)
  15671. * @param radius defines radius
  15672. * @param target defines camera target
  15673. * @param interaxialDistance defines distance between each color axis
  15674. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15675. * @param scene defines the hosting scene
  15676. */
  15677. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15678. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15679. _this.interaxialDistance = interaxialDistance;
  15680. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15681. _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 });
  15682. return _this;
  15683. }
  15684. /**
  15685. * Gets camera class name
  15686. * @returns StereoscopicArcRotateCamera
  15687. */
  15688. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15689. return "StereoscopicArcRotateCamera";
  15690. };
  15691. return StereoscopicArcRotateCamera;
  15692. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15693. /***/ }),
  15694. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15695. /*!********************************************************!*\
  15696. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15697. \********************************************************/
  15698. /*! exports provided: StereoscopicFreeCamera */
  15699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15700. "use strict";
  15701. __webpack_require__.r(__webpack_exports__);
  15702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15703. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15704. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15705. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15706. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15707. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15708. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15709. // Side effect import to define the stereoscopic mode.
  15710. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15711. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15712. });
  15713. /**
  15714. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15715. * @see http://doc.babylonjs.com/features/cameras
  15716. */
  15717. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15718. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15719. /**
  15720. * Creates a new StereoscopicFreeCamera
  15721. * @param name defines camera name
  15722. * @param position defines initial position
  15723. * @param interaxialDistance defines distance between each color axis
  15724. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15725. * @param scene defines the hosting scene
  15726. */
  15727. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15728. var _this = _super.call(this, name, position, scene) || this;
  15729. _this.interaxialDistance = interaxialDistance;
  15730. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15731. _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 });
  15732. return _this;
  15733. }
  15734. /**
  15735. * Gets camera class name
  15736. * @returns StereoscopicFreeCamera
  15737. */
  15738. StereoscopicFreeCamera.prototype.getClassName = function () {
  15739. return "StereoscopicFreeCamera";
  15740. };
  15741. return StereoscopicFreeCamera;
  15742. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15743. /***/ }),
  15744. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15745. /*!***********************************************************!*\
  15746. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15747. \***********************************************************/
  15748. /*! exports provided: StereoscopicGamepadCamera */
  15749. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15750. "use strict";
  15751. __webpack_require__.r(__webpack_exports__);
  15752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15753. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15754. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15755. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15756. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15757. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15758. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15759. // Side effect import to define the stereoscopic mode.
  15760. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15761. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15762. });
  15763. /**
  15764. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15765. * @see http://doc.babylonjs.com/features/cameras
  15766. */
  15767. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15768. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15769. /**
  15770. * Creates a new StereoscopicGamepadCamera
  15771. * @param name defines camera name
  15772. * @param position defines initial position
  15773. * @param interaxialDistance defines distance between each color axis
  15774. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15775. * @param scene defines the hosting scene
  15776. */
  15777. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15778. var _this = _super.call(this, name, position, scene) || this;
  15779. _this.interaxialDistance = interaxialDistance;
  15780. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15781. _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 });
  15782. return _this;
  15783. }
  15784. /**
  15785. * Gets camera class name
  15786. * @returns StereoscopicGamepadCamera
  15787. */
  15788. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15789. return "StereoscopicGamepadCamera";
  15790. };
  15791. return StereoscopicGamepadCamera;
  15792. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15793. /***/ }),
  15794. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15795. /*!*************************************************************!*\
  15796. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15797. \*************************************************************/
  15798. /*! exports provided: StereoscopicUniversalCamera */
  15799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15800. "use strict";
  15801. __webpack_require__.r(__webpack_exports__);
  15802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15803. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15804. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15805. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15806. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15807. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15808. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15809. // Side effect import to define the stereoscopic mode.
  15810. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15811. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15812. });
  15813. /**
  15814. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15815. * @see http://doc.babylonjs.com/features/cameras
  15816. */
  15817. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15818. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15819. /**
  15820. * Creates a new StereoscopicUniversalCamera
  15821. * @param name defines camera name
  15822. * @param position defines initial position
  15823. * @param interaxialDistance defines distance between each color axis
  15824. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15825. * @param scene defines the hosting scene
  15826. */
  15827. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15828. var _this = _super.call(this, name, position, scene) || this;
  15829. _this.interaxialDistance = interaxialDistance;
  15830. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15831. _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 });
  15832. return _this;
  15833. }
  15834. /**
  15835. * Gets camera class name
  15836. * @returns StereoscopicUniversalCamera
  15837. */
  15838. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15839. return "StereoscopicUniversalCamera";
  15840. };
  15841. return StereoscopicUniversalCamera;
  15842. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15843. /***/ }),
  15844. /***/ "./Cameras/VR/index.ts":
  15845. /*!*****************************!*\
  15846. !*** ./Cameras/VR/index.ts ***!
  15847. \*****************************/
  15848. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera */
  15849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15850. "use strict";
  15851. __webpack_require__.r(__webpack_exports__);
  15852. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15854. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15856. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15858. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15860. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["OnAfterEnteringVRObservableEvent"]; });
  15862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15863. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15865. /***/ }),
  15866. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15867. /*!***************************************!*\
  15868. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15869. \***************************************/
  15870. /*! exports provided: VRCameraMetrics */
  15871. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15872. "use strict";
  15873. __webpack_require__.r(__webpack_exports__);
  15874. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15875. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15876. /**
  15877. * This represents all the required metrics to create a VR camera.
  15878. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15879. */
  15880. var VRCameraMetrics = /** @class */ (function () {
  15881. function VRCameraMetrics() {
  15882. /**
  15883. * Define if the current vr camera should compensate the distortion of the lense or not.
  15884. */
  15885. this.compensateDistortion = true;
  15886. /**
  15887. * Defines if multiview should be enabled when rendering (Default: false)
  15888. */
  15889. this.multiviewEnabled = false;
  15890. }
  15891. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15892. /**
  15893. * Gets the rendering aspect ratio based on the provided resolutions.
  15894. */
  15895. get: function () {
  15896. return this.hResolution / (2 * this.vResolution);
  15897. },
  15898. enumerable: true,
  15899. configurable: true
  15900. });
  15901. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15902. /**
  15903. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15904. */
  15905. get: function () {
  15906. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15907. },
  15908. enumerable: true,
  15909. configurable: true
  15910. });
  15911. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15912. /**
  15913. * @hidden
  15914. */
  15915. get: function () {
  15916. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15917. var h = (4 * meters) / this.hScreenSize;
  15918. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15919. },
  15920. enumerable: true,
  15921. configurable: true
  15922. });
  15923. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15924. /**
  15925. * @hidden
  15926. */
  15927. get: function () {
  15928. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15929. var h = (4 * meters) / this.hScreenSize;
  15930. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15931. },
  15932. enumerable: true,
  15933. configurable: true
  15934. });
  15935. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15936. /**
  15937. * @hidden
  15938. */
  15939. get: function () {
  15940. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15941. },
  15942. enumerable: true,
  15943. configurable: true
  15944. });
  15945. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15946. /**
  15947. * @hidden
  15948. */
  15949. get: function () {
  15950. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15951. },
  15952. enumerable: true,
  15953. configurable: true
  15954. });
  15955. /**
  15956. * Get the default VRMetrics based on the most generic setup.
  15957. * @returns the default vr metrics
  15958. */
  15959. VRCameraMetrics.GetDefault = function () {
  15960. var result = new VRCameraMetrics();
  15961. result.hResolution = 1280;
  15962. result.vResolution = 800;
  15963. result.hScreenSize = 0.149759993;
  15964. result.vScreenSize = 0.0935999975;
  15965. result.vScreenCenter = 0.0467999987;
  15966. result.eyeToScreenDistance = 0.0410000011;
  15967. result.lensSeparationDistance = 0.0635000020;
  15968. result.interpupillaryDistance = 0.0640000030;
  15969. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15970. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15971. result.postProcessScaleFactor = 1.714605507808412;
  15972. result.lensCenterOffset = 0.151976421;
  15973. return result;
  15974. };
  15975. return VRCameraMetrics;
  15976. }());
  15977. /***/ }),
  15978. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15979. /*!**********************************************************!*\
  15980. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15981. \**********************************************************/
  15982. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15983. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15984. "use strict";
  15985. __webpack_require__.r(__webpack_exports__);
  15986. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15987. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15988. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15989. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15990. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15991. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15992. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15993. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15994. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15995. // Side effect import to define the stereoscopic mode.
  15996. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15997. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15998. });
  15999. /**
  16000. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  16001. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  16002. */
  16003. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  16004. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  16005. /**
  16006. * Creates a new VRDeviceOrientationArcRotateCamera
  16007. * @param name defines camera name
  16008. * @param alpha defines the camera rotation along the logitudinal axis
  16009. * @param beta defines the camera rotation along the latitudinal axis
  16010. * @param radius defines the camera distance from its target
  16011. * @param target defines the camera target
  16012. * @param scene defines the scene the camera belongs to
  16013. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  16014. * @param vrCameraMetrics defines the vr metrics associated to the camera
  16015. */
  16016. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  16017. if (compensateDistortion === void 0) { compensateDistortion = true; }
  16018. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  16019. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  16020. vrCameraMetrics.compensateDistortion = compensateDistortion;
  16021. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  16022. _this.inputs.addVRDeviceOrientation();
  16023. return _this;
  16024. }
  16025. /**
  16026. * Gets camera class name
  16027. * @returns VRDeviceOrientationArcRotateCamera
  16028. */
  16029. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  16030. return "VRDeviceOrientationArcRotateCamera";
  16031. };
  16032. return VRDeviceOrientationArcRotateCamera;
  16033. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  16034. /***/ }),
  16035. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  16036. /*!*****************************************************!*\
  16037. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  16038. \*****************************************************/
  16039. /*! exports provided: VRDeviceOrientationFreeCamera */
  16040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16041. "use strict";
  16042. __webpack_require__.r(__webpack_exports__);
  16043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  16044. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16045. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  16046. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  16047. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16048. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  16049. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  16050. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  16051. // Side effect import to define the stereoscopic mode.
  16052. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  16053. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  16054. });
  16055. /**
  16056. * Camera used to simulate VR rendering (based on FreeCamera)
  16057. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  16058. */
  16059. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  16060. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  16061. /**
  16062. * Creates a new VRDeviceOrientationFreeCamera
  16063. * @param name defines camera name
  16064. * @param position defines the start position of the camera
  16065. * @param scene defines the scene the camera belongs to
  16066. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  16067. * @param vrCameraMetrics defines the vr metrics associated to the camera
  16068. */
  16069. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  16070. if (compensateDistortion === void 0) { compensateDistortion = true; }
  16071. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  16072. var _this = _super.call(this, name, position, scene) || this;
  16073. vrCameraMetrics.compensateDistortion = compensateDistortion;
  16074. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  16075. return _this;
  16076. }
  16077. /**
  16078. * Gets camera class name
  16079. * @returns VRDeviceOrientationFreeCamera
  16080. */
  16081. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  16082. return "VRDeviceOrientationFreeCamera";
  16083. };
  16084. return VRDeviceOrientationFreeCamera;
  16085. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  16086. /***/ }),
  16087. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  16088. /*!********************************************************!*\
  16089. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  16090. \********************************************************/
  16091. /*! exports provided: VRDeviceOrientationGamepadCamera */
  16092. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16093. "use strict";
  16094. __webpack_require__.r(__webpack_exports__);
  16095. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  16096. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16097. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  16098. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16099. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  16100. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  16101. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  16102. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  16103. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  16104. });
  16105. /**
  16106. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  16107. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  16108. */
  16109. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  16110. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  16111. /**
  16112. * Creates a new VRDeviceOrientationGamepadCamera
  16113. * @param name defines camera name
  16114. * @param position defines the start position of the camera
  16115. * @param scene defines the scene the camera belongs to
  16116. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  16117. * @param vrCameraMetrics defines the vr metrics associated to the camera
  16118. */
  16119. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  16120. if (compensateDistortion === void 0) { compensateDistortion = true; }
  16121. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  16122. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  16123. _this.inputs.addGamepad();
  16124. return _this;
  16125. }
  16126. /**
  16127. * Gets camera class name
  16128. * @returns VRDeviceOrientationGamepadCamera
  16129. */
  16130. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  16131. return "VRDeviceOrientationGamepadCamera";
  16132. };
  16133. return VRDeviceOrientationGamepadCamera;
  16134. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  16135. /***/ }),
  16136. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  16137. /*!******************************************!*\
  16138. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  16139. \******************************************/
  16140. /*! exports provided: OnAfterEnteringVRObservableEvent, VRExperienceHelper */
  16141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16142. "use strict";
  16143. __webpack_require__.r(__webpack_exports__);
  16144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return OnAfterEnteringVRObservableEvent; });
  16145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  16146. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16147. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  16148. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  16149. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  16150. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  16151. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  16152. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  16153. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  16154. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  16155. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  16156. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  16157. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  16158. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  16159. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  16160. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  16161. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  16162. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  16163. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  16164. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  16165. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  16166. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  16167. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  16168. /* harmony import */ var _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Cameras/VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16169. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  16170. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  16171. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  16172. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  16173. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  16174. var VRExperienceHelperGazer = /** @class */ (function () {
  16175. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  16176. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  16177. this.scene = scene;
  16178. /** @hidden */
  16179. this._pointerDownOnMeshAsked = false;
  16180. /** @hidden */
  16181. this._isActionableMesh = false;
  16182. /** @hidden */
  16183. this._teleportationRequestInitiated = false;
  16184. /** @hidden */
  16185. this._teleportationBackRequestInitiated = false;
  16186. /** @hidden */
  16187. this._rotationRightAsked = false;
  16188. /** @hidden */
  16189. this._rotationLeftAsked = false;
  16190. /** @hidden */
  16191. this._dpadPressed = true;
  16192. /** @hidden */
  16193. this._activePointer = false;
  16194. this._id = VRExperienceHelperGazer._idCounter++;
  16195. // Gaze tracker
  16196. if (!gazeTrackerToClone) {
  16197. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  16198. this._gazeTracker.bakeCurrentTransformIntoVertices();
  16199. this._gazeTracker.isPickable = false;
  16200. this._gazeTracker.isVisible = false;
  16201. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  16202. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  16203. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16204. targetMat.backFaceCulling = false;
  16205. this._gazeTracker.material = targetMat;
  16206. }
  16207. else {
  16208. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  16209. }
  16210. }
  16211. /** @hidden */
  16212. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  16213. 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));
  16214. };
  16215. /** @hidden */
  16216. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  16217. this._pointerDownOnMeshAsked = true;
  16218. if (this._currentHit) {
  16219. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  16220. }
  16221. };
  16222. /** @hidden */
  16223. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  16224. if (this._currentHit) {
  16225. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  16226. }
  16227. this._pointerDownOnMeshAsked = false;
  16228. };
  16229. /** @hidden */
  16230. VRExperienceHelperGazer.prototype._activatePointer = function () {
  16231. this._activePointer = true;
  16232. };
  16233. /** @hidden */
  16234. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  16235. this._activePointer = false;
  16236. };
  16237. /** @hidden */
  16238. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  16239. if (distance === void 0) { distance = 100; }
  16240. };
  16241. VRExperienceHelperGazer.prototype.dispose = function () {
  16242. this._interactionsEnabled = false;
  16243. this._teleportationEnabled = false;
  16244. if (this._gazeTracker) {
  16245. this._gazeTracker.dispose();
  16246. }
  16247. };
  16248. VRExperienceHelperGazer._idCounter = 0;
  16249. return VRExperienceHelperGazer;
  16250. }());
  16251. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  16252. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  16253. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  16254. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  16255. _this.webVRController = webVRController;
  16256. // Laser pointer
  16257. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  16258. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  16259. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16260. laserPointerMaterial.alpha = 0.6;
  16261. _this._laserPointer.material = laserPointerMaterial;
  16262. _this._laserPointer.rotation.x = Math.PI / 2;
  16263. _this._laserPointer.position.z = -0.5;
  16264. _this._laserPointer.isVisible = false;
  16265. _this._laserPointer.isPickable = false;
  16266. if (!webVRController.mesh) {
  16267. // Create an empty mesh that is used prior to loading the high quality model
  16268. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  16269. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  16270. preloadPointerPose.rotation.x = -0.7;
  16271. preloadMesh.addChild(preloadPointerPose);
  16272. webVRController.attachToMesh(preloadMesh);
  16273. }
  16274. _this._setLaserPointerParent(webVRController.mesh);
  16275. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  16276. _this._setLaserPointerParent(mesh);
  16277. });
  16278. return _this;
  16279. }
  16280. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  16281. return this.webVRController.getForwardRay(length);
  16282. };
  16283. /** @hidden */
  16284. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  16285. _super.prototype._activatePointer.call(this);
  16286. this._laserPointer.isVisible = true;
  16287. };
  16288. /** @hidden */
  16289. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  16290. _super.prototype._deactivatePointer.call(this);
  16291. this._laserPointer.isVisible = false;
  16292. };
  16293. /** @hidden */
  16294. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  16295. this._laserPointer.material.emissiveColor = color;
  16296. };
  16297. /** @hidden */
  16298. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  16299. var makeNotPick = function (root) {
  16300. root.isPickable = false;
  16301. root.getChildMeshes().forEach(function (c) {
  16302. makeNotPick(c);
  16303. });
  16304. };
  16305. makeNotPick(mesh);
  16306. var meshChildren = mesh.getChildren(undefined, false);
  16307. var laserParent = mesh;
  16308. this.webVRController._pointingPoseNode = null;
  16309. for (var i = 0; i < meshChildren.length; i++) {
  16310. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  16311. laserParent = meshChildren[i];
  16312. this.webVRController._pointingPoseNode = laserParent;
  16313. break;
  16314. }
  16315. }
  16316. this._laserPointer.parent = laserParent;
  16317. };
  16318. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  16319. if (distance === void 0) { distance = 100; }
  16320. this._laserPointer.scaling.y = distance;
  16321. this._laserPointer.position.z = -distance / 2;
  16322. };
  16323. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  16324. _super.prototype.dispose.call(this);
  16325. this._laserPointer.dispose();
  16326. if (this._meshAttachedObserver) {
  16327. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  16328. }
  16329. };
  16330. return VRExperienceHelperControllerGazer;
  16331. }(VRExperienceHelperGazer));
  16332. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  16333. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  16334. function VRExperienceHelperCameraGazer(getCamera, scene) {
  16335. var _this = _super.call(this, scene) || this;
  16336. _this.getCamera = getCamera;
  16337. return _this;
  16338. }
  16339. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  16340. var camera = this.getCamera();
  16341. if (camera) {
  16342. return camera.getForwardRay(length);
  16343. }
  16344. else {
  16345. 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());
  16346. }
  16347. };
  16348. return VRExperienceHelperCameraGazer;
  16349. }(VRExperienceHelperGazer));
  16350. /**
  16351. * Event containing information after VR has been entered
  16352. */
  16353. var OnAfterEnteringVRObservableEvent = /** @class */ (function () {
  16354. function OnAfterEnteringVRObservableEvent() {
  16355. }
  16356. return OnAfterEnteringVRObservableEvent;
  16357. }());
  16358. /**
  16359. * Helps to quickly add VR support to an existing scene.
  16360. * See http://doc.babylonjs.com/how_to/webvr_helper
  16361. */
  16362. var VRExperienceHelper = /** @class */ (function () {
  16363. /**
  16364. * Instantiates a VRExperienceHelper.
  16365. * Helps to quickly add VR support to an existing scene.
  16366. * @param scene The scene the VRExperienceHelper belongs to.
  16367. * @param webVROptions Options to modify the vr experience helper's behavior.
  16368. */
  16369. function VRExperienceHelper(scene,
  16370. /** Options to modify the vr experience helper's behavior. */
  16371. webVROptions) {
  16372. var _this = this;
  16373. if (webVROptions === void 0) { webVROptions = {}; }
  16374. this.webVROptions = webVROptions;
  16375. // Can the system support WebVR, even if a headset isn't plugged in?
  16376. this._webVRsupported = false;
  16377. // If WebVR is supported, is a headset plugged in and are we ready to present?
  16378. this._webVRready = false;
  16379. // Are we waiting for the requestPresent callback to complete?
  16380. this._webVRrequesting = false;
  16381. // Are we presenting to the headset right now? (this is the vrDevice state)
  16382. this._webVRpresenting = false;
  16383. // Are we presenting in the fullscreen fallback?
  16384. this._fullscreenVRpresenting = false;
  16385. /**
  16386. * Observable raised right before entering VR.
  16387. */
  16388. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16389. /**
  16390. * Observable raised when entering VR has completed.
  16391. */
  16392. this.onAfterEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16393. /**
  16394. * Observable raised when exiting VR.
  16395. */
  16396. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16397. /**
  16398. * Observable raised when controller mesh is loaded.
  16399. */
  16400. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16401. this._useCustomVRButton = false;
  16402. this._teleportationRequested = false;
  16403. this._teleportActive = false;
  16404. this._floorMeshesCollection = [];
  16405. this._rotationAllowed = true;
  16406. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  16407. this._isDefaultTeleportationTarget = true;
  16408. this._teleportationFillColor = "#444444";
  16409. this._teleportationBorderColor = "#FFFFFF";
  16410. this._rotationAngle = 0;
  16411. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  16412. this._padSensibilityUp = 0.65;
  16413. this._padSensibilityDown = 0.35;
  16414. this._leftController = null;
  16415. this._rightController = null;
  16416. /**
  16417. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  16418. */
  16419. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16420. /**
  16421. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  16422. */
  16423. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16424. /**
  16425. * Observable raised before camera teleportation
  16426. */
  16427. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16428. /**
  16429. * Observable raised after camera teleportation
  16430. */
  16431. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16432. /**
  16433. * Observable raised when current selected mesh gets unselected
  16434. */
  16435. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16436. /**
  16437. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  16438. */
  16439. this.teleportationEnabled = true;
  16440. this._teleportationInitialized = false;
  16441. this._interactionsEnabled = false;
  16442. this._interactionsRequested = false;
  16443. this._displayGaze = true;
  16444. this._displayLaserPointer = true;
  16445. /**
  16446. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  16447. */
  16448. this.updateGazeTrackerScale = true;
  16449. /**
  16450. * If the gaze trackers color should be updated when selecting meshes
  16451. */
  16452. this.updateGazeTrackerColor = true;
  16453. /**
  16454. * Defines wether or not Pointer lock should be requested when switching to
  16455. * full screen.
  16456. */
  16457. this.requestPointerLockOnFullScreen = true;
  16458. this._onResize = function () {
  16459. _this.moveButtonToBottomRight();
  16460. if (_this._fullscreenVRpresenting && _this._webVRready) {
  16461. _this.exitVR();
  16462. }
  16463. };
  16464. this._onFullscreenChange = function () {
  16465. var anyDoc = document;
  16466. if (anyDoc.fullscreen !== undefined) {
  16467. _this._fullscreenVRpresenting = document.fullscreen;
  16468. }
  16469. else if (anyDoc.mozFullScreen !== undefined) {
  16470. _this._fullscreenVRpresenting = anyDoc.mozFullScreen;
  16471. }
  16472. else if (anyDoc.webkitIsFullScreen !== undefined) {
  16473. _this._fullscreenVRpresenting = anyDoc.webkitIsFullScreen;
  16474. }
  16475. else if (anyDoc.msIsFullScreen !== undefined) {
  16476. _this._fullscreenVRpresenting = anyDoc.msIsFullScreen;
  16477. }
  16478. else if (document.msFullscreenElement !== undefined) {
  16479. _this._fullscreenVRpresenting = document.msFullscreenElement;
  16480. }
  16481. if (!_this._fullscreenVRpresenting && _this._canvas) {
  16482. _this.exitVR();
  16483. if (!_this._useCustomVRButton) {
  16484. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  16485. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  16486. }
  16487. }
  16488. };
  16489. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  16490. this.beforeRender = function () {
  16491. if (_this._leftController && _this._leftController._activePointer) {
  16492. _this._castRayAndSelectObject(_this._leftController);
  16493. }
  16494. if (_this._rightController && _this._rightController._activePointer) {
  16495. _this._castRayAndSelectObject(_this._rightController);
  16496. }
  16497. if (_this._noControllerIsActive) {
  16498. _this._castRayAndSelectObject(_this._cameraGazer);
  16499. }
  16500. else {
  16501. _this._cameraGazer._gazeTracker.isVisible = false;
  16502. }
  16503. };
  16504. this._onNewGamepadConnected = function (gamepad) {
  16505. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  16506. if (gamepad.leftStick) {
  16507. gamepad.onleftstickchanged(function (stickValues) {
  16508. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  16509. // Listening to classic/xbox gamepad only if no VR controller is active
  16510. if ((!_this._leftController && !_this._rightController) ||
  16511. ((_this._leftController && !_this._leftController._activePointer) &&
  16512. (_this._rightController && !_this._rightController._activePointer))) {
  16513. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  16514. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  16515. }
  16516. }
  16517. });
  16518. }
  16519. if (gamepad.rightStick) {
  16520. gamepad.onrightstickchanged(function (stickValues) {
  16521. if (_this._teleportationInitialized) {
  16522. _this._checkRotate(stickValues, _this._cameraGazer);
  16523. }
  16524. });
  16525. }
  16526. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  16527. gamepad.onbuttondown(function (buttonPressed) {
  16528. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16529. _this._cameraGazer._selectionPointerDown();
  16530. }
  16531. });
  16532. gamepad.onbuttonup(function (buttonPressed) {
  16533. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16534. _this._cameraGazer._selectionPointerUp();
  16535. }
  16536. });
  16537. }
  16538. }
  16539. else {
  16540. var webVRController = gamepad;
  16541. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  16542. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  16543. _this._rightController = controller;
  16544. }
  16545. else {
  16546. _this._leftController = controller;
  16547. }
  16548. _this._tryEnableInteractionOnController(controller);
  16549. }
  16550. };
  16551. // 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
  16552. this._tryEnableInteractionOnController = function (controller) {
  16553. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  16554. _this._enableInteractionOnController(controller);
  16555. }
  16556. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  16557. _this._enableTeleportationOnController(controller);
  16558. }
  16559. };
  16560. this._onNewGamepadDisconnected = function (gamepad) {
  16561. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  16562. if (gamepad.hand === "left" && _this._leftController != null) {
  16563. _this._leftController.dispose();
  16564. _this._leftController = null;
  16565. }
  16566. if (gamepad.hand === "right" && _this._rightController != null) {
  16567. _this._rightController.dispose();
  16568. _this._rightController = null;
  16569. }
  16570. }
  16571. };
  16572. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  16573. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  16574. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  16575. this._scene = scene;
  16576. this._canvas = scene.getEngine().getRenderingCanvas();
  16577. // Parse options
  16578. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  16579. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  16580. }
  16581. if (webVROptions.createDeviceOrientationCamera === undefined) {
  16582. webVROptions.createDeviceOrientationCamera = true;
  16583. }
  16584. if (webVROptions.laserToggle === undefined) {
  16585. webVROptions.laserToggle = true;
  16586. }
  16587. if (webVROptions.defaultHeight === undefined) {
  16588. webVROptions.defaultHeight = 1.7;
  16589. }
  16590. if (webVROptions.useCustomVRButton) {
  16591. this._useCustomVRButton = true;
  16592. if (webVROptions.customVRButton) {
  16593. this._btnVR = webVROptions.customVRButton;
  16594. }
  16595. }
  16596. if (webVROptions.rayLength) {
  16597. this._rayLength = webVROptions.rayLength;
  16598. }
  16599. this._defaultHeight = webVROptions.defaultHeight;
  16600. if (webVROptions.positionScale) {
  16601. this._rayLength *= webVROptions.positionScale;
  16602. this._defaultHeight *= webVROptions.positionScale;
  16603. }
  16604. this._hasEnteredVR = false;
  16605. // Set position
  16606. if (this._scene.activeCamera) {
  16607. this._position = this._scene.activeCamera.position.clone();
  16608. }
  16609. else {
  16610. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16611. }
  16612. // Set non-vr camera
  16613. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16614. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16615. // Copy data from existing camera
  16616. if (this._scene.activeCamera) {
  16617. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16618. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16619. // Set rotation from previous camera
  16620. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16621. var targetCamera = this._scene.activeCamera;
  16622. if (targetCamera.rotationQuaternion) {
  16623. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16624. }
  16625. else {
  16626. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16627. }
  16628. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16629. }
  16630. }
  16631. this._scene.activeCamera = this._deviceOrientationCamera;
  16632. if (this._canvas) {
  16633. this._scene.activeCamera.attachControl(this._canvas);
  16634. }
  16635. }
  16636. else {
  16637. this._existingCamera = this._scene.activeCamera;
  16638. }
  16639. // Create VR cameras
  16640. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16641. if (webVROptions.useMultiview) {
  16642. if (!webVROptions.vrDeviceOrientationCameraMetrics) {
  16643. webVROptions.vrDeviceOrientationCameraMetrics = _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_22__["VRCameraMetrics"].GetDefault();
  16644. }
  16645. webVROptions.vrDeviceOrientationCameraMetrics.multiviewEnabled = true;
  16646. }
  16647. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16648. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16649. }
  16650. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16651. this._webVRCamera.useStandingMatrix();
  16652. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16653. // Create default button
  16654. if (!this._useCustomVRButton) {
  16655. this._btnVR = document.createElement("BUTTON");
  16656. this._btnVR.className = "babylonVRicon";
  16657. this._btnVR.id = "babylonVRiconbtn";
  16658. this._btnVR.title = "Click to switch to VR";
  16659. 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) }";
  16660. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16661. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16662. // css += ".babylonVRicon.vrdisplaysupported { }";
  16663. // css += ".babylonVRicon.vrdisplayready { }";
  16664. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16665. var style = document.createElement('style');
  16666. style.appendChild(document.createTextNode(css));
  16667. document.getElementsByTagName('head')[0].appendChild(style);
  16668. this.moveButtonToBottomRight();
  16669. }
  16670. // VR button click event
  16671. if (this._btnVR) {
  16672. this._btnVR.addEventListener("click", function () {
  16673. if (!_this.isInVRMode) {
  16674. _this.enterVR();
  16675. }
  16676. else {
  16677. _this.exitVR();
  16678. }
  16679. });
  16680. }
  16681. // Window events
  16682. window.addEventListener("resize", this._onResize);
  16683. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16684. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16685. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16686. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16687. document.onmsfullscreenchange = this._onFullscreenChange;
  16688. // Display vr button when headset is connected
  16689. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16690. this.displayVRButton();
  16691. }
  16692. else {
  16693. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16694. if (e.vrDisplay) {
  16695. _this.displayVRButton();
  16696. }
  16697. });
  16698. }
  16699. // Exiting VR mode using 'ESC' key on desktop
  16700. this._onKeyDown = function (event) {
  16701. if (event.keyCode === 27 && _this.isInVRMode) {
  16702. _this.exitVR();
  16703. }
  16704. };
  16705. document.addEventListener("keydown", this._onKeyDown);
  16706. // Exiting VR mode double tapping the touch screen
  16707. this._scene.onPrePointerObservable.add(function () {
  16708. if (_this.isInVRMode) {
  16709. _this.exitVR();
  16710. if (_this._fullscreenVRpresenting) {
  16711. _this._scene.getEngine().exitFullscreen();
  16712. }
  16713. }
  16714. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16715. // Listen for WebVR display changes
  16716. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16717. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16718. this._onVRRequestPresentStart = function () {
  16719. _this._webVRrequesting = true;
  16720. _this.updateButtonVisibility();
  16721. };
  16722. this._onVRRequestPresentComplete = function () {
  16723. _this._webVRrequesting = false;
  16724. _this.updateButtonVisibility();
  16725. };
  16726. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16727. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16728. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16729. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16730. scene.onDisposeObservable.add(function () {
  16731. _this.dispose();
  16732. });
  16733. // Gamepad connection events
  16734. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16735. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16736. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16737. this.updateButtonVisibility();
  16738. //create easing functions
  16739. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16740. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16741. if (this.webVROptions.floorMeshes) {
  16742. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16743. }
  16744. }
  16745. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16746. /** Return this.onEnteringVRObservable
  16747. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16748. */
  16749. get: function () {
  16750. return this.onEnteringVRObservable;
  16751. },
  16752. enumerable: true,
  16753. configurable: true
  16754. });
  16755. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16756. /** Return this.onExitingVRObservable
  16757. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16758. */
  16759. get: function () {
  16760. return this.onExitingVRObservable;
  16761. },
  16762. enumerable: true,
  16763. configurable: true
  16764. });
  16765. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16766. /** Return this.onControllerMeshLoadedObservable
  16767. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16768. */
  16769. get: function () {
  16770. return this.onControllerMeshLoadedObservable;
  16771. },
  16772. enumerable: true,
  16773. configurable: true
  16774. });
  16775. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16776. /**
  16777. * The mesh used to display where the user is going to teleport.
  16778. */
  16779. get: function () {
  16780. return this._teleportationTarget;
  16781. },
  16782. /**
  16783. * Sets the mesh to be used to display where the user is going to teleport.
  16784. */
  16785. set: function (value) {
  16786. if (value) {
  16787. value.name = "teleportationTarget";
  16788. this._isDefaultTeleportationTarget = false;
  16789. this._teleportationTarget = value;
  16790. }
  16791. },
  16792. enumerable: true,
  16793. configurable: true
  16794. });
  16795. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16796. /**
  16797. * 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
  16798. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16799. * See http://doc.babylonjs.com/resources/baking_transformations
  16800. */
  16801. get: function () {
  16802. return this._cameraGazer._gazeTracker;
  16803. },
  16804. set: function (value) {
  16805. if (value) {
  16806. // Dispose of existing meshes
  16807. if (this._cameraGazer._gazeTracker) {
  16808. this._cameraGazer._gazeTracker.dispose();
  16809. }
  16810. if (this._leftController && this._leftController._gazeTracker) {
  16811. this._leftController._gazeTracker.dispose();
  16812. }
  16813. if (this._rightController && this._rightController._gazeTracker) {
  16814. this._rightController._gazeTracker.dispose();
  16815. }
  16816. // Set and create gaze trackers on head and controllers
  16817. this._cameraGazer._gazeTracker = value;
  16818. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16819. this._cameraGazer._gazeTracker.isPickable = false;
  16820. this._cameraGazer._gazeTracker.isVisible = false;
  16821. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16822. if (this._leftController) {
  16823. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16824. }
  16825. if (this._rightController) {
  16826. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16827. }
  16828. }
  16829. },
  16830. enumerable: true,
  16831. configurable: true
  16832. });
  16833. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16834. /**
  16835. * The gaze tracking mesh corresponding to the left controller
  16836. */
  16837. get: function () {
  16838. if (this._leftController) {
  16839. return this._leftController._gazeTracker;
  16840. }
  16841. return null;
  16842. },
  16843. enumerable: true,
  16844. configurable: true
  16845. });
  16846. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16847. /**
  16848. * The gaze tracking mesh corresponding to the right controller
  16849. */
  16850. get: function () {
  16851. if (this._rightController) {
  16852. return this._rightController._gazeTracker;
  16853. }
  16854. return null;
  16855. },
  16856. enumerable: true,
  16857. configurable: true
  16858. });
  16859. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16860. /**
  16861. * If the ray of the gaze should be displayed.
  16862. */
  16863. get: function () {
  16864. return this._displayGaze;
  16865. },
  16866. /**
  16867. * Sets if the ray of the gaze should be displayed.
  16868. */
  16869. set: function (value) {
  16870. this._displayGaze = value;
  16871. if (!value) {
  16872. this._cameraGazer._gazeTracker.isVisible = false;
  16873. if (this._leftController) {
  16874. this._leftController._gazeTracker.isVisible = false;
  16875. }
  16876. if (this._rightController) {
  16877. this._rightController._gazeTracker.isVisible = false;
  16878. }
  16879. }
  16880. },
  16881. enumerable: true,
  16882. configurable: true
  16883. });
  16884. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16885. /**
  16886. * If the ray of the LaserPointer should be displayed.
  16887. */
  16888. get: function () {
  16889. return this._displayLaserPointer;
  16890. },
  16891. /**
  16892. * Sets if the ray of the LaserPointer should be displayed.
  16893. */
  16894. set: function (value) {
  16895. this._displayLaserPointer = value;
  16896. if (!value) {
  16897. if (this._rightController) {
  16898. this._rightController._deactivatePointer();
  16899. this._rightController._gazeTracker.isVisible = false;
  16900. }
  16901. if (this._leftController) {
  16902. this._leftController._deactivatePointer();
  16903. this._leftController._gazeTracker.isVisible = false;
  16904. }
  16905. }
  16906. else {
  16907. if (this._rightController) {
  16908. this._rightController._activatePointer();
  16909. }
  16910. if (this._leftController) {
  16911. this._leftController._activatePointer();
  16912. }
  16913. }
  16914. },
  16915. enumerable: true,
  16916. configurable: true
  16917. });
  16918. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16919. /**
  16920. * The deviceOrientationCamera used as the camera when not in VR.
  16921. */
  16922. get: function () {
  16923. return this._deviceOrientationCamera;
  16924. },
  16925. enumerable: true,
  16926. configurable: true
  16927. });
  16928. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16929. /**
  16930. * Based on the current WebVR support, returns the current VR camera used.
  16931. */
  16932. get: function () {
  16933. if (this._webVRready) {
  16934. return this._webVRCamera;
  16935. }
  16936. else {
  16937. return this._scene.activeCamera;
  16938. }
  16939. },
  16940. enumerable: true,
  16941. configurable: true
  16942. });
  16943. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16944. /**
  16945. * The webVRCamera which is used when in VR.
  16946. */
  16947. get: function () {
  16948. return this._webVRCamera;
  16949. },
  16950. enumerable: true,
  16951. configurable: true
  16952. });
  16953. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16954. /**
  16955. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16956. */
  16957. get: function () {
  16958. return this._vrDeviceOrientationCamera;
  16959. },
  16960. enumerable: true,
  16961. configurable: true
  16962. });
  16963. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16964. get: function () {
  16965. var result = this._cameraGazer._teleportationRequestInitiated
  16966. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16967. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16968. return result;
  16969. },
  16970. enumerable: true,
  16971. configurable: true
  16972. });
  16973. // Raised when one of the controller has loaded successfully its associated default mesh
  16974. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16975. if (this._leftController && this._leftController.webVRController == webVRController) {
  16976. if (webVRController.mesh) {
  16977. this._leftController._setLaserPointerParent(webVRController.mesh);
  16978. }
  16979. }
  16980. if (this._rightController && this._rightController.webVRController == webVRController) {
  16981. if (webVRController.mesh) {
  16982. this._rightController._setLaserPointerParent(webVRController.mesh);
  16983. }
  16984. }
  16985. try {
  16986. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16987. }
  16988. catch (err) {
  16989. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16990. }
  16991. };
  16992. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16993. /**
  16994. * Gets a value indicating if we are currently in VR mode.
  16995. */
  16996. get: function () {
  16997. return this._webVRpresenting || this._fullscreenVRpresenting;
  16998. },
  16999. enumerable: true,
  17000. configurable: true
  17001. });
  17002. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  17003. var vrDisplay = this._scene.getEngine().getVRDevice();
  17004. if (vrDisplay) {
  17005. var wasPresenting = this._webVRpresenting;
  17006. this._webVRpresenting = vrDisplay.isPresenting;
  17007. if (wasPresenting && !this._webVRpresenting) {
  17008. this.exitVR();
  17009. }
  17010. }
  17011. else {
  17012. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  17013. }
  17014. this.updateButtonVisibility();
  17015. };
  17016. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  17017. this._webVRsupported = eventArgs.vrSupported;
  17018. this._webVRready = !!eventArgs.vrDisplay;
  17019. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  17020. this.updateButtonVisibility();
  17021. };
  17022. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  17023. if (this._canvas && !this._useCustomVRButton) {
  17024. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  17025. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  17026. }
  17027. };
  17028. VRExperienceHelper.prototype.displayVRButton = function () {
  17029. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  17030. document.body.appendChild(this._btnVR);
  17031. this._btnVRDisplayed = true;
  17032. }
  17033. };
  17034. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  17035. if (!this._btnVR || this._useCustomVRButton) {
  17036. return;
  17037. }
  17038. this._btnVR.className = "babylonVRicon";
  17039. if (this.isInVRMode) {
  17040. this._btnVR.className += " vrdisplaypresenting";
  17041. }
  17042. else {
  17043. if (this._webVRready) {
  17044. this._btnVR.className += " vrdisplayready";
  17045. }
  17046. if (this._webVRsupported) {
  17047. this._btnVR.className += " vrdisplaysupported";
  17048. }
  17049. if (this._webVRrequesting) {
  17050. this._btnVR.className += " vrdisplayrequesting";
  17051. }
  17052. }
  17053. };
  17054. /**
  17055. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  17056. * Otherwise, will use the fullscreen API.
  17057. */
  17058. VRExperienceHelper.prototype.enterVR = function () {
  17059. var _this = this;
  17060. if (this.onEnteringVRObservable) {
  17061. try {
  17062. this.onEnteringVRObservable.notifyObservers(this);
  17063. }
  17064. catch (err) {
  17065. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  17066. }
  17067. }
  17068. if (this._scene.activeCamera) {
  17069. this._position = this._scene.activeCamera.position.clone();
  17070. if (this.vrDeviceOrientationCamera) {
  17071. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  17072. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  17073. }
  17074. if (this.webVRCamera) {
  17075. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  17076. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  17077. var delta = desiredYRotation - currentYRotation;
  17078. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  17079. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  17080. }
  17081. // make sure that we return to the last active camera
  17082. this._existingCamera = this._scene.activeCamera;
  17083. // Remove and cache angular sensability to avoid camera rotation when in VR
  17084. if (this._existingCamera.angularSensibilityX) {
  17085. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  17086. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  17087. }
  17088. if (this._existingCamera.angularSensibilityY) {
  17089. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  17090. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  17091. }
  17092. if (this._existingCamera.angularSensibility) {
  17093. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  17094. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  17095. }
  17096. }
  17097. if (this._webVRrequesting) {
  17098. return;
  17099. }
  17100. // If WebVR is supported and a headset is connected
  17101. if (this._webVRready) {
  17102. if (!this._webVRpresenting) {
  17103. this._scene.getEngine().onVRRequestPresentComplete.addOnce(function (result) {
  17104. _this.onAfterEnteringVRObservable.notifyObservers({ success: result });
  17105. });
  17106. this._webVRCamera.position = this._position;
  17107. this._scene.activeCamera = this._webVRCamera;
  17108. }
  17109. }
  17110. else if (this._vrDeviceOrientationCamera) {
  17111. this._vrDeviceOrientationCamera.position = this._position;
  17112. if (this._scene.activeCamera) {
  17113. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  17114. }
  17115. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  17116. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen);
  17117. this.updateButtonVisibility();
  17118. this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function () {
  17119. _this.onAfterEnteringVRObservable.notifyObservers({ success: true });
  17120. });
  17121. }
  17122. if (this._scene.activeCamera && this._canvas) {
  17123. this._scene.activeCamera.attachControl(this._canvas);
  17124. }
  17125. if (this._interactionsEnabled) {
  17126. this._scene.registerBeforeRender(this.beforeRender);
  17127. }
  17128. if (this._displayLaserPointer) {
  17129. [this._leftController, this._rightController].forEach(function (controller) {
  17130. if (controller) {
  17131. controller._activatePointer();
  17132. }
  17133. });
  17134. }
  17135. this._hasEnteredVR = true;
  17136. };
  17137. /**
  17138. * Attempt to exit VR, or fullscreen.
  17139. */
  17140. VRExperienceHelper.prototype.exitVR = function () {
  17141. if (this._hasEnteredVR) {
  17142. if (this.onExitingVRObservable) {
  17143. try {
  17144. this.onExitingVRObservable.notifyObservers(this);
  17145. }
  17146. catch (err) {
  17147. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  17148. }
  17149. }
  17150. if (this._webVRpresenting) {
  17151. this._scene.getEngine().disableVR();
  17152. }
  17153. if (this._scene.activeCamera) {
  17154. this._position = this._scene.activeCamera.position.clone();
  17155. }
  17156. if (this.vrDeviceOrientationCamera) {
  17157. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  17158. }
  17159. if (this._deviceOrientationCamera) {
  17160. this._deviceOrientationCamera.position = this._position;
  17161. this._scene.activeCamera = this._deviceOrientationCamera;
  17162. if (this._canvas) {
  17163. this._scene.activeCamera.attachControl(this._canvas);
  17164. }
  17165. // Restore angular sensibility
  17166. if (this._cachedAngularSensibility.angularSensibilityX) {
  17167. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17168. this._cachedAngularSensibility.angularSensibilityX = null;
  17169. }
  17170. if (this._cachedAngularSensibility.angularSensibilityY) {
  17171. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17172. this._cachedAngularSensibility.angularSensibilityY = null;
  17173. }
  17174. if (this._cachedAngularSensibility.angularSensibility) {
  17175. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17176. this._cachedAngularSensibility.angularSensibility = null;
  17177. }
  17178. }
  17179. else if (this._existingCamera) {
  17180. this._existingCamera.position = this._position;
  17181. this._scene.activeCamera = this._existingCamera;
  17182. // Restore angular sensibility
  17183. if (this._cachedAngularSensibility.angularSensibilityX) {
  17184. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17185. this._cachedAngularSensibility.angularSensibilityX = null;
  17186. }
  17187. if (this._cachedAngularSensibility.angularSensibilityY) {
  17188. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17189. this._cachedAngularSensibility.angularSensibilityY = null;
  17190. }
  17191. if (this._cachedAngularSensibility.angularSensibility) {
  17192. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17193. this._cachedAngularSensibility.angularSensibility = null;
  17194. }
  17195. }
  17196. this.updateButtonVisibility();
  17197. if (this._interactionsEnabled) {
  17198. this._scene.unregisterBeforeRender(this.beforeRender);
  17199. this._cameraGazer._gazeTracker.isVisible = false;
  17200. if (this._leftController) {
  17201. this._leftController._gazeTracker.isVisible = false;
  17202. }
  17203. if (this._rightController) {
  17204. this._rightController._gazeTracker.isVisible = false;
  17205. }
  17206. }
  17207. // resize to update width and height when exiting vr exits fullscreen
  17208. this._scene.getEngine().resize();
  17209. [this._leftController, this._rightController].forEach(function (controller) {
  17210. if (controller) {
  17211. controller._deactivatePointer();
  17212. }
  17213. });
  17214. this._hasEnteredVR = false;
  17215. // Update engine state to re enable non-vr camera input
  17216. var engine = this._scene.getEngine();
  17217. if (engine._onVrDisplayPresentChange) {
  17218. engine._onVrDisplayPresentChange();
  17219. }
  17220. }
  17221. };
  17222. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  17223. /**
  17224. * The position of the vr experience helper.
  17225. */
  17226. get: function () {
  17227. return this._position;
  17228. },
  17229. /**
  17230. * Sets the position of the vr experience helper.
  17231. */
  17232. set: function (value) {
  17233. this._position = value;
  17234. if (this._scene.activeCamera) {
  17235. this._scene.activeCamera.position = value;
  17236. }
  17237. },
  17238. enumerable: true,
  17239. configurable: true
  17240. });
  17241. /**
  17242. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  17243. */
  17244. VRExperienceHelper.prototype.enableInteractions = function () {
  17245. var _this = this;
  17246. if (!this._interactionsEnabled) {
  17247. this._interactionsRequested = true;
  17248. if (this._leftController) {
  17249. this._enableInteractionOnController(this._leftController);
  17250. }
  17251. if (this._rightController) {
  17252. this._enableInteractionOnController(this._rightController);
  17253. }
  17254. this.raySelectionPredicate = function (mesh) {
  17255. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  17256. };
  17257. this.meshSelectionPredicate = function () {
  17258. return true;
  17259. };
  17260. this._raySelectionPredicate = function (mesh) {
  17261. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  17262. && mesh.name.indexOf("teleportationTarget") === -1
  17263. && mesh.name.indexOf("torusTeleportation") === -1)) {
  17264. return _this.raySelectionPredicate(mesh);
  17265. }
  17266. return false;
  17267. };
  17268. this._interactionsEnabled = true;
  17269. }
  17270. };
  17271. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  17272. get: function () {
  17273. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  17274. },
  17275. enumerable: true,
  17276. configurable: true
  17277. });
  17278. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  17279. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  17280. if (this._floorMeshesCollection[i].id === mesh.id) {
  17281. return true;
  17282. }
  17283. }
  17284. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  17285. return true;
  17286. }
  17287. return false;
  17288. };
  17289. /**
  17290. * Adds a floor mesh to be used for teleportation.
  17291. * @param floorMesh the mesh to be used for teleportation.
  17292. */
  17293. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  17294. if (!this._floorMeshesCollection) {
  17295. return;
  17296. }
  17297. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  17298. return;
  17299. }
  17300. this._floorMeshesCollection.push(floorMesh);
  17301. };
  17302. /**
  17303. * Removes a floor mesh from being used for teleportation.
  17304. * @param floorMesh the mesh to be removed.
  17305. */
  17306. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  17307. if (!this._floorMeshesCollection) {
  17308. return;
  17309. }
  17310. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  17311. if (meshIndex !== -1) {
  17312. this._floorMeshesCollection.splice(meshIndex, 1);
  17313. }
  17314. };
  17315. /**
  17316. * Enables interactions and teleportation using the VR controllers and gaze.
  17317. * @param vrTeleportationOptions options to modify teleportation behavior.
  17318. */
  17319. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  17320. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  17321. if (!this._teleportationInitialized) {
  17322. this._teleportationRequested = true;
  17323. this.enableInteractions();
  17324. if (vrTeleportationOptions.floorMeshName) {
  17325. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  17326. }
  17327. if (vrTeleportationOptions.floorMeshes) {
  17328. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  17329. }
  17330. if (this._leftController != null) {
  17331. this._enableTeleportationOnController(this._leftController);
  17332. }
  17333. if (this._rightController != null) {
  17334. this._enableTeleportationOnController(this._rightController);
  17335. }
  17336. // Creates an image processing post process for the vignette not relying
  17337. // on the main scene configuration for image processing to reduce setup and spaces
  17338. // (gamma/linear) conflicts.
  17339. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  17340. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  17341. imageProcessingConfiguration.vignetteEnabled = true;
  17342. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  17343. this._webVRCamera.detachPostProcess(this._postProcessMove);
  17344. this._teleportationInitialized = true;
  17345. if (this._isDefaultTeleportationTarget) {
  17346. this._createTeleportationCircles();
  17347. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  17348. }
  17349. }
  17350. };
  17351. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  17352. var _this = this;
  17353. var controllerMesh = controller.webVRController.mesh;
  17354. if (controllerMesh) {
  17355. controller._interactionsEnabled = true;
  17356. if (this.isInVRMode && this._displayLaserPointer) {
  17357. controller._activatePointer();
  17358. }
  17359. if (this.webVROptions.laserToggle) {
  17360. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  17361. // Enabling / disabling laserPointer
  17362. if (_this._displayLaserPointer && stateObject.value === 1) {
  17363. if (controller._activePointer) {
  17364. controller._deactivatePointer();
  17365. }
  17366. else {
  17367. controller._activatePointer();
  17368. }
  17369. if (_this.displayGaze) {
  17370. controller._gazeTracker.isVisible = controller._activePointer;
  17371. }
  17372. }
  17373. });
  17374. }
  17375. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  17376. var gazer = controller;
  17377. if (_this._noControllerIsActive) {
  17378. gazer = _this._cameraGazer;
  17379. }
  17380. if (!gazer._pointerDownOnMeshAsked) {
  17381. if (stateObject.value > _this._padSensibilityUp) {
  17382. gazer._selectionPointerDown();
  17383. }
  17384. }
  17385. else if (stateObject.value < _this._padSensibilityDown) {
  17386. gazer._selectionPointerUp();
  17387. }
  17388. });
  17389. }
  17390. };
  17391. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  17392. // Dont teleport if another gaze already requested teleportation
  17393. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  17394. return;
  17395. }
  17396. if (!gazer._teleportationRequestInitiated) {
  17397. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  17398. gazer._activatePointer();
  17399. gazer._teleportationRequestInitiated = true;
  17400. }
  17401. }
  17402. else {
  17403. // Listening to the proper controller values changes to confirm teleportation
  17404. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  17405. if (this._teleportActive) {
  17406. this.teleportCamera(this._haloCenter);
  17407. }
  17408. gazer._teleportationRequestInitiated = false;
  17409. }
  17410. }
  17411. };
  17412. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  17413. // Only rotate when user is not currently selecting a teleportation location
  17414. if (gazer._teleportationRequestInitiated) {
  17415. return;
  17416. }
  17417. if (!gazer._rotationLeftAsked) {
  17418. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  17419. gazer._rotationLeftAsked = true;
  17420. if (this._rotationAllowed) {
  17421. this._rotateCamera(false);
  17422. }
  17423. }
  17424. }
  17425. else {
  17426. if (stateObject.x > -this._padSensibilityDown) {
  17427. gazer._rotationLeftAsked = false;
  17428. }
  17429. }
  17430. if (!gazer._rotationRightAsked) {
  17431. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  17432. gazer._rotationRightAsked = true;
  17433. if (this._rotationAllowed) {
  17434. this._rotateCamera(true);
  17435. }
  17436. }
  17437. }
  17438. else {
  17439. if (stateObject.x < this._padSensibilityDown) {
  17440. gazer._rotationRightAsked = false;
  17441. }
  17442. }
  17443. };
  17444. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  17445. // Only teleport backwards when user is not currently selecting a teleportation location
  17446. if (gazer._teleportationRequestInitiated) {
  17447. return;
  17448. }
  17449. // Teleport backwards
  17450. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  17451. if (!gazer._teleportationBackRequestInitiated) {
  17452. if (!this.currentVRCamera) {
  17453. return;
  17454. }
  17455. // Get rotation and position of the current camera
  17456. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  17457. var position = this.currentVRCamera.position;
  17458. // If the camera has device position, use that instead
  17459. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  17460. rotation = this.currentVRCamera.deviceRotationQuaternion;
  17461. position = this.currentVRCamera.devicePosition;
  17462. }
  17463. // Get matrix with only the y rotation of the device rotation
  17464. rotation.toEulerAnglesToRef(this._workingVector);
  17465. this._workingVector.z = 0;
  17466. this._workingVector.x = 0;
  17467. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  17468. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  17469. // Rotate backwards ray by device rotation to cast at the ground behind the user
  17470. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  17471. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  17472. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  17473. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17474. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  17475. this.teleportCamera(hit.pickedPoint);
  17476. }
  17477. gazer._teleportationBackRequestInitiated = true;
  17478. }
  17479. }
  17480. else {
  17481. gazer._teleportationBackRequestInitiated = false;
  17482. }
  17483. };
  17484. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  17485. var _this = this;
  17486. var controllerMesh = controller.webVRController.mesh;
  17487. if (controllerMesh) {
  17488. if (!controller._interactionsEnabled) {
  17489. this._enableInteractionOnController(controller);
  17490. }
  17491. controller._interactionsEnabled = true;
  17492. controller._teleportationEnabled = true;
  17493. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  17494. controller._dpadPressed = false;
  17495. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  17496. controller._dpadPressed = stateObject.pressed;
  17497. if (!controller._dpadPressed) {
  17498. controller._rotationLeftAsked = false;
  17499. controller._rotationRightAsked = false;
  17500. controller._teleportationBackRequestInitiated = false;
  17501. }
  17502. });
  17503. }
  17504. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  17505. if (_this.teleportationEnabled) {
  17506. _this._checkTeleportBackwards(stateObject, controller);
  17507. _this._checkTeleportWithRay(stateObject, controller);
  17508. }
  17509. _this._checkRotate(stateObject, controller);
  17510. });
  17511. }
  17512. };
  17513. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  17514. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  17515. this._teleportationTarget.isPickable = false;
  17516. var length = 512;
  17517. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  17518. dynamicTexture.hasAlpha = true;
  17519. var context = dynamicTexture.getContext();
  17520. var centerX = length / 2;
  17521. var centerY = length / 2;
  17522. var radius = 200;
  17523. context.beginPath();
  17524. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  17525. context.fillStyle = this._teleportationFillColor;
  17526. context.fill();
  17527. context.lineWidth = 10;
  17528. context.strokeStyle = this._teleportationBorderColor;
  17529. context.stroke();
  17530. context.closePath();
  17531. dynamicTexture.update();
  17532. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  17533. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  17534. this._teleportationTarget.material = teleportationCircleMaterial;
  17535. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  17536. torus.isPickable = false;
  17537. torus.parent = this._teleportationTarget;
  17538. 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);
  17539. var keys = [];
  17540. keys.push({
  17541. frame: 0,
  17542. value: 0
  17543. });
  17544. keys.push({
  17545. frame: 30,
  17546. value: 0.4
  17547. });
  17548. keys.push({
  17549. frame: 60,
  17550. value: 0
  17551. });
  17552. animationInnerCircle.setKeys(keys);
  17553. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  17554. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  17555. animationInnerCircle.setEasingFunction(easingFunction);
  17556. torus.animations = [];
  17557. torus.animations.push(animationInnerCircle);
  17558. this._scene.beginAnimation(torus, 0, 60, true);
  17559. this._hideTeleportationTarget();
  17560. };
  17561. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  17562. this._teleportActive = true;
  17563. if (this._teleportationInitialized) {
  17564. this._teleportationTarget.isVisible = true;
  17565. if (this._isDefaultTeleportationTarget) {
  17566. this._teleportationTarget.getChildren()[0].isVisible = true;
  17567. }
  17568. }
  17569. };
  17570. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  17571. this._teleportActive = false;
  17572. if (this._teleportationInitialized) {
  17573. this._teleportationTarget.isVisible = false;
  17574. if (this._isDefaultTeleportationTarget) {
  17575. this._teleportationTarget.getChildren()[0].isVisible = false;
  17576. }
  17577. }
  17578. };
  17579. VRExperienceHelper.prototype._rotateCamera = function (right) {
  17580. var _this = this;
  17581. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17582. return;
  17583. }
  17584. if (right) {
  17585. this._rotationAngle++;
  17586. }
  17587. else {
  17588. this._rotationAngle--;
  17589. }
  17590. this.currentVRCamera.animations = [];
  17591. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  17592. 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);
  17593. var animationRotationKeys = [];
  17594. animationRotationKeys.push({
  17595. frame: 0,
  17596. value: this.currentVRCamera.rotationQuaternion
  17597. });
  17598. animationRotationKeys.push({
  17599. frame: 6,
  17600. value: target
  17601. });
  17602. animationRotation.setKeys(animationRotationKeys);
  17603. animationRotation.setEasingFunction(this._circleEase);
  17604. this.currentVRCamera.animations.push(animationRotation);
  17605. this._postProcessMove.animations = [];
  17606. 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);
  17607. var vignetteWeightKeys = [];
  17608. vignetteWeightKeys.push({
  17609. frame: 0,
  17610. value: 0
  17611. });
  17612. vignetteWeightKeys.push({
  17613. frame: 3,
  17614. value: 4
  17615. });
  17616. vignetteWeightKeys.push({
  17617. frame: 6,
  17618. value: 0
  17619. });
  17620. animationPP.setKeys(vignetteWeightKeys);
  17621. animationPP.setEasingFunction(this._circleEase);
  17622. this._postProcessMove.animations.push(animationPP);
  17623. 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);
  17624. var vignetteStretchKeys = [];
  17625. vignetteStretchKeys.push({
  17626. frame: 0,
  17627. value: 0
  17628. });
  17629. vignetteStretchKeys.push({
  17630. frame: 3,
  17631. value: 10
  17632. });
  17633. vignetteStretchKeys.push({
  17634. frame: 6,
  17635. value: 0
  17636. });
  17637. animationPP2.setKeys(vignetteStretchKeys);
  17638. animationPP2.setEasingFunction(this._circleEase);
  17639. this._postProcessMove.animations.push(animationPP2);
  17640. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17641. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17642. this._postProcessMove.samples = 4;
  17643. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17644. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17645. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17646. });
  17647. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17648. };
  17649. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17650. if (hit.pickedPoint) {
  17651. if (gazer._teleportationRequestInitiated) {
  17652. this._displayTeleportationTarget();
  17653. this._haloCenter.copyFrom(hit.pickedPoint);
  17654. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17655. }
  17656. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17657. if (pickNormal) {
  17658. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17659. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17660. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17661. }
  17662. this._teleportationTarget.position.y += 0.1;
  17663. }
  17664. };
  17665. /**
  17666. * Teleports the users feet to the desired location
  17667. * @param location The location where the user's feet should be placed
  17668. */
  17669. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17670. var _this = this;
  17671. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17672. return;
  17673. }
  17674. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17675. // offset of the headset from the anchor.
  17676. if (this.webVRCamera.leftCamera) {
  17677. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17678. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17679. location.subtractToRef(this._workingVector, this._workingVector);
  17680. }
  17681. else {
  17682. this._workingVector.copyFrom(location);
  17683. }
  17684. // Add height to account for user's height offset
  17685. if (this.isInVRMode) {
  17686. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17687. }
  17688. else {
  17689. this._workingVector.y += this._defaultHeight;
  17690. }
  17691. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17692. // Create animation from the camera's position to the new location
  17693. this.currentVRCamera.animations = [];
  17694. 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);
  17695. var animationCameraTeleportationKeys = [{
  17696. frame: 0,
  17697. value: this.currentVRCamera.position
  17698. },
  17699. {
  17700. frame: 11,
  17701. value: this._workingVector
  17702. }
  17703. ];
  17704. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17705. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17706. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17707. this._postProcessMove.animations = [];
  17708. 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);
  17709. var vignetteWeightKeys = [];
  17710. vignetteWeightKeys.push({
  17711. frame: 0,
  17712. value: 0
  17713. });
  17714. vignetteWeightKeys.push({
  17715. frame: 5,
  17716. value: 8
  17717. });
  17718. vignetteWeightKeys.push({
  17719. frame: 11,
  17720. value: 0
  17721. });
  17722. animationPP.setKeys(vignetteWeightKeys);
  17723. this._postProcessMove.animations.push(animationPP);
  17724. 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);
  17725. var vignetteStretchKeys = [];
  17726. vignetteStretchKeys.push({
  17727. frame: 0,
  17728. value: 0
  17729. });
  17730. vignetteStretchKeys.push({
  17731. frame: 5,
  17732. value: 10
  17733. });
  17734. vignetteStretchKeys.push({
  17735. frame: 11,
  17736. value: 0
  17737. });
  17738. animationPP2.setKeys(vignetteStretchKeys);
  17739. this._postProcessMove.animations.push(animationPP2);
  17740. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17741. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17742. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17743. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17744. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17745. });
  17746. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17747. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17748. });
  17749. this._hideTeleportationTarget();
  17750. };
  17751. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17752. if (normal) {
  17753. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17754. if (angle < Math.PI / 2) {
  17755. normal.scaleInPlace(-1);
  17756. }
  17757. }
  17758. return normal;
  17759. };
  17760. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17761. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17762. return;
  17763. }
  17764. var ray = gazer._getForwardRay(this._rayLength);
  17765. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17766. if (hit) {
  17767. // Populate the contrllers mesh that can be used for drag/drop
  17768. if (gazer._laserPointer) {
  17769. hit.originMesh = gazer._laserPointer.parent;
  17770. }
  17771. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17772. }
  17773. gazer._currentHit = hit;
  17774. // Moving the gazeTracker on the mesh face targetted
  17775. if (hit && hit.pickedPoint) {
  17776. if (this._displayGaze) {
  17777. var multiplier = 1;
  17778. gazer._gazeTracker.isVisible = true;
  17779. if (gazer._isActionableMesh) {
  17780. multiplier = 3;
  17781. }
  17782. if (this.updateGazeTrackerScale) {
  17783. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17784. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17785. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17786. }
  17787. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17788. // To avoid z-fighting
  17789. var deltaFighting = 0.002;
  17790. if (pickNormal) {
  17791. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17792. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17793. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17794. }
  17795. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17796. if (gazer._gazeTracker.position.x < 0) {
  17797. gazer._gazeTracker.position.x += deltaFighting;
  17798. }
  17799. else {
  17800. gazer._gazeTracker.position.x -= deltaFighting;
  17801. }
  17802. if (gazer._gazeTracker.position.y < 0) {
  17803. gazer._gazeTracker.position.y += deltaFighting;
  17804. }
  17805. else {
  17806. gazer._gazeTracker.position.y -= deltaFighting;
  17807. }
  17808. if (gazer._gazeTracker.position.z < 0) {
  17809. gazer._gazeTracker.position.z += deltaFighting;
  17810. }
  17811. else {
  17812. gazer._gazeTracker.position.z -= deltaFighting;
  17813. }
  17814. }
  17815. // Changing the size of the laser pointer based on the distance from the targetted point
  17816. gazer._updatePointerDistance(hit.distance);
  17817. }
  17818. else {
  17819. gazer._updatePointerDistance();
  17820. gazer._gazeTracker.isVisible = false;
  17821. }
  17822. if (hit && hit.pickedMesh) {
  17823. // The object selected is the floor, we're in a teleportation scenario
  17824. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17825. // Moving the teleportation area to this targetted point
  17826. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17827. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17828. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17829. }
  17830. gazer._currentMeshSelected = null;
  17831. if (gazer._teleportationRequestInitiated) {
  17832. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17833. }
  17834. return;
  17835. }
  17836. // If not, we're in a selection scenario
  17837. //this._teleportationAllowed = false;
  17838. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17839. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17840. this.onNewMeshPicked.notifyObservers(hit);
  17841. gazer._currentMeshSelected = hit.pickedMesh;
  17842. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17843. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17844. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17845. gazer._isActionableMesh = true;
  17846. }
  17847. else {
  17848. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17849. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17850. gazer._isActionableMesh = false;
  17851. }
  17852. try {
  17853. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17854. }
  17855. catch (err) {
  17856. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17857. }
  17858. }
  17859. else {
  17860. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17861. gazer._currentMeshSelected = null;
  17862. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17863. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17864. }
  17865. }
  17866. }
  17867. else {
  17868. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17869. gazer._currentMeshSelected = null;
  17870. //this._teleportationAllowed = false;
  17871. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17872. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17873. }
  17874. };
  17875. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17876. if (mesh) {
  17877. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17878. }
  17879. };
  17880. /**
  17881. * Sets the color of the laser ray from the vr controllers.
  17882. * @param color new color for the ray.
  17883. */
  17884. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17885. if (this._leftController) {
  17886. this._leftController._setLaserPointerColor(color);
  17887. }
  17888. if (this._rightController) {
  17889. this._rightController._setLaserPointerColor(color);
  17890. }
  17891. };
  17892. /**
  17893. * Sets the color of the ray from the vr headsets gaze.
  17894. * @param color new color for the ray.
  17895. */
  17896. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17897. if (!this.updateGazeTrackerColor) {
  17898. return;
  17899. }
  17900. if (!this._cameraGazer._gazeTracker.material) {
  17901. return;
  17902. }
  17903. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17904. if (this._leftController) {
  17905. this._leftController._gazeTracker.material.emissiveColor = color;
  17906. }
  17907. if (this._rightController) {
  17908. this._rightController._gazeTracker.material.emissiveColor = color;
  17909. }
  17910. };
  17911. /**
  17912. * Exits VR and disposes of the vr experience helper
  17913. */
  17914. VRExperienceHelper.prototype.dispose = function () {
  17915. if (this.isInVRMode) {
  17916. this.exitVR();
  17917. }
  17918. if (this._postProcessMove) {
  17919. this._postProcessMove.dispose();
  17920. }
  17921. if (this._webVRCamera) {
  17922. this._webVRCamera.dispose();
  17923. }
  17924. if (this._vrDeviceOrientationCamera) {
  17925. this._vrDeviceOrientationCamera.dispose();
  17926. }
  17927. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17928. document.body.removeChild(this._btnVR);
  17929. }
  17930. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17931. this._deviceOrientationCamera.dispose();
  17932. }
  17933. if (this._cameraGazer) {
  17934. this._cameraGazer.dispose();
  17935. }
  17936. if (this._leftController) {
  17937. this._leftController.dispose();
  17938. }
  17939. if (this._rightController) {
  17940. this._rightController.dispose();
  17941. }
  17942. if (this._teleportationTarget) {
  17943. this._teleportationTarget.dispose();
  17944. }
  17945. this._floorMeshesCollection = [];
  17946. document.removeEventListener("keydown", this._onKeyDown);
  17947. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17948. window.removeEventListener("resize", this._onResize);
  17949. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17950. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17951. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17952. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17953. document.onmsfullscreenchange = null;
  17954. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17955. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17956. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17957. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17958. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17959. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17960. this._scene.unregisterBeforeRender(this.beforeRender);
  17961. };
  17962. /**
  17963. * Gets the name of the VRExperienceHelper class
  17964. * @returns "VRExperienceHelper"
  17965. */
  17966. VRExperienceHelper.prototype.getClassName = function () {
  17967. return "VRExperienceHelper";
  17968. };
  17969. return VRExperienceHelper;
  17970. }());
  17971. /***/ }),
  17972. /***/ "./Cameras/VR/webVRCamera.ts":
  17973. /*!***********************************!*\
  17974. !*** ./Cameras/VR/webVRCamera.ts ***!
  17975. \***********************************/
  17976. /*! exports provided: WebVRFreeCamera */
  17977. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17978. "use strict";
  17979. __webpack_require__.r(__webpack_exports__);
  17980. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17981. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17982. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17983. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17984. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17985. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17986. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17987. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17988. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17989. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17990. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  17991. /* harmony import */ var _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../PostProcesses/vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  17992. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17993. /* harmony import */ var _Engines_Extensions_engine_webVR__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/Extensions/engine.webVR */ "./Engines/Extensions/engine.webVR.ts");
  17994. // Side effect import to define the stereoscopic mode.
  17995. // Side effect import to add webvr support to engine
  17996. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17997. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17998. });
  17999. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  18000. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  18001. });
  18002. /**
  18003. * This represents a WebVR camera.
  18004. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18005. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18006. */
  18007. var WebVRFreeCamera = /** @class */ (function (_super) {
  18008. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  18009. /**
  18010. * Instantiates a WebVRFreeCamera.
  18011. * @param name The name of the WebVRFreeCamera
  18012. * @param position The starting anchor position for the camera
  18013. * @param scene The scene the camera belongs to
  18014. * @param webVROptions a set of customizable options for the webVRCamera
  18015. */
  18016. function WebVRFreeCamera(name, position, scene, webVROptions) {
  18017. if (webVROptions === void 0) { webVROptions = {}; }
  18018. var _this = _super.call(this, name, position, scene) || this;
  18019. _this.webVROptions = webVROptions;
  18020. /**
  18021. * @hidden
  18022. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18023. */
  18024. _this._vrDevice = null;
  18025. /**
  18026. * The rawPose of the vrDevice.
  18027. */
  18028. _this.rawPose = null;
  18029. _this._specsVersion = "1.1";
  18030. _this._attached = false;
  18031. _this._descendants = [];
  18032. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  18033. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  18034. /** @hidden */
  18035. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  18036. _this._standingMatrix = null;
  18037. /**
  18038. * Represents device position in babylon space.
  18039. */
  18040. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  18041. /**
  18042. * Represents device rotation in babylon space.
  18043. */
  18044. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  18045. /**
  18046. * The scale of the device to be used when translating from device space to babylon space.
  18047. */
  18048. _this.deviceScaleFactor = 1;
  18049. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18050. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18051. /**
  18052. * References to the webVR controllers for the vrDevice.
  18053. */
  18054. _this.controllers = [];
  18055. /**
  18056. * Emits an event when a controller is attached.
  18057. */
  18058. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18059. /**
  18060. * Emits an event when a controller's mesh has been loaded;
  18061. */
  18062. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18063. /**
  18064. * Emits an event when the HMD's pose has been updated.
  18065. */
  18066. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18067. _this._poseSet = false;
  18068. /**
  18069. * If the rig cameras be used as parent instead of this camera.
  18070. */
  18071. _this.rigParenting = true;
  18072. _this._defaultHeight = undefined;
  18073. _this._htmlElementAttached = null;
  18074. _this._detachIfAttached = function () {
  18075. var vrDisplay = _this.getEngine().getVRDevice();
  18076. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  18077. _this.detachControl(_this._htmlElementAttached);
  18078. }
  18079. };
  18080. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  18081. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  18082. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18083. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  18084. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  18085. if (webVROptions.defaultHeight) {
  18086. _this._defaultHeight = webVROptions.defaultHeight;
  18087. _this.position.y = _this._defaultHeight;
  18088. }
  18089. _this.minZ = 0.1;
  18090. //legacy support - the compensation boolean was removed.
  18091. if (arguments.length === 5) {
  18092. _this.webVROptions = arguments[4];
  18093. }
  18094. // default webVR options
  18095. if (_this.webVROptions.trackPosition == undefined) {
  18096. _this.webVROptions.trackPosition = true;
  18097. }
  18098. if (_this.webVROptions.controllerMeshes == undefined) {
  18099. _this.webVROptions.controllerMeshes = true;
  18100. }
  18101. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  18102. _this.webVROptions.defaultLightingOnControllers = true;
  18103. }
  18104. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  18105. if (_this.webVROptions && _this.webVROptions.positionScale) {
  18106. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  18107. }
  18108. //enable VR
  18109. var engine = _this.getEngine();
  18110. _this._onVREnabled = function (success) { if (success) {
  18111. _this.initControllers();
  18112. } };
  18113. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  18114. engine.initWebVR().add(function (event) {
  18115. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  18116. return;
  18117. }
  18118. _this._vrDevice = event.vrDisplay;
  18119. //reset the rig parameters.
  18120. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  18121. if (_this._attached) {
  18122. _this.getEngine().enableVR();
  18123. }
  18124. });
  18125. if (typeof (VRFrameData) !== "undefined") {
  18126. _this._frameData = new VRFrameData();
  18127. }
  18128. if (webVROptions.useMultiview) {
  18129. if (!_this.getScene().getEngine().getCaps().multiview) {
  18130. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn("Multiview is not supported, falling back to standard rendering");
  18131. _this._useMultiviewToSingleView = false;
  18132. }
  18133. else {
  18134. _this._useMultiviewToSingleView = true;
  18135. _this._rigPostProcess = new _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_10__["VRMultiviewToSingleviewPostProcess"]("VRMultiviewToSingleview", _this, 1.0);
  18136. }
  18137. }
  18138. /**
  18139. * The idea behind the following lines:
  18140. * objects that have the camera as parent should actually have the rig cameras as a parent.
  18141. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  18142. * the second will not show it correctly.
  18143. *
  18144. * To solve this - each object that has the camera as parent will be added to a protected array.
  18145. * When the rig camera renders, it will take this array and set all of those to be its children.
  18146. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  18147. * Amazing!
  18148. */
  18149. scene.onBeforeCameraRenderObservable.add(function (camera) {
  18150. if (camera.parent === _this && _this.rigParenting) {
  18151. _this._descendants = _this.getDescendants(true, function (n) {
  18152. // don't take the cameras or the controllers!
  18153. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  18154. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  18155. return !isController && !isRigCamera;
  18156. });
  18157. _this._descendants.forEach(function (node) {
  18158. node.parent = camera;
  18159. });
  18160. }
  18161. });
  18162. scene.onAfterCameraRenderObservable.add(function (camera) {
  18163. if (camera.parent === _this && _this.rigParenting) {
  18164. _this._descendants.forEach(function (node) {
  18165. node.parent = _this;
  18166. });
  18167. }
  18168. });
  18169. return _this;
  18170. }
  18171. /**
  18172. * Gets the device distance from the ground in meters.
  18173. * @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.
  18174. */
  18175. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  18176. if (this._standingMatrix) {
  18177. // Add standing matrix offset to get real offset from ground in room
  18178. this._standingMatrix.getTranslationToRef(this._workingVector);
  18179. return this._deviceRoomPosition.y + this._workingVector.y;
  18180. }
  18181. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  18182. return this._defaultHeight || 0;
  18183. };
  18184. /**
  18185. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18186. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18187. */
  18188. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  18189. var _this = this;
  18190. if (callback === void 0) { callback = function (bool) { }; }
  18191. // Use standing matrix if available
  18192. this.getEngine().initWebVRAsync().then(function (result) {
  18193. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  18194. callback(false);
  18195. }
  18196. else {
  18197. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  18198. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  18199. if (!_this.getScene().useRightHandedSystem) {
  18200. if (_this._standingMatrix) {
  18201. _this._standingMatrix.toggleModelMatrixHandInPlace();
  18202. }
  18203. }
  18204. callback(true);
  18205. }
  18206. });
  18207. };
  18208. /**
  18209. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18210. * @returns A promise with a boolean set to if the standing matrix is supported.
  18211. */
  18212. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  18213. var _this = this;
  18214. return new Promise(function (res) {
  18215. _this.useStandingMatrix(function (supported) {
  18216. res(supported);
  18217. });
  18218. });
  18219. };
  18220. /**
  18221. * Disposes the camera
  18222. */
  18223. WebVRFreeCamera.prototype.dispose = function () {
  18224. this._detachIfAttached();
  18225. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  18226. if (this._updateCacheWhenTrackingDisabledObserver) {
  18227. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  18228. }
  18229. _super.prototype.dispose.call(this);
  18230. };
  18231. /**
  18232. * Gets a vrController by name.
  18233. * @param name The name of the controller to retreive
  18234. * @returns the controller matching the name specified or null if not found
  18235. */
  18236. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  18237. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  18238. var gp = _a[_i];
  18239. if (gp.hand === name) {
  18240. return gp;
  18241. }
  18242. }
  18243. return null;
  18244. };
  18245. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  18246. /**
  18247. * The controller corrisponding to the users left hand.
  18248. */
  18249. get: function () {
  18250. if (!this._leftController) {
  18251. this._leftController = this.getControllerByName("left");
  18252. }
  18253. return this._leftController;
  18254. },
  18255. enumerable: true,
  18256. configurable: true
  18257. });
  18258. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  18259. /**
  18260. * The controller corrisponding to the users right hand.
  18261. */
  18262. get: function () {
  18263. if (!this._rightController) {
  18264. this._rightController = this.getControllerByName("right");
  18265. }
  18266. return this._rightController;
  18267. },
  18268. enumerable: true,
  18269. configurable: true
  18270. });
  18271. /**
  18272. * Casts a ray forward from the vrCamera's gaze.
  18273. * @param length Length of the ray (default: 100)
  18274. * @returns the ray corrisponding to the gaze
  18275. */
  18276. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  18277. if (length === void 0) { length = 100; }
  18278. if (this.leftCamera) {
  18279. // Use left eye to avoid computation to compute center on every call
  18280. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  18281. }
  18282. else {
  18283. return _super.prototype.getForwardRay.call(this, length);
  18284. }
  18285. };
  18286. /**
  18287. * @hidden
  18288. * Updates the camera based on device's frame data
  18289. */
  18290. WebVRFreeCamera.prototype._checkInputs = function () {
  18291. if (this._vrDevice && this._vrDevice.isPresenting) {
  18292. this._vrDevice.getFrameData(this._frameData);
  18293. this.updateFromDevice(this._frameData.pose);
  18294. }
  18295. _super.prototype._checkInputs.call(this);
  18296. };
  18297. /**
  18298. * Updates the poseControlled values based on the input device pose.
  18299. * @param poseData Pose coming from the device
  18300. */
  18301. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  18302. if (poseData && poseData.orientation) {
  18303. this.rawPose = poseData;
  18304. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  18305. if (this.getScene().useRightHandedSystem) {
  18306. this._deviceRoomRotationQuaternion.z *= -1;
  18307. this._deviceRoomRotationQuaternion.w *= -1;
  18308. }
  18309. if (this.webVROptions.trackPosition && this.rawPose.position) {
  18310. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  18311. if (this.getScene().useRightHandedSystem) {
  18312. this._deviceRoomPosition.z *= -1;
  18313. }
  18314. }
  18315. this._poseSet = true;
  18316. }
  18317. };
  18318. /**
  18319. * WebVR's attach control will start broadcasting frames to the device.
  18320. * Note that in certain browsers (chrome for example) this function must be called
  18321. * within a user-interaction callback. Example:
  18322. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18323. *
  18324. * @param element html element to attach the vrDevice to
  18325. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18326. */
  18327. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  18328. _super.prototype.attachControl.call(this, element, noPreventDefault);
  18329. this._attached = true;
  18330. this._htmlElementAttached = element;
  18331. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  18332. if (this._vrDevice) {
  18333. this.getEngine().enableVR();
  18334. }
  18335. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18336. };
  18337. /**
  18338. * Detaches the camera from the html element and disables VR
  18339. *
  18340. * @param element html element to detach from
  18341. */
  18342. WebVRFreeCamera.prototype.detachControl = function (element) {
  18343. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  18344. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  18345. _super.prototype.detachControl.call(this, element);
  18346. this._attached = false;
  18347. this.getEngine().disableVR();
  18348. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18349. };
  18350. /**
  18351. * @returns the name of this class
  18352. */
  18353. WebVRFreeCamera.prototype.getClassName = function () {
  18354. return "WebVRFreeCamera";
  18355. };
  18356. /**
  18357. * Calls resetPose on the vrDisplay
  18358. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18359. */
  18360. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  18361. //uses the vrDisplay's "resetPose()".
  18362. //pitch and roll won't be affected.
  18363. this._vrDevice.resetPose();
  18364. };
  18365. /**
  18366. * @hidden
  18367. * Updates the rig cameras (left and right eye)
  18368. */
  18369. WebVRFreeCamera.prototype._updateRigCameras = function () {
  18370. var camLeft = this._rigCameras[0];
  18371. var camRight = this._rigCameras[1];
  18372. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18373. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18374. camLeft.position.copyFrom(this._deviceRoomPosition);
  18375. camRight.position.copyFrom(this._deviceRoomPosition);
  18376. };
  18377. // Remove translation from 6dof headset if trackposition is set to false
  18378. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  18379. if (isViewMatrix === void 0) { isViewMatrix = false; }
  18380. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  18381. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  18382. if (!isViewMatrix) {
  18383. this._tmpMatrix.invert();
  18384. }
  18385. this._tmpMatrix.multiplyToRef(matrix, matrix);
  18386. }
  18387. };
  18388. /**
  18389. * @hidden
  18390. * Updates the cached values of the camera
  18391. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18392. */
  18393. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  18394. var _this = this;
  18395. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  18396. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  18397. if (!this.updateCacheCalled) {
  18398. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  18399. this.updateCacheCalled = true;
  18400. this.update();
  18401. }
  18402. // Set working vector to the device position in room space rotated by the new rotation
  18403. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  18404. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  18405. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  18406. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  18407. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  18408. // Add translation from anchor position
  18409. this._deviceToWorld.getTranslationToRef(this._workingVector);
  18410. this._workingVector.addInPlace(this.position);
  18411. this._workingVector.subtractInPlace(this._cache.position);
  18412. this._deviceToWorld.setTranslation(this._workingVector);
  18413. // Set an inverted matrix to be used when updating the camera
  18414. this._deviceToWorld.invertToRef(this._worldToDevice);
  18415. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  18416. this.controllers.forEach(function (controller) {
  18417. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  18418. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  18419. controller.update();
  18420. });
  18421. }
  18422. if (!ignoreParentClass) {
  18423. _super.prototype._updateCache.call(this);
  18424. }
  18425. this.updateCacheCalled = false;
  18426. };
  18427. /**
  18428. * @hidden
  18429. * Get current device position in babylon world
  18430. */
  18431. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  18432. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  18433. };
  18434. /**
  18435. * Updates the current device position and rotation in the babylon world
  18436. */
  18437. WebVRFreeCamera.prototype.update = function () {
  18438. this._computeDevicePosition();
  18439. // Get current device rotation in babylon world
  18440. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  18441. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  18442. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  18443. if (this._poseSet) {
  18444. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  18445. }
  18446. _super.prototype.update.call(this);
  18447. };
  18448. /**
  18449. * @hidden
  18450. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18451. * @returns an identity matrix
  18452. */
  18453. WebVRFreeCamera.prototype._getViewMatrix = function () {
  18454. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18455. };
  18456. /**
  18457. * This function is called by the two RIG cameras.
  18458. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18459. * @hidden
  18460. */
  18461. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  18462. // Update the parent camera prior to using a child camera to avoid desynchronization
  18463. var parentCamera = this._cameraRigParams["parentCamera"];
  18464. parentCamera._updateCache();
  18465. //WebVR 1.1
  18466. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  18467. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  18468. if (!this.getScene().useRightHandedSystem) {
  18469. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  18470. }
  18471. // update the camera rotation matrix
  18472. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  18473. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  18474. // Computing target and final matrix
  18475. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  18476. // should the view matrix be updated with scale and position offset?
  18477. if (parentCamera.deviceScaleFactor !== 1) {
  18478. this._webvrViewMatrix.invert();
  18479. // scale the position, if set
  18480. if (parentCamera.deviceScaleFactor) {
  18481. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  18482. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  18483. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  18484. }
  18485. this._webvrViewMatrix.invert();
  18486. }
  18487. // Remove translation from 6dof headset if trackposition is set to false
  18488. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  18489. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  18490. // Compute global position
  18491. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18492. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  18493. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  18494. this._workingMatrix.getTranslationToRef(this._globalPosition);
  18495. this._markSyncedWithParent();
  18496. return this._webvrViewMatrix;
  18497. };
  18498. /** @hidden */
  18499. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  18500. var parentCamera = this.parent;
  18501. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  18502. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  18503. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  18504. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  18505. //babylon compatible matrix
  18506. if (!this.getScene().useRightHandedSystem) {
  18507. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18508. }
  18509. return this._projectionMatrix;
  18510. };
  18511. /**
  18512. * Initializes the controllers and their meshes
  18513. */
  18514. WebVRFreeCamera.prototype.initControllers = function () {
  18515. var _this = this;
  18516. this.controllers = [];
  18517. var manager = this.getScene().gamepadManager;
  18518. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  18519. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18520. var webVrController = gamepad;
  18521. if (webVrController.defaultModel) {
  18522. webVrController.defaultModel.setEnabled(false);
  18523. }
  18524. if (webVrController.hand === "right") {
  18525. _this._rightController = null;
  18526. }
  18527. if (webVrController.hand === "left") {
  18528. _this._leftController = null;
  18529. }
  18530. var controllerIndex = _this.controllers.indexOf(webVrController);
  18531. if (controllerIndex !== -1) {
  18532. _this.controllers.splice(controllerIndex, 1);
  18533. }
  18534. }
  18535. });
  18536. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  18537. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18538. var webVrController_1 = gamepad;
  18539. if (!_this.webVROptions.trackPosition) {
  18540. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  18541. // Cache must be updated before rendering controllers to avoid them being one frame behind
  18542. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  18543. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  18544. _this._updateCache();
  18545. });
  18546. }
  18547. }
  18548. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  18549. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  18550. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  18551. if (_this.webVROptions.controllerMeshes) {
  18552. if (webVrController_1.defaultModel) {
  18553. webVrController_1.defaultModel.setEnabled(true);
  18554. }
  18555. else {
  18556. // Load the meshes
  18557. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  18558. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  18559. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  18560. if (_this.webVROptions.defaultLightingOnControllers) {
  18561. if (!_this._lightOnControllers) {
  18562. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  18563. }
  18564. var activateLightOnSubMeshes_1 = function (mesh, light) {
  18565. var children = mesh.getChildren();
  18566. if (children && children.length !== 0) {
  18567. children.forEach(function (mesh) {
  18568. light.includedOnlyMeshes.push(mesh);
  18569. activateLightOnSubMeshes_1(mesh, light);
  18570. });
  18571. }
  18572. };
  18573. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  18574. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  18575. }
  18576. });
  18577. }
  18578. }
  18579. webVrController_1.attachToPoseControlledCamera(_this);
  18580. // since this is async - sanity check. Is the controller already stored?
  18581. if (_this.controllers.indexOf(webVrController_1) === -1) {
  18582. //add to the controllers array
  18583. _this.controllers.push(webVrController_1);
  18584. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  18585. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  18586. // So we're overriding setting left & right manually to be sure
  18587. var firstViveWandDetected = false;
  18588. for (var i = 0; i < _this.controllers.length; i++) {
  18589. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  18590. if (!firstViveWandDetected) {
  18591. firstViveWandDetected = true;
  18592. _this.controllers[i].hand = "left";
  18593. }
  18594. else {
  18595. _this.controllers[i].hand = "right";
  18596. }
  18597. }
  18598. }
  18599. //did we find enough controllers? Great! let the developer know.
  18600. if (_this.controllers.length >= 2) {
  18601. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  18602. }
  18603. }
  18604. }
  18605. });
  18606. };
  18607. return WebVRFreeCamera;
  18608. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  18609. /***/ }),
  18610. /***/ "./Cameras/XR/index.ts":
  18611. /*!*****************************!*\
  18612. !*** ./Cameras/XR/index.ts ***!
  18613. \*****************************/
  18614. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  18615. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18616. "use strict";
  18617. __webpack_require__.r(__webpack_exports__);
  18618. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  18620. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  18621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  18622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  18623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  18624. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  18626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  18627. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  18628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  18629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  18630. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  18631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  18632. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  18634. /***/ }),
  18635. /***/ "./Cameras/XR/webXRCamera.ts":
  18636. /*!***********************************!*\
  18637. !*** ./Cameras/XR/webXRCamera.ts ***!
  18638. \***********************************/
  18639. /*! exports provided: WebXRCamera */
  18640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18641. "use strict";
  18642. __webpack_require__.r(__webpack_exports__);
  18643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18644. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18645. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18646. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18647. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18648. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18649. /**
  18650. * WebXR Camera which holds the views for the xrSession
  18651. * @see https://doc.babylonjs.com/how_to/webxr
  18652. */
  18653. var WebXRCamera = /** @class */ (function (_super) {
  18654. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18655. /**
  18656. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18657. * @param name the name of the camera
  18658. * @param scene the scene to add the camera to
  18659. */
  18660. function WebXRCamera(name, scene) {
  18661. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18662. // Initial camera configuration
  18663. _this.minZ = 0;
  18664. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18665. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18666. _this.updateUpVectorFromRotation = true;
  18667. _this._updateNumberOfRigCameras(1);
  18668. return _this;
  18669. }
  18670. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18671. if (viewCount === void 0) { viewCount = 1; }
  18672. while (this.rigCameras.length < viewCount) {
  18673. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18674. newCamera.minZ = 0;
  18675. newCamera.parent = this;
  18676. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18677. newCamera.updateUpVectorFromRotation = true;
  18678. this.rigCameras.push(newCamera);
  18679. }
  18680. while (this.rigCameras.length > viewCount) {
  18681. var removedCamera = this.rigCameras.pop();
  18682. if (removedCamera) {
  18683. removedCamera.dispose();
  18684. }
  18685. }
  18686. };
  18687. /** @hidden */
  18688. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18689. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18690. // Create initial camera rigs
  18691. this._updateNumberOfRigCameras(2);
  18692. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18693. this.rigCameras[0].position.x = -pupilDistance / 2;
  18694. this.rigCameras[0].outputRenderTarget = null;
  18695. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18696. this.rigCameras[1].position.x = pupilDistance / 2;
  18697. this.rigCameras[1].outputRenderTarget = null;
  18698. };
  18699. /**
  18700. * Updates the cameras position from the current pose information of the XR session
  18701. * @param xrSessionManager the session containing pose information
  18702. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18703. */
  18704. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18705. var _this = this;
  18706. // Ensure all frame data is available
  18707. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18708. return false;
  18709. }
  18710. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18711. if (!pose || !pose.poseModelMatrix) {
  18712. return false;
  18713. }
  18714. // Update the parent cameras matrix
  18715. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18716. if (!this._scene.useRightHandedSystem) {
  18717. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18718. }
  18719. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18720. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18721. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18722. this.computeWorldMatrix();
  18723. // Update camera rigs
  18724. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18725. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18726. // Update view/projection matrix
  18727. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18728. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18729. if (!_this._scene.useRightHandedSystem) {
  18730. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18731. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18732. }
  18733. // Update viewport
  18734. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18735. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18736. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18737. _this.rigCameras[i].viewport.width = viewport.width / width;
  18738. _this.rigCameras[i].viewport.height = viewport.height / height;
  18739. _this.rigCameras[i].viewport.x = viewport.x / width;
  18740. _this.rigCameras[i].viewport.y = viewport.y / height;
  18741. // Set cameras to render to the session's render target
  18742. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18743. });
  18744. return true;
  18745. };
  18746. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18747. return WebXRCamera;
  18748. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18749. /***/ }),
  18750. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18751. /*!****************************************!*\
  18752. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18753. \****************************************/
  18754. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18756. "use strict";
  18757. __webpack_require__.r(__webpack_exports__);
  18758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18761. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18762. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18763. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18764. /**
  18765. * Button which can be used to enter a different mode of XR
  18766. */
  18767. var WebXREnterExitUIButton = /** @class */ (function () {
  18768. /**
  18769. * Creates a WebXREnterExitUIButton
  18770. * @param element button element
  18771. * @param initializationOptions XR initialization options for the button
  18772. */
  18773. function WebXREnterExitUIButton(
  18774. /** button element */
  18775. element,
  18776. /** XR initialization options for the button */
  18777. initializationOptions) {
  18778. this.element = element;
  18779. this.initializationOptions = initializationOptions;
  18780. }
  18781. /**
  18782. * Overwritable function which can be used to update the button's visuals when the state changes
  18783. * @param activeButton the current active button in the UI
  18784. */
  18785. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18786. };
  18787. return WebXREnterExitUIButton;
  18788. }());
  18789. /**
  18790. * Options to create the webXR UI
  18791. */
  18792. var WebXREnterExitUIOptions = /** @class */ (function () {
  18793. function WebXREnterExitUIOptions() {
  18794. }
  18795. return WebXREnterExitUIOptions;
  18796. }());
  18797. /**
  18798. * UI to allow the user to enter/exit XR mode
  18799. */
  18800. var WebXREnterExitUI = /** @class */ (function () {
  18801. function WebXREnterExitUI(scene, options) {
  18802. var _this = this;
  18803. this.scene = scene;
  18804. this._buttons = [];
  18805. this._activeButton = null;
  18806. /**
  18807. * Fired every time the active button is changed.
  18808. *
  18809. * When xr is entered via a button that launches xr that button will be the callback parameter
  18810. *
  18811. * When exiting xr the callback parameter will be null)
  18812. */
  18813. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18814. this._overlay = document.createElement("div");
  18815. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18816. if (options.customButtons) {
  18817. this._buttons = options.customButtons;
  18818. }
  18819. else {
  18820. var hmdBtn = document.createElement("button");
  18821. 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;";
  18822. hmdBtn.innerText = "HMD";
  18823. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18824. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18825. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18826. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18827. };
  18828. var windowBtn = document.createElement("button");
  18829. windowBtn.style.cssText = hmdBtn.style.cssText;
  18830. windowBtn.innerText = "Window";
  18831. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18832. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18833. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18834. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18835. };
  18836. this._updateButtons(null);
  18837. }
  18838. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18839. if (renderCanvas && renderCanvas.parentNode) {
  18840. renderCanvas.parentNode.appendChild(this._overlay);
  18841. scene.onDisposeObservable.addOnce(function () {
  18842. _this.dispose();
  18843. });
  18844. }
  18845. }
  18846. /**
  18847. * Creates UI to allow the user to enter/exit XR mode
  18848. * @param scene the scene to add the ui to
  18849. * @param helper the xr experience helper to enter/exit xr with
  18850. * @param options options to configure the UI
  18851. * @returns the created ui
  18852. */
  18853. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18854. var _this = this;
  18855. var ui = new WebXREnterExitUI(scene, options);
  18856. var supportedPromises = ui._buttons.map(function (btn) {
  18857. return helper.supportsSessionAsync(btn.initializationOptions);
  18858. });
  18859. helper.onStateChangedObservable.add(function (state) {
  18860. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18861. ui._updateButtons(null);
  18862. }
  18863. });
  18864. return Promise.all(supportedPromises).then(function (results) {
  18865. results.forEach(function (supported, i) {
  18866. if (supported) {
  18867. ui._overlay.appendChild(ui._buttons[i].element);
  18868. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18869. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18870. switch (_a.label) {
  18871. case 0:
  18872. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18873. ui._updateButtons(null);
  18874. return [4 /*yield*/, helper.exitXRAsync()];
  18875. case 1:
  18876. _a.sent();
  18877. return [2 /*return*/];
  18878. case 2:
  18879. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18880. ui._updateButtons(ui._buttons[i]);
  18881. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18882. case 3:
  18883. _a.sent();
  18884. _a.label = 4;
  18885. case 4: return [2 /*return*/];
  18886. }
  18887. });
  18888. }); };
  18889. }
  18890. });
  18891. return ui;
  18892. });
  18893. };
  18894. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18895. var _this = this;
  18896. this._activeButton = activeButton;
  18897. this._buttons.forEach(function (b) {
  18898. b.update(_this._activeButton);
  18899. });
  18900. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18901. };
  18902. /**
  18903. * Disposes of the object
  18904. */
  18905. WebXREnterExitUI.prototype.dispose = function () {
  18906. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18907. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18908. renderCanvas.parentNode.removeChild(this._overlay);
  18909. }
  18910. this.activeButtonChangedObservable.clear();
  18911. };
  18912. return WebXREnterExitUI;
  18913. }());
  18914. /***/ }),
  18915. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18916. /*!*********************************************!*\
  18917. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18918. \*********************************************/
  18919. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18920. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18921. "use strict";
  18922. __webpack_require__.r(__webpack_exports__);
  18923. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18925. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18926. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18927. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18928. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18929. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18930. /**
  18931. * States of the webXR experience
  18932. */
  18933. var WebXRState;
  18934. (function (WebXRState) {
  18935. /**
  18936. * Transitioning to being in XR mode
  18937. */
  18938. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18939. /**
  18940. * Transitioning to non XR mode
  18941. */
  18942. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18943. /**
  18944. * In XR mode and presenting
  18945. */
  18946. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18947. /**
  18948. * Not entered XR mode
  18949. */
  18950. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18951. })(WebXRState || (WebXRState = {}));
  18952. /**
  18953. * Helper class used to enable XR
  18954. * @see https://doc.babylonjs.com/how_to/webxr
  18955. */
  18956. var WebXRExperienceHelper = /** @class */ (function () {
  18957. /**
  18958. * Creates a WebXRExperienceHelper
  18959. * @param scene The scene the helper should be created in
  18960. */
  18961. function WebXRExperienceHelper(scene) {
  18962. this.scene = scene;
  18963. /**
  18964. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18965. */
  18966. this.state = WebXRState.NOT_IN_XR;
  18967. /**
  18968. * Fires when the state of the experience helper has changed
  18969. */
  18970. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18971. this._nonVRCamera = null;
  18972. this._originalSceneAutoClear = true;
  18973. this._supported = false;
  18974. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18975. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18976. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18977. this.camera.parent = this.container;
  18978. }
  18979. WebXRExperienceHelper.prototype._setState = function (val) {
  18980. this.state = val;
  18981. this.onStateChangedObservable.notifyObservers(this.state);
  18982. };
  18983. /**
  18984. * Creates the experience helper
  18985. * @param scene the scene to attach the experience helper to
  18986. * @returns a promise for the experience helper
  18987. */
  18988. WebXRExperienceHelper.CreateAsync = function (scene) {
  18989. var helper = new WebXRExperienceHelper(scene);
  18990. return helper._sessionManager.initializeAsync().then(function () {
  18991. helper._supported = true;
  18992. return helper;
  18993. }).catch(function () {
  18994. return helper;
  18995. });
  18996. };
  18997. /**
  18998. * Exits XR mode and returns the scene to its original state
  18999. * @returns promise that resolves after xr mode has exited
  19000. */
  19001. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  19002. this._setState(WebXRState.EXITING_XR);
  19003. return this._sessionManager.exitXRAsync();
  19004. };
  19005. /**
  19006. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  19007. * @param sessionCreationOptions options for the XR session
  19008. * @param frameOfReference frame of reference of the XR session
  19009. * @returns promise that resolves after xr mode has entered
  19010. */
  19011. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  19012. var _this = this;
  19013. if (!this._supported) {
  19014. throw "XR session not supported by this browser";
  19015. }
  19016. this._setState(WebXRState.ENTERING_XR);
  19017. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  19018. // Cache pre xr scene settings
  19019. _this._originalSceneAutoClear = _this.scene.autoClear;
  19020. _this._nonVRCamera = _this.scene.activeCamera;
  19021. // Overwrite current scene settings
  19022. _this.scene.autoClear = false;
  19023. _this.scene.activeCamera = _this.camera;
  19024. _this._sessionManager.onXRFrameObservable.add(function () {
  19025. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  19026. });
  19027. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  19028. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  19029. _this.camera.rigCameras.forEach(function (c) {
  19030. c.outputRenderTarget = null;
  19031. });
  19032. // Restore scene settings
  19033. _this.scene.autoClear = _this._originalSceneAutoClear;
  19034. _this.scene.activeCamera = _this._nonVRCamera;
  19035. _this._sessionManager.onXRFrameObservable.clear();
  19036. _this._setState(WebXRState.NOT_IN_XR);
  19037. });
  19038. _this._setState(WebXRState.IN_XR);
  19039. });
  19040. };
  19041. /**
  19042. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  19043. * @param ray ray to cast into the environment
  19044. * @returns Promise which resolves with a collision point in the environment if it exists
  19045. */
  19046. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  19047. return this._sessionManager.environmentPointHitTestAsync(ray);
  19048. };
  19049. /**
  19050. * Updates the global position of the camera by moving the camera's container
  19051. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  19052. * @param position The desired global position of the camera
  19053. */
  19054. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  19055. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  19056. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  19057. };
  19058. /**
  19059. * Rotates the xr camera by rotating the camera's container around the camera's position
  19060. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  19061. * @param rotation the desired quaternion rotation to apply to the camera
  19062. */
  19063. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  19064. if (!this.container.rotationQuaternion) {
  19065. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  19066. }
  19067. this.container.rotationQuaternion.multiplyInPlace(rotation);
  19068. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  19069. };
  19070. /**
  19071. * Checks if the creation options are supported by the xr session
  19072. * @param options creation options
  19073. * @returns true if supported
  19074. */
  19075. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  19076. if (!this._supported) {
  19077. return Promise.resolve(false);
  19078. }
  19079. return this._sessionManager.supportsSessionAsync(options);
  19080. };
  19081. /**
  19082. * Disposes of the experience helper
  19083. */
  19084. WebXRExperienceHelper.prototype.dispose = function () {
  19085. this.camera.dispose();
  19086. this.container.dispose();
  19087. this.onStateChangedObservable.clear();
  19088. this._sessionManager.dispose();
  19089. };
  19090. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  19091. return WebXRExperienceHelper;
  19092. }());
  19093. /***/ }),
  19094. /***/ "./Cameras/XR/webXRInput.ts":
  19095. /*!**********************************!*\
  19096. !*** ./Cameras/XR/webXRInput.ts ***!
  19097. \**********************************/
  19098. /*! exports provided: WebXRController, WebXRInput */
  19099. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19100. "use strict";
  19101. __webpack_require__.r(__webpack_exports__);
  19102. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  19103. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  19104. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  19105. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  19106. /**
  19107. * Represents an XR input
  19108. */
  19109. var WebXRController = /** @class */ (function () {
  19110. /**
  19111. * Creates the controller
  19112. * @see https://doc.babylonjs.com/how_to/webxr
  19113. * @param scene the scene which the controller should be associated to
  19114. */
  19115. function WebXRController(scene) {
  19116. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  19117. }
  19118. /**
  19119. * Disposes of the object
  19120. */
  19121. WebXRController.prototype.dispose = function () {
  19122. if (this.grip) {
  19123. this.grip.dispose();
  19124. }
  19125. this.pointer.dispose();
  19126. };
  19127. return WebXRController;
  19128. }());
  19129. /**
  19130. * XR input used to track XR inputs such as controllers/rays
  19131. */
  19132. var WebXRInput = /** @class */ (function () {
  19133. /**
  19134. * Initializes the WebXRInput
  19135. * @param helper experience helper which the input should be created for
  19136. */
  19137. function WebXRInput(helper) {
  19138. var _this = this;
  19139. this.helper = helper;
  19140. /**
  19141. * XR controllers being tracked
  19142. */
  19143. this.controllers = [];
  19144. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  19145. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  19146. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  19147. return;
  19148. }
  19149. var xrFrame = helper._sessionManager._currentXRFrame;
  19150. var inputSources = helper._sessionManager._xrSession.getInputSources();
  19151. inputSources.forEach(function (input, i) {
  19152. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  19153. if (inputPose) {
  19154. if (_this.controllers.length <= i) {
  19155. _this.controllers.push(new WebXRController(helper.container.getScene()));
  19156. }
  19157. var controller = _this.controllers[i];
  19158. // Manage the grip if it exists
  19159. if (inputPose.gripMatrix) {
  19160. if (!controller.grip) {
  19161. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  19162. }
  19163. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  19164. if (!controller.grip.getScene().useRightHandedSystem) {
  19165. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  19166. }
  19167. if (!controller.grip.rotationQuaternion) {
  19168. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  19169. }
  19170. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  19171. }
  19172. // Manager pointer of controller
  19173. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  19174. if (!controller.pointer.getScene().useRightHandedSystem) {
  19175. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  19176. }
  19177. if (!controller.pointer.rotationQuaternion) {
  19178. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  19179. }
  19180. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  19181. }
  19182. });
  19183. });
  19184. }
  19185. /**
  19186. * Disposes of the object
  19187. */
  19188. WebXRInput.prototype.dispose = function () {
  19189. this.controllers.forEach(function (c) {
  19190. c.dispose();
  19191. });
  19192. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  19193. };
  19194. return WebXRInput;
  19195. }());
  19196. /***/ }),
  19197. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  19198. /*!************************************************!*\
  19199. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  19200. \************************************************/
  19201. /*! exports provided: WebXRManagedOutputCanvas */
  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__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  19206. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  19207. /**
  19208. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  19209. */
  19210. var WebXRManagedOutputCanvas = /** @class */ (function () {
  19211. /**
  19212. * Initializes the canvas to be added/removed upon entering/exiting xr
  19213. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  19214. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  19215. */
  19216. function WebXRManagedOutputCanvas(helper, canvas) {
  19217. var _this = this;
  19218. this._canvas = null;
  19219. /**
  19220. * xrpresent context of the canvas which can be used to display/mirror xr content
  19221. */
  19222. this.canvasContext = null;
  19223. if (!canvas) {
  19224. canvas = document.createElement('canvas');
  19225. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  19226. }
  19227. this._setManagedOutputCanvas(canvas);
  19228. helper.onStateChangedObservable.add(function (stateInfo) {
  19229. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  19230. // 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
  19231. _this._addCanvas();
  19232. }
  19233. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  19234. _this._removeCanvas();
  19235. }
  19236. });
  19237. }
  19238. /**
  19239. * Disposes of the object
  19240. */
  19241. WebXRManagedOutputCanvas.prototype.dispose = function () {
  19242. this._removeCanvas();
  19243. this._setManagedOutputCanvas(null);
  19244. };
  19245. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  19246. this._removeCanvas();
  19247. if (!canvas) {
  19248. this._canvas = null;
  19249. this.canvasContext = null;
  19250. }
  19251. else {
  19252. this._canvas = canvas;
  19253. this.canvasContext = this._canvas.getContext('xrpresent');
  19254. }
  19255. };
  19256. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  19257. if (this._canvas) {
  19258. document.body.appendChild(this._canvas);
  19259. }
  19260. };
  19261. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  19262. if (this._canvas && document.body.contains(this._canvas)) {
  19263. document.body.removeChild(this._canvas);
  19264. }
  19265. };
  19266. return WebXRManagedOutputCanvas;
  19267. }());
  19268. /***/ }),
  19269. /***/ "./Cameras/XR/webXRSessionManager.ts":
  19270. /*!*******************************************!*\
  19271. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  19272. \*******************************************/
  19273. /*! exports provided: WebXRSessionManager */
  19274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19275. "use strict";
  19276. __webpack_require__.r(__webpack_exports__);
  19277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  19278. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  19279. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  19280. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  19281. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  19282. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  19283. /**
  19284. * Manages an XRSession
  19285. * @see https://doc.babylonjs.com/how_to/webxr
  19286. */
  19287. var WebXRSessionManager = /** @class */ (function () {
  19288. /**
  19289. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  19290. * @param scene The scene which the session should be created for
  19291. */
  19292. function WebXRSessionManager(scene) {
  19293. this.scene = scene;
  19294. /**
  19295. * Fires every time a new xrFrame arrives which can be used to update the camera
  19296. */
  19297. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19298. /**
  19299. * Fires when the xr session is ended either by the device or manually done
  19300. */
  19301. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19302. /** @hidden */
  19303. this._sessionRenderTargetTexture = null;
  19304. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  19305. }
  19306. /**
  19307. * Initializes the manager
  19308. * After initialization enterXR can be called to start an XR session
  19309. * @returns Promise which resolves after it is initialized
  19310. */
  19311. WebXRSessionManager.prototype.initializeAsync = function () {
  19312. var _this = this;
  19313. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  19314. // Check if the browser supports webXR
  19315. this._xrNavigator = navigator;
  19316. if (!this._xrNavigator.xr) {
  19317. return Promise.reject("webXR not supported by this browser");
  19318. }
  19319. // Request the webXR device
  19320. return this._xrNavigator.xr.requestDevice().then(function (device) {
  19321. _this._xrDevice = device;
  19322. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  19323. });
  19324. };
  19325. /**
  19326. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  19327. * @param sessionCreationOptions xr options to create the session with
  19328. * @param frameOfReferenceType option to configure how the xr pose is expressed
  19329. * @returns Promise which resolves after it enters XR
  19330. */
  19331. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  19332. var _this = this;
  19333. // initialize session
  19334. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  19335. _this._xrSession = session;
  19336. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  19337. _this._xrSession.addEventListener("end", function () {
  19338. // Remove render target texture and notify frame obervers
  19339. _this._sessionRenderTargetTexture = null;
  19340. // Restore frame buffer to avoid clear on xr framebuffer after session end
  19341. _this.scene.getEngine().restoreDefaultFramebuffer();
  19342. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  19343. _this.scene.getEngine().customAnimationFrameRequester = null;
  19344. _this.onXRSessionEnded.notifyObservers(null);
  19345. _this.scene.getEngine()._renderLoop();
  19346. }, { once: true });
  19347. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  19348. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  19349. }).then(function (frameOfRef) {
  19350. _this._frameOfReference = frameOfRef;
  19351. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  19352. _this.scene.getEngine().customAnimationFrameRequester = {
  19353. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  19354. renderFunction: function (timestamp, xrFrame) {
  19355. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  19356. _this._currentXRFrame = xrFrame;
  19357. _this.onXRFrameObservable.notifyObservers(null);
  19358. _this.scene.getEngine()._renderLoop();
  19359. }
  19360. };
  19361. // Create render target texture from xr's webgl render target
  19362. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  19363. // Stop window's animation frame and trigger sessions animation frame
  19364. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  19365. _this.scene.getEngine()._renderLoop();
  19366. });
  19367. };
  19368. /**
  19369. * Stops the xrSession and restores the renderloop
  19370. * @returns Promise which resolves after it exits XR
  19371. */
  19372. WebXRSessionManager.prototype.exitXRAsync = function () {
  19373. return this._xrSession.end();
  19374. };
  19375. /**
  19376. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  19377. * @param ray ray to cast into the environment
  19378. * @returns Promise which resolves with a collision point in the environment if it exists
  19379. */
  19380. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  19381. var _this = this;
  19382. return new Promise(function (res) {
  19383. // Compute left handed inputs to request hit test
  19384. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  19385. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  19386. if (!_this.scene.useRightHandedSystem) {
  19387. origin[2] *= -1;
  19388. direction[2] *= -1;
  19389. }
  19390. // Fire hittest
  19391. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  19392. .then(function (hits) {
  19393. if (hits.length > 0) {
  19394. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  19395. var hitPoint = _this._tmpMatrix.getTranslation();
  19396. if (!_this.scene.useRightHandedSystem) {
  19397. hitPoint.z *= -1;
  19398. }
  19399. res(hitPoint);
  19400. }
  19401. else {
  19402. res(null);
  19403. }
  19404. }).catch(function () {
  19405. res(null);
  19406. });
  19407. });
  19408. };
  19409. /**
  19410. * Checks if a session would be supported for the creation options specified
  19411. * @param options creation options to check if they are supported
  19412. * @returns true if supported
  19413. */
  19414. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  19415. return this._xrDevice.supportsSession(options).then(function () {
  19416. return true;
  19417. }).catch(function () {
  19418. return false;
  19419. });
  19420. };
  19421. /**
  19422. * @hidden
  19423. * Converts the render layer of xrSession to a render target
  19424. * @param session session to create render target for
  19425. * @param scene scene the new render target should be created for
  19426. */
  19427. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  19428. // Create internal texture
  19429. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  19430. internalTexture.width = session.baseLayer.framebufferWidth;
  19431. internalTexture.height = session.baseLayer.framebufferHeight;
  19432. internalTexture._framebuffer = session.baseLayer.framebuffer;
  19433. // Create render target texture from the internal texture
  19434. 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);
  19435. renderTargetTexture._texture = internalTexture;
  19436. return renderTargetTexture;
  19437. };
  19438. /**
  19439. * Disposes of the session manager
  19440. */
  19441. WebXRSessionManager.prototype.dispose = function () {
  19442. this.onXRFrameObservable.clear();
  19443. this.onXRSessionEnded.clear();
  19444. };
  19445. return WebXRSessionManager;
  19446. }());
  19447. /***/ }),
  19448. /***/ "./Cameras/arcRotateCamera.ts":
  19449. /*!************************************!*\
  19450. !*** ./Cameras/arcRotateCamera.ts ***!
  19451. \************************************/
  19452. /*! exports provided: ArcRotateCamera */
  19453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19454. "use strict";
  19455. __webpack_require__.r(__webpack_exports__);
  19456. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  19457. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19458. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19459. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19460. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19461. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  19462. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  19463. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  19464. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  19465. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  19466. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  19467. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  19468. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  19469. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  19470. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  19471. });
  19472. /**
  19473. * This represents an orbital type of camera.
  19474. *
  19475. * 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.
  19476. * 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.
  19477. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  19478. */
  19479. var ArcRotateCamera = /** @class */ (function (_super) {
  19480. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  19481. /**
  19482. * Instantiates a new ArcRotateCamera in a given scene
  19483. * @param name Defines the name of the camera
  19484. * @param alpha Defines the camera rotation along the logitudinal axis
  19485. * @param beta Defines the camera rotation along the latitudinal axis
  19486. * @param radius Defines the camera distance from its target
  19487. * @param target Defines the camera target
  19488. * @param scene Defines the scene the camera belongs to
  19489. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19490. */
  19491. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  19492. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19493. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  19494. _this._upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  19495. /**
  19496. * Current inertia value on the longitudinal axis.
  19497. * The bigger this number the longer it will take for the camera to stop.
  19498. */
  19499. _this.inertialAlphaOffset = 0;
  19500. /**
  19501. * Current inertia value on the latitudinal axis.
  19502. * The bigger this number the longer it will take for the camera to stop.
  19503. */
  19504. _this.inertialBetaOffset = 0;
  19505. /**
  19506. * Current inertia value on the radius axis.
  19507. * The bigger this number the longer it will take for the camera to stop.
  19508. */
  19509. _this.inertialRadiusOffset = 0;
  19510. /**
  19511. * Minimum allowed angle on the longitudinal axis.
  19512. * This can help limiting how the Camera is able to move in the scene.
  19513. */
  19514. _this.lowerAlphaLimit = null;
  19515. /**
  19516. * Maximum allowed angle on the longitudinal axis.
  19517. * This can help limiting how the Camera is able to move in the scene.
  19518. */
  19519. _this.upperAlphaLimit = null;
  19520. /**
  19521. * Minimum allowed angle on the latitudinal axis.
  19522. * This can help limiting how the Camera is able to move in the scene.
  19523. */
  19524. _this.lowerBetaLimit = 0.01;
  19525. /**
  19526. * Maximum allowed angle on the latitudinal axis.
  19527. * This can help limiting how the Camera is able to move in the scene.
  19528. */
  19529. _this.upperBetaLimit = Math.PI - 0.01;
  19530. /**
  19531. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  19532. * This can help limiting how the Camera is able to move in the scene.
  19533. */
  19534. _this.lowerRadiusLimit = null;
  19535. /**
  19536. * Maximum allowed distance of the camera to the target (The camera can not get further).
  19537. * This can help limiting how the Camera is able to move in the scene.
  19538. */
  19539. _this.upperRadiusLimit = null;
  19540. /**
  19541. * Defines the current inertia value used during panning of the camera along the X axis.
  19542. */
  19543. _this.inertialPanningX = 0;
  19544. /**
  19545. * Defines the current inertia value used during panning of the camera along the Y axis.
  19546. */
  19547. _this.inertialPanningY = 0;
  19548. /**
  19549. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  19550. * Basically if your fingers moves away from more than this distance you will be considered
  19551. * in pinch mode.
  19552. */
  19553. _this.pinchToPanMaxDistance = 20;
  19554. /**
  19555. * Defines the maximum distance the camera can pan.
  19556. * This could help keeping the cammera always in your scene.
  19557. */
  19558. _this.panningDistanceLimit = null;
  19559. /**
  19560. * Defines the target of the camera before paning.
  19561. */
  19562. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19563. /**
  19564. * Defines the value of the inertia used during panning.
  19565. * 0 would mean stop inertia and one would mean no decelleration at all.
  19566. */
  19567. _this.panningInertia = 0.9;
  19568. //-- end properties for backward compatibility for inputs
  19569. /**
  19570. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  19571. */
  19572. _this.zoomOnFactor = 1;
  19573. /**
  19574. * Defines a screen offset for the camera position.
  19575. */
  19576. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19577. /**
  19578. * Allows the camera to be completely reversed.
  19579. * If false the camera can not arrive upside down.
  19580. */
  19581. _this.allowUpsideDown = true;
  19582. /**
  19583. * Define if double tap/click is used to restore the previously saved state of the camera.
  19584. */
  19585. _this.useInputToRestoreState = true;
  19586. /** @hidden */
  19587. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19588. /**
  19589. * Defines the allowed panning axis.
  19590. */
  19591. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  19592. /**
  19593. * Observable triggered when the mesh target has been changed on the camera.
  19594. */
  19595. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  19596. /**
  19597. * Defines whether the camera should check collision with the objects oh the scene.
  19598. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  19599. */
  19600. _this.checkCollisions = false;
  19601. /**
  19602. * Defines the collision radius of the camera.
  19603. * This simulates a sphere around the camera.
  19604. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19605. */
  19606. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  19607. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19608. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19609. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19610. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19611. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  19612. if (collidedMesh === void 0) { collidedMesh = null; }
  19613. if (!collidedMesh) {
  19614. _this._previousPosition.copyFrom(_this._position);
  19615. }
  19616. else {
  19617. _this.setPosition(newPosition);
  19618. if (_this.onCollide) {
  19619. _this.onCollide(collidedMesh);
  19620. }
  19621. }
  19622. // Recompute because of constraints
  19623. var cosa = Math.cos(_this.alpha);
  19624. var sina = Math.sin(_this.alpha);
  19625. var cosb = Math.cos(_this.beta);
  19626. var sinb = Math.sin(_this.beta);
  19627. if (sinb === 0) {
  19628. sinb = 0.0001;
  19629. }
  19630. var target = _this._getTargetPosition();
  19631. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  19632. target.addToRef(_this._computationVector, _this._newPosition);
  19633. _this._position.copyFrom(_this._newPosition);
  19634. var up = _this.upVector;
  19635. if (_this.allowUpsideDown && _this.beta < 0) {
  19636. up = up.clone();
  19637. up = up.negate();
  19638. }
  19639. _this._computeViewMatrix(_this._position, target, up);
  19640. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19641. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19642. _this._collisionTriggered = false;
  19643. };
  19644. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19645. if (target) {
  19646. _this.setTarget(target);
  19647. }
  19648. _this.alpha = alpha;
  19649. _this.beta = beta;
  19650. _this.radius = radius;
  19651. _this.getViewMatrix();
  19652. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19653. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19654. return _this;
  19655. }
  19656. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19657. /**
  19658. * Defines the target point of the camera.
  19659. * The camera looks towards it form the radius distance.
  19660. */
  19661. get: function () {
  19662. return this._target;
  19663. },
  19664. set: function (value) {
  19665. this.setTarget(value);
  19666. },
  19667. enumerable: true,
  19668. configurable: true
  19669. });
  19670. Object.defineProperty(ArcRotateCamera.prototype, "position", {
  19671. /**
  19672. * Define the current local position of the camera in the scene
  19673. */
  19674. get: function () {
  19675. return this._position;
  19676. },
  19677. set: function (newPosition) {
  19678. this.setPosition(newPosition);
  19679. },
  19680. enumerable: true,
  19681. configurable: true
  19682. });
  19683. Object.defineProperty(ArcRotateCamera.prototype, "upVector", {
  19684. get: function () {
  19685. return this._upVector;
  19686. },
  19687. /**
  19688. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  19689. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  19690. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  19691. */
  19692. set: function (vec) {
  19693. if (!this._upToYMatrix) {
  19694. this._YToUpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19695. this._upToYMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19696. this._upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19697. }
  19698. vec.normalize();
  19699. this._upVector.copyFrom(vec);
  19700. this.setMatUp();
  19701. },
  19702. enumerable: true,
  19703. configurable: true
  19704. });
  19705. /**
  19706. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  19707. */
  19708. ArcRotateCamera.prototype.setMatUp = function () {
  19709. // from y-up to custom-up (used in _getViewMatrix)
  19710. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAlignToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this._upVector, this._YToUpMatrix);
  19711. // from custom-up to y-up (used in rebuildAnglesAndRadius)
  19712. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAlignToRef(this._upVector, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this._upToYMatrix);
  19713. };
  19714. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19715. //-- begin properties for backward compatibility for inputs
  19716. /**
  19717. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19718. */
  19719. get: function () {
  19720. var pointers = this.inputs.attached["pointers"];
  19721. if (pointers) {
  19722. return pointers.angularSensibilityX;
  19723. }
  19724. return 0;
  19725. },
  19726. set: function (value) {
  19727. var pointers = this.inputs.attached["pointers"];
  19728. if (pointers) {
  19729. pointers.angularSensibilityX = value;
  19730. }
  19731. },
  19732. enumerable: true,
  19733. configurable: true
  19734. });
  19735. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19736. /**
  19737. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19738. */
  19739. get: function () {
  19740. var pointers = this.inputs.attached["pointers"];
  19741. if (pointers) {
  19742. return pointers.angularSensibilityY;
  19743. }
  19744. return 0;
  19745. },
  19746. set: function (value) {
  19747. var pointers = this.inputs.attached["pointers"];
  19748. if (pointers) {
  19749. pointers.angularSensibilityY = value;
  19750. }
  19751. },
  19752. enumerable: true,
  19753. configurable: true
  19754. });
  19755. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19756. /**
  19757. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19758. */
  19759. get: function () {
  19760. var pointers = this.inputs.attached["pointers"];
  19761. if (pointers) {
  19762. return pointers.pinchPrecision;
  19763. }
  19764. return 0;
  19765. },
  19766. set: function (value) {
  19767. var pointers = this.inputs.attached["pointers"];
  19768. if (pointers) {
  19769. pointers.pinchPrecision = value;
  19770. }
  19771. },
  19772. enumerable: true,
  19773. configurable: true
  19774. });
  19775. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19776. /**
  19777. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19778. * It will be used instead of pinchDeltaPrecision if different from 0.
  19779. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19780. */
  19781. get: function () {
  19782. var pointers = this.inputs.attached["pointers"];
  19783. if (pointers) {
  19784. return pointers.pinchDeltaPercentage;
  19785. }
  19786. return 0;
  19787. },
  19788. set: function (value) {
  19789. var pointers = this.inputs.attached["pointers"];
  19790. if (pointers) {
  19791. pointers.pinchDeltaPercentage = value;
  19792. }
  19793. },
  19794. enumerable: true,
  19795. configurable: true
  19796. });
  19797. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19798. /**
  19799. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19800. */
  19801. get: function () {
  19802. var pointers = this.inputs.attached["pointers"];
  19803. if (pointers) {
  19804. return pointers.panningSensibility;
  19805. }
  19806. return 0;
  19807. },
  19808. set: function (value) {
  19809. var pointers = this.inputs.attached["pointers"];
  19810. if (pointers) {
  19811. pointers.panningSensibility = value;
  19812. }
  19813. },
  19814. enumerable: true,
  19815. configurable: true
  19816. });
  19817. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19818. /**
  19819. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19820. */
  19821. get: function () {
  19822. var keyboard = this.inputs.attached["keyboard"];
  19823. if (keyboard) {
  19824. return keyboard.keysUp;
  19825. }
  19826. return [];
  19827. },
  19828. set: function (value) {
  19829. var keyboard = this.inputs.attached["keyboard"];
  19830. if (keyboard) {
  19831. keyboard.keysUp = value;
  19832. }
  19833. },
  19834. enumerable: true,
  19835. configurable: true
  19836. });
  19837. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19838. /**
  19839. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19840. */
  19841. get: function () {
  19842. var keyboard = this.inputs.attached["keyboard"];
  19843. if (keyboard) {
  19844. return keyboard.keysDown;
  19845. }
  19846. return [];
  19847. },
  19848. set: function (value) {
  19849. var keyboard = this.inputs.attached["keyboard"];
  19850. if (keyboard) {
  19851. keyboard.keysDown = value;
  19852. }
  19853. },
  19854. enumerable: true,
  19855. configurable: true
  19856. });
  19857. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19858. /**
  19859. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19860. */
  19861. get: function () {
  19862. var keyboard = this.inputs.attached["keyboard"];
  19863. if (keyboard) {
  19864. return keyboard.keysLeft;
  19865. }
  19866. return [];
  19867. },
  19868. set: function (value) {
  19869. var keyboard = this.inputs.attached["keyboard"];
  19870. if (keyboard) {
  19871. keyboard.keysLeft = value;
  19872. }
  19873. },
  19874. enumerable: true,
  19875. configurable: true
  19876. });
  19877. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19878. /**
  19879. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19880. */
  19881. get: function () {
  19882. var keyboard = this.inputs.attached["keyboard"];
  19883. if (keyboard) {
  19884. return keyboard.keysRight;
  19885. }
  19886. return [];
  19887. },
  19888. set: function (value) {
  19889. var keyboard = this.inputs.attached["keyboard"];
  19890. if (keyboard) {
  19891. keyboard.keysRight = value;
  19892. }
  19893. },
  19894. enumerable: true,
  19895. configurable: true
  19896. });
  19897. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19898. /**
  19899. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19900. */
  19901. get: function () {
  19902. var mousewheel = this.inputs.attached["mousewheel"];
  19903. if (mousewheel) {
  19904. return mousewheel.wheelPrecision;
  19905. }
  19906. return 0;
  19907. },
  19908. set: function (value) {
  19909. var mousewheel = this.inputs.attached["mousewheel"];
  19910. if (mousewheel) {
  19911. mousewheel.wheelPrecision = value;
  19912. }
  19913. },
  19914. enumerable: true,
  19915. configurable: true
  19916. });
  19917. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19918. /**
  19919. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19920. * It will be used instead of pinchDeltaPrecision if different from 0.
  19921. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19922. */
  19923. get: function () {
  19924. var mousewheel = this.inputs.attached["mousewheel"];
  19925. if (mousewheel) {
  19926. return mousewheel.wheelDeltaPercentage;
  19927. }
  19928. return 0;
  19929. },
  19930. set: function (value) {
  19931. var mousewheel = this.inputs.attached["mousewheel"];
  19932. if (mousewheel) {
  19933. mousewheel.wheelDeltaPercentage = value;
  19934. }
  19935. },
  19936. enumerable: true,
  19937. configurable: true
  19938. });
  19939. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19940. /**
  19941. * Gets the bouncing behavior of the camera if it has been enabled.
  19942. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19943. */
  19944. get: function () {
  19945. return this._bouncingBehavior;
  19946. },
  19947. enumerable: true,
  19948. configurable: true
  19949. });
  19950. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19951. /**
  19952. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19953. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19954. */
  19955. get: function () {
  19956. return this._bouncingBehavior != null;
  19957. },
  19958. set: function (value) {
  19959. if (value === this.useBouncingBehavior) {
  19960. return;
  19961. }
  19962. if (value) {
  19963. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19964. this.addBehavior(this._bouncingBehavior);
  19965. }
  19966. else if (this._bouncingBehavior) {
  19967. this.removeBehavior(this._bouncingBehavior);
  19968. this._bouncingBehavior = null;
  19969. }
  19970. },
  19971. enumerable: true,
  19972. configurable: true
  19973. });
  19974. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19975. /**
  19976. * Gets the framing behavior of the camera if it has been enabled.
  19977. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19978. */
  19979. get: function () {
  19980. return this._framingBehavior;
  19981. },
  19982. enumerable: true,
  19983. configurable: true
  19984. });
  19985. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19986. /**
  19987. * Defines if the framing behavior of the camera is enabled on the camera.
  19988. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19989. */
  19990. get: function () {
  19991. return this._framingBehavior != null;
  19992. },
  19993. set: function (value) {
  19994. if (value === this.useFramingBehavior) {
  19995. return;
  19996. }
  19997. if (value) {
  19998. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19999. this.addBehavior(this._framingBehavior);
  20000. }
  20001. else if (this._framingBehavior) {
  20002. this.removeBehavior(this._framingBehavior);
  20003. this._framingBehavior = null;
  20004. }
  20005. },
  20006. enumerable: true,
  20007. configurable: true
  20008. });
  20009. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  20010. /**
  20011. * Gets the auto rotation behavior of the camera if it has been enabled.
  20012. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  20013. */
  20014. get: function () {
  20015. return this._autoRotationBehavior;
  20016. },
  20017. enumerable: true,
  20018. configurable: true
  20019. });
  20020. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  20021. /**
  20022. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  20023. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  20024. */
  20025. get: function () {
  20026. return this._autoRotationBehavior != null;
  20027. },
  20028. set: function (value) {
  20029. if (value === this.useAutoRotationBehavior) {
  20030. return;
  20031. }
  20032. if (value) {
  20033. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  20034. this.addBehavior(this._autoRotationBehavior);
  20035. }
  20036. else if (this._autoRotationBehavior) {
  20037. this.removeBehavior(this._autoRotationBehavior);
  20038. this._autoRotationBehavior = null;
  20039. }
  20040. },
  20041. enumerable: true,
  20042. configurable: true
  20043. });
  20044. // Cache
  20045. /** @hidden */
  20046. ArcRotateCamera.prototype._initCache = function () {
  20047. _super.prototype._initCache.call(this);
  20048. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20049. this._cache.alpha = undefined;
  20050. this._cache.beta = undefined;
  20051. this._cache.radius = undefined;
  20052. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  20053. };
  20054. /** @hidden */
  20055. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  20056. if (!ignoreParentClass) {
  20057. _super.prototype._updateCache.call(this);
  20058. }
  20059. this._cache._target.copyFrom(this._getTargetPosition());
  20060. this._cache.alpha = this.alpha;
  20061. this._cache.beta = this.beta;
  20062. this._cache.radius = this.radius;
  20063. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  20064. };
  20065. ArcRotateCamera.prototype._getTargetPosition = function () {
  20066. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  20067. var pos = this._targetHost.absolutePosition;
  20068. if (this._targetBoundingCenter) {
  20069. pos.addToRef(this._targetBoundingCenter, this._target);
  20070. }
  20071. else {
  20072. this._target.copyFrom(pos);
  20073. }
  20074. }
  20075. var lockedTargetPosition = this._getLockedTargetPosition();
  20076. if (lockedTargetPosition) {
  20077. return lockedTargetPosition;
  20078. }
  20079. return this._target;
  20080. };
  20081. /**
  20082. * Stores the current state of the camera (alpha, beta, radius and target)
  20083. * @returns the camera itself
  20084. */
  20085. ArcRotateCamera.prototype.storeState = function () {
  20086. this._storedAlpha = this.alpha;
  20087. this._storedBeta = this.beta;
  20088. this._storedRadius = this.radius;
  20089. this._storedTarget = this._getTargetPosition().clone();
  20090. return _super.prototype.storeState.call(this);
  20091. };
  20092. /**
  20093. * @hidden
  20094. * Restored camera state. You must call storeState() first
  20095. */
  20096. ArcRotateCamera.prototype._restoreStateValues = function () {
  20097. if (!_super.prototype._restoreStateValues.call(this)) {
  20098. return false;
  20099. }
  20100. this.alpha = this._storedAlpha;
  20101. this.beta = this._storedBeta;
  20102. this.radius = this._storedRadius;
  20103. this.setTarget(this._storedTarget.clone());
  20104. this.inertialAlphaOffset = 0;
  20105. this.inertialBetaOffset = 0;
  20106. this.inertialRadiusOffset = 0;
  20107. this.inertialPanningX = 0;
  20108. this.inertialPanningY = 0;
  20109. return true;
  20110. };
  20111. // Synchronized
  20112. /** @hidden */
  20113. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  20114. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  20115. return false;
  20116. }
  20117. return this._cache._target.equals(this._getTargetPosition())
  20118. && this._cache.alpha === this.alpha
  20119. && this._cache.beta === this.beta
  20120. && this._cache.radius === this.radius
  20121. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  20122. };
  20123. /**
  20124. * Attached controls to the current camera.
  20125. * @param element Defines the element the controls should be listened from
  20126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20127. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  20128. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  20129. */
  20130. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  20131. var _this = this;
  20132. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  20133. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  20134. this._useCtrlForPanning = useCtrlForPanning;
  20135. this._panningMouseButton = panningMouseButton;
  20136. this.inputs.attachElement(element, noPreventDefault);
  20137. this._reset = function () {
  20138. _this.inertialAlphaOffset = 0;
  20139. _this.inertialBetaOffset = 0;
  20140. _this.inertialRadiusOffset = 0;
  20141. _this.inertialPanningX = 0;
  20142. _this.inertialPanningY = 0;
  20143. };
  20144. };
  20145. /**
  20146. * Detach the current controls from the camera.
  20147. * The camera will stop reacting to inputs.
  20148. * @param element Defines the element to stop listening the inputs from
  20149. */
  20150. ArcRotateCamera.prototype.detachControl = function (element) {
  20151. this.inputs.detachElement(element);
  20152. if (this._reset) {
  20153. this._reset();
  20154. }
  20155. };
  20156. /** @hidden */
  20157. ArcRotateCamera.prototype._checkInputs = function () {
  20158. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  20159. if (this._collisionTriggered) {
  20160. return;
  20161. }
  20162. this.inputs.checkInputs();
  20163. // Inertia
  20164. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  20165. var inertialAlphaOffset = this.inertialAlphaOffset;
  20166. if (this.beta <= 0) {
  20167. inertialAlphaOffset *= -1;
  20168. }
  20169. if (this.getScene().useRightHandedSystem) {
  20170. inertialAlphaOffset *= -1;
  20171. }
  20172. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  20173. inertialAlphaOffset *= -1;
  20174. }
  20175. this.alpha += inertialAlphaOffset;
  20176. this.beta += this.inertialBetaOffset;
  20177. this.radius -= this.inertialRadiusOffset;
  20178. this.inertialAlphaOffset *= this.inertia;
  20179. this.inertialBetaOffset *= this.inertia;
  20180. this.inertialRadiusOffset *= this.inertia;
  20181. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20182. this.inertialAlphaOffset = 0;
  20183. }
  20184. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20185. this.inertialBetaOffset = 0;
  20186. }
  20187. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20188. this.inertialRadiusOffset = 0;
  20189. }
  20190. }
  20191. // Panning inertia
  20192. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  20193. if (!this._localDirection) {
  20194. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20195. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20196. }
  20197. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  20198. this._localDirection.multiplyInPlace(this.panningAxis);
  20199. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  20200. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  20201. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  20202. if (!this.panningAxis.y) {
  20203. this._transformedDirection.y = 0;
  20204. }
  20205. if (!this._targetHost) {
  20206. if (this.panningDistanceLimit) {
  20207. this._transformedDirection.addInPlace(this._target);
  20208. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  20209. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  20210. this._target.copyFrom(this._transformedDirection);
  20211. }
  20212. }
  20213. else {
  20214. this._target.addInPlace(this._transformedDirection);
  20215. }
  20216. }
  20217. this.inertialPanningX *= this.panningInertia;
  20218. this.inertialPanningY *= this.panningInertia;
  20219. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20220. this.inertialPanningX = 0;
  20221. }
  20222. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20223. this.inertialPanningY = 0;
  20224. }
  20225. }
  20226. // Limits
  20227. this._checkLimits();
  20228. _super.prototype._checkInputs.call(this);
  20229. };
  20230. ArcRotateCamera.prototype._checkLimits = function () {
  20231. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  20232. if (this.allowUpsideDown && this.beta > Math.PI) {
  20233. this.beta = this.beta - (2 * Math.PI);
  20234. }
  20235. }
  20236. else {
  20237. if (this.beta < this.lowerBetaLimit) {
  20238. this.beta = this.lowerBetaLimit;
  20239. }
  20240. }
  20241. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  20242. if (this.allowUpsideDown && this.beta < -Math.PI) {
  20243. this.beta = this.beta + (2 * Math.PI);
  20244. }
  20245. }
  20246. else {
  20247. if (this.beta > this.upperBetaLimit) {
  20248. this.beta = this.upperBetaLimit;
  20249. }
  20250. }
  20251. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  20252. this.alpha = this.lowerAlphaLimit;
  20253. }
  20254. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  20255. this.alpha = this.upperAlphaLimit;
  20256. }
  20257. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  20258. this.radius = this.lowerRadiusLimit;
  20259. this.inertialRadiusOffset = 0;
  20260. }
  20261. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  20262. this.radius = this.upperRadiusLimit;
  20263. this.inertialRadiusOffset = 0;
  20264. }
  20265. };
  20266. /**
  20267. * Rebuilds angles (alpha, beta) and radius from the give position and target
  20268. */
  20269. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  20270. this._position.subtractToRef(this._getTargetPosition(), this._computationVector);
  20271. // need to rotate to Y up equivalent if up vector not Axis.Y
  20272. if (this._upVector.x !== 0 || this._upVector.y !== 1.0 || this._upVector.z !== 0) {
  20273. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._computationVector, this._upToYMatrix, this._computationVector);
  20274. }
  20275. this.radius = this._computationVector.length();
  20276. if (this.radius === 0) {
  20277. this.radius = 0.0001; // Just to avoid division by zero
  20278. }
  20279. // Alpha
  20280. if (this._computationVector.x === 0 && this._computationVector.z === 0) {
  20281. this.alpha = Math.PI / 2; // avoid division by zero when looking along up axis, and set to acos(0)
  20282. }
  20283. else {
  20284. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  20285. }
  20286. if (this._computationVector.z < 0) {
  20287. this.alpha = 2 * Math.PI - this.alpha;
  20288. }
  20289. // Beta
  20290. this.beta = Math.acos(this._computationVector.y / this.radius);
  20291. this._checkLimits();
  20292. };
  20293. /**
  20294. * Use a position to define the current camera related information like aplha, beta and radius
  20295. * @param position Defines the position to set the camera at
  20296. */
  20297. ArcRotateCamera.prototype.setPosition = function (position) {
  20298. if (this._position.equals(position)) {
  20299. return;
  20300. }
  20301. this._position.copyFrom(position);
  20302. this.rebuildAnglesAndRadius();
  20303. };
  20304. /**
  20305. * Defines the target the camera should look at.
  20306. * This will automatically adapt alpha beta and radius to fit within the new target.
  20307. * @param target Defines the new target as a Vector or a mesh
  20308. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  20309. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  20310. */
  20311. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  20312. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  20313. if (allowSamePosition === void 0) { allowSamePosition = false; }
  20314. if (target.getBoundingInfo) {
  20315. if (toBoundingCenter) {
  20316. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  20317. }
  20318. else {
  20319. this._targetBoundingCenter = null;
  20320. }
  20321. target.computeWorldMatrix();
  20322. this._targetHost = target;
  20323. this._target = this._getTargetPosition();
  20324. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  20325. }
  20326. else {
  20327. var newTarget = target;
  20328. var currentTarget = this._getTargetPosition();
  20329. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  20330. return;
  20331. }
  20332. this._targetHost = null;
  20333. this._target = newTarget;
  20334. this._targetBoundingCenter = null;
  20335. this.onMeshTargetChangedObservable.notifyObservers(null);
  20336. }
  20337. this.rebuildAnglesAndRadius();
  20338. };
  20339. /** @hidden */
  20340. ArcRotateCamera.prototype._getViewMatrix = function () {
  20341. // Compute
  20342. var cosa = Math.cos(this.alpha);
  20343. var sina = Math.sin(this.alpha);
  20344. var cosb = Math.cos(this.beta);
  20345. var sinb = Math.sin(this.beta);
  20346. if (sinb === 0) {
  20347. sinb = 0.0001;
  20348. }
  20349. var target = this._getTargetPosition();
  20350. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  20351. // Rotate according to up vector
  20352. if (this._upVector.x !== 0 || this._upVector.y !== 1.0 || this._upVector.z !== 0) {
  20353. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._computationVector, this._YToUpMatrix, this._computationVector);
  20354. }
  20355. target.addToRef(this._computationVector, this._newPosition);
  20356. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  20357. var coordinator = this.getScene().collisionCoordinator;
  20358. if (!this._collider) {
  20359. this._collider = coordinator.createCollider();
  20360. }
  20361. this._collider._radius = this.collisionRadius;
  20362. this._newPosition.subtractToRef(this._position, this._collisionVelocity);
  20363. this._collisionTriggered = true;
  20364. coordinator.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  20365. }
  20366. else {
  20367. this._position.copyFrom(this._newPosition);
  20368. var up = this.upVector;
  20369. if (this.allowUpsideDown && sinb < 0) {
  20370. up = up.clone();
  20371. up = up.negate();
  20372. }
  20373. this._computeViewMatrix(this._position, target, up);
  20374. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  20375. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  20376. }
  20377. this._currentTarget = target;
  20378. return this._viewMatrix;
  20379. };
  20380. /**
  20381. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  20382. * @param meshes Defines the mesh to zoom on
  20383. * @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)
  20384. */
  20385. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  20386. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20387. meshes = meshes || this.getScene().meshes;
  20388. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20389. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  20390. this.radius = distance * this.zoomOnFactor;
  20391. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  20392. };
  20393. /**
  20394. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  20395. * The target will be changed but the radius
  20396. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  20397. * @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)
  20398. */
  20399. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  20400. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20401. var meshesOrMinMaxVector;
  20402. var distance;
  20403. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  20404. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  20405. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20406. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  20407. }
  20408. else { //minMaxVector and distance
  20409. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  20410. meshesOrMinMaxVector = minMaxVectorAndDistance;
  20411. distance = minMaxVectorAndDistance.distance;
  20412. }
  20413. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  20414. if (!doNotUpdateMaxZ) {
  20415. this.maxZ = distance * 2;
  20416. }
  20417. };
  20418. /**
  20419. * @override
  20420. * Override Camera.createRigCamera
  20421. */
  20422. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  20423. var alphaShift = 0;
  20424. switch (this.cameraRigMode) {
  20425. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20426. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20427. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20428. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20429. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  20430. break;
  20431. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20432. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  20433. break;
  20434. }
  20435. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  20436. rigCam._cameraRigParams = {};
  20437. return rigCam;
  20438. };
  20439. /**
  20440. * @hidden
  20441. * @override
  20442. * Override Camera._updateRigCameras
  20443. */
  20444. ArcRotateCamera.prototype._updateRigCameras = function () {
  20445. var camLeft = this._rigCameras[0];
  20446. var camRight = this._rigCameras[1];
  20447. camLeft.beta = camRight.beta = this.beta;
  20448. switch (this.cameraRigMode) {
  20449. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20450. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20451. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20452. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20453. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20454. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20455. break;
  20456. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20457. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20458. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20459. break;
  20460. }
  20461. _super.prototype._updateRigCameras.call(this);
  20462. };
  20463. /**
  20464. * Destroy the camera and release the current resources hold by it.
  20465. */
  20466. ArcRotateCamera.prototype.dispose = function () {
  20467. this.inputs.clear();
  20468. _super.prototype.dispose.call(this);
  20469. };
  20470. /**
  20471. * Gets the current object class name.
  20472. * @return the class name
  20473. */
  20474. ArcRotateCamera.prototype.getClassName = function () {
  20475. return "ArcRotateCamera";
  20476. };
  20477. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20478. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20479. ], ArcRotateCamera.prototype, "alpha", void 0);
  20480. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20481. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20482. ], ArcRotateCamera.prototype, "beta", void 0);
  20483. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20484. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20485. ], ArcRotateCamera.prototype, "radius", void 0);
  20486. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20487. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  20488. ], ArcRotateCamera.prototype, "_target", void 0);
  20489. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20490. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("upVector")
  20491. ], ArcRotateCamera.prototype, "_upVector", void 0);
  20492. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20493. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20494. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  20495. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20496. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20497. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  20498. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20499. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20500. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  20501. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20502. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20503. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  20504. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20505. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20506. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  20507. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20508. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20509. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  20510. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20511. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20512. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  20513. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20514. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20515. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  20516. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20517. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20518. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  20519. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20520. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20521. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  20522. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20523. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20524. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  20525. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20526. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20527. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  20528. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20529. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20530. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  20531. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20532. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20533. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  20534. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20536. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  20537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20539. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  20540. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20541. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20542. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  20543. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20544. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20545. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  20546. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20548. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  20549. return ArcRotateCamera;
  20550. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  20551. /***/ }),
  20552. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  20553. /*!*************************************************!*\
  20554. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  20555. \*************************************************/
  20556. /*! exports provided: ArcRotateCameraInputsManager */
  20557. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20558. "use strict";
  20559. __webpack_require__.r(__webpack_exports__);
  20560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  20561. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20562. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  20563. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  20564. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  20565. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  20566. /**
  20567. * Default Inputs manager for the ArcRotateCamera.
  20568. * It groups all the default supported inputs for ease of use.
  20569. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20570. */
  20571. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  20572. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  20573. /**
  20574. * Instantiates a new ArcRotateCameraInputsManager.
  20575. * @param camera Defines the camera the inputs belong to
  20576. */
  20577. function ArcRotateCameraInputsManager(camera) {
  20578. return _super.call(this, camera) || this;
  20579. }
  20580. /**
  20581. * Add mouse wheel input support to the input manager.
  20582. * @returns the current input manager
  20583. */
  20584. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  20585. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  20586. return this;
  20587. };
  20588. /**
  20589. * Add pointers input support to the input manager.
  20590. * @returns the current input manager
  20591. */
  20592. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  20593. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  20594. return this;
  20595. };
  20596. /**
  20597. * Add keyboard input support to the input manager.
  20598. * @returns the current input manager
  20599. */
  20600. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  20601. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  20602. return this;
  20603. };
  20604. return ArcRotateCameraInputsManager;
  20605. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  20606. /***/ }),
  20607. /***/ "./Cameras/camera.ts":
  20608. /*!***************************!*\
  20609. !*** ./Cameras/camera.ts ***!
  20610. \***************************/
  20611. /*! exports provided: Camera */
  20612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20613. "use strict";
  20614. __webpack_require__.r(__webpack_exports__);
  20615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  20616. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20617. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20618. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  20619. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  20620. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  20621. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20622. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  20623. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  20624. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  20625. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  20626. /**
  20627. * This is the base class of all the camera used in the application.
  20628. * @see http://doc.babylonjs.com/features/cameras
  20629. */
  20630. var Camera = /** @class */ (function (_super) {
  20631. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  20632. /**
  20633. * Instantiates a new camera object.
  20634. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  20635. * @see http://doc.babylonjs.com/features/cameras
  20636. * @param name Defines the name of the camera in the scene
  20637. * @param position Defines the position of the camera
  20638. * @param scene Defines the scene the camera belongs too
  20639. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  20640. */
  20641. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  20642. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  20643. var _this = _super.call(this, name, scene) || this;
  20644. /** @hidden */
  20645. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20646. /**
  20647. * The vector the camera should consider as up.
  20648. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  20649. */
  20650. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  20651. /**
  20652. * Define the current limit on the left side for an orthographic camera
  20653. * In scene unit
  20654. */
  20655. _this.orthoLeft = null;
  20656. /**
  20657. * Define the current limit on the right side for an orthographic camera
  20658. * In scene unit
  20659. */
  20660. _this.orthoRight = null;
  20661. /**
  20662. * Define the current limit on the bottom side for an orthographic camera
  20663. * In scene unit
  20664. */
  20665. _this.orthoBottom = null;
  20666. /**
  20667. * Define the current limit on the top side for an orthographic camera
  20668. * In scene unit
  20669. */
  20670. _this.orthoTop = null;
  20671. /**
  20672. * Field Of View is set in Radians. (default is 0.8)
  20673. */
  20674. _this.fov = 0.8;
  20675. /**
  20676. * Define the minimum distance the camera can see from.
  20677. * This is important to note that the depth buffer are not infinite and the closer it starts
  20678. * the more your scene might encounter depth fighting issue.
  20679. */
  20680. _this.minZ = 1;
  20681. /**
  20682. * Define the maximum distance the camera can see to.
  20683. * This is important to note that the depth buffer are not infinite and the further it end
  20684. * the more your scene might encounter depth fighting issue.
  20685. */
  20686. _this.maxZ = 10000.0;
  20687. /**
  20688. * Define the default inertia of the camera.
  20689. * This helps giving a smooth feeling to the camera movement.
  20690. */
  20691. _this.inertia = 0.9;
  20692. /**
  20693. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20694. */
  20695. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20696. /**
  20697. * Define wether the camera is intermediate.
  20698. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20699. */
  20700. _this.isIntermediate = false;
  20701. /**
  20702. * Define the viewport of the camera.
  20703. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20704. */
  20705. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20706. /**
  20707. * Restricts the camera to viewing objects with the same layerMask.
  20708. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20709. */
  20710. _this.layerMask = 0x0FFFFFFF;
  20711. /**
  20712. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20713. */
  20714. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20715. /**
  20716. * Rig mode of the camera.
  20717. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20718. * This is normally controlled byt the camera themselves as internal use.
  20719. */
  20720. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20721. /**
  20722. * 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
  20723. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20724. * else in the scene.
  20725. */
  20726. _this.customRenderTargets = new Array();
  20727. /**
  20728. * When set, the camera will render to this render target instead of the default canvas
  20729. */
  20730. _this.outputRenderTarget = null;
  20731. /**
  20732. * Observable triggered when the camera view matrix has changed.
  20733. */
  20734. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20735. /**
  20736. * Observable triggered when the camera Projection matrix has changed.
  20737. */
  20738. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20739. /**
  20740. * Observable triggered when the inputs have been processed.
  20741. */
  20742. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20743. /**
  20744. * Observable triggered when reset has been called and applied to the camera.
  20745. */
  20746. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20747. /** @hidden */
  20748. _this._rigCameras = new Array();
  20749. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20750. /** @hidden */
  20751. _this._skipRendering = false;
  20752. /** @hidden */
  20753. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20754. /** @hidden */
  20755. _this._postProcesses = new Array();
  20756. /** @hidden */
  20757. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20758. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20759. /** hidden */
  20760. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20761. _this._doNotComputeProjectionMatrix = false;
  20762. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20763. _this._refreshFrustumPlanes = true;
  20764. /** @hidden */
  20765. _this._isCamera = true;
  20766. /** @hidden */
  20767. _this._isLeftCamera = false;
  20768. /** @hidden */
  20769. _this._isRightCamera = true;
  20770. _this.getScene().addCamera(_this);
  20771. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20772. _this.getScene().activeCamera = _this;
  20773. }
  20774. _this.position = position;
  20775. return _this;
  20776. }
  20777. Object.defineProperty(Camera.prototype, "position", {
  20778. /**
  20779. * Define the current local position of the camera in the scene
  20780. */
  20781. get: function () {
  20782. return this._position;
  20783. },
  20784. set: function (newPosition) {
  20785. this._position = newPosition;
  20786. },
  20787. enumerable: true,
  20788. configurable: true
  20789. });
  20790. /**
  20791. * Store current camera state (fov, position, etc..)
  20792. * @returns the camera
  20793. */
  20794. Camera.prototype.storeState = function () {
  20795. this._stateStored = true;
  20796. this._storedFov = this.fov;
  20797. return this;
  20798. };
  20799. /**
  20800. * Restores the camera state values if it has been stored. You must call storeState() first
  20801. */
  20802. Camera.prototype._restoreStateValues = function () {
  20803. if (!this._stateStored) {
  20804. return false;
  20805. }
  20806. this.fov = this._storedFov;
  20807. return true;
  20808. };
  20809. /**
  20810. * Restored camera state. You must call storeState() first.
  20811. * @returns true if restored and false otherwise
  20812. */
  20813. Camera.prototype.restoreState = function () {
  20814. if (this._restoreStateValues()) {
  20815. this.onRestoreStateObservable.notifyObservers(this);
  20816. return true;
  20817. }
  20818. return false;
  20819. };
  20820. /**
  20821. * Gets the class name of the camera.
  20822. * @returns the class name
  20823. */
  20824. Camera.prototype.getClassName = function () {
  20825. return "Camera";
  20826. };
  20827. /**
  20828. * Gets a string representation of the camera useful for debug purpose.
  20829. * @param fullDetails Defines that a more verboe level of logging is required
  20830. * @returns the string representation
  20831. */
  20832. Camera.prototype.toString = function (fullDetails) {
  20833. var ret = "Name: " + this.name;
  20834. ret += ", type: " + this.getClassName();
  20835. if (this.animations) {
  20836. for (var i = 0; i < this.animations.length; i++) {
  20837. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20838. }
  20839. }
  20840. if (fullDetails) {
  20841. }
  20842. return ret;
  20843. };
  20844. Object.defineProperty(Camera.prototype, "globalPosition", {
  20845. /**
  20846. * Gets the current world space position of the camera.
  20847. */
  20848. get: function () {
  20849. return this._globalPosition;
  20850. },
  20851. enumerable: true,
  20852. configurable: true
  20853. });
  20854. /**
  20855. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20856. * @returns the active meshe list
  20857. */
  20858. Camera.prototype.getActiveMeshes = function () {
  20859. return this._activeMeshes;
  20860. };
  20861. /**
  20862. * Check wether a mesh is part of the current active mesh list of the camera
  20863. * @param mesh Defines the mesh to check
  20864. * @returns true if active, false otherwise
  20865. */
  20866. Camera.prototype.isActiveMesh = function (mesh) {
  20867. return (this._activeMeshes.indexOf(mesh) !== -1);
  20868. };
  20869. /**
  20870. * Is this camera ready to be used/rendered
  20871. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20872. * @return true if the camera is ready
  20873. */
  20874. Camera.prototype.isReady = function (completeCheck) {
  20875. if (completeCheck === void 0) { completeCheck = false; }
  20876. if (completeCheck) {
  20877. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20878. var pp = _a[_i];
  20879. if (pp && !pp.isReady()) {
  20880. return false;
  20881. }
  20882. }
  20883. }
  20884. return _super.prototype.isReady.call(this, completeCheck);
  20885. };
  20886. /** @hidden */
  20887. Camera.prototype._initCache = function () {
  20888. _super.prototype._initCache.call(this);
  20889. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20890. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20891. this._cache.mode = undefined;
  20892. this._cache.minZ = undefined;
  20893. this._cache.maxZ = undefined;
  20894. this._cache.fov = undefined;
  20895. this._cache.fovMode = undefined;
  20896. this._cache.aspectRatio = undefined;
  20897. this._cache.orthoLeft = undefined;
  20898. this._cache.orthoRight = undefined;
  20899. this._cache.orthoBottom = undefined;
  20900. this._cache.orthoTop = undefined;
  20901. this._cache.renderWidth = undefined;
  20902. this._cache.renderHeight = undefined;
  20903. };
  20904. /** @hidden */
  20905. Camera.prototype._updateCache = function (ignoreParentClass) {
  20906. if (!ignoreParentClass) {
  20907. _super.prototype._updateCache.call(this);
  20908. }
  20909. this._cache.position.copyFrom(this.position);
  20910. this._cache.upVector.copyFrom(this.upVector);
  20911. };
  20912. /** @hidden */
  20913. Camera.prototype._isSynchronized = function () {
  20914. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20915. };
  20916. /** @hidden */
  20917. Camera.prototype._isSynchronizedViewMatrix = function () {
  20918. if (!_super.prototype._isSynchronized.call(this)) {
  20919. return false;
  20920. }
  20921. return this._cache.position.equals(this.position)
  20922. && this._cache.upVector.equals(this.upVector)
  20923. && this.isSynchronizedWithParent();
  20924. };
  20925. /** @hidden */
  20926. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20927. var check = this._cache.mode === this.mode
  20928. && this._cache.minZ === this.minZ
  20929. && this._cache.maxZ === this.maxZ;
  20930. if (!check) {
  20931. return false;
  20932. }
  20933. var engine = this.getEngine();
  20934. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20935. check = this._cache.fov === this.fov
  20936. && this._cache.fovMode === this.fovMode
  20937. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20938. }
  20939. else {
  20940. check = this._cache.orthoLeft === this.orthoLeft
  20941. && this._cache.orthoRight === this.orthoRight
  20942. && this._cache.orthoBottom === this.orthoBottom
  20943. && this._cache.orthoTop === this.orthoTop
  20944. && this._cache.renderWidth === engine.getRenderWidth()
  20945. && this._cache.renderHeight === engine.getRenderHeight();
  20946. }
  20947. return check;
  20948. };
  20949. /**
  20950. * Attach the input controls to a specific dom element to get the input from.
  20951. * @param element Defines the element the controls should be listened from
  20952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20953. */
  20954. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20955. };
  20956. /**
  20957. * Detach the current controls from the specified dom element.
  20958. * @param element Defines the element to stop listening the inputs from
  20959. */
  20960. Camera.prototype.detachControl = function (element) {
  20961. };
  20962. /**
  20963. * Update the camera state according to the different inputs gathered during the frame.
  20964. */
  20965. Camera.prototype.update = function () {
  20966. this._checkInputs();
  20967. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20968. this._updateRigCameras();
  20969. }
  20970. };
  20971. /** @hidden */
  20972. Camera.prototype._checkInputs = function () {
  20973. this.onAfterCheckInputsObservable.notifyObservers(this);
  20974. };
  20975. Object.defineProperty(Camera.prototype, "rigCameras", {
  20976. /** @hidden */
  20977. get: function () {
  20978. return this._rigCameras;
  20979. },
  20980. enumerable: true,
  20981. configurable: true
  20982. });
  20983. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20984. /**
  20985. * Gets the post process used by the rig cameras
  20986. */
  20987. get: function () {
  20988. return this._rigPostProcess;
  20989. },
  20990. enumerable: true,
  20991. configurable: true
  20992. });
  20993. /**
  20994. * Internal, gets the first post proces.
  20995. * @returns the first post process to be run on this camera.
  20996. */
  20997. Camera.prototype._getFirstPostProcess = function () {
  20998. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20999. if (this._postProcesses[ppIndex] !== null) {
  21000. return this._postProcesses[ppIndex];
  21001. }
  21002. }
  21003. return null;
  21004. };
  21005. Camera.prototype._cascadePostProcessesToRigCams = function () {
  21006. // invalidate framebuffer
  21007. var firstPostProcess = this._getFirstPostProcess();
  21008. if (firstPostProcess) {
  21009. firstPostProcess.markTextureDirty();
  21010. }
  21011. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  21012. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  21013. var cam = this._rigCameras[i];
  21014. var rigPostProcess = cam._rigPostProcess;
  21015. // for VR rig, there does not have to be a post process
  21016. if (rigPostProcess) {
  21017. var isPass = rigPostProcess.getEffectName() === "pass";
  21018. if (isPass) {
  21019. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  21020. cam.isIntermediate = this._postProcesses.length === 0;
  21021. }
  21022. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  21023. rigPostProcess.markTextureDirty();
  21024. }
  21025. else {
  21026. cam._postProcesses = this._postProcesses.slice(0);
  21027. }
  21028. }
  21029. };
  21030. /**
  21031. * Attach a post process to the camera.
  21032. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  21033. * @param postProcess The post process to attach to the camera
  21034. * @param insertAt The position of the post process in case several of them are in use in the scene
  21035. * @returns the position the post process has been inserted at
  21036. */
  21037. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  21038. if (insertAt === void 0) { insertAt = null; }
  21039. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  21040. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  21041. return 0;
  21042. }
  21043. if (insertAt == null || insertAt < 0) {
  21044. this._postProcesses.push(postProcess);
  21045. }
  21046. else if (this._postProcesses[insertAt] === null) {
  21047. this._postProcesses[insertAt] = postProcess;
  21048. }
  21049. else {
  21050. this._postProcesses.splice(insertAt, 0, postProcess);
  21051. }
  21052. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  21053. return this._postProcesses.indexOf(postProcess);
  21054. };
  21055. /**
  21056. * Detach a post process to the camera.
  21057. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  21058. * @param postProcess The post process to detach from the camera
  21059. */
  21060. Camera.prototype.detachPostProcess = function (postProcess) {
  21061. var idx = this._postProcesses.indexOf(postProcess);
  21062. if (idx !== -1) {
  21063. this._postProcesses[idx] = null;
  21064. }
  21065. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  21066. };
  21067. /**
  21068. * Gets the current world matrix of the camera
  21069. */
  21070. Camera.prototype.getWorldMatrix = function () {
  21071. if (this._isSynchronizedViewMatrix()) {
  21072. return this._worldMatrix;
  21073. }
  21074. // Getting the the view matrix will also compute the world matrix.
  21075. this.getViewMatrix();
  21076. return this._worldMatrix;
  21077. };
  21078. /** @hidden */
  21079. Camera.prototype._getViewMatrix = function () {
  21080. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21081. };
  21082. /**
  21083. * Gets the current view matrix of the camera.
  21084. * @param force forces the camera to recompute the matrix without looking at the cached state
  21085. * @returns the view matrix
  21086. */
  21087. Camera.prototype.getViewMatrix = function (force) {
  21088. if (!force && this._isSynchronizedViewMatrix()) {
  21089. return this._computedViewMatrix;
  21090. }
  21091. this.updateCache();
  21092. this._computedViewMatrix = this._getViewMatrix();
  21093. this._currentRenderId = this.getScene().getRenderId();
  21094. this._childUpdateId++;
  21095. this._refreshFrustumPlanes = true;
  21096. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  21097. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  21098. }
  21099. // Notify parent camera if rig camera is changed
  21100. if (this.parent && this.parent.onViewMatrixChangedObservable) {
  21101. this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent);
  21102. }
  21103. this.onViewMatrixChangedObservable.notifyObservers(this);
  21104. this._computedViewMatrix.invertToRef(this._worldMatrix);
  21105. return this._computedViewMatrix;
  21106. };
  21107. /**
  21108. * Freeze the projection matrix.
  21109. * It will prevent the cache check of the camera projection compute and can speed up perf
  21110. * if no parameter of the camera are meant to change
  21111. * @param projection Defines manually a projection if necessary
  21112. */
  21113. Camera.prototype.freezeProjectionMatrix = function (projection) {
  21114. this._doNotComputeProjectionMatrix = true;
  21115. if (projection !== undefined) {
  21116. this._projectionMatrix = projection;
  21117. }
  21118. };
  21119. /**
  21120. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  21121. */
  21122. Camera.prototype.unfreezeProjectionMatrix = function () {
  21123. this._doNotComputeProjectionMatrix = false;
  21124. };
  21125. /**
  21126. * Gets the current projection matrix of the camera.
  21127. * @param force forces the camera to recompute the matrix without looking at the cached state
  21128. * @returns the projection matrix
  21129. */
  21130. Camera.prototype.getProjectionMatrix = function (force) {
  21131. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  21132. return this._projectionMatrix;
  21133. }
  21134. // Cache
  21135. this._cache.mode = this.mode;
  21136. this._cache.minZ = this.minZ;
  21137. this._cache.maxZ = this.maxZ;
  21138. // Matrix
  21139. this._refreshFrustumPlanes = true;
  21140. var engine = this.getEngine();
  21141. var scene = this.getScene();
  21142. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  21143. this._cache.fov = this.fov;
  21144. this._cache.fovMode = this.fovMode;
  21145. this._cache.aspectRatio = engine.getAspectRatio(this);
  21146. if (this.minZ <= 0) {
  21147. this.minZ = 0.1;
  21148. }
  21149. if (scene.useRightHandedSystem) {
  21150. _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);
  21151. }
  21152. else {
  21153. _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);
  21154. }
  21155. }
  21156. else {
  21157. var halfWidth = engine.getRenderWidth() / 2.0;
  21158. var halfHeight = engine.getRenderHeight() / 2.0;
  21159. if (scene.useRightHandedSystem) {
  21160. _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);
  21161. }
  21162. else {
  21163. _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);
  21164. }
  21165. this._cache.orthoLeft = this.orthoLeft;
  21166. this._cache.orthoRight = this.orthoRight;
  21167. this._cache.orthoBottom = this.orthoBottom;
  21168. this._cache.orthoTop = this.orthoTop;
  21169. this._cache.renderWidth = engine.getRenderWidth();
  21170. this._cache.renderHeight = engine.getRenderHeight();
  21171. }
  21172. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  21173. return this._projectionMatrix;
  21174. };
  21175. /**
  21176. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  21177. * @returns a Matrix
  21178. */
  21179. Camera.prototype.getTransformationMatrix = function () {
  21180. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  21181. return this._transformMatrix;
  21182. };
  21183. Camera.prototype._updateFrustumPlanes = function () {
  21184. if (!this._refreshFrustumPlanes) {
  21185. return;
  21186. }
  21187. this.getTransformationMatrix();
  21188. if (!this._frustumPlanes) {
  21189. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  21190. }
  21191. else {
  21192. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  21193. }
  21194. this._refreshFrustumPlanes = false;
  21195. };
  21196. /**
  21197. * Checks if a cullable object (mesh...) is in the camera frustum
  21198. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  21199. * @param target The object to check
  21200. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  21201. * @returns true if the object is in frustum otherwise false
  21202. */
  21203. Camera.prototype.isInFrustum = function (target, checkRigCameras) {
  21204. if (checkRigCameras === void 0) { checkRigCameras = false; }
  21205. this._updateFrustumPlanes();
  21206. if (checkRigCameras && this.rigCameras.length > 0) {
  21207. var result = false;
  21208. this.rigCameras.forEach(function (cam) {
  21209. cam._updateFrustumPlanes();
  21210. result = result || target.isInFrustum(cam._frustumPlanes);
  21211. });
  21212. return result;
  21213. }
  21214. else {
  21215. return target.isInFrustum(this._frustumPlanes);
  21216. }
  21217. };
  21218. /**
  21219. * Checks if a cullable object (mesh...) is in the camera frustum
  21220. * Unlike isInFrustum this cheks the full bounding box
  21221. * @param target The object to check
  21222. * @returns true if the object is in frustum otherwise false
  21223. */
  21224. Camera.prototype.isCompletelyInFrustum = function (target) {
  21225. this._updateFrustumPlanes();
  21226. return target.isCompletelyInFrustum(this._frustumPlanes);
  21227. };
  21228. /**
  21229. * Gets a ray in the forward direction from the camera.
  21230. * @param length Defines the length of the ray to create
  21231. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  21232. * @param origin Defines the start point of the ray which defaults to the camera position
  21233. * @returns the forward ray
  21234. */
  21235. Camera.prototype.getForwardRay = function (length, transform, origin) {
  21236. if (length === void 0) { length = 100; }
  21237. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  21238. };
  21239. /**
  21240. * Releases resources associated with this node.
  21241. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21242. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21243. */
  21244. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  21245. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  21246. // Observables
  21247. this.onViewMatrixChangedObservable.clear();
  21248. this.onProjectionMatrixChangedObservable.clear();
  21249. this.onAfterCheckInputsObservable.clear();
  21250. this.onRestoreStateObservable.clear();
  21251. // Inputs
  21252. if (this.inputs) {
  21253. this.inputs.clear();
  21254. }
  21255. // Animations
  21256. this.getScene().stopAnimation(this);
  21257. // Remove from scene
  21258. this.getScene().removeCamera(this);
  21259. while (this._rigCameras.length > 0) {
  21260. var camera = this._rigCameras.pop();
  21261. if (camera) {
  21262. camera.dispose();
  21263. }
  21264. }
  21265. // Postprocesses
  21266. if (this._rigPostProcess) {
  21267. this._rigPostProcess.dispose(this);
  21268. this._rigPostProcess = null;
  21269. this._postProcesses = [];
  21270. }
  21271. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21272. this._rigPostProcess = null;
  21273. this._postProcesses = [];
  21274. }
  21275. else {
  21276. var i = this._postProcesses.length;
  21277. while (--i >= 0) {
  21278. var postProcess = this._postProcesses[i];
  21279. if (postProcess) {
  21280. postProcess.dispose(this);
  21281. }
  21282. }
  21283. }
  21284. // Render targets
  21285. var i = this.customRenderTargets.length;
  21286. while (--i >= 0) {
  21287. this.customRenderTargets[i].dispose();
  21288. }
  21289. this.customRenderTargets = [];
  21290. // Active Meshes
  21291. this._activeMeshes.dispose();
  21292. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  21293. };
  21294. Object.defineProperty(Camera.prototype, "isLeftCamera", {
  21295. /**
  21296. * Gets the left camera of a rig setup in case of Rigged Camera
  21297. */
  21298. get: function () {
  21299. return this._isLeftCamera;
  21300. },
  21301. enumerable: true,
  21302. configurable: true
  21303. });
  21304. Object.defineProperty(Camera.prototype, "isRightCamera", {
  21305. /**
  21306. * Gets the right camera of a rig setup in case of Rigged Camera
  21307. */
  21308. get: function () {
  21309. return this._isRightCamera;
  21310. },
  21311. enumerable: true,
  21312. configurable: true
  21313. });
  21314. Object.defineProperty(Camera.prototype, "leftCamera", {
  21315. /**
  21316. * Gets the left camera of a rig setup in case of Rigged Camera
  21317. */
  21318. get: function () {
  21319. if (this._rigCameras.length < 1) {
  21320. return null;
  21321. }
  21322. return this._rigCameras[0];
  21323. },
  21324. enumerable: true,
  21325. configurable: true
  21326. });
  21327. Object.defineProperty(Camera.prototype, "rightCamera", {
  21328. /**
  21329. * Gets the right camera of a rig setup in case of Rigged Camera
  21330. */
  21331. get: function () {
  21332. if (this._rigCameras.length < 2) {
  21333. return null;
  21334. }
  21335. return this._rigCameras[1];
  21336. },
  21337. enumerable: true,
  21338. configurable: true
  21339. });
  21340. /**
  21341. * Gets the left camera target of a rig setup in case of Rigged Camera
  21342. * @returns the target position
  21343. */
  21344. Camera.prototype.getLeftTarget = function () {
  21345. if (this._rigCameras.length < 1) {
  21346. return null;
  21347. }
  21348. return this._rigCameras[0].getTarget();
  21349. };
  21350. /**
  21351. * Gets the right camera target of a rig setup in case of Rigged Camera
  21352. * @returns the target position
  21353. */
  21354. Camera.prototype.getRightTarget = function () {
  21355. if (this._rigCameras.length < 2) {
  21356. return null;
  21357. }
  21358. return this._rigCameras[1].getTarget();
  21359. };
  21360. /**
  21361. * @hidden
  21362. */
  21363. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  21364. if (this.cameraRigMode === mode) {
  21365. return;
  21366. }
  21367. while (this._rigCameras.length > 0) {
  21368. var camera = this._rigCameras.pop();
  21369. if (camera) {
  21370. camera.dispose();
  21371. }
  21372. }
  21373. this.cameraRigMode = mode;
  21374. this._cameraRigParams = {};
  21375. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  21376. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  21377. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  21378. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  21379. // create the rig cameras, unless none
  21380. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21381. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  21382. if (leftCamera) {
  21383. leftCamera._isLeftCamera = true;
  21384. }
  21385. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  21386. if (rightCamera) {
  21387. rightCamera._isRightCamera = true;
  21388. }
  21389. if (leftCamera && rightCamera) {
  21390. this._rigCameras.push(leftCamera);
  21391. this._rigCameras.push(rightCamera);
  21392. }
  21393. }
  21394. switch (this.cameraRigMode) {
  21395. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  21396. Camera._setStereoscopicAnaglyphRigMode(this);
  21397. break;
  21398. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  21399. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  21400. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  21401. Camera._setStereoscopicRigMode(this);
  21402. break;
  21403. case Camera.RIG_MODE_VR:
  21404. Camera._setVRRigMode(this, rigParams);
  21405. break;
  21406. case Camera.RIG_MODE_WEBVR:
  21407. Camera._setWebVRRigMode(this, rigParams);
  21408. break;
  21409. }
  21410. this._cascadePostProcessesToRigCams();
  21411. this.update();
  21412. };
  21413. /** @hidden */
  21414. Camera._setStereoscopicRigMode = function (camera) {
  21415. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  21416. };
  21417. /** @hidden */
  21418. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  21419. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  21420. };
  21421. /** @hidden */
  21422. Camera._setVRRigMode = function (camera, rigParams) {
  21423. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  21424. };
  21425. /** @hidden */
  21426. Camera._setWebVRRigMode = function (camera, rigParams) {
  21427. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  21428. };
  21429. /** @hidden */
  21430. Camera.prototype._getVRProjectionMatrix = function () {
  21431. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  21432. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  21433. return this._projectionMatrix;
  21434. };
  21435. Camera.prototype._updateCameraRotationMatrix = function () {
  21436. //Here for WebVR
  21437. };
  21438. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  21439. //Here for WebVR
  21440. };
  21441. /**
  21442. * This function MUST be overwritten by the different WebVR cameras available.
  21443. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21444. * @hidden
  21445. */
  21446. Camera.prototype._getWebVRProjectionMatrix = function () {
  21447. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21448. };
  21449. /**
  21450. * This function MUST be overwritten by the different WebVR cameras available.
  21451. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21452. * @hidden
  21453. */
  21454. Camera.prototype._getWebVRViewMatrix = function () {
  21455. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21456. };
  21457. /** @hidden */
  21458. Camera.prototype.setCameraRigParameter = function (name, value) {
  21459. if (!this._cameraRigParams) {
  21460. this._cameraRigParams = {};
  21461. }
  21462. this._cameraRigParams[name] = value;
  21463. //provisionnally:
  21464. if (name === "interaxialDistance") {
  21465. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  21466. }
  21467. };
  21468. /**
  21469. * needs to be overridden by children so sub has required properties to be copied
  21470. * @hidden
  21471. */
  21472. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  21473. return null;
  21474. };
  21475. /**
  21476. * May need to be overridden by children
  21477. * @hidden
  21478. */
  21479. Camera.prototype._updateRigCameras = function () {
  21480. for (var i = 0; i < this._rigCameras.length; i++) {
  21481. this._rigCameras[i].minZ = this.minZ;
  21482. this._rigCameras[i].maxZ = this.maxZ;
  21483. this._rigCameras[i].fov = this.fov;
  21484. this._rigCameras[i].upVector.copyFrom(this.upVector);
  21485. }
  21486. // only update viewport when ANAGLYPH
  21487. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  21488. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  21489. }
  21490. };
  21491. /** @hidden */
  21492. Camera.prototype._setupInputs = function () {
  21493. };
  21494. /**
  21495. * Serialiaze the camera setup to a json represention
  21496. * @returns the JSON representation
  21497. */
  21498. Camera.prototype.serialize = function () {
  21499. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  21500. // Type
  21501. serializationObject.type = this.getClassName();
  21502. // Parent
  21503. if (this.parent) {
  21504. serializationObject.parentId = this.parent.id;
  21505. }
  21506. if (this.inputs) {
  21507. this.inputs.serialize(serializationObject);
  21508. }
  21509. // Animations
  21510. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  21511. serializationObject.ranges = this.serializeAnimationRanges();
  21512. return serializationObject;
  21513. };
  21514. /**
  21515. * Clones the current camera.
  21516. * @param name The cloned camera name
  21517. * @returns the cloned camera
  21518. */
  21519. Camera.prototype.clone = function (name) {
  21520. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  21521. };
  21522. /**
  21523. * Gets the direction of the camera relative to a given local axis.
  21524. * @param localAxis Defines the reference axis to provide a relative direction.
  21525. * @return the direction
  21526. */
  21527. Camera.prototype.getDirection = function (localAxis) {
  21528. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  21529. this.getDirectionToRef(localAxis, result);
  21530. return result;
  21531. };
  21532. /**
  21533. * Gets the direction of the camera relative to a given local axis into a passed vector.
  21534. * @param localAxis Defines the reference axis to provide a relative direction.
  21535. * @param result Defines the vector to store the result in
  21536. */
  21537. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  21538. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  21539. };
  21540. /**
  21541. * Gets a camera constructor for a given camera type
  21542. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  21543. * @param name The name of the camera the result will be able to instantiate
  21544. * @param scene The scene the result will construct the camera in
  21545. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  21546. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  21547. * @returns a factory method to construc the camera
  21548. */
  21549. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  21550. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  21551. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  21552. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  21553. interaxial_distance: interaxial_distance,
  21554. isStereoscopicSideBySide: isStereoscopicSideBySide
  21555. });
  21556. if (constructorFunc) {
  21557. return constructorFunc;
  21558. }
  21559. // Default to universal camera
  21560. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  21561. };
  21562. /**
  21563. * Compute the world matrix of the camera.
  21564. * @returns the camera workd matrix
  21565. */
  21566. Camera.prototype.computeWorldMatrix = function () {
  21567. return this.getWorldMatrix();
  21568. };
  21569. /**
  21570. * Parse a JSON and creates the camera from the parsed information
  21571. * @param parsedCamera The JSON to parse
  21572. * @param scene The scene to instantiate the camera in
  21573. * @returns the newly constructed camera
  21574. */
  21575. Camera.Parse = function (parsedCamera, scene) {
  21576. var type = parsedCamera.type;
  21577. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  21578. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  21579. // Parent
  21580. if (parsedCamera.parentId) {
  21581. camera._waitingParentId = parsedCamera.parentId;
  21582. }
  21583. //If camera has an input manager, let it parse inputs settings
  21584. if (camera.inputs) {
  21585. camera.inputs.parse(parsedCamera);
  21586. camera._setupInputs();
  21587. }
  21588. if (camera.setPosition) { // need to force position
  21589. camera.position.copyFromFloats(0, 0, 0);
  21590. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  21591. }
  21592. // Target
  21593. if (parsedCamera.target) {
  21594. if (camera.setTarget) {
  21595. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  21596. }
  21597. }
  21598. // Apply 3d rig, when found
  21599. if (parsedCamera.cameraRigMode) {
  21600. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  21601. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  21602. }
  21603. // Animations
  21604. if (parsedCamera.animations) {
  21605. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  21606. var parsedAnimation = parsedCamera.animations[animationIndex];
  21607. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  21608. if (internalClass) {
  21609. camera.animations.push(internalClass.Parse(parsedAnimation));
  21610. }
  21611. }
  21612. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  21613. }
  21614. if (parsedCamera.autoAnimate) {
  21615. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  21616. }
  21617. return camera;
  21618. };
  21619. /** @hidden */
  21620. Camera._createDefaultParsedCamera = function (name, scene) {
  21621. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  21622. };
  21623. /**
  21624. * This is the default projection mode used by the cameras.
  21625. * It helps recreating a feeling of perspective and better appreciate depth.
  21626. * This is the best way to simulate real life cameras.
  21627. */
  21628. Camera.PERSPECTIVE_CAMERA = 0;
  21629. /**
  21630. * This helps creating camera with an orthographic mode.
  21631. * 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.
  21632. */
  21633. Camera.ORTHOGRAPHIC_CAMERA = 1;
  21634. /**
  21635. * This is the default FOV mode for perspective cameras.
  21636. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  21637. */
  21638. Camera.FOVMODE_VERTICAL_FIXED = 0;
  21639. /**
  21640. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  21641. */
  21642. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  21643. /**
  21644. * This specifies ther is no need for a camera rig.
  21645. * Basically only one eye is rendered corresponding to the camera.
  21646. */
  21647. Camera.RIG_MODE_NONE = 0;
  21648. /**
  21649. * Simulates a camera Rig with one blue eye and one red eye.
  21650. * This can be use with 3d blue and red glasses.
  21651. */
  21652. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  21653. /**
  21654. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  21655. */
  21656. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  21657. /**
  21658. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  21659. */
  21660. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  21661. /**
  21662. * Defines that both eyes of the camera will be rendered over under each other.
  21663. */
  21664. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  21665. /**
  21666. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  21667. */
  21668. Camera.RIG_MODE_VR = 20;
  21669. /**
  21670. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  21671. */
  21672. Camera.RIG_MODE_WEBVR = 21;
  21673. /**
  21674. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  21675. */
  21676. Camera.RIG_MODE_CUSTOM = 22;
  21677. /**
  21678. * Defines if by default attaching controls should prevent the default javascript event to continue.
  21679. */
  21680. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  21681. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21682. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  21683. ], Camera.prototype, "_position", void 0);
  21684. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21685. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21686. ], Camera.prototype, "upVector", void 0);
  21687. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21688. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21689. ], Camera.prototype, "orthoLeft", void 0);
  21690. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21691. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21692. ], Camera.prototype, "orthoRight", void 0);
  21693. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21694. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21695. ], Camera.prototype, "orthoBottom", void 0);
  21696. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21697. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21698. ], Camera.prototype, "orthoTop", void 0);
  21699. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21700. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21701. ], Camera.prototype, "fov", void 0);
  21702. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21703. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21704. ], Camera.prototype, "minZ", void 0);
  21705. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21706. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21707. ], Camera.prototype, "maxZ", void 0);
  21708. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21710. ], Camera.prototype, "inertia", void 0);
  21711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21713. ], Camera.prototype, "mode", void 0);
  21714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21716. ], Camera.prototype, "layerMask", void 0);
  21717. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21718. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21719. ], Camera.prototype, "fovMode", void 0);
  21720. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21721. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21722. ], Camera.prototype, "cameraRigMode", void 0);
  21723. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21724. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21725. ], Camera.prototype, "interaxialDistance", void 0);
  21726. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21727. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21728. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  21729. return Camera;
  21730. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  21731. /***/ }),
  21732. /***/ "./Cameras/cameraInputsManager.ts":
  21733. /*!****************************************!*\
  21734. !*** ./Cameras/cameraInputsManager.ts ***!
  21735. \****************************************/
  21736. /*! exports provided: CameraInputTypes, CameraInputsManager */
  21737. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21738. "use strict";
  21739. __webpack_require__.r(__webpack_exports__);
  21740. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21742. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21743. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21744. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21745. /**
  21746. * @ignore
  21747. * This is a list of all the different input types that are available in the application.
  21748. * Fo instance: ArcRotateCameraGamepadInput...
  21749. */
  21750. var CameraInputTypes = {};
  21751. /**
  21752. * This represents the input manager used within a camera.
  21753. * It helps dealing with all the different kind of input attached to a camera.
  21754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21755. */
  21756. var CameraInputsManager = /** @class */ (function () {
  21757. /**
  21758. * Instantiate a new Camera Input Manager.
  21759. * @param camera Defines the camera the input manager blongs to
  21760. */
  21761. function CameraInputsManager(camera) {
  21762. this.attached = {};
  21763. this.camera = camera;
  21764. this.checkInputs = function () { };
  21765. }
  21766. /**
  21767. * Add an input method to a camera
  21768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21769. * @param input camera input method
  21770. */
  21771. CameraInputsManager.prototype.add = function (input) {
  21772. var type = input.getSimpleName();
  21773. if (this.attached[type]) {
  21774. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21775. return;
  21776. }
  21777. this.attached[type] = input;
  21778. input.camera = this.camera;
  21779. //for checkInputs, we are dynamically creating a function
  21780. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21781. if (input.checkInputs) {
  21782. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21783. }
  21784. if (this.attachedElement) {
  21785. input.attachControl(this.attachedElement);
  21786. }
  21787. };
  21788. /**
  21789. * Remove a specific input method from a camera
  21790. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21791. * @param inputToRemove camera input method
  21792. */
  21793. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21794. for (var cam in this.attached) {
  21795. var input = this.attached[cam];
  21796. if (input === inputToRemove) {
  21797. input.detachControl(this.attachedElement);
  21798. input.camera = null;
  21799. delete this.attached[cam];
  21800. this.rebuildInputCheck();
  21801. }
  21802. }
  21803. };
  21804. /**
  21805. * Remove a specific input type from a camera
  21806. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21807. * @param inputType the type of the input to remove
  21808. */
  21809. CameraInputsManager.prototype.removeByType = function (inputType) {
  21810. for (var cam in this.attached) {
  21811. var input = this.attached[cam];
  21812. if (input.getClassName() === inputType) {
  21813. input.detachControl(this.attachedElement);
  21814. input.camera = null;
  21815. delete this.attached[cam];
  21816. this.rebuildInputCheck();
  21817. }
  21818. }
  21819. };
  21820. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21821. var current = this.checkInputs;
  21822. return function () {
  21823. current();
  21824. fn();
  21825. };
  21826. };
  21827. /**
  21828. * Attach the input controls to the currently attached dom element to listen the events from.
  21829. * @param input Defines the input to attach
  21830. */
  21831. CameraInputsManager.prototype.attachInput = function (input) {
  21832. if (this.attachedElement) {
  21833. input.attachControl(this.attachedElement, this.noPreventDefault);
  21834. }
  21835. };
  21836. /**
  21837. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21838. * @param element Defines the dom element to collect the events from
  21839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21840. */
  21841. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21842. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21843. if (this.attachedElement) {
  21844. return;
  21845. }
  21846. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21847. this.attachedElement = element;
  21848. this.noPreventDefault = noPreventDefault;
  21849. for (var cam in this.attached) {
  21850. this.attached[cam].attachControl(element, noPreventDefault);
  21851. }
  21852. };
  21853. /**
  21854. * Detach the current manager inputs controls from a specific dom element.
  21855. * @param element Defines the dom element to collect the events from
  21856. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21857. */
  21858. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21859. if (disconnect === void 0) { disconnect = false; }
  21860. if (this.attachedElement !== element) {
  21861. return;
  21862. }
  21863. for (var cam in this.attached) {
  21864. this.attached[cam].detachControl(element);
  21865. if (disconnect) {
  21866. this.attached[cam].camera = null;
  21867. }
  21868. }
  21869. this.attachedElement = null;
  21870. };
  21871. /**
  21872. * Rebuild the dynamic inputCheck function from the current list of
  21873. * defined inputs in the manager.
  21874. */
  21875. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21876. this.checkInputs = function () { };
  21877. for (var cam in this.attached) {
  21878. var input = this.attached[cam];
  21879. if (input.checkInputs) {
  21880. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21881. }
  21882. }
  21883. };
  21884. /**
  21885. * Remove all attached input methods from a camera
  21886. */
  21887. CameraInputsManager.prototype.clear = function () {
  21888. if (this.attachedElement) {
  21889. this.detachElement(this.attachedElement, true);
  21890. }
  21891. this.attached = {};
  21892. this.attachedElement = null;
  21893. this.checkInputs = function () { };
  21894. };
  21895. /**
  21896. * Serialize the current input manager attached to a camera.
  21897. * This ensures than once parsed,
  21898. * the input associated to the camera will be identical to the current ones
  21899. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21900. */
  21901. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21902. var inputs = {};
  21903. for (var cam in this.attached) {
  21904. var input = this.attached[cam];
  21905. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21906. inputs[input.getClassName()] = res;
  21907. }
  21908. serializedCamera.inputsmgr = inputs;
  21909. };
  21910. /**
  21911. * Parses an input manager serialized JSON to restore the previous list of inputs
  21912. * and states associated to a camera.
  21913. * @param parsedCamera Defines the JSON to parse
  21914. */
  21915. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21916. var parsedInputs = parsedCamera.inputsmgr;
  21917. if (parsedInputs) {
  21918. this.clear();
  21919. for (var n in parsedInputs) {
  21920. var construct = CameraInputTypes[n];
  21921. if (construct) {
  21922. var parsedinput = parsedInputs[n];
  21923. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21924. this.add(input);
  21925. }
  21926. }
  21927. }
  21928. else {
  21929. //2016-03-08 this part is for managing backward compatibility
  21930. for (var n in this.attached) {
  21931. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21932. if (construct) {
  21933. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21934. this.remove(this.attached[n]);
  21935. this.add(input);
  21936. }
  21937. }
  21938. }
  21939. };
  21940. return CameraInputsManager;
  21941. }());
  21942. /***/ }),
  21943. /***/ "./Cameras/deviceOrientationCamera.ts":
  21944. /*!********************************************!*\
  21945. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21946. \********************************************/
  21947. /*! exports provided: DeviceOrientationCamera */
  21948. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21949. "use strict";
  21950. __webpack_require__.r(__webpack_exports__);
  21951. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21952. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21953. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21954. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21955. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21956. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21957. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21958. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21959. });
  21960. // We're mainly based on the logic defined into the FreeCamera code
  21961. /**
  21962. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21963. * being tilted forward or back and left or right.
  21964. */
  21965. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21966. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21967. /**
  21968. * Creates a new device orientation camera
  21969. * @param name The name of the camera
  21970. * @param position The start position camera
  21971. * @param scene The scene the camera belongs to
  21972. */
  21973. function DeviceOrientationCamera(name, position, scene) {
  21974. var _this = _super.call(this, name, position, scene) || this;
  21975. _this._tmpDragQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21976. /**
  21977. * @hidden
  21978. * Disabled pointer input on first orientation sensor update (Default: true)
  21979. */
  21980. _this._disablePointerInputWhenUsingDeviceOrientation = true;
  21981. _this._dragFactor = 0;
  21982. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21983. _this.inputs.addDeviceOrientation();
  21984. // When the orientation sensor fires it's first event, disable mouse input
  21985. if (_this.inputs._deviceOrientationInput) {
  21986. _this.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce(function () {
  21987. if (_this._disablePointerInputWhenUsingDeviceOrientation) {
  21988. if (_this.inputs._mouseInput) {
  21989. _this.inputs._mouseInput._allowCameraRotation = false;
  21990. _this.inputs._mouseInput.onPointerMovedObservable.add(function (e) {
  21991. if (_this._dragFactor != 0) {
  21992. if (!_this._initialQuaternion) {
  21993. _this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21994. }
  21995. // Rotate the initial space around the y axis to allow users to "turn around" via touch/mouse
  21996. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromEulerAnglesToRef(0, e.offsetX * _this._dragFactor, 0, _this._tmpDragQuaternion);
  21997. _this._initialQuaternion.multiplyToRef(_this._tmpDragQuaternion, _this._initialQuaternion);
  21998. }
  21999. });
  22000. }
  22001. }
  22002. });
  22003. }
  22004. return _this;
  22005. }
  22006. /**
  22007. * Enabled turning on the y axis when the orientation sensor is active
  22008. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  22009. */
  22010. DeviceOrientationCamera.prototype.enableHorizontalDragging = function (dragFactor) {
  22011. if (dragFactor === void 0) { dragFactor = 1 / 300; }
  22012. this._dragFactor = dragFactor;
  22013. };
  22014. /**
  22015. * Gets the current instance class name ("DeviceOrientationCamera").
  22016. * This helps avoiding instanceof at run time.
  22017. * @returns the class name
  22018. */
  22019. DeviceOrientationCamera.prototype.getClassName = function () {
  22020. return "DeviceOrientationCamera";
  22021. };
  22022. /**
  22023. * @hidden
  22024. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  22025. */
  22026. DeviceOrientationCamera.prototype._checkInputs = function () {
  22027. _super.prototype._checkInputs.call(this);
  22028. this._quaternionCache.copyFrom(this.rotationQuaternion);
  22029. if (this._initialQuaternion) {
  22030. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  22031. }
  22032. };
  22033. /**
  22034. * Reset the camera to its default orientation on the specified axis only.
  22035. * @param axis The axis to reset
  22036. */
  22037. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  22038. var _this = this;
  22039. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  22040. //can only work if this camera has a rotation quaternion already.
  22041. if (!this.rotationQuaternion) {
  22042. return;
  22043. }
  22044. if (!this._initialQuaternion) {
  22045. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  22046. }
  22047. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  22048. ['x', 'y', 'z'].forEach(function (axisName) {
  22049. if (!axis[axisName]) {
  22050. _this._initialQuaternion[axisName] = 0;
  22051. }
  22052. else {
  22053. _this._initialQuaternion[axisName] *= -1;
  22054. }
  22055. });
  22056. this._initialQuaternion.normalize();
  22057. //force rotation update
  22058. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  22059. };
  22060. return DeviceOrientationCamera;
  22061. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  22062. /***/ }),
  22063. /***/ "./Cameras/flyCamera.ts":
  22064. /*!******************************!*\
  22065. !*** ./Cameras/flyCamera.ts ***!
  22066. \******************************/
  22067. /*! exports provided: FlyCamera */
  22068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22069. "use strict";
  22070. __webpack_require__.r(__webpack_exports__);
  22071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  22072. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22073. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22074. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22075. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22076. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22077. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  22078. /**
  22079. * This is a flying camera, designed for 3D movement and rotation in all directions,
  22080. * such as in a 3D Space Shooter or a Flight Simulator.
  22081. */
  22082. var FlyCamera = /** @class */ (function (_super) {
  22083. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  22084. /**
  22085. * Instantiates a FlyCamera.
  22086. * This is a flying camera, designed for 3D movement and rotation in all directions,
  22087. * such as in a 3D Space Shooter or a Flight Simulator.
  22088. * @param name Define the name of the camera in the scene.
  22089. * @param position Define the starting position of the camera in the scene.
  22090. * @param scene Define the scene the camera belongs to.
  22091. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  22092. */
  22093. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22094. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22095. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22096. /**
  22097. * Define the collision ellipsoid of the camera.
  22098. * This is helpful for simulating a camera body, like a player's body.
  22099. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22100. */
  22101. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  22102. /**
  22103. * Define an offset for the position of the ellipsoid around the camera.
  22104. * This can be helpful if the camera is attached away from the player's body center,
  22105. * such as at its head.
  22106. */
  22107. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22108. /**
  22109. * Enable or disable collisions of the camera with the rest of the scene objects.
  22110. */
  22111. _this.checkCollisions = false;
  22112. /**
  22113. * Enable or disable gravity on the camera.
  22114. */
  22115. _this.applyGravity = false;
  22116. /**
  22117. * Define the current direction the camera is moving to.
  22118. */
  22119. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22120. /**
  22121. * Track Roll to maintain the wanted Rolling when looking around.
  22122. */
  22123. _this._trackRoll = 0;
  22124. /**
  22125. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  22126. */
  22127. _this.rollCorrect = 100;
  22128. /**
  22129. * Mimic a banked turn, Rolling the camera when Yawing.
  22130. * It's recommended to use rollCorrect = 10 for faster banking correction.
  22131. */
  22132. _this.bankedTurn = false;
  22133. /**
  22134. * Limit in radians for how much Roll banking will add. (Default: 90°)
  22135. */
  22136. _this.bankedTurnLimit = Math.PI / 2;
  22137. /**
  22138. * Value of 0 disables the banked Roll.
  22139. * Value of 1 is equal to the Yaw angle in radians.
  22140. */
  22141. _this.bankedTurnMultiplier = 1;
  22142. _this._needMoveForGravity = false;
  22143. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22144. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22145. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22146. // Collisions.
  22147. _this._collisionMask = -1;
  22148. /** @hidden */
  22149. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22150. if (collidedMesh === void 0) { collidedMesh = null; }
  22151. var updatePosition = function (newPos) {
  22152. _this._newPosition.copyFrom(newPos);
  22153. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22154. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22155. _this.position.addInPlace(_this._diffPosition);
  22156. if (_this.onCollide && collidedMesh) {
  22157. _this.onCollide(collidedMesh);
  22158. }
  22159. }
  22160. };
  22161. updatePosition(newPosition);
  22162. };
  22163. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  22164. _this.inputs.addKeyboard().addMouse();
  22165. return _this;
  22166. }
  22167. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  22168. /**
  22169. * Gets the input sensibility for mouse input.
  22170. * Higher values reduce sensitivity.
  22171. */
  22172. get: function () {
  22173. var mouse = this.inputs.attached["mouse"];
  22174. if (mouse) {
  22175. return mouse.angularSensibility;
  22176. }
  22177. return 0;
  22178. },
  22179. /**
  22180. * Sets the input sensibility for a mouse input.
  22181. * Higher values reduce sensitivity.
  22182. */
  22183. set: function (value) {
  22184. var mouse = this.inputs.attached["mouse"];
  22185. if (mouse) {
  22186. mouse.angularSensibility = value;
  22187. }
  22188. },
  22189. enumerable: true,
  22190. configurable: true
  22191. });
  22192. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  22193. /**
  22194. * Get the keys for camera movement forward.
  22195. */
  22196. get: function () {
  22197. var keyboard = this.inputs.attached["keyboard"];
  22198. if (keyboard) {
  22199. return keyboard.keysForward;
  22200. }
  22201. return [];
  22202. },
  22203. /**
  22204. * Set the keys for camera movement forward.
  22205. */
  22206. set: function (value) {
  22207. var keyboard = this.inputs.attached["keyboard"];
  22208. if (keyboard) {
  22209. keyboard.keysForward = value;
  22210. }
  22211. },
  22212. enumerable: true,
  22213. configurable: true
  22214. });
  22215. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  22216. /**
  22217. * Get the keys for camera movement backward.
  22218. */
  22219. get: function () {
  22220. var keyboard = this.inputs.attached["keyboard"];
  22221. if (keyboard) {
  22222. return keyboard.keysBackward;
  22223. }
  22224. return [];
  22225. },
  22226. set: function (value) {
  22227. var keyboard = this.inputs.attached["keyboard"];
  22228. if (keyboard) {
  22229. keyboard.keysBackward = value;
  22230. }
  22231. },
  22232. enumerable: true,
  22233. configurable: true
  22234. });
  22235. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  22236. /**
  22237. * Get the keys for camera movement up.
  22238. */
  22239. get: function () {
  22240. var keyboard = this.inputs.attached["keyboard"];
  22241. if (keyboard) {
  22242. return keyboard.keysUp;
  22243. }
  22244. return [];
  22245. },
  22246. /**
  22247. * Set the keys for camera movement up.
  22248. */
  22249. set: function (value) {
  22250. var keyboard = this.inputs.attached["keyboard"];
  22251. if (keyboard) {
  22252. keyboard.keysUp = value;
  22253. }
  22254. },
  22255. enumerable: true,
  22256. configurable: true
  22257. });
  22258. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  22259. /**
  22260. * Get the keys for camera movement down.
  22261. */
  22262. get: function () {
  22263. var keyboard = this.inputs.attached["keyboard"];
  22264. if (keyboard) {
  22265. return keyboard.keysDown;
  22266. }
  22267. return [];
  22268. },
  22269. /**
  22270. * Set the keys for camera movement down.
  22271. */
  22272. set: function (value) {
  22273. var keyboard = this.inputs.attached["keyboard"];
  22274. if (keyboard) {
  22275. keyboard.keysDown = value;
  22276. }
  22277. },
  22278. enumerable: true,
  22279. configurable: true
  22280. });
  22281. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  22282. /**
  22283. * Get the keys for camera movement left.
  22284. */
  22285. get: function () {
  22286. var keyboard = this.inputs.attached["keyboard"];
  22287. if (keyboard) {
  22288. return keyboard.keysLeft;
  22289. }
  22290. return [];
  22291. },
  22292. /**
  22293. * Set the keys for camera movement left.
  22294. */
  22295. set: function (value) {
  22296. var keyboard = this.inputs.attached["keyboard"];
  22297. if (keyboard) {
  22298. keyboard.keysLeft = value;
  22299. }
  22300. },
  22301. enumerable: true,
  22302. configurable: true
  22303. });
  22304. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  22305. /**
  22306. * Set the keys for camera movement right.
  22307. */
  22308. get: function () {
  22309. var keyboard = this.inputs.attached["keyboard"];
  22310. if (keyboard) {
  22311. return keyboard.keysRight;
  22312. }
  22313. return [];
  22314. },
  22315. /**
  22316. * Set the keys for camera movement right.
  22317. */
  22318. set: function (value) {
  22319. var keyboard = this.inputs.attached["keyboard"];
  22320. if (keyboard) {
  22321. keyboard.keysRight = value;
  22322. }
  22323. },
  22324. enumerable: true,
  22325. configurable: true
  22326. });
  22327. /**
  22328. * Attach a control to the HTML DOM element.
  22329. * @param element Defines the element that listens to the input events.
  22330. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  22331. */
  22332. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  22333. this.inputs.attachElement(element, noPreventDefault);
  22334. };
  22335. /**
  22336. * Detach a control from the HTML DOM element.
  22337. * The camera will stop reacting to that input.
  22338. * @param element Defines the element that listens to the input events.
  22339. */
  22340. FlyCamera.prototype.detachControl = function (element) {
  22341. this.inputs.detachElement(element);
  22342. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22343. };
  22344. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  22345. /**
  22346. * Get the mask that the camera ignores in collision events.
  22347. */
  22348. get: function () {
  22349. return this._collisionMask;
  22350. },
  22351. /**
  22352. * Set the mask that the camera ignores in collision events.
  22353. */
  22354. set: function (mask) {
  22355. this._collisionMask = !isNaN(mask) ? mask : -1;
  22356. },
  22357. enumerable: true,
  22358. configurable: true
  22359. });
  22360. /** @hidden */
  22361. FlyCamera.prototype._collideWithWorld = function (displacement) {
  22362. var globalPosition;
  22363. if (this.parent) {
  22364. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22365. }
  22366. else {
  22367. globalPosition = this.position;
  22368. }
  22369. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22370. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22371. var coordinator = this.getScene().collisionCoordinator;
  22372. if (!this._collider) {
  22373. this._collider = coordinator.createCollider();
  22374. }
  22375. this._collider._radius = this.ellipsoid;
  22376. this._collider.collisionMask = this._collisionMask;
  22377. // No need for clone, as long as gravity is not on.
  22378. var actualDisplacement = displacement;
  22379. // Add gravity to direction to prevent dual-collision checking.
  22380. if (this.applyGravity) {
  22381. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  22382. actualDisplacement = displacement.add(this.getScene().gravity);
  22383. }
  22384. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22385. };
  22386. /** @hidden */
  22387. FlyCamera.prototype._checkInputs = function () {
  22388. if (!this._localDirection) {
  22389. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22390. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22391. }
  22392. this.inputs.checkInputs();
  22393. _super.prototype._checkInputs.call(this);
  22394. };
  22395. /** @hidden */
  22396. FlyCamera.prototype._decideIfNeedsToMove = function () {
  22397. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22398. };
  22399. /** @hidden */
  22400. FlyCamera.prototype._updatePosition = function () {
  22401. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22402. this._collideWithWorld(this.cameraDirection);
  22403. }
  22404. else {
  22405. _super.prototype._updatePosition.call(this);
  22406. }
  22407. };
  22408. /**
  22409. * Restore the Roll to its target value at the rate specified.
  22410. * @param rate - Higher means slower restoring.
  22411. * @hidden
  22412. */
  22413. FlyCamera.prototype.restoreRoll = function (rate) {
  22414. var limit = this._trackRoll; // Target Roll.
  22415. var z = this.rotation.z; // Current Roll.
  22416. var delta = limit - z; // Difference in Roll.
  22417. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  22418. // If the difference is noticable, restore the Roll.
  22419. if (Math.abs(delta) >= minRad) {
  22420. // Change Z rotation towards the target Roll.
  22421. this.rotation.z += delta / rate;
  22422. // Match when near enough.
  22423. if (Math.abs(limit - this.rotation.z) <= minRad) {
  22424. this.rotation.z = limit;
  22425. }
  22426. }
  22427. };
  22428. /**
  22429. * Destroy the camera and release the current resources held by it.
  22430. */
  22431. FlyCamera.prototype.dispose = function () {
  22432. this.inputs.clear();
  22433. _super.prototype.dispose.call(this);
  22434. };
  22435. /**
  22436. * Get the current object class name.
  22437. * @returns the class name.
  22438. */
  22439. FlyCamera.prototype.getClassName = function () {
  22440. return "FlyCamera";
  22441. };
  22442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22444. ], FlyCamera.prototype, "ellipsoid", void 0);
  22445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22447. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  22448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22450. ], FlyCamera.prototype, "checkCollisions", void 0);
  22451. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22453. ], FlyCamera.prototype, "applyGravity", void 0);
  22454. return FlyCamera;
  22455. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22456. /***/ }),
  22457. /***/ "./Cameras/flyCameraInputsManager.ts":
  22458. /*!*******************************************!*\
  22459. !*** ./Cameras/flyCameraInputsManager.ts ***!
  22460. \*******************************************/
  22461. /*! exports provided: FlyCameraInputsManager */
  22462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22463. "use strict";
  22464. __webpack_require__.r(__webpack_exports__);
  22465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  22466. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22467. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22468. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  22469. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  22470. /**
  22471. * Default Inputs manager for the FlyCamera.
  22472. * It groups all the default supported inputs for ease of use.
  22473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22474. */
  22475. var FlyCameraInputsManager = /** @class */ (function (_super) {
  22476. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  22477. /**
  22478. * Instantiates a new FlyCameraInputsManager.
  22479. * @param camera Defines the camera the inputs belong to.
  22480. */
  22481. function FlyCameraInputsManager(camera) {
  22482. return _super.call(this, camera) || this;
  22483. }
  22484. /**
  22485. * Add keyboard input support to the input manager.
  22486. * @returns the new FlyCameraKeyboardMoveInput().
  22487. */
  22488. FlyCameraInputsManager.prototype.addKeyboard = function () {
  22489. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  22490. return this;
  22491. };
  22492. /**
  22493. * Add mouse input support to the input manager.
  22494. * @param touchEnabled Enable touch screen support.
  22495. * @returns the new FlyCameraMouseInput().
  22496. */
  22497. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22498. if (touchEnabled === void 0) { touchEnabled = true; }
  22499. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  22500. return this;
  22501. };
  22502. return FlyCameraInputsManager;
  22503. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22504. /***/ }),
  22505. /***/ "./Cameras/followCamera.ts":
  22506. /*!*********************************!*\
  22507. !*** ./Cameras/followCamera.ts ***!
  22508. \*********************************/
  22509. /*! exports provided: FollowCamera, ArcFollowCamera */
  22510. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22511. "use strict";
  22512. __webpack_require__.r(__webpack_exports__);
  22513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  22514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  22515. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22516. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22517. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  22518. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22519. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22520. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  22521. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  22522. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  22523. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  22524. });
  22525. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  22526. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  22527. });
  22528. /**
  22529. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  22530. * an arc rotate version arcFollowCamera are available.
  22531. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22532. */
  22533. var FollowCamera = /** @class */ (function (_super) {
  22534. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  22535. /**
  22536. * Instantiates the follow camera.
  22537. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22538. * @param name Define the name of the camera in the scene
  22539. * @param position Define the position of the camera
  22540. * @param scene Define the scene the camera belong to
  22541. * @param lockedTarget Define the target of the camera
  22542. */
  22543. function FollowCamera(name, position, scene, lockedTarget) {
  22544. if (lockedTarget === void 0) { lockedTarget = null; }
  22545. var _this = _super.call(this, name, position, scene) || this;
  22546. /**
  22547. * Distance the follow camera should follow an object at
  22548. */
  22549. _this.radius = 12;
  22550. /**
  22551. * Minimum allowed distance of the camera to the axis of rotation
  22552. * (The camera can not get closer).
  22553. * This can help limiting how the Camera is able to move in the scene.
  22554. */
  22555. _this.lowerRadiusLimit = null;
  22556. /**
  22557. * Maximum allowed distance of the camera to the axis of rotation
  22558. * (The camera can not get further).
  22559. * This can help limiting how the Camera is able to move in the scene.
  22560. */
  22561. _this.upperRadiusLimit = null;
  22562. /**
  22563. * Define a rotation offset between the camera and the object it follows
  22564. */
  22565. _this.rotationOffset = 0;
  22566. /**
  22567. * Minimum allowed angle to camera position relative to target object.
  22568. * This can help limiting how the Camera is able to move in the scene.
  22569. */
  22570. _this.lowerRotationOffsetLimit = null;
  22571. /**
  22572. * Maximum allowed angle to camera position relative to target object.
  22573. * This can help limiting how the Camera is able to move in the scene.
  22574. */
  22575. _this.upperRotationOffsetLimit = null;
  22576. /**
  22577. * Define a height offset between the camera and the object it follows.
  22578. * It can help following an object from the top (like a car chaing a plane)
  22579. */
  22580. _this.heightOffset = 4;
  22581. /**
  22582. * Minimum allowed height of camera position relative to target object.
  22583. * This can help limiting how the Camera is able to move in the scene.
  22584. */
  22585. _this.lowerHeightOffsetLimit = null;
  22586. /**
  22587. * Maximum allowed height of camera position relative to target object.
  22588. * This can help limiting how the Camera is able to move in the scene.
  22589. */
  22590. _this.upperHeightOffsetLimit = null;
  22591. /**
  22592. * Define how fast the camera can accelerate to follow it s target.
  22593. */
  22594. _this.cameraAcceleration = 0.05;
  22595. /**
  22596. * Define the speed limit of the camera following an object.
  22597. */
  22598. _this.maxCameraSpeed = 20;
  22599. _this.lockedTarget = lockedTarget;
  22600. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  22601. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  22602. return _this;
  22603. // Uncomment the following line when the relevant handlers have been implemented.
  22604. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  22605. }
  22606. FollowCamera.prototype._follow = function (cameraTarget) {
  22607. if (!cameraTarget) {
  22608. return;
  22609. }
  22610. var yRotation;
  22611. if (cameraTarget.rotationQuaternion) {
  22612. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  22613. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  22614. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  22615. }
  22616. else {
  22617. yRotation = cameraTarget.rotation.y;
  22618. }
  22619. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  22620. var targetPosition = cameraTarget.getAbsolutePosition();
  22621. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  22622. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  22623. var dx = targetX - this.position.x;
  22624. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  22625. var dz = (targetZ) - this.position.z;
  22626. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  22627. var vy = dy * this.cameraAcceleration;
  22628. var vz = dz * this.cameraAcceleration * 2;
  22629. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  22630. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22631. }
  22632. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  22633. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22634. }
  22635. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  22636. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22637. }
  22638. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  22639. this.setTarget(targetPosition);
  22640. };
  22641. /**
  22642. * Attached controls to the current camera.
  22643. * @param element Defines the element the controls should be listened from
  22644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22645. */
  22646. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  22647. this.inputs.attachElement(element, noPreventDefault);
  22648. this._reset = function () {
  22649. };
  22650. };
  22651. /**
  22652. * Detach the current controls from the camera.
  22653. * The camera will stop reacting to inputs.
  22654. * @param element Defines the element to stop listening the inputs from
  22655. */
  22656. FollowCamera.prototype.detachControl = function (element) {
  22657. this.inputs.detachElement(element);
  22658. if (this._reset) {
  22659. this._reset();
  22660. }
  22661. };
  22662. /** @hidden */
  22663. FollowCamera.prototype._checkInputs = function () {
  22664. this.inputs.checkInputs();
  22665. this._checkLimits();
  22666. _super.prototype._checkInputs.call(this);
  22667. if (this.lockedTarget) {
  22668. this._follow(this.lockedTarget);
  22669. }
  22670. };
  22671. FollowCamera.prototype._checkLimits = function () {
  22672. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  22673. this.radius = this.lowerRadiusLimit;
  22674. }
  22675. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  22676. this.radius = this.upperRadiusLimit;
  22677. }
  22678. if (this.lowerHeightOffsetLimit !== null &&
  22679. this.heightOffset < this.lowerHeightOffsetLimit) {
  22680. this.heightOffset = this.lowerHeightOffsetLimit;
  22681. }
  22682. if (this.upperHeightOffsetLimit !== null &&
  22683. this.heightOffset > this.upperHeightOffsetLimit) {
  22684. this.heightOffset = this.upperHeightOffsetLimit;
  22685. }
  22686. if (this.lowerRotationOffsetLimit !== null &&
  22687. this.rotationOffset < this.lowerRotationOffsetLimit) {
  22688. this.rotationOffset = this.lowerRotationOffsetLimit;
  22689. }
  22690. if (this.upperRotationOffsetLimit !== null &&
  22691. this.rotationOffset > this.upperRotationOffsetLimit) {
  22692. this.rotationOffset = this.upperRotationOffsetLimit;
  22693. }
  22694. };
  22695. /**
  22696. * Gets the camera class name.
  22697. * @returns the class name
  22698. */
  22699. FollowCamera.prototype.getClassName = function () {
  22700. return "FollowCamera";
  22701. };
  22702. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22703. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22704. ], FollowCamera.prototype, "radius", void 0);
  22705. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22706. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22707. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  22708. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22710. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  22711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22713. ], FollowCamera.prototype, "rotationOffset", void 0);
  22714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22716. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  22717. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22718. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22719. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  22720. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22721. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22722. ], FollowCamera.prototype, "heightOffset", void 0);
  22723. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22724. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22725. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  22726. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22727. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22728. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  22729. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22730. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22731. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  22732. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22733. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22734. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  22735. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22736. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  22737. ], FollowCamera.prototype, "lockedTarget", void 0);
  22738. return FollowCamera;
  22739. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22740. /**
  22741. * Arc Rotate version of the follow camera.
  22742. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  22743. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22744. */
  22745. var ArcFollowCamera = /** @class */ (function (_super) {
  22746. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  22747. /**
  22748. * Instantiates a new ArcFollowCamera
  22749. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22750. * @param name Define the name of the camera
  22751. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  22752. * @param beta Define the rotation angle of the camera around the elevation axis
  22753. * @param radius Define the radius of the camera from its target point
  22754. * @param target Define the target of the camera
  22755. * @param scene Define the scene the camera belongs to
  22756. */
  22757. function ArcFollowCamera(name,
  22758. /** The longitudinal angle of the camera */
  22759. alpha,
  22760. /** The latitudinal angle of the camera */
  22761. beta,
  22762. /** The radius of the camera from its target */
  22763. radius,
  22764. /** Define the camera target (the messh it should follow) */
  22765. target, scene) {
  22766. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  22767. _this.alpha = alpha;
  22768. _this.beta = beta;
  22769. _this.radius = radius;
  22770. _this.target = target;
  22771. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  22772. _this._follow();
  22773. return _this;
  22774. }
  22775. ArcFollowCamera.prototype._follow = function () {
  22776. if (!this.target) {
  22777. return;
  22778. }
  22779. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22780. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22781. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22782. var targetPosition = this.target.getAbsolutePosition();
  22783. this.position = targetPosition.add(this._cartesianCoordinates);
  22784. this.setTarget(targetPosition);
  22785. };
  22786. /** @hidden */
  22787. ArcFollowCamera.prototype._checkInputs = function () {
  22788. _super.prototype._checkInputs.call(this);
  22789. this._follow();
  22790. };
  22791. /**
  22792. * Returns the class name of the object.
  22793. * It is mostly used internally for serialization purposes.
  22794. */
  22795. ArcFollowCamera.prototype.getClassName = function () {
  22796. return "ArcFollowCamera";
  22797. };
  22798. return ArcFollowCamera;
  22799. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22800. /***/ }),
  22801. /***/ "./Cameras/followCameraInputsManager.ts":
  22802. /*!**********************************************!*\
  22803. !*** ./Cameras/followCameraInputsManager.ts ***!
  22804. \**********************************************/
  22805. /*! exports provided: FollowCameraInputsManager */
  22806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22807. "use strict";
  22808. __webpack_require__.r(__webpack_exports__);
  22809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22810. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22811. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22812. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22813. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22814. /* harmony import */ var _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  22815. /**
  22816. * Default Inputs manager for the FollowCamera.
  22817. * It groups all the default supported inputs for ease of use.
  22818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22819. */
  22820. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22821. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22822. /**
  22823. * Instantiates a new FollowCameraInputsManager.
  22824. * @param camera Defines the camera the inputs belong to
  22825. */
  22826. function FollowCameraInputsManager(camera) {
  22827. return _super.call(this, camera) || this;
  22828. }
  22829. /**
  22830. * Add keyboard input support to the input manager.
  22831. * @returns the current input manager
  22832. */
  22833. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22834. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22835. return this;
  22836. };
  22837. /**
  22838. * Add mouse wheel input support to the input manager.
  22839. * @returns the current input manager
  22840. */
  22841. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22842. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22843. return this;
  22844. };
  22845. /**
  22846. * Add pointers input support to the input manager.
  22847. * @returns the current input manager
  22848. */
  22849. FollowCameraInputsManager.prototype.addPointers = function () {
  22850. this.add(new _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__["FollowCameraPointersInput"]());
  22851. return this;
  22852. };
  22853. /**
  22854. * Add orientation input support to the input manager.
  22855. * @returns the current input manager
  22856. */
  22857. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22858. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22859. return this;
  22860. };
  22861. return FollowCameraInputsManager;
  22862. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22863. /***/ }),
  22864. /***/ "./Cameras/freeCamera.ts":
  22865. /*!*******************************!*\
  22866. !*** ./Cameras/freeCamera.ts ***!
  22867. \*******************************/
  22868. /*! exports provided: FreeCamera */
  22869. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22870. "use strict";
  22871. __webpack_require__.r(__webpack_exports__);
  22872. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22873. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22874. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22875. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22876. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22877. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22878. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22879. /**
  22880. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22881. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22882. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22883. */
  22884. var FreeCamera = /** @class */ (function (_super) {
  22885. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22886. /**
  22887. * Instantiates a Free Camera.
  22888. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22889. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22890. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22891. * @param name Define the name of the camera in the scene
  22892. * @param position Define the start position of the camera in the scene
  22893. * @param scene Define the scene the camera belongs to
  22894. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22895. */
  22896. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22897. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22898. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22899. /**
  22900. * Define the collision ellipsoid of the camera.
  22901. * This is helpful to simulate a camera body like the player body around the camera
  22902. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22903. */
  22904. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22905. /**
  22906. * Define an offset for the position of the ellipsoid around the camera.
  22907. * This can be helpful to determine the center of the body near the gravity center of the body
  22908. * instead of its head.
  22909. */
  22910. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22911. /**
  22912. * Enable or disable collisions of the camera with the rest of the scene objects.
  22913. */
  22914. _this.checkCollisions = false;
  22915. /**
  22916. * Enable or disable gravity on the camera.
  22917. */
  22918. _this.applyGravity = false;
  22919. _this._needMoveForGravity = false;
  22920. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22921. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22922. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22923. // Collisions
  22924. _this._collisionMask = -1;
  22925. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22926. if (collidedMesh === void 0) { collidedMesh = null; }
  22927. var updatePosition = function (newPos) {
  22928. _this._newPosition.copyFrom(newPos);
  22929. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22930. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22931. _this.position.addInPlace(_this._diffPosition);
  22932. if (_this.onCollide && collidedMesh) {
  22933. _this.onCollide(collidedMesh);
  22934. }
  22935. }
  22936. };
  22937. updatePosition(newPosition);
  22938. };
  22939. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22940. _this.inputs.addKeyboard().addMouse();
  22941. return _this;
  22942. }
  22943. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22944. /**
  22945. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22946. * Higher values reduce sensitivity.
  22947. */
  22948. get: function () {
  22949. var mouse = this.inputs.attached["mouse"];
  22950. if (mouse) {
  22951. return mouse.angularSensibility;
  22952. }
  22953. return 0;
  22954. },
  22955. /**
  22956. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22957. * Higher values reduce sensitivity.
  22958. */
  22959. set: function (value) {
  22960. var mouse = this.inputs.attached["mouse"];
  22961. if (mouse) {
  22962. mouse.angularSensibility = value;
  22963. }
  22964. },
  22965. enumerable: true,
  22966. configurable: true
  22967. });
  22968. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22969. /**
  22970. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22971. */
  22972. get: function () {
  22973. var keyboard = this.inputs.attached["keyboard"];
  22974. if (keyboard) {
  22975. return keyboard.keysUp;
  22976. }
  22977. return [];
  22978. },
  22979. set: function (value) {
  22980. var keyboard = this.inputs.attached["keyboard"];
  22981. if (keyboard) {
  22982. keyboard.keysUp = value;
  22983. }
  22984. },
  22985. enumerable: true,
  22986. configurable: true
  22987. });
  22988. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22989. /**
  22990. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22991. */
  22992. get: function () {
  22993. var keyboard = this.inputs.attached["keyboard"];
  22994. if (keyboard) {
  22995. return keyboard.keysDown;
  22996. }
  22997. return [];
  22998. },
  22999. set: function (value) {
  23000. var keyboard = this.inputs.attached["keyboard"];
  23001. if (keyboard) {
  23002. keyboard.keysDown = value;
  23003. }
  23004. },
  23005. enumerable: true,
  23006. configurable: true
  23007. });
  23008. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  23009. /**
  23010. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  23011. */
  23012. get: function () {
  23013. var keyboard = this.inputs.attached["keyboard"];
  23014. if (keyboard) {
  23015. return keyboard.keysLeft;
  23016. }
  23017. return [];
  23018. },
  23019. set: function (value) {
  23020. var keyboard = this.inputs.attached["keyboard"];
  23021. if (keyboard) {
  23022. keyboard.keysLeft = value;
  23023. }
  23024. },
  23025. enumerable: true,
  23026. configurable: true
  23027. });
  23028. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  23029. /**
  23030. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  23031. */
  23032. get: function () {
  23033. var keyboard = this.inputs.attached["keyboard"];
  23034. if (keyboard) {
  23035. return keyboard.keysRight;
  23036. }
  23037. return [];
  23038. },
  23039. set: function (value) {
  23040. var keyboard = this.inputs.attached["keyboard"];
  23041. if (keyboard) {
  23042. keyboard.keysRight = value;
  23043. }
  23044. },
  23045. enumerable: true,
  23046. configurable: true
  23047. });
  23048. /**
  23049. * Attached controls to the current camera.
  23050. * @param element Defines the element the controls should be listened from
  23051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23052. */
  23053. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  23054. this.inputs.attachElement(element, noPreventDefault);
  23055. };
  23056. /**
  23057. * Detach the current controls from the camera.
  23058. * The camera will stop reacting to inputs.
  23059. * @param element Defines the element to stop listening the inputs from
  23060. */
  23061. FreeCamera.prototype.detachControl = function (element) {
  23062. this.inputs.detachElement(element);
  23063. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  23064. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  23065. };
  23066. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  23067. /**
  23068. * Define a collision mask to limit the list of object the camera can collide with
  23069. */
  23070. get: function () {
  23071. return this._collisionMask;
  23072. },
  23073. set: function (mask) {
  23074. this._collisionMask = !isNaN(mask) ? mask : -1;
  23075. },
  23076. enumerable: true,
  23077. configurable: true
  23078. });
  23079. /** @hidden */
  23080. FreeCamera.prototype._collideWithWorld = function (displacement) {
  23081. var globalPosition;
  23082. if (this.parent) {
  23083. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  23084. }
  23085. else {
  23086. globalPosition = this.position;
  23087. }
  23088. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  23089. this._oldPosition.addInPlace(this.ellipsoidOffset);
  23090. var coordinator = this.getScene().collisionCoordinator;
  23091. if (!this._collider) {
  23092. this._collider = coordinator.createCollider();
  23093. }
  23094. this._collider._radius = this.ellipsoid;
  23095. this._collider.collisionMask = this._collisionMask;
  23096. //no need for clone, as long as gravity is not on.
  23097. var actualDisplacement = displacement;
  23098. //add gravity to the direction to prevent the dual-collision checking
  23099. if (this.applyGravity) {
  23100. //this prevents mending with cameraDirection, a global variable of the free camera class.
  23101. actualDisplacement = displacement.add(this.getScene().gravity);
  23102. }
  23103. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  23104. };
  23105. /** @hidden */
  23106. FreeCamera.prototype._checkInputs = function () {
  23107. if (!this._localDirection) {
  23108. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23109. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23110. }
  23111. this.inputs.checkInputs();
  23112. _super.prototype._checkInputs.call(this);
  23113. };
  23114. /** @hidden */
  23115. FreeCamera.prototype._decideIfNeedsToMove = function () {
  23116. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23117. };
  23118. /** @hidden */
  23119. FreeCamera.prototype._updatePosition = function () {
  23120. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  23121. this._collideWithWorld(this.cameraDirection);
  23122. }
  23123. else {
  23124. _super.prototype._updatePosition.call(this);
  23125. }
  23126. };
  23127. /**
  23128. * Destroy the camera and release the current resources hold by it.
  23129. */
  23130. FreeCamera.prototype.dispose = function () {
  23131. this.inputs.clear();
  23132. _super.prototype.dispose.call(this);
  23133. };
  23134. /**
  23135. * Gets the current object class name.
  23136. * @return the class name
  23137. */
  23138. FreeCamera.prototype.getClassName = function () {
  23139. return "FreeCamera";
  23140. };
  23141. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23142. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23143. ], FreeCamera.prototype, "ellipsoid", void 0);
  23144. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23145. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23146. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  23147. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23148. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23149. ], FreeCamera.prototype, "checkCollisions", void 0);
  23150. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23152. ], FreeCamera.prototype, "applyGravity", void 0);
  23153. return FreeCamera;
  23154. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  23155. /***/ }),
  23156. /***/ "./Cameras/freeCameraInputsManager.ts":
  23157. /*!********************************************!*\
  23158. !*** ./Cameras/freeCameraInputsManager.ts ***!
  23159. \********************************************/
  23160. /*! exports provided: FreeCameraInputsManager */
  23161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23162. "use strict";
  23163. __webpack_require__.r(__webpack_exports__);
  23164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  23165. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23166. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23167. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  23168. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  23169. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  23170. /**
  23171. * Default Inputs manager for the FreeCamera.
  23172. * It groups all the default supported inputs for ease of use.
  23173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  23174. */
  23175. var FreeCameraInputsManager = /** @class */ (function (_super) {
  23176. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  23177. /**
  23178. * Instantiates a new FreeCameraInputsManager.
  23179. * @param camera Defines the camera the inputs belong to
  23180. */
  23181. function FreeCameraInputsManager(camera) {
  23182. var _this = _super.call(this, camera) || this;
  23183. /**
  23184. * @hidden
  23185. */
  23186. _this._mouseInput = null;
  23187. return _this;
  23188. }
  23189. /**
  23190. * Add keyboard input support to the input manager.
  23191. * @returns the current input manager
  23192. */
  23193. FreeCameraInputsManager.prototype.addKeyboard = function () {
  23194. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  23195. return this;
  23196. };
  23197. /**
  23198. * Add mouse input support to the input manager.
  23199. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  23200. * @returns the current input manager
  23201. */
  23202. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  23203. if (touchEnabled === void 0) { touchEnabled = true; }
  23204. if (!this._mouseInput) {
  23205. this._mouseInput = new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled);
  23206. this.add(this._mouseInput);
  23207. }
  23208. return this;
  23209. };
  23210. /**
  23211. * Removes the mouse input support from the manager
  23212. * @returns the current input manager
  23213. */
  23214. FreeCameraInputsManager.prototype.removeMouse = function () {
  23215. if (this._mouseInput) {
  23216. this.remove(this._mouseInput);
  23217. }
  23218. return this;
  23219. };
  23220. /**
  23221. * Add touch input support to the input manager.
  23222. * @returns the current input manager
  23223. */
  23224. FreeCameraInputsManager.prototype.addTouch = function () {
  23225. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  23226. return this;
  23227. };
  23228. /**
  23229. * Remove all attached input methods from a camera
  23230. */
  23231. FreeCameraInputsManager.prototype.clear = function () {
  23232. _super.prototype.clear.call(this);
  23233. this._mouseInput = null;
  23234. };
  23235. return FreeCameraInputsManager;
  23236. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  23237. /***/ }),
  23238. /***/ "./Cameras/gamepadCamera.ts":
  23239. /*!**********************************!*\
  23240. !*** ./Cameras/gamepadCamera.ts ***!
  23241. \**********************************/
  23242. /*! exports provided: GamepadCamera */
  23243. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23244. "use strict";
  23245. __webpack_require__.r(__webpack_exports__);
  23246. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  23247. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23248. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23249. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23250. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23251. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  23252. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23253. });
  23254. /**
  23255. * This represents a FPS type of camera. This is only here for back compat purpose.
  23256. * Please use the UniversalCamera instead as both are identical.
  23257. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23258. */
  23259. var GamepadCamera = /** @class */ (function (_super) {
  23260. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  23261. /**
  23262. * Instantiates a new Gamepad Camera
  23263. * This represents a FPS type of camera. This is only here for back compat purpose.
  23264. * Please use the UniversalCamera instead as both are identical.
  23265. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23266. * @param name Define the name of the camera in the scene
  23267. * @param position Define the start position of the camera in the scene
  23268. * @param scene Define the scene the camera belongs to
  23269. */
  23270. function GamepadCamera(name, position, scene) {
  23271. return _super.call(this, name, position, scene) || this;
  23272. }
  23273. /**
  23274. * Gets the current object class name.
  23275. * @return the class name
  23276. */
  23277. GamepadCamera.prototype.getClassName = function () {
  23278. return "GamepadCamera";
  23279. };
  23280. return GamepadCamera;
  23281. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  23282. /***/ }),
  23283. /***/ "./Cameras/index.ts":
  23284. /*!**************************!*\
  23285. !*** ./Cameras/index.ts ***!
  23286. \**************************/
  23287. /*! 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 */
  23288. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23289. "use strict";
  23290. __webpack_require__.r(__webpack_exports__);
  23291. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  23292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  23293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  23294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  23295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  23296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  23297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  23298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  23299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  23300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  23301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  23302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  23303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  23304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  23305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  23306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  23307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  23308. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  23310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  23311. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  23313. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  23314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  23315. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  23317. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  23318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  23319. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  23321. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  23322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  23323. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  23324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  23325. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  23326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  23327. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  23328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  23329. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  23330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  23331. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  23332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  23333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  23334. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  23335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  23336. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  23337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  23338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  23339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  23340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  23341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  23342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  23343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  23344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  23345. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  23347. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  23348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  23349. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  23350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  23351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  23352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  23353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  23354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["OnAfterEnteringVRObservableEvent"]; });
  23355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  23356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  23357. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  23358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  23359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  23360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  23361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  23362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  23363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  23364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  23365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  23366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  23367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  23368. /***/ }),
  23369. /***/ "./Cameras/targetCamera.ts":
  23370. /*!*********************************!*\
  23371. !*** ./Cameras/targetCamera.ts ***!
  23372. \*********************************/
  23373. /*! exports provided: TargetCamera */
  23374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23375. "use strict";
  23376. __webpack_require__.r(__webpack_exports__);
  23377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  23378. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23379. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  23380. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23381. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23382. /**
  23383. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  23384. * This is the base of the follow, arc rotate cameras and Free camera
  23385. * @see http://doc.babylonjs.com/features/cameras
  23386. */
  23387. var TargetCamera = /** @class */ (function (_super) {
  23388. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  23389. /**
  23390. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  23391. * This is the base of the follow, arc rotate cameras and Free camera
  23392. * @see http://doc.babylonjs.com/features/cameras
  23393. * @param name Defines the name of the camera in the scene
  23394. * @param position Defines the start position of the camera in the scene
  23395. * @param scene Defines the scene the camera belongs to
  23396. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  23397. */
  23398. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  23399. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  23400. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  23401. /**
  23402. * Define the current direction the camera is moving to
  23403. */
  23404. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23405. /**
  23406. * Define the current rotation the camera is rotating to
  23407. */
  23408. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  23409. /**
  23410. * When set, the up vector of the camera will be updated by the rotation of the camera
  23411. */
  23412. _this.updateUpVectorFromRotation = false;
  23413. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23414. /**
  23415. * Define the current rotation of the camera
  23416. */
  23417. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23418. /**
  23419. * Define the current speed of the camera
  23420. */
  23421. _this.speed = 2.0;
  23422. /**
  23423. * Add cconstraint to the camera to prevent it to move freely in all directions and
  23424. * around all axis.
  23425. */
  23426. _this.noRotationConstraint = false;
  23427. /**
  23428. * Define the current target of the camera as an object or a position.
  23429. */
  23430. _this.lockedTarget = null;
  23431. /** @hidden */
  23432. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23433. /** @hidden */
  23434. _this._initialFocalDistance = 1;
  23435. /** @hidden */
  23436. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23437. /** @hidden */
  23438. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23439. /** @hidden */
  23440. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23441. /** @hidden */
  23442. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23443. /** @hidden */
  23444. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  23445. /** @hidden */
  23446. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23447. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23448. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23449. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  23450. _this._cachedRotationZ = 0;
  23451. _this._cachedQuaternionRotationZ = 0;
  23452. return _this;
  23453. }
  23454. /**
  23455. * Gets the position in front of the camera at a given distance.
  23456. * @param distance The distance from the camera we want the position to be
  23457. * @returns the position
  23458. */
  23459. TargetCamera.prototype.getFrontPosition = function (distance) {
  23460. this.getWorldMatrix();
  23461. var direction = this.getTarget().subtract(this.position);
  23462. direction.normalize();
  23463. direction.scaleInPlace(distance);
  23464. return this.globalPosition.add(direction);
  23465. };
  23466. /** @hidden */
  23467. TargetCamera.prototype._getLockedTargetPosition = function () {
  23468. if (!this.lockedTarget) {
  23469. return null;
  23470. }
  23471. if (this.lockedTarget.absolutePosition) {
  23472. this.lockedTarget.computeWorldMatrix();
  23473. }
  23474. return this.lockedTarget.absolutePosition || this.lockedTarget;
  23475. };
  23476. /**
  23477. * Store current camera state of the camera (fov, position, rotation, etc..)
  23478. * @returns the camera
  23479. */
  23480. TargetCamera.prototype.storeState = function () {
  23481. this._storedPosition = this.position.clone();
  23482. this._storedRotation = this.rotation.clone();
  23483. if (this.rotationQuaternion) {
  23484. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  23485. }
  23486. return _super.prototype.storeState.call(this);
  23487. };
  23488. /**
  23489. * Restored camera state. You must call storeState() first
  23490. * @returns whether it was successful or not
  23491. * @hidden
  23492. */
  23493. TargetCamera.prototype._restoreStateValues = function () {
  23494. if (!_super.prototype._restoreStateValues.call(this)) {
  23495. return false;
  23496. }
  23497. this.position = this._storedPosition.clone();
  23498. this.rotation = this._storedRotation.clone();
  23499. if (this.rotationQuaternion) {
  23500. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  23501. }
  23502. this.cameraDirection.copyFromFloats(0, 0, 0);
  23503. this.cameraRotation.copyFromFloats(0, 0);
  23504. return true;
  23505. };
  23506. /** @hidden */
  23507. TargetCamera.prototype._initCache = function () {
  23508. _super.prototype._initCache.call(this);
  23509. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23510. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23511. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23512. };
  23513. /** @hidden */
  23514. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  23515. if (!ignoreParentClass) {
  23516. _super.prototype._updateCache.call(this);
  23517. }
  23518. var lockedTargetPosition = this._getLockedTargetPosition();
  23519. if (!lockedTargetPosition) {
  23520. this._cache.lockedTarget = null;
  23521. }
  23522. else {
  23523. if (!this._cache.lockedTarget) {
  23524. this._cache.lockedTarget = lockedTargetPosition.clone();
  23525. }
  23526. else {
  23527. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  23528. }
  23529. }
  23530. this._cache.rotation.copyFrom(this.rotation);
  23531. if (this.rotationQuaternion) {
  23532. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23533. }
  23534. };
  23535. // Synchronized
  23536. /** @hidden */
  23537. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  23538. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  23539. return false;
  23540. }
  23541. var lockedTargetPosition = this._getLockedTargetPosition();
  23542. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  23543. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  23544. };
  23545. // Methods
  23546. /** @hidden */
  23547. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  23548. var engine = this.getEngine();
  23549. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  23550. };
  23551. // Target
  23552. /**
  23553. * Defines the target the camera should look at.
  23554. * This will automatically adapt alpha beta and radius to fit within the new target.
  23555. * @param target Defines the new target as a Vector or a mesh
  23556. */
  23557. TargetCamera.prototype.setTarget = function (target) {
  23558. this.upVector.normalize();
  23559. this._initialFocalDistance = target.subtract(this.position).length();
  23560. if (this.position.z === target.z) {
  23561. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  23562. }
  23563. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  23564. this._camMatrix.invert();
  23565. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  23566. var vDir = target.subtract(this.position);
  23567. if (vDir.x >= 0.0) {
  23568. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  23569. }
  23570. else {
  23571. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  23572. }
  23573. this.rotation.z = 0;
  23574. if (isNaN(this.rotation.x)) {
  23575. this.rotation.x = 0;
  23576. }
  23577. if (isNaN(this.rotation.y)) {
  23578. this.rotation.y = 0;
  23579. }
  23580. if (isNaN(this.rotation.z)) {
  23581. this.rotation.z = 0;
  23582. }
  23583. if (this.rotationQuaternion) {
  23584. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23585. }
  23586. };
  23587. /**
  23588. * Return the current target position of the camera. This value is expressed in local space.
  23589. * @returns the target position
  23590. */
  23591. TargetCamera.prototype.getTarget = function () {
  23592. return this._currentTarget;
  23593. };
  23594. /** @hidden */
  23595. TargetCamera.prototype._decideIfNeedsToMove = function () {
  23596. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23597. };
  23598. /** @hidden */
  23599. TargetCamera.prototype._updatePosition = function () {
  23600. if (this.parent) {
  23601. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  23602. _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]);
  23603. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  23604. return;
  23605. }
  23606. this.position.addInPlace(this.cameraDirection);
  23607. };
  23608. /** @hidden */
  23609. TargetCamera.prototype._checkInputs = function () {
  23610. var needToMove = this._decideIfNeedsToMove();
  23611. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  23612. // Move
  23613. if (needToMove) {
  23614. this._updatePosition();
  23615. }
  23616. // Rotate
  23617. if (needToRotate) {
  23618. this.rotation.x += this.cameraRotation.x;
  23619. this.rotation.y += this.cameraRotation.y;
  23620. //rotate, if quaternion is set and rotation was used
  23621. if (this.rotationQuaternion) {
  23622. var len = this.rotation.lengthSquared();
  23623. if (len) {
  23624. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23625. }
  23626. }
  23627. if (!this.noRotationConstraint) {
  23628. var limit = (Math.PI / 2) * 0.95;
  23629. if (this.rotation.x > limit) {
  23630. this.rotation.x = limit;
  23631. }
  23632. if (this.rotation.x < -limit) {
  23633. this.rotation.x = -limit;
  23634. }
  23635. }
  23636. }
  23637. // Inertia
  23638. if (needToMove) {
  23639. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23640. this.cameraDirection.x = 0;
  23641. }
  23642. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23643. this.cameraDirection.y = 0;
  23644. }
  23645. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23646. this.cameraDirection.z = 0;
  23647. }
  23648. this.cameraDirection.scaleInPlace(this.inertia);
  23649. }
  23650. if (needToRotate) {
  23651. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23652. this.cameraRotation.x = 0;
  23653. }
  23654. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23655. this.cameraRotation.y = 0;
  23656. }
  23657. this.cameraRotation.scaleInPlace(this.inertia);
  23658. }
  23659. _super.prototype._checkInputs.call(this);
  23660. };
  23661. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  23662. if (this.rotationQuaternion) {
  23663. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  23664. }
  23665. else {
  23666. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  23667. }
  23668. };
  23669. /**
  23670. * 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)
  23671. * @returns the current camera
  23672. */
  23673. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  23674. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  23675. return this;
  23676. };
  23677. /** @hidden */
  23678. TargetCamera.prototype._getViewMatrix = function () {
  23679. if (this.lockedTarget) {
  23680. this.setTarget(this._getLockedTargetPosition());
  23681. }
  23682. // Compute
  23683. this._updateCameraRotationMatrix();
  23684. // Apply the changed rotation to the upVector
  23685. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  23686. this._rotateUpVectorWithCameraRotationMatrix();
  23687. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  23688. }
  23689. else if (this._cachedRotationZ != this.rotation.z) {
  23690. this._rotateUpVectorWithCameraRotationMatrix();
  23691. this._cachedRotationZ = this.rotation.z;
  23692. }
  23693. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  23694. // Computing target and final matrix
  23695. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  23696. if (this.updateUpVectorFromRotation) {
  23697. if (this.rotationQuaternion) {
  23698. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  23699. }
  23700. else {
  23701. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  23702. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  23703. }
  23704. }
  23705. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  23706. return this._viewMatrix;
  23707. };
  23708. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  23709. if (this.parent) {
  23710. var parentWorldMatrix = this.parent.getWorldMatrix();
  23711. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  23712. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  23713. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  23714. this._markSyncedWithParent();
  23715. }
  23716. else {
  23717. this._globalPosition.copyFrom(position);
  23718. this._globalCurrentTarget.copyFrom(target);
  23719. this._globalCurrentUpVector.copyFrom(up);
  23720. }
  23721. if (this.getScene().useRightHandedSystem) {
  23722. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23723. }
  23724. else {
  23725. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23726. }
  23727. };
  23728. /**
  23729. * @hidden
  23730. */
  23731. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  23732. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  23733. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  23734. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  23735. if (!this.rotationQuaternion) {
  23736. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23737. }
  23738. rigCamera._cameraRigParams = {};
  23739. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23740. }
  23741. return rigCamera;
  23742. }
  23743. return null;
  23744. };
  23745. /**
  23746. * @hidden
  23747. */
  23748. TargetCamera.prototype._updateRigCameras = function () {
  23749. var camLeft = this._rigCameras[0];
  23750. var camRight = this._rigCameras[1];
  23751. this.computeWorldMatrix();
  23752. switch (this.cameraRigMode) {
  23753. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  23754. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  23755. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  23756. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  23757. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  23758. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  23759. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  23760. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  23761. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  23762. break;
  23763. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  23764. if (camLeft.rotationQuaternion) {
  23765. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23766. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23767. }
  23768. else {
  23769. camLeft.rotation.copyFrom(this.rotation);
  23770. camRight.rotation.copyFrom(this.rotation);
  23771. }
  23772. camLeft.position.copyFrom(this.position);
  23773. camRight.position.copyFrom(this.position);
  23774. break;
  23775. }
  23776. _super.prototype._updateRigCameras.call(this);
  23777. };
  23778. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  23779. var target = this.getTarget();
  23780. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  23781. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  23782. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  23783. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23784. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  23785. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23786. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  23787. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  23788. rigCamera.setTarget(newFocalTarget);
  23789. };
  23790. /**
  23791. * Gets the current object class name.
  23792. * @return the class name
  23793. */
  23794. TargetCamera.prototype.getClassName = function () {
  23795. return "TargetCamera";
  23796. };
  23797. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23798. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23799. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  23800. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23801. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23802. ], TargetCamera.prototype, "rotation", void 0);
  23803. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23804. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23805. ], TargetCamera.prototype, "speed", void 0);
  23806. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23807. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23808. ], TargetCamera.prototype, "lockedTarget", void 0);
  23809. return TargetCamera;
  23810. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23811. /***/ }),
  23812. /***/ "./Cameras/touchCamera.ts":
  23813. /*!********************************!*\
  23814. !*** ./Cameras/touchCamera.ts ***!
  23815. \********************************/
  23816. /*! exports provided: TouchCamera */
  23817. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23818. "use strict";
  23819. __webpack_require__.r(__webpack_exports__);
  23820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23821. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23822. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23823. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23824. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23825. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23826. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23827. });
  23828. /**
  23829. * This represents a FPS type of camera controlled by touch.
  23830. * This is like a universal camera minus the Gamepad controls.
  23831. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23832. */
  23833. var TouchCamera = /** @class */ (function (_super) {
  23834. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23835. /**
  23836. * Instantiates a new touch camera.
  23837. * This represents a FPS type of camera controlled by touch.
  23838. * This is like a universal camera minus the Gamepad controls.
  23839. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23840. * @param name Define the name of the camera in the scene
  23841. * @param position Define the start position of the camera in the scene
  23842. * @param scene Define the scene the camera belongs to
  23843. */
  23844. function TouchCamera(name, position, scene) {
  23845. var _this = _super.call(this, name, position, scene) || this;
  23846. _this.inputs.addTouch();
  23847. _this._setupInputs();
  23848. return _this;
  23849. }
  23850. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23851. /**
  23852. * Defines the touch sensibility for rotation.
  23853. * The higher the faster.
  23854. */
  23855. get: function () {
  23856. var touch = this.inputs.attached["touch"];
  23857. if (touch) {
  23858. return touch.touchAngularSensibility;
  23859. }
  23860. return 0;
  23861. },
  23862. set: function (value) {
  23863. var touch = this.inputs.attached["touch"];
  23864. if (touch) {
  23865. touch.touchAngularSensibility = value;
  23866. }
  23867. },
  23868. enumerable: true,
  23869. configurable: true
  23870. });
  23871. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23872. /**
  23873. * Defines the touch sensibility for move.
  23874. * The higher the faster.
  23875. */
  23876. get: function () {
  23877. var touch = this.inputs.attached["touch"];
  23878. if (touch) {
  23879. return touch.touchMoveSensibility;
  23880. }
  23881. return 0;
  23882. },
  23883. set: function (value) {
  23884. var touch = this.inputs.attached["touch"];
  23885. if (touch) {
  23886. touch.touchMoveSensibility = value;
  23887. }
  23888. },
  23889. enumerable: true,
  23890. configurable: true
  23891. });
  23892. /**
  23893. * Gets the current object class name.
  23894. * @return the class name
  23895. */
  23896. TouchCamera.prototype.getClassName = function () {
  23897. return "TouchCamera";
  23898. };
  23899. /** @hidden */
  23900. TouchCamera.prototype._setupInputs = function () {
  23901. var mouse = this.inputs.attached["mouse"];
  23902. if (mouse) {
  23903. mouse.touchEnabled = false;
  23904. }
  23905. };
  23906. return TouchCamera;
  23907. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23908. /***/ }),
  23909. /***/ "./Cameras/universalCamera.ts":
  23910. /*!************************************!*\
  23911. !*** ./Cameras/universalCamera.ts ***!
  23912. \************************************/
  23913. /*! exports provided: UniversalCamera */
  23914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23915. "use strict";
  23916. __webpack_require__.r(__webpack_exports__);
  23917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23918. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23919. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23920. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23921. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23922. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23923. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  23924. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23925. // Forcing to use the Universal camera
  23926. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23927. });
  23928. /**
  23929. * 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,
  23930. * which still works and will still be found in many Playgrounds.
  23931. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23932. */
  23933. var UniversalCamera = /** @class */ (function (_super) {
  23934. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23935. /**
  23936. * 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,
  23937. * which still works and will still be found in many Playgrounds.
  23938. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23939. * @param name Define the name of the camera in the scene
  23940. * @param position Define the start position of the camera in the scene
  23941. * @param scene Define the scene the camera belongs to
  23942. */
  23943. function UniversalCamera(name, position, scene) {
  23944. var _this = _super.call(this, name, position, scene) || this;
  23945. _this.inputs.addGamepad();
  23946. return _this;
  23947. }
  23948. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23949. /**
  23950. * Defines the gamepad rotation sensiblity.
  23951. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23952. */
  23953. get: function () {
  23954. var gamepad = this.inputs.attached["gamepad"];
  23955. if (gamepad) {
  23956. return gamepad.gamepadAngularSensibility;
  23957. }
  23958. return 0;
  23959. },
  23960. set: function (value) {
  23961. var gamepad = this.inputs.attached["gamepad"];
  23962. if (gamepad) {
  23963. gamepad.gamepadAngularSensibility = value;
  23964. }
  23965. },
  23966. enumerable: true,
  23967. configurable: true
  23968. });
  23969. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23970. /**
  23971. * Defines the gamepad move sensiblity.
  23972. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23973. */
  23974. get: function () {
  23975. var gamepad = this.inputs.attached["gamepad"];
  23976. if (gamepad) {
  23977. return gamepad.gamepadMoveSensibility;
  23978. }
  23979. return 0;
  23980. },
  23981. set: function (value) {
  23982. var gamepad = this.inputs.attached["gamepad"];
  23983. if (gamepad) {
  23984. gamepad.gamepadMoveSensibility = value;
  23985. }
  23986. },
  23987. enumerable: true,
  23988. configurable: true
  23989. });
  23990. /**
  23991. * Gets the current object class name.
  23992. * @return the class name
  23993. */
  23994. UniversalCamera.prototype.getClassName = function () {
  23995. return "UniversalCamera";
  23996. };
  23997. return UniversalCamera;
  23998. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23999. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  24000. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  24001. };
  24002. /***/ }),
  24003. /***/ "./Cameras/virtualJoysticksCamera.ts":
  24004. /*!*******************************************!*\
  24005. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  24006. \*******************************************/
  24007. /*! exports provided: VirtualJoysticksCamera */
  24008. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24009. "use strict";
  24010. __webpack_require__.r(__webpack_exports__);
  24011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  24012. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  24013. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  24014. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24015. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  24016. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  24017. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  24018. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  24019. });
  24020. /**
  24021. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24022. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  24023. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  24024. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  24025. */
  24026. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  24027. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  24028. /**
  24029. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  24030. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  24031. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  24032. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  24033. * @param name Define the name of the camera in the scene
  24034. * @param position Define the start position of the camera in the scene
  24035. * @param scene Define the scene the camera belongs to
  24036. */
  24037. function VirtualJoysticksCamera(name, position, scene) {
  24038. var _this = _super.call(this, name, position, scene) || this;
  24039. _this.inputs.addVirtualJoystick();
  24040. return _this;
  24041. }
  24042. /**
  24043. * Gets the current object class name.
  24044. * @return the class name
  24045. */
  24046. VirtualJoysticksCamera.prototype.getClassName = function () {
  24047. return "VirtualJoysticksCamera";
  24048. };
  24049. return VirtualJoysticksCamera;
  24050. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  24051. /***/ }),
  24052. /***/ "./Collisions/collider.ts":
  24053. /*!********************************!*\
  24054. !*** ./Collisions/collider.ts ***!
  24055. \********************************/
  24056. /*! exports provided: Collider */
  24057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24058. "use strict";
  24059. __webpack_require__.r(__webpack_exports__);
  24060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  24061. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24062. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  24063. if (boxMin.x > sphereCenter.x + sphereRadius) {
  24064. return false;
  24065. }
  24066. if (sphereCenter.x - sphereRadius > boxMax.x) {
  24067. return false;
  24068. }
  24069. if (boxMin.y > sphereCenter.y + sphereRadius) {
  24070. return false;
  24071. }
  24072. if (sphereCenter.y - sphereRadius > boxMax.y) {
  24073. return false;
  24074. }
  24075. if (boxMin.z > sphereCenter.z + sphereRadius) {
  24076. return false;
  24077. }
  24078. if (sphereCenter.z - sphereRadius > boxMax.z) {
  24079. return false;
  24080. }
  24081. return true;
  24082. };
  24083. var getLowestRoot = (function () {
  24084. var result = { root: 0, found: false };
  24085. return function (a, b, c, maxR) {
  24086. result.root = 0;
  24087. result.found = false;
  24088. var determinant = b * b - 4.0 * a * c;
  24089. if (determinant < 0) {
  24090. return result;
  24091. }
  24092. var sqrtD = Math.sqrt(determinant);
  24093. var r1 = (-b - sqrtD) / (2.0 * a);
  24094. var r2 = (-b + sqrtD) / (2.0 * a);
  24095. if (r1 > r2) {
  24096. var temp = r2;
  24097. r2 = r1;
  24098. r1 = temp;
  24099. }
  24100. if (r1 > 0 && r1 < maxR) {
  24101. result.root = r1;
  24102. result.found = true;
  24103. return result;
  24104. }
  24105. if (r2 > 0 && r2 < maxR) {
  24106. result.root = r2;
  24107. result.found = true;
  24108. return result;
  24109. }
  24110. return result;
  24111. };
  24112. })();
  24113. /** @hidden */
  24114. var Collider = /** @class */ (function () {
  24115. function Collider() {
  24116. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24117. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24118. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24119. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24120. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24121. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24122. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24123. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24124. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24125. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24126. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24127. /** @hidden */
  24128. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  24129. /** @hidden */
  24130. this._retry = 0;
  24131. /** @hidden */
  24132. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24133. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24134. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24135. this._collisionMask = -1;
  24136. }
  24137. Object.defineProperty(Collider.prototype, "collisionMask", {
  24138. get: function () {
  24139. return this._collisionMask;
  24140. },
  24141. set: function (mask) {
  24142. this._collisionMask = !isNaN(mask) ? mask : -1;
  24143. },
  24144. enumerable: true,
  24145. configurable: true
  24146. });
  24147. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  24148. /**
  24149. * Gets the plane normal used to compute the sliding response (in local space)
  24150. */
  24151. get: function () {
  24152. return this._slidePlaneNormal;
  24153. },
  24154. enumerable: true,
  24155. configurable: true
  24156. });
  24157. // Methods
  24158. /** @hidden */
  24159. Collider.prototype._initialize = function (source, dir, e) {
  24160. this._velocity = dir;
  24161. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  24162. this._basePoint = source;
  24163. source.multiplyToRef(this._radius, this._basePointWorld);
  24164. dir.multiplyToRef(this._radius, this._velocityWorld);
  24165. this._velocityWorldLength = this._velocityWorld.length();
  24166. this._epsilon = e;
  24167. this.collisionFound = false;
  24168. };
  24169. /** @hidden */
  24170. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  24171. pa.subtractToRef(point, this._tempVector);
  24172. pb.subtractToRef(point, this._tempVector2);
  24173. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  24174. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24175. if (d < 0) {
  24176. return false;
  24177. }
  24178. pc.subtractToRef(point, this._tempVector3);
  24179. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  24180. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24181. if (d < 0) {
  24182. return false;
  24183. }
  24184. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  24185. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24186. return d >= 0;
  24187. };
  24188. /** @hidden */
  24189. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  24190. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  24191. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  24192. if (distance > this._velocityWorldLength + max + sphereRadius) {
  24193. return false;
  24194. }
  24195. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  24196. return false;
  24197. }
  24198. return true;
  24199. };
  24200. /** @hidden */
  24201. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  24202. var t0;
  24203. var embeddedInPlane = false;
  24204. //defensive programming, actually not needed.
  24205. if (!trianglePlaneArray) {
  24206. trianglePlaneArray = [];
  24207. }
  24208. if (!trianglePlaneArray[faceIndex]) {
  24209. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  24210. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  24211. }
  24212. var trianglePlane = trianglePlaneArray[faceIndex];
  24213. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  24214. return;
  24215. }
  24216. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  24217. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  24218. if (normalDotVelocity == 0) {
  24219. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  24220. return;
  24221. }
  24222. embeddedInPlane = true;
  24223. t0 = 0;
  24224. }
  24225. else {
  24226. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  24227. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  24228. if (t0 > t1) {
  24229. var temp = t1;
  24230. t1 = t0;
  24231. t0 = temp;
  24232. }
  24233. if (t0 > 1.0 || t1 < 0.0) {
  24234. return;
  24235. }
  24236. if (t0 < 0) {
  24237. t0 = 0;
  24238. }
  24239. if (t0 > 1.0) {
  24240. t0 = 1.0;
  24241. }
  24242. }
  24243. this._collisionPoint.copyFromFloats(0, 0, 0);
  24244. var found = false;
  24245. var t = 1.0;
  24246. if (!embeddedInPlane) {
  24247. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  24248. this._velocity.scaleToRef(t0, this._tempVector);
  24249. this._planeIntersectionPoint.addInPlace(this._tempVector);
  24250. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  24251. found = true;
  24252. t = t0;
  24253. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  24254. }
  24255. }
  24256. if (!found) {
  24257. var velocitySquaredLength = this._velocity.lengthSquared();
  24258. var a = velocitySquaredLength;
  24259. this._basePoint.subtractToRef(p1, this._tempVector);
  24260. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24261. var c = this._tempVector.lengthSquared() - 1.0;
  24262. var lowestRoot = getLowestRoot(a, b, c, t);
  24263. if (lowestRoot.found) {
  24264. t = lowestRoot.root;
  24265. found = true;
  24266. this._collisionPoint.copyFrom(p1);
  24267. }
  24268. this._basePoint.subtractToRef(p2, this._tempVector);
  24269. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24270. c = this._tempVector.lengthSquared() - 1.0;
  24271. lowestRoot = getLowestRoot(a, b, c, t);
  24272. if (lowestRoot.found) {
  24273. t = lowestRoot.root;
  24274. found = true;
  24275. this._collisionPoint.copyFrom(p2);
  24276. }
  24277. this._basePoint.subtractToRef(p3, this._tempVector);
  24278. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24279. c = this._tempVector.lengthSquared() - 1.0;
  24280. lowestRoot = getLowestRoot(a, b, c, t);
  24281. if (lowestRoot.found) {
  24282. t = lowestRoot.root;
  24283. found = true;
  24284. this._collisionPoint.copyFrom(p3);
  24285. }
  24286. p2.subtractToRef(p1, this._edge);
  24287. p1.subtractToRef(this._basePoint, this._baseToVertex);
  24288. var edgeSquaredLength = this._edge.lengthSquared();
  24289. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24290. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24291. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24292. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24293. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24294. lowestRoot = getLowestRoot(a, b, c, t);
  24295. if (lowestRoot.found) {
  24296. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24297. if (f >= 0.0 && f <= 1.0) {
  24298. t = lowestRoot.root;
  24299. found = true;
  24300. this._edge.scaleInPlace(f);
  24301. p1.addToRef(this._edge, this._collisionPoint);
  24302. }
  24303. }
  24304. p3.subtractToRef(p2, this._edge);
  24305. p2.subtractToRef(this._basePoint, this._baseToVertex);
  24306. edgeSquaredLength = this._edge.lengthSquared();
  24307. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24308. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24309. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24310. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24311. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24312. lowestRoot = getLowestRoot(a, b, c, t);
  24313. if (lowestRoot.found) {
  24314. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24315. if (f >= 0.0 && f <= 1.0) {
  24316. t = lowestRoot.root;
  24317. found = true;
  24318. this._edge.scaleInPlace(f);
  24319. p2.addToRef(this._edge, this._collisionPoint);
  24320. }
  24321. }
  24322. p1.subtractToRef(p3, this._edge);
  24323. p3.subtractToRef(this._basePoint, this._baseToVertex);
  24324. edgeSquaredLength = this._edge.lengthSquared();
  24325. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24326. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24327. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24328. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24329. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24330. lowestRoot = getLowestRoot(a, b, c, t);
  24331. if (lowestRoot.found) {
  24332. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24333. if (f >= 0.0 && f <= 1.0) {
  24334. t = lowestRoot.root;
  24335. found = true;
  24336. this._edge.scaleInPlace(f);
  24337. p3.addToRef(this._edge, this._collisionPoint);
  24338. }
  24339. }
  24340. }
  24341. if (found) {
  24342. var distToCollision = t * this._velocity.length();
  24343. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  24344. if (!this.intersectionPoint) {
  24345. this.intersectionPoint = this._collisionPoint.clone();
  24346. }
  24347. else {
  24348. this.intersectionPoint.copyFrom(this._collisionPoint);
  24349. }
  24350. this._nearestDistance = distToCollision;
  24351. this.collisionFound = true;
  24352. }
  24353. }
  24354. };
  24355. /** @hidden */
  24356. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  24357. for (var i = indexStart; i < indexEnd; i += 3) {
  24358. var p1 = pts[indices[i] - decal];
  24359. var p2 = pts[indices[i + 1] - decal];
  24360. var p3 = pts[indices[i + 2] - decal];
  24361. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  24362. }
  24363. };
  24364. /** @hidden */
  24365. Collider.prototype._getResponse = function (pos, vel) {
  24366. pos.addToRef(vel, this._destinationPoint);
  24367. vel.scaleInPlace((this._nearestDistance / vel.length()));
  24368. this._basePoint.addToRef(vel, pos);
  24369. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  24370. this._slidePlaneNormal.normalize();
  24371. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  24372. pos.addInPlace(this._displacementVector);
  24373. this.intersectionPoint.addInPlace(this._displacementVector);
  24374. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  24375. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  24376. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  24377. };
  24378. return Collider;
  24379. }());
  24380. /***/ }),
  24381. /***/ "./Collisions/collisionCoordinator.ts":
  24382. /*!********************************************!*\
  24383. !*** ./Collisions/collisionCoordinator.ts ***!
  24384. \********************************************/
  24385. /*! exports provided: DefaultCollisionCoordinator */
  24386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24387. "use strict";
  24388. __webpack_require__.r(__webpack_exports__);
  24389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  24390. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  24391. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24392. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  24393. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24394. /** @hidden */
  24395. var DefaultCollisionCoordinator = /** @class */ (function () {
  24396. function DefaultCollisionCoordinator() {
  24397. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24398. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24399. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24400. }
  24401. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  24402. position.divideToRef(collider._radius, this._scaledPosition);
  24403. displacement.divideToRef(collider._radius, this._scaledVelocity);
  24404. collider.collidedMesh = null;
  24405. collider._retry = 0;
  24406. collider._initialVelocity = this._scaledVelocity;
  24407. collider._initialPosition = this._scaledPosition;
  24408. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  24409. this._finalPosition.multiplyInPlace(collider._radius);
  24410. //run the callback
  24411. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  24412. };
  24413. DefaultCollisionCoordinator.prototype.createCollider = function () {
  24414. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  24415. };
  24416. DefaultCollisionCoordinator.prototype.init = function (scene) {
  24417. this._scene = scene;
  24418. };
  24419. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  24420. if (excludedMesh === void 0) { excludedMesh = null; }
  24421. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  24422. if (collider._retry >= maximumRetry) {
  24423. finalPosition.copyFrom(position);
  24424. return;
  24425. }
  24426. // Check if this is a mesh else camera or -1
  24427. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  24428. collider._initialize(position, velocity, closeDistance);
  24429. // Check all meshes
  24430. for (var index = 0; index < this._scene.meshes.length; index++) {
  24431. var mesh = this._scene.meshes[index];
  24432. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  24433. mesh._checkCollision(collider);
  24434. }
  24435. }
  24436. if (!collider.collisionFound) {
  24437. position.addToRef(velocity, finalPosition);
  24438. return;
  24439. }
  24440. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  24441. collider._getResponse(position, velocity);
  24442. }
  24443. if (velocity.length() <= closeDistance) {
  24444. finalPosition.copyFrom(position);
  24445. return;
  24446. }
  24447. collider._retry++;
  24448. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  24449. };
  24450. return DefaultCollisionCoordinator;
  24451. }());
  24452. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  24453. return new DefaultCollisionCoordinator();
  24454. };
  24455. /***/ }),
  24456. /***/ "./Collisions/index.ts":
  24457. /*!*****************************!*\
  24458. !*** ./Collisions/index.ts ***!
  24459. \*****************************/
  24460. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, _MeshCollisionData */
  24461. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24462. "use strict";
  24463. __webpack_require__.r(__webpack_exports__);
  24464. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  24466. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  24467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  24468. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  24469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  24470. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  24471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  24472. /* harmony import */ var _meshCollisionData__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./meshCollisionData */ "./Collisions/meshCollisionData.ts");
  24473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_MeshCollisionData", function() { return _meshCollisionData__WEBPACK_IMPORTED_MODULE_4__["_MeshCollisionData"]; });
  24474. /***/ }),
  24475. /***/ "./Collisions/intersectionInfo.ts":
  24476. /*!****************************************!*\
  24477. !*** ./Collisions/intersectionInfo.ts ***!
  24478. \****************************************/
  24479. /*! exports provided: IntersectionInfo */
  24480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24481. "use strict";
  24482. __webpack_require__.r(__webpack_exports__);
  24483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  24484. /**
  24485. * @hidden
  24486. */
  24487. var IntersectionInfo = /** @class */ (function () {
  24488. function IntersectionInfo(bu, bv, distance) {
  24489. this.bu = bu;
  24490. this.bv = bv;
  24491. this.distance = distance;
  24492. this.faceId = 0;
  24493. this.subMeshId = 0;
  24494. }
  24495. return IntersectionInfo;
  24496. }());
  24497. /***/ }),
  24498. /***/ "./Collisions/meshCollisionData.ts":
  24499. /*!*****************************************!*\
  24500. !*** ./Collisions/meshCollisionData.ts ***!
  24501. \*****************************************/
  24502. /*! exports provided: _MeshCollisionData */
  24503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24504. "use strict";
  24505. __webpack_require__.r(__webpack_exports__);
  24506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_MeshCollisionData", function() { return _MeshCollisionData; });
  24507. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24508. /**
  24509. * @hidden
  24510. */
  24511. var _MeshCollisionData = /** @class */ (function () {
  24512. function _MeshCollisionData() {
  24513. this._checkCollisions = false;
  24514. this._collisionMask = -1;
  24515. this._collisionGroup = -1;
  24516. this._collider = null;
  24517. this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  24518. this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  24519. }
  24520. return _MeshCollisionData;
  24521. }());
  24522. /***/ }),
  24523. /***/ "./Collisions/pickingInfo.ts":
  24524. /*!***********************************!*\
  24525. !*** ./Collisions/pickingInfo.ts ***!
  24526. \***********************************/
  24527. /*! exports provided: PickingInfo */
  24528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24529. "use strict";
  24530. __webpack_require__.r(__webpack_exports__);
  24531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  24532. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24533. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  24534. /**
  24535. * Information about the result of picking within a scene
  24536. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24537. */
  24538. var PickingInfo = /** @class */ (function () {
  24539. function PickingInfo() {
  24540. /** @hidden */
  24541. this._pickingUnavailable = false;
  24542. /**
  24543. * If the pick collided with an object
  24544. */
  24545. this.hit = false;
  24546. /**
  24547. * Distance away where the pick collided
  24548. */
  24549. this.distance = 0;
  24550. /**
  24551. * The location of pick collision
  24552. */
  24553. this.pickedPoint = null;
  24554. /**
  24555. * The mesh corresponding the the pick collision
  24556. */
  24557. this.pickedMesh = null;
  24558. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  24559. this.bu = 0;
  24560. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  24561. this.bv = 0;
  24562. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24563. this.faceId = -1;
  24564. /** Id of the the submesh that was picked */
  24565. this.subMeshId = 0;
  24566. /** If a sprite was picked, this will be the sprite the pick collided with */
  24567. this.pickedSprite = null;
  24568. /**
  24569. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24570. */
  24571. this.originMesh = null;
  24572. /**
  24573. * The ray that was used to perform the picking.
  24574. */
  24575. this.ray = null;
  24576. }
  24577. /**
  24578. * Gets the normal correspodning to the face the pick collided with
  24579. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24580. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24581. * @returns The normal correspodning to the face the pick collided with
  24582. */
  24583. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  24584. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  24585. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  24586. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  24587. return null;
  24588. }
  24589. var indices = this.pickedMesh.getIndices();
  24590. if (!indices) {
  24591. return null;
  24592. }
  24593. var result;
  24594. if (useVerticesNormals) {
  24595. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  24596. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  24597. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  24598. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  24599. normal0 = normal0.scale(this.bu);
  24600. normal1 = normal1.scale(this.bv);
  24601. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  24602. 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);
  24603. }
  24604. else {
  24605. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  24606. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  24607. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  24608. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  24609. var p1p2 = vertex1.subtract(vertex2);
  24610. var p3p2 = vertex3.subtract(vertex2);
  24611. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  24612. }
  24613. if (useWorldCoordinates) {
  24614. var wm = this.pickedMesh.getWorldMatrix();
  24615. if (this.pickedMesh.nonUniformScaling) {
  24616. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  24617. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  24618. wm.setTranslationFromFloats(0, 0, 0);
  24619. wm.invert();
  24620. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  24621. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  24622. }
  24623. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  24624. }
  24625. result.normalize();
  24626. return result;
  24627. };
  24628. /**
  24629. * Gets the texture coordinates of where the pick occured
  24630. * @returns the vector containing the coordnates of the texture
  24631. */
  24632. PickingInfo.prototype.getTextureCoordinates = function () {
  24633. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  24634. return null;
  24635. }
  24636. var indices = this.pickedMesh.getIndices();
  24637. if (!indices) {
  24638. return null;
  24639. }
  24640. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  24641. if (!uvs) {
  24642. return null;
  24643. }
  24644. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  24645. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  24646. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  24647. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  24648. uv1 = uv1.scale(this.bu);
  24649. uv2 = uv2.scale(this.bv);
  24650. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  24651. };
  24652. return PickingInfo;
  24653. }());
  24654. /***/ }),
  24655. /***/ "./Culling/Octrees/index.ts":
  24656. /*!**********************************!*\
  24657. !*** ./Culling/Octrees/index.ts ***!
  24658. \**********************************/
  24659. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  24660. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24661. "use strict";
  24662. __webpack_require__.r(__webpack_exports__);
  24663. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  24665. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  24667. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  24668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  24669. /***/ }),
  24670. /***/ "./Culling/Octrees/octree.ts":
  24671. /*!***********************************!*\
  24672. !*** ./Culling/Octrees/octree.ts ***!
  24673. \***********************************/
  24674. /*! exports provided: Octree */
  24675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24676. "use strict";
  24677. __webpack_require__.r(__webpack_exports__);
  24678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  24679. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  24680. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24681. /**
  24682. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  24683. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24684. */
  24685. var Octree = /** @class */ (function () {
  24686. /**
  24687. * Creates a octree
  24688. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24689. * @param creationFunc function to be used to instatiate the octree
  24690. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  24691. * @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.)
  24692. */
  24693. function Octree(creationFunc, maxBlockCapacity,
  24694. /** 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.) */
  24695. maxDepth) {
  24696. if (maxDepth === void 0) { maxDepth = 2; }
  24697. this.maxDepth = maxDepth;
  24698. /**
  24699. * Content stored in the octree
  24700. */
  24701. this.dynamicContent = new Array();
  24702. this._maxBlockCapacity = maxBlockCapacity || 64;
  24703. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  24704. this._creationFunc = creationFunc;
  24705. }
  24706. // Methods
  24707. /**
  24708. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  24709. * @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);
  24710. * @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);
  24711. * @param entries meshes to be added to the octree blocks
  24712. */
  24713. Octree.prototype.update = function (worldMin, worldMax, entries) {
  24714. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  24715. };
  24716. /**
  24717. * Adds a mesh to the octree
  24718. * @param entry Mesh to add to the octree
  24719. */
  24720. Octree.prototype.addMesh = function (entry) {
  24721. for (var index = 0; index < this.blocks.length; index++) {
  24722. var block = this.blocks[index];
  24723. block.addEntry(entry);
  24724. }
  24725. };
  24726. /**
  24727. * Remove an element from the octree
  24728. * @param entry defines the element to remove
  24729. */
  24730. Octree.prototype.removeMesh = function (entry) {
  24731. for (var index = 0; index < this.blocks.length; index++) {
  24732. var block = this.blocks[index];
  24733. block.removeEntry(entry);
  24734. }
  24735. };
  24736. /**
  24737. * Selects an array of meshes within the frustum
  24738. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  24739. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  24740. * @returns array of meshes within the frustum
  24741. */
  24742. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  24743. this._selectionContent.reset();
  24744. for (var index = 0; index < this.blocks.length; index++) {
  24745. var block = this.blocks[index];
  24746. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  24747. }
  24748. if (allowDuplicate) {
  24749. this._selectionContent.concat(this.dynamicContent);
  24750. }
  24751. else {
  24752. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24753. }
  24754. return this._selectionContent;
  24755. };
  24756. /**
  24757. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  24758. * @param sphereCenter defines the bounding sphere center
  24759. * @param sphereRadius defines the bounding sphere radius
  24760. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24761. * @returns an array of objects that intersect the sphere
  24762. */
  24763. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  24764. this._selectionContent.reset();
  24765. for (var index = 0; index < this.blocks.length; index++) {
  24766. var block = this.blocks[index];
  24767. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  24768. }
  24769. if (allowDuplicate) {
  24770. this._selectionContent.concat(this.dynamicContent);
  24771. }
  24772. else {
  24773. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24774. }
  24775. return this._selectionContent;
  24776. };
  24777. /**
  24778. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  24779. * @param ray defines the ray to test with
  24780. * @returns array of intersected objects
  24781. */
  24782. Octree.prototype.intersectsRay = function (ray) {
  24783. this._selectionContent.reset();
  24784. for (var index = 0; index < this.blocks.length; index++) {
  24785. var block = this.blocks[index];
  24786. block.intersectsRay(ray, this._selectionContent);
  24787. }
  24788. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24789. return this._selectionContent;
  24790. };
  24791. /**
  24792. * Adds a mesh into the octree block if it intersects the block
  24793. */
  24794. Octree.CreationFuncForMeshes = function (entry, block) {
  24795. var boundingInfo = entry.getBoundingInfo();
  24796. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24797. block.entries.push(entry);
  24798. }
  24799. };
  24800. /**
  24801. * Adds a submesh into the octree block if it intersects the block
  24802. */
  24803. Octree.CreationFuncForSubMeshes = function (entry, block) {
  24804. var boundingInfo = entry.getBoundingInfo();
  24805. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24806. block.entries.push(entry);
  24807. }
  24808. };
  24809. return Octree;
  24810. }());
  24811. /***/ }),
  24812. /***/ "./Culling/Octrees/octreeBlock.ts":
  24813. /*!****************************************!*\
  24814. !*** ./Culling/Octrees/octreeBlock.ts ***!
  24815. \****************************************/
  24816. /*! exports provided: OctreeBlock */
  24817. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24818. "use strict";
  24819. __webpack_require__.r(__webpack_exports__);
  24820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  24821. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24822. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  24823. /**
  24824. * Class used to store a cell in an octree
  24825. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24826. */
  24827. var OctreeBlock = /** @class */ (function () {
  24828. /**
  24829. * Creates a new block
  24830. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  24831. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  24832. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24833. * @param depth defines the current depth of this block in the octree
  24834. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  24835. * @param creationFunc defines a callback to call when an element is added to the block
  24836. */
  24837. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24838. /**
  24839. * Gets the content of the current block
  24840. */
  24841. this.entries = new Array();
  24842. this._boundingVectors = new Array();
  24843. this._capacity = capacity;
  24844. this._depth = depth;
  24845. this._maxDepth = maxDepth;
  24846. this._creationFunc = creationFunc;
  24847. this._minPoint = minPoint;
  24848. this._maxPoint = maxPoint;
  24849. this._boundingVectors.push(minPoint.clone());
  24850. this._boundingVectors.push(maxPoint.clone());
  24851. this._boundingVectors.push(minPoint.clone());
  24852. this._boundingVectors[2].x = maxPoint.x;
  24853. this._boundingVectors.push(minPoint.clone());
  24854. this._boundingVectors[3].y = maxPoint.y;
  24855. this._boundingVectors.push(minPoint.clone());
  24856. this._boundingVectors[4].z = maxPoint.z;
  24857. this._boundingVectors.push(maxPoint.clone());
  24858. this._boundingVectors[5].z = minPoint.z;
  24859. this._boundingVectors.push(maxPoint.clone());
  24860. this._boundingVectors[6].x = minPoint.x;
  24861. this._boundingVectors.push(maxPoint.clone());
  24862. this._boundingVectors[7].y = minPoint.y;
  24863. }
  24864. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24865. // Property
  24866. /**
  24867. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24868. */
  24869. get: function () {
  24870. return this._capacity;
  24871. },
  24872. enumerable: true,
  24873. configurable: true
  24874. });
  24875. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24876. /**
  24877. * Gets the minimum vector (in world space) of the block's bounding box
  24878. */
  24879. get: function () {
  24880. return this._minPoint;
  24881. },
  24882. enumerable: true,
  24883. configurable: true
  24884. });
  24885. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24886. /**
  24887. * Gets the maximum vector (in world space) of the block's bounding box
  24888. */
  24889. get: function () {
  24890. return this._maxPoint;
  24891. },
  24892. enumerable: true,
  24893. configurable: true
  24894. });
  24895. // Methods
  24896. /**
  24897. * Add a new element to this block
  24898. * @param entry defines the element to add
  24899. */
  24900. OctreeBlock.prototype.addEntry = function (entry) {
  24901. if (this.blocks) {
  24902. for (var index = 0; index < this.blocks.length; index++) {
  24903. var block = this.blocks[index];
  24904. block.addEntry(entry);
  24905. }
  24906. return;
  24907. }
  24908. this._creationFunc(entry, this);
  24909. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24910. this.createInnerBlocks();
  24911. }
  24912. };
  24913. /**
  24914. * Remove an element from this block
  24915. * @param entry defines the element to remove
  24916. */
  24917. OctreeBlock.prototype.removeEntry = function (entry) {
  24918. if (this.blocks) {
  24919. for (var index = 0; index < this.blocks.length; index++) {
  24920. var block = this.blocks[index];
  24921. block.removeEntry(entry);
  24922. }
  24923. return;
  24924. }
  24925. var entryIndex = this.entries.indexOf(entry);
  24926. if (entryIndex > -1) {
  24927. this.entries.splice(entryIndex, 1);
  24928. }
  24929. };
  24930. /**
  24931. * Add an array of elements to this block
  24932. * @param entries defines the array of elements to add
  24933. */
  24934. OctreeBlock.prototype.addEntries = function (entries) {
  24935. for (var index = 0; index < entries.length; index++) {
  24936. var mesh = entries[index];
  24937. this.addEntry(mesh);
  24938. }
  24939. };
  24940. /**
  24941. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24942. * @param frustumPlanes defines the frustum planes to test
  24943. * @param selection defines the array to store current content if selection is positive
  24944. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24945. */
  24946. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24947. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24948. if (this.blocks) {
  24949. for (var index = 0; index < this.blocks.length; index++) {
  24950. var block = this.blocks[index];
  24951. block.select(frustumPlanes, selection, allowDuplicate);
  24952. }
  24953. return;
  24954. }
  24955. if (allowDuplicate) {
  24956. selection.concat(this.entries);
  24957. }
  24958. else {
  24959. selection.concatWithNoDuplicate(this.entries);
  24960. }
  24961. }
  24962. };
  24963. /**
  24964. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24965. * @param sphereCenter defines the bounding sphere center
  24966. * @param sphereRadius defines the bounding sphere radius
  24967. * @param selection defines the array to store current content if selection is positive
  24968. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24969. */
  24970. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24971. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24972. if (this.blocks) {
  24973. for (var index = 0; index < this.blocks.length; index++) {
  24974. var block = this.blocks[index];
  24975. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24976. }
  24977. return;
  24978. }
  24979. if (allowDuplicate) {
  24980. selection.concat(this.entries);
  24981. }
  24982. else {
  24983. selection.concatWithNoDuplicate(this.entries);
  24984. }
  24985. }
  24986. };
  24987. /**
  24988. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24989. * @param ray defines the ray to test with
  24990. * @param selection defines the array to store current content if selection is positive
  24991. */
  24992. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24993. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24994. if (this.blocks) {
  24995. for (var index = 0; index < this.blocks.length; index++) {
  24996. var block = this.blocks[index];
  24997. block.intersectsRay(ray, selection);
  24998. }
  24999. return;
  25000. }
  25001. selection.concatWithNoDuplicate(this.entries);
  25002. }
  25003. };
  25004. /**
  25005. * Subdivide the content into child blocks (this block will then be empty)
  25006. */
  25007. OctreeBlock.prototype.createInnerBlocks = function () {
  25008. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  25009. };
  25010. /**
  25011. * @hidden
  25012. */
  25013. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  25014. target.blocks = new Array();
  25015. 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);
  25016. // Segmenting space
  25017. for (var x = 0; x < 2; x++) {
  25018. for (var y = 0; y < 2; y++) {
  25019. for (var z = 0; z < 2; z++) {
  25020. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  25021. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  25022. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  25023. block.addEntries(entries);
  25024. target.blocks.push(block);
  25025. }
  25026. }
  25027. }
  25028. };
  25029. return OctreeBlock;
  25030. }());
  25031. /***/ }),
  25032. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  25033. /*!*************************************************!*\
  25034. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  25035. \*************************************************/
  25036. /*! exports provided: OctreeSceneComponent */
  25037. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25038. "use strict";
  25039. __webpack_require__.r(__webpack_exports__);
  25040. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  25041. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  25042. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  25043. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  25044. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  25045. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  25046. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  25047. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  25048. if (maxCapacity === void 0) { maxCapacity = 64; }
  25049. if (maxDepth === void 0) { maxDepth = 2; }
  25050. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  25051. if (!component) {
  25052. component = new OctreeSceneComponent(this);
  25053. this._addComponent(component);
  25054. }
  25055. if (!this._selectionOctree) {
  25056. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  25057. }
  25058. var worldExtends = this.getWorldExtends();
  25059. // Update octree
  25060. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  25061. return this._selectionOctree;
  25062. };
  25063. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  25064. get: function () {
  25065. return this._selectionOctree;
  25066. },
  25067. enumerable: true,
  25068. configurable: true
  25069. });
  25070. /**
  25071. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  25072. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25073. * @param maxCapacity defines the maximum size of each block (64 by default)
  25074. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  25075. * @returns the new octree
  25076. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  25077. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  25078. */
  25079. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  25080. if (maxCapacity === void 0) { maxCapacity = 64; }
  25081. if (maxDepth === void 0) { maxDepth = 2; }
  25082. var scene = this.getScene();
  25083. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  25084. if (!component) {
  25085. component = new OctreeSceneComponent(scene);
  25086. scene._addComponent(component);
  25087. }
  25088. if (!this._submeshesOctree) {
  25089. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  25090. }
  25091. this.computeWorldMatrix(true);
  25092. var boundingInfo = this.getBoundingInfo();
  25093. // Update octree
  25094. var bbox = boundingInfo.boundingBox;
  25095. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  25096. return this._submeshesOctree;
  25097. };
  25098. /**
  25099. * Defines the octree scene component responsible to manage any octrees
  25100. * in a given scene.
  25101. */
  25102. var OctreeSceneComponent = /** @class */ (function () {
  25103. /**
  25104. * Creates a new instance of the component for the given scene
  25105. * @param scene Defines the scene to register the component in
  25106. */
  25107. function OctreeSceneComponent(scene) {
  25108. /**
  25109. * The component name help to identify the component in the list of scene components.
  25110. */
  25111. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  25112. /**
  25113. * Indicates if the meshes have been checked to make sure they are isEnabled()
  25114. */
  25115. this.checksIsEnabled = true;
  25116. 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));
  25117. this.scene = scene;
  25118. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  25119. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  25120. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  25121. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  25122. }
  25123. /**
  25124. * Registers the component in a given scene
  25125. */
  25126. OctreeSceneComponent.prototype.register = function () {
  25127. var _this = this;
  25128. this.scene.onMeshRemovedObservable.add(function (mesh) {
  25129. var sceneOctree = _this.scene.selectionOctree;
  25130. if (sceneOctree !== undefined && sceneOctree !== null) {
  25131. var index = sceneOctree.dynamicContent.indexOf(mesh);
  25132. if (index !== -1) {
  25133. sceneOctree.dynamicContent.splice(index, 1);
  25134. }
  25135. }
  25136. });
  25137. this.scene.onMeshImportedObservable.add(function (mesh) {
  25138. var sceneOctree = _this.scene.selectionOctree;
  25139. if (sceneOctree !== undefined && sceneOctree !== null) {
  25140. sceneOctree.addMesh(mesh);
  25141. }
  25142. });
  25143. };
  25144. /**
  25145. * Return the list of active meshes
  25146. * @returns the list of active meshes
  25147. */
  25148. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  25149. if (this.scene._selectionOctree) {
  25150. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  25151. return selection;
  25152. }
  25153. return this.scene._getDefaultMeshCandidates();
  25154. };
  25155. /**
  25156. * Return the list of active sub meshes
  25157. * @param mesh The mesh to get the candidates sub meshes from
  25158. * @returns the list of active sub meshes
  25159. */
  25160. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  25161. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  25162. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  25163. return intersections;
  25164. }
  25165. return this.scene._getDefaultSubMeshCandidates(mesh);
  25166. };
  25167. /**
  25168. * Return the list of sub meshes intersecting with a given local ray
  25169. * @param mesh defines the mesh to find the submesh for
  25170. * @param localRay defines the ray in local space
  25171. * @returns the list of intersecting sub meshes
  25172. */
  25173. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  25174. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  25175. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  25176. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  25177. return intersections;
  25178. }
  25179. return this.scene._getDefaultSubMeshCandidates(mesh);
  25180. };
  25181. /**
  25182. * Return the list of sub meshes colliding with a collider
  25183. * @param mesh defines the mesh to find the submesh for
  25184. * @param collider defines the collider to evaluate the collision against
  25185. * @returns the list of colliding sub meshes
  25186. */
  25187. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  25188. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  25189. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  25190. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  25191. return intersections;
  25192. }
  25193. return this.scene._getDefaultSubMeshCandidates(mesh);
  25194. };
  25195. /**
  25196. * Rebuilds the elements related to this component in case of
  25197. * context lost for instance.
  25198. */
  25199. OctreeSceneComponent.prototype.rebuild = function () {
  25200. // Nothing to do here.
  25201. };
  25202. /**
  25203. * Disposes the component and the associated ressources.
  25204. */
  25205. OctreeSceneComponent.prototype.dispose = function () {
  25206. // Nothing to do here.
  25207. };
  25208. return OctreeSceneComponent;
  25209. }());
  25210. /***/ }),
  25211. /***/ "./Culling/boundingBox.ts":
  25212. /*!********************************!*\
  25213. !*** ./Culling/boundingBox.ts ***!
  25214. \********************************/
  25215. /*! exports provided: BoundingBox */
  25216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25217. "use strict";
  25218. __webpack_require__.r(__webpack_exports__);
  25219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  25220. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25221. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25222. /**
  25223. * Class used to store bounding box information
  25224. */
  25225. var BoundingBox = /** @class */ (function () {
  25226. /**
  25227. * Creates a new bounding box
  25228. * @param min defines the minimum vector (in local space)
  25229. * @param max defines the maximum vector (in local space)
  25230. * @param worldMatrix defines the new world matrix
  25231. */
  25232. function BoundingBox(min, max, worldMatrix) {
  25233. /**
  25234. * Gets the 8 vectors representing the bounding box in local space
  25235. */
  25236. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25237. /**
  25238. * Gets the center of the bounding box in local space
  25239. */
  25240. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25241. /**
  25242. * Gets the center of the bounding box in world space
  25243. */
  25244. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25245. /**
  25246. * Gets the extend size in local space
  25247. */
  25248. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25249. /**
  25250. * Gets the extend size in world space
  25251. */
  25252. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25253. /**
  25254. * Gets the OBB (object bounding box) directions
  25255. */
  25256. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25257. /**
  25258. * Gets the 8 vectors representing the bounding box in world space
  25259. */
  25260. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25261. /**
  25262. * Gets the minimum vector in world space
  25263. */
  25264. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25265. /**
  25266. * Gets the maximum vector in world space
  25267. */
  25268. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25269. /**
  25270. * Gets the minimum vector in local space
  25271. */
  25272. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25273. /**
  25274. * Gets the maximum vector in local space
  25275. */
  25276. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25277. this.reConstruct(min, max, worldMatrix);
  25278. }
  25279. // Methods
  25280. /**
  25281. * Recreates the entire bounding box from scratch as if we call the constructor in place
  25282. * @param min defines the new minimum vector (in local space)
  25283. * @param max defines the new maximum vector (in local space)
  25284. * @param worldMatrix defines the new world matrix
  25285. */
  25286. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  25287. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25288. var vectors = this.vectors;
  25289. this.minimum.copyFromFloats(minX, minY, minZ);
  25290. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  25291. vectors[0].copyFromFloats(minX, minY, minZ);
  25292. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  25293. vectors[2].copyFromFloats(maxX, minY, minZ);
  25294. vectors[3].copyFromFloats(minX, maxY, minZ);
  25295. vectors[4].copyFromFloats(minX, minY, maxZ);
  25296. vectors[5].copyFromFloats(maxX, maxY, minZ);
  25297. vectors[6].copyFromFloats(minX, maxY, maxZ);
  25298. vectors[7].copyFromFloats(maxX, minY, maxZ);
  25299. // OBB
  25300. max.addToRef(min, this.center).scaleInPlace(0.5);
  25301. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  25302. this._worldMatrix = worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly;
  25303. this._update(this._worldMatrix);
  25304. };
  25305. /**
  25306. * Scale the current bounding box by applying a scale factor
  25307. * @param factor defines the scale factor to apply
  25308. * @returns the current bounding box
  25309. */
  25310. BoundingBox.prototype.scale = function (factor) {
  25311. var tmpVectors = BoundingBox.TmpVector3;
  25312. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  25313. var len = diff.length();
  25314. diff.normalizeFromLength(len);
  25315. var distance = len * factor;
  25316. var newRadius = diff.scaleInPlace(distance * 0.5);
  25317. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  25318. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  25319. this.reConstruct(min, max, this._worldMatrix);
  25320. return this;
  25321. };
  25322. /**
  25323. * Gets the world matrix of the bounding box
  25324. * @returns a matrix
  25325. */
  25326. BoundingBox.prototype.getWorldMatrix = function () {
  25327. return this._worldMatrix;
  25328. };
  25329. /** @hidden */
  25330. BoundingBox.prototype._update = function (world) {
  25331. var minWorld = this.minimumWorld;
  25332. var maxWorld = this.maximumWorld;
  25333. var directions = this.directions;
  25334. var vectorsWorld = this.vectorsWorld;
  25335. var vectors = this.vectors;
  25336. if (!world.isIdentity()) {
  25337. minWorld.setAll(Number.MAX_VALUE);
  25338. maxWorld.setAll(-Number.MAX_VALUE);
  25339. for (var index = 0; index < 8; ++index) {
  25340. var v = vectorsWorld[index];
  25341. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  25342. minWorld.minimizeInPlace(v);
  25343. maxWorld.maximizeInPlace(v);
  25344. }
  25345. // Extend
  25346. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  25347. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  25348. }
  25349. else {
  25350. minWorld.copyFrom(this.minimum);
  25351. maxWorld.copyFrom(this.maximum);
  25352. for (var index = 0; index < 8; ++index) {
  25353. vectorsWorld[index].copyFrom(vectors[index]);
  25354. }
  25355. // Extend
  25356. this.extendSizeWorld.copyFrom(this.extendSize);
  25357. this.centerWorld.copyFrom(this.center);
  25358. }
  25359. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  25360. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  25361. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  25362. this._worldMatrix = world;
  25363. };
  25364. /**
  25365. * Tests if the bounding box is intersecting the frustum planes
  25366. * @param frustumPlanes defines the frustum planes to test
  25367. * @returns true if there is an intersection
  25368. */
  25369. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  25370. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  25371. };
  25372. /**
  25373. * Tests if the bounding box is entirely inside the frustum planes
  25374. * @param frustumPlanes defines the frustum planes to test
  25375. * @returns true if there is an inclusion
  25376. */
  25377. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25378. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  25379. };
  25380. /**
  25381. * Tests if a point is inside the bounding box
  25382. * @param point defines the point to test
  25383. * @returns true if the point is inside the bounding box
  25384. */
  25385. BoundingBox.prototype.intersectsPoint = function (point) {
  25386. var min = this.minimumWorld;
  25387. var max = this.maximumWorld;
  25388. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25389. var pointX = point.x, pointY = point.y, pointZ = point.z;
  25390. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  25391. if (maxX - pointX < delta || delta > pointX - minX) {
  25392. return false;
  25393. }
  25394. if (maxY - pointY < delta || delta > pointY - minY) {
  25395. return false;
  25396. }
  25397. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  25398. return false;
  25399. }
  25400. return true;
  25401. };
  25402. /**
  25403. * Tests if the bounding box intersects with a bounding sphere
  25404. * @param sphere defines the sphere to test
  25405. * @returns true if there is an intersection
  25406. */
  25407. BoundingBox.prototype.intersectsSphere = function (sphere) {
  25408. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  25409. };
  25410. /**
  25411. * Tests if the bounding box intersects with a box defined by a min and max vectors
  25412. * @param min defines the min vector to use
  25413. * @param max defines the max vector to use
  25414. * @returns true if there is an intersection
  25415. */
  25416. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  25417. var myMin = this.minimumWorld;
  25418. var myMax = this.maximumWorld;
  25419. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  25420. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25421. if (myMaxX < minX || myMinX > maxX) {
  25422. return false;
  25423. }
  25424. if (myMaxY < minY || myMinY > maxY) {
  25425. return false;
  25426. }
  25427. if (myMaxZ < minZ || myMinZ > maxZ) {
  25428. return false;
  25429. }
  25430. return true;
  25431. };
  25432. // Statics
  25433. /**
  25434. * Tests if two bounding boxes are intersections
  25435. * @param box0 defines the first box to test
  25436. * @param box1 defines the second box to test
  25437. * @returns true if there is an intersection
  25438. */
  25439. BoundingBox.Intersects = function (box0, box1) {
  25440. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  25441. };
  25442. /**
  25443. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  25444. * @param minPoint defines the minimum vector of the bounding box
  25445. * @param maxPoint defines the maximum vector of the bounding box
  25446. * @param sphereCenter defines the sphere center
  25447. * @param sphereRadius defines the sphere radius
  25448. * @returns true if there is an intersection
  25449. */
  25450. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  25451. var vector = BoundingBox.TmpVector3[0];
  25452. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  25453. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  25454. return (num <= (sphereRadius * sphereRadius));
  25455. };
  25456. /**
  25457. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  25458. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25459. * @param frustumPlanes defines the frustum planes to test
  25460. * @return true if there is an inclusion
  25461. */
  25462. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  25463. for (var p = 0; p < 6; ++p) {
  25464. var frustumPlane = frustumPlanes[p];
  25465. for (var i = 0; i < 8; ++i) {
  25466. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  25467. return false;
  25468. }
  25469. }
  25470. }
  25471. return true;
  25472. };
  25473. /**
  25474. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  25475. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25476. * @param frustumPlanes defines the frustum planes to test
  25477. * @return true if there is an intersection
  25478. */
  25479. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  25480. for (var p = 0; p < 6; ++p) {
  25481. var canReturnFalse = true;
  25482. var frustumPlane = frustumPlanes[p];
  25483. for (var i = 0; i < 8; ++i) {
  25484. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  25485. canReturnFalse = false;
  25486. break;
  25487. }
  25488. }
  25489. if (canReturnFalse) {
  25490. return false;
  25491. }
  25492. }
  25493. return true;
  25494. };
  25495. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25496. return BoundingBox;
  25497. }());
  25498. /***/ }),
  25499. /***/ "./Culling/boundingInfo.ts":
  25500. /*!*********************************!*\
  25501. !*** ./Culling/boundingInfo.ts ***!
  25502. \*********************************/
  25503. /*! exports provided: BoundingInfo */
  25504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25505. "use strict";
  25506. __webpack_require__.r(__webpack_exports__);
  25507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  25508. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25509. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25510. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  25511. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25512. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25513. var _result0 = { min: 0, max: 0 };
  25514. var _result1 = { min: 0, max: 0 };
  25515. var computeBoxExtents = function (axis, box, result) {
  25516. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  25517. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  25518. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  25519. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  25520. var r = r0 + r1 + r2;
  25521. result.min = p - r;
  25522. result.max = p + r;
  25523. };
  25524. var axisOverlap = function (axis, box0, box1) {
  25525. computeBoxExtents(axis, box0, _result0);
  25526. computeBoxExtents(axis, box1, _result1);
  25527. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  25528. };
  25529. /**
  25530. * Info for a bounding data of a mesh
  25531. */
  25532. var BoundingInfo = /** @class */ (function () {
  25533. /**
  25534. * Constructs bounding info
  25535. * @param minimum min vector of the bounding box/sphere
  25536. * @param maximum max vector of the bounding box/sphere
  25537. * @param worldMatrix defines the new world matrix
  25538. */
  25539. function BoundingInfo(minimum, maximum, worldMatrix) {
  25540. this._isLocked = false;
  25541. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  25542. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  25543. }
  25544. /**
  25545. * Recreates the entire bounding info from scratch as if we call the constructor in place
  25546. * @param min defines the new minimum vector (in local space)
  25547. * @param max defines the new maximum vector (in local space)
  25548. * @param worldMatrix defines the new world matrix
  25549. */
  25550. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  25551. this.boundingBox.reConstruct(min, max, worldMatrix);
  25552. this.boundingSphere.reConstruct(min, max, worldMatrix);
  25553. };
  25554. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  25555. /**
  25556. * min vector of the bounding box/sphere
  25557. */
  25558. get: function () {
  25559. return this.boundingBox.minimum;
  25560. },
  25561. enumerable: true,
  25562. configurable: true
  25563. });
  25564. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  25565. /**
  25566. * max vector of the bounding box/sphere
  25567. */
  25568. get: function () {
  25569. return this.boundingBox.maximum;
  25570. },
  25571. enumerable: true,
  25572. configurable: true
  25573. });
  25574. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  25575. /**
  25576. * If the info is locked and won't be updated to avoid perf overhead
  25577. */
  25578. get: function () {
  25579. return this._isLocked;
  25580. },
  25581. set: function (value) {
  25582. this._isLocked = value;
  25583. },
  25584. enumerable: true,
  25585. configurable: true
  25586. });
  25587. // Methods
  25588. /**
  25589. * Updates the bounding sphere and box
  25590. * @param world world matrix to be used to update
  25591. */
  25592. BoundingInfo.prototype.update = function (world) {
  25593. if (this._isLocked) {
  25594. return;
  25595. }
  25596. this.boundingBox._update(world);
  25597. this.boundingSphere._update(world);
  25598. };
  25599. /**
  25600. * Recreate the bounding info to be centered around a specific point given a specific extend.
  25601. * @param center New center of the bounding info
  25602. * @param extend New extend of the bounding info
  25603. * @returns the current bounding info
  25604. */
  25605. BoundingInfo.prototype.centerOn = function (center, extend) {
  25606. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  25607. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  25608. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25609. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25610. return this;
  25611. };
  25612. /**
  25613. * Scale the current bounding info by applying a scale factor
  25614. * @param factor defines the scale factor to apply
  25615. * @returns the current bounding info
  25616. */
  25617. BoundingInfo.prototype.scale = function (factor) {
  25618. this.boundingBox.scale(factor);
  25619. this.boundingSphere.scale(factor);
  25620. return this;
  25621. };
  25622. /**
  25623. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  25624. * @param frustumPlanes defines the frustum to test
  25625. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  25626. * @returns true if the bounding info is in the frustum planes
  25627. */
  25628. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  25629. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  25630. 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);
  25631. if (inclusionTest) {
  25632. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  25633. return true;
  25634. }
  25635. }
  25636. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  25637. return false;
  25638. }
  25639. 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);
  25640. if (bSphereOnlyTest) {
  25641. return true;
  25642. }
  25643. return this.boundingBox.isInFrustum(frustumPlanes);
  25644. };
  25645. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  25646. /**
  25647. * Gets the world distance between the min and max points of the bounding box
  25648. */
  25649. get: function () {
  25650. var boundingBox = this.boundingBox;
  25651. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  25652. return diag.length();
  25653. },
  25654. enumerable: true,
  25655. configurable: true
  25656. });
  25657. /**
  25658. * Checks if a cullable object (mesh...) is in the camera frustum
  25659. * Unlike isInFrustum this cheks the full bounding box
  25660. * @param frustumPlanes Camera near/planes
  25661. * @returns true if the object is in frustum otherwise false
  25662. */
  25663. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25664. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  25665. };
  25666. /** @hidden */
  25667. BoundingInfo.prototype._checkCollision = function (collider) {
  25668. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  25669. };
  25670. /**
  25671. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  25672. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25673. * @param point the point to check intersection with
  25674. * @returns if the point intersects
  25675. */
  25676. BoundingInfo.prototype.intersectsPoint = function (point) {
  25677. if (!this.boundingSphere.centerWorld) {
  25678. return false;
  25679. }
  25680. if (!this.boundingSphere.intersectsPoint(point)) {
  25681. return false;
  25682. }
  25683. if (!this.boundingBox.intersectsPoint(point)) {
  25684. return false;
  25685. }
  25686. return true;
  25687. };
  25688. /**
  25689. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  25690. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25691. * @param boundingInfo the bounding info to check intersection with
  25692. * @param precise if the intersection should be done using OBB
  25693. * @returns if the bounding info intersects
  25694. */
  25695. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  25696. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  25697. return false;
  25698. }
  25699. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  25700. return false;
  25701. }
  25702. if (!precise) {
  25703. return true;
  25704. }
  25705. var box0 = this.boundingBox;
  25706. var box1 = boundingInfo.boundingBox;
  25707. if (!axisOverlap(box0.directions[0], box0, box1)) {
  25708. return false;
  25709. }
  25710. if (!axisOverlap(box0.directions[1], box0, box1)) {
  25711. return false;
  25712. }
  25713. if (!axisOverlap(box0.directions[2], box0, box1)) {
  25714. return false;
  25715. }
  25716. if (!axisOverlap(box1.directions[0], box0, box1)) {
  25717. return false;
  25718. }
  25719. if (!axisOverlap(box1.directions[1], box0, box1)) {
  25720. return false;
  25721. }
  25722. if (!axisOverlap(box1.directions[2], box0, box1)) {
  25723. return false;
  25724. }
  25725. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  25726. return false;
  25727. }
  25728. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  25729. return false;
  25730. }
  25731. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  25732. return false;
  25733. }
  25734. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  25735. return false;
  25736. }
  25737. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  25738. return false;
  25739. }
  25740. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  25741. return false;
  25742. }
  25743. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  25744. return false;
  25745. }
  25746. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  25747. return false;
  25748. }
  25749. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  25750. return false;
  25751. }
  25752. return true;
  25753. };
  25754. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25755. return BoundingInfo;
  25756. }());
  25757. /***/ }),
  25758. /***/ "./Culling/boundingSphere.ts":
  25759. /*!***********************************!*\
  25760. !*** ./Culling/boundingSphere.ts ***!
  25761. \***********************************/
  25762. /*! exports provided: BoundingSphere */
  25763. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25764. "use strict";
  25765. __webpack_require__.r(__webpack_exports__);
  25766. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  25767. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25768. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25769. /**
  25770. * Class used to store bounding sphere information
  25771. */
  25772. var BoundingSphere = /** @class */ (function () {
  25773. /**
  25774. * Creates a new bounding sphere
  25775. * @param min defines the minimum vector (in local space)
  25776. * @param max defines the maximum vector (in local space)
  25777. * @param worldMatrix defines the new world matrix
  25778. */
  25779. function BoundingSphere(min, max, worldMatrix) {
  25780. /**
  25781. * Gets the center of the bounding sphere in local space
  25782. */
  25783. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25784. /**
  25785. * Gets the center of the bounding sphere in world space
  25786. */
  25787. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25788. /**
  25789. * Gets the minimum vector in local space
  25790. */
  25791. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25792. /**
  25793. * Gets the maximum vector in local space
  25794. */
  25795. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25796. this.reConstruct(min, max, worldMatrix);
  25797. }
  25798. /**
  25799. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  25800. * @param min defines the new minimum vector (in local space)
  25801. * @param max defines the new maximum vector (in local space)
  25802. * @param worldMatrix defines the new world matrix
  25803. */
  25804. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  25805. this.minimum.copyFrom(min);
  25806. this.maximum.copyFrom(max);
  25807. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  25808. max.addToRef(min, this.center).scaleInPlace(0.5);
  25809. this.radius = distance * 0.5;
  25810. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  25811. };
  25812. /**
  25813. * Scale the current bounding sphere by applying a scale factor
  25814. * @param factor defines the scale factor to apply
  25815. * @returns the current bounding box
  25816. */
  25817. BoundingSphere.prototype.scale = function (factor) {
  25818. var newRadius = this.radius * factor;
  25819. var tmpVectors = BoundingSphere.TmpVector3;
  25820. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  25821. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  25822. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  25823. this.reConstruct(min, max, this._worldMatrix);
  25824. return this;
  25825. };
  25826. /**
  25827. * Gets the world matrix of the bounding box
  25828. * @returns a matrix
  25829. */
  25830. BoundingSphere.prototype.getWorldMatrix = function () {
  25831. return this._worldMatrix;
  25832. };
  25833. // Methods
  25834. /** @hidden */
  25835. BoundingSphere.prototype._update = function (worldMatrix) {
  25836. if (!worldMatrix.isIdentity()) {
  25837. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25838. var tempVector = BoundingSphere.TmpVector3[0];
  25839. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25840. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25841. }
  25842. else {
  25843. this.centerWorld.copyFrom(this.center);
  25844. this.radiusWorld = this.radius;
  25845. }
  25846. };
  25847. /**
  25848. * Tests if the bounding sphere is intersecting the frustum planes
  25849. * @param frustumPlanes defines the frustum planes to test
  25850. * @returns true if there is an intersection
  25851. */
  25852. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25853. var center = this.centerWorld;
  25854. var radius = this.radiusWorld;
  25855. for (var i = 0; i < 6; i++) {
  25856. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25857. return false;
  25858. }
  25859. }
  25860. return true;
  25861. };
  25862. /**
  25863. * Tests if the bounding sphere center is in between the frustum planes.
  25864. * Used for optimistic fast inclusion.
  25865. * @param frustumPlanes defines the frustum planes to test
  25866. * @returns true if the sphere center is in between the frustum planes
  25867. */
  25868. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25869. var center = this.centerWorld;
  25870. for (var i = 0; i < 6; i++) {
  25871. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25872. return false;
  25873. }
  25874. }
  25875. return true;
  25876. };
  25877. /**
  25878. * Tests if a point is inside the bounding sphere
  25879. * @param point defines the point to test
  25880. * @returns true if the point is inside the bounding sphere
  25881. */
  25882. BoundingSphere.prototype.intersectsPoint = function (point) {
  25883. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25884. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25885. return false;
  25886. }
  25887. return true;
  25888. };
  25889. // Statics
  25890. /**
  25891. * Checks if two sphere intersct
  25892. * @param sphere0 sphere 0
  25893. * @param sphere1 sphere 1
  25894. * @returns true if the speres intersect
  25895. */
  25896. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25897. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25898. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25899. if (radiusSum * radiusSum < squareDistance) {
  25900. return false;
  25901. }
  25902. return true;
  25903. };
  25904. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25905. return BoundingSphere;
  25906. }());
  25907. /***/ }),
  25908. /***/ "./Culling/index.ts":
  25909. /*!**************************!*\
  25910. !*** ./Culling/index.ts ***!
  25911. \**************************/
  25912. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25913. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25914. "use strict";
  25915. __webpack_require__.r(__webpack_exports__);
  25916. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25918. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25920. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25922. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25926. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25928. /***/ }),
  25929. /***/ "./Culling/ray.ts":
  25930. /*!************************!*\
  25931. !*** ./Culling/ray.ts ***!
  25932. \************************/
  25933. /*! exports provided: Ray */
  25934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25935. "use strict";
  25936. __webpack_require__.r(__webpack_exports__);
  25937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25938. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25939. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25940. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  25941. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25942. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25943. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  25944. /**
  25945. * Class representing a ray with position and direction
  25946. */
  25947. var Ray = /** @class */ (function () {
  25948. /**
  25949. * Creates a new ray
  25950. * @param origin origin point
  25951. * @param direction direction
  25952. * @param length length of the ray
  25953. */
  25954. function Ray(
  25955. /** origin point */
  25956. origin,
  25957. /** direction */
  25958. direction,
  25959. /** length of the ray */
  25960. length) {
  25961. if (length === void 0) { length = Number.MAX_VALUE; }
  25962. this.origin = origin;
  25963. this.direction = direction;
  25964. this.length = length;
  25965. }
  25966. // Methods
  25967. /**
  25968. * Checks if the ray intersects a box
  25969. * @param minimum bound of the box
  25970. * @param maximum bound of the box
  25971. * @param intersectionTreshold extra extend to be added to the box in all direction
  25972. * @returns if the box was hit
  25973. */
  25974. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25975. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25976. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25977. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25978. var d = 0.0;
  25979. var maxValue = Number.MAX_VALUE;
  25980. var inv;
  25981. var min;
  25982. var max;
  25983. var temp;
  25984. if (Math.abs(this.direction.x) < 0.0000001) {
  25985. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25986. return false;
  25987. }
  25988. }
  25989. else {
  25990. inv = 1.0 / this.direction.x;
  25991. min = (newMinimum.x - this.origin.x) * inv;
  25992. max = (newMaximum.x - this.origin.x) * inv;
  25993. if (max === -Infinity) {
  25994. max = Infinity;
  25995. }
  25996. if (min > max) {
  25997. temp = min;
  25998. min = max;
  25999. max = temp;
  26000. }
  26001. d = Math.max(min, d);
  26002. maxValue = Math.min(max, maxValue);
  26003. if (d > maxValue) {
  26004. return false;
  26005. }
  26006. }
  26007. if (Math.abs(this.direction.y) < 0.0000001) {
  26008. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  26009. return false;
  26010. }
  26011. }
  26012. else {
  26013. inv = 1.0 / this.direction.y;
  26014. min = (newMinimum.y - this.origin.y) * inv;
  26015. max = (newMaximum.y - this.origin.y) * inv;
  26016. if (max === -Infinity) {
  26017. max = Infinity;
  26018. }
  26019. if (min > max) {
  26020. temp = min;
  26021. min = max;
  26022. max = temp;
  26023. }
  26024. d = Math.max(min, d);
  26025. maxValue = Math.min(max, maxValue);
  26026. if (d > maxValue) {
  26027. return false;
  26028. }
  26029. }
  26030. if (Math.abs(this.direction.z) < 0.0000001) {
  26031. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  26032. return false;
  26033. }
  26034. }
  26035. else {
  26036. inv = 1.0 / this.direction.z;
  26037. min = (newMinimum.z - this.origin.z) * inv;
  26038. max = (newMaximum.z - this.origin.z) * inv;
  26039. if (max === -Infinity) {
  26040. max = Infinity;
  26041. }
  26042. if (min > max) {
  26043. temp = min;
  26044. min = max;
  26045. max = temp;
  26046. }
  26047. d = Math.max(min, d);
  26048. maxValue = Math.min(max, maxValue);
  26049. if (d > maxValue) {
  26050. return false;
  26051. }
  26052. }
  26053. return true;
  26054. };
  26055. /**
  26056. * Checks if the ray intersects a box
  26057. * @param box the bounding box to check
  26058. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  26059. * @returns if the box was hit
  26060. */
  26061. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  26062. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  26063. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  26064. };
  26065. /**
  26066. * If the ray hits a sphere
  26067. * @param sphere the bounding sphere to check
  26068. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  26069. * @returns true if it hits the sphere
  26070. */
  26071. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  26072. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  26073. var x = sphere.center.x - this.origin.x;
  26074. var y = sphere.center.y - this.origin.y;
  26075. var z = sphere.center.z - this.origin.z;
  26076. var pyth = (x * x) + (y * y) + (z * z);
  26077. var radius = sphere.radius + intersectionTreshold;
  26078. var rr = radius * radius;
  26079. if (pyth <= rr) {
  26080. return true;
  26081. }
  26082. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  26083. if (dot < 0.0) {
  26084. return false;
  26085. }
  26086. var temp = pyth - (dot * dot);
  26087. return temp <= rr;
  26088. };
  26089. /**
  26090. * If the ray hits a triange
  26091. * @param vertex0 triangle vertex
  26092. * @param vertex1 triangle vertex
  26093. * @param vertex2 triangle vertex
  26094. * @returns intersection information if hit
  26095. */
  26096. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  26097. var edge1 = Ray.TmpVector3[0];
  26098. var edge2 = Ray.TmpVector3[1];
  26099. var pvec = Ray.TmpVector3[2];
  26100. var tvec = Ray.TmpVector3[3];
  26101. var qvec = Ray.TmpVector3[4];
  26102. vertex1.subtractToRef(vertex0, edge1);
  26103. vertex2.subtractToRef(vertex0, edge2);
  26104. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  26105. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  26106. if (det === 0) {
  26107. return null;
  26108. }
  26109. var invdet = 1 / det;
  26110. this.origin.subtractToRef(vertex0, tvec);
  26111. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  26112. if (bu < 0 || bu > 1.0) {
  26113. return null;
  26114. }
  26115. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  26116. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  26117. if (bv < 0 || bu + bv > 1.0) {
  26118. return null;
  26119. }
  26120. //check if the distance is longer than the predefined length.
  26121. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  26122. if (distance > this.length) {
  26123. return null;
  26124. }
  26125. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](bu, bv, distance);
  26126. };
  26127. /**
  26128. * Checks if ray intersects a plane
  26129. * @param plane the plane to check
  26130. * @returns the distance away it was hit
  26131. */
  26132. Ray.prototype.intersectsPlane = function (plane) {
  26133. var distance;
  26134. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  26135. if (Math.abs(result1) < 9.99999997475243E-07) {
  26136. return null;
  26137. }
  26138. else {
  26139. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  26140. distance = (-plane.d - result2) / result1;
  26141. if (distance < 0.0) {
  26142. if (distance < -9.99999997475243E-07) {
  26143. return null;
  26144. }
  26145. else {
  26146. return 0;
  26147. }
  26148. }
  26149. return distance;
  26150. }
  26151. };
  26152. /**
  26153. * Checks if ray intersects a mesh
  26154. * @param mesh the mesh to check
  26155. * @param fastCheck if only the bounding box should checked
  26156. * @returns picking info of the intersecton
  26157. */
  26158. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  26159. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  26160. mesh.getWorldMatrix().invertToRef(tm);
  26161. if (this._tmpRay) {
  26162. Ray.TransformToRef(this, tm, this._tmpRay);
  26163. }
  26164. else {
  26165. this._tmpRay = Ray.Transform(this, tm);
  26166. }
  26167. return mesh.intersects(this._tmpRay, fastCheck);
  26168. };
  26169. /**
  26170. * Checks if ray intersects a mesh
  26171. * @param meshes the meshes to check
  26172. * @param fastCheck if only the bounding box should checked
  26173. * @param results array to store result in
  26174. * @returns Array of picking infos
  26175. */
  26176. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  26177. if (results) {
  26178. results.length = 0;
  26179. }
  26180. else {
  26181. results = [];
  26182. }
  26183. for (var i = 0; i < meshes.length; i++) {
  26184. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  26185. if (pickInfo.hit) {
  26186. results.push(pickInfo);
  26187. }
  26188. }
  26189. results.sort(this._comparePickingInfo);
  26190. return results;
  26191. };
  26192. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  26193. if (pickingInfoA.distance < pickingInfoB.distance) {
  26194. return -1;
  26195. }
  26196. else if (pickingInfoA.distance > pickingInfoB.distance) {
  26197. return 1;
  26198. }
  26199. else {
  26200. return 0;
  26201. }
  26202. };
  26203. /**
  26204. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  26205. * @param sega the first point of the segment to test the intersection against
  26206. * @param segb the second point of the segment to test the intersection against
  26207. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  26208. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  26209. */
  26210. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  26211. var o = this.origin;
  26212. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  26213. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  26214. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  26215. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  26216. segb.subtractToRef(sega, u);
  26217. this.direction.scaleToRef(Ray.rayl, v);
  26218. o.addToRef(v, rsegb);
  26219. sega.subtractToRef(o, w);
  26220. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  26221. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  26222. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  26223. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  26224. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  26225. var D = a * c - b * b; // always >= 0
  26226. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  26227. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  26228. // compute the line parameters of the two closest points
  26229. if (D < Ray.smallnum) { // the lines are almost parallel
  26230. sN = 0.0; // force using point P0 on segment S1
  26231. sD = 1.0; // to prevent possible division by 0.0 later
  26232. tN = e;
  26233. tD = c;
  26234. }
  26235. else { // get the closest points on the infinite lines
  26236. sN = (b * e - c * d);
  26237. tN = (a * e - b * d);
  26238. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  26239. sN = 0.0;
  26240. tN = e;
  26241. tD = c;
  26242. }
  26243. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  26244. sN = sD;
  26245. tN = e + b;
  26246. tD = c;
  26247. }
  26248. }
  26249. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  26250. tN = 0.0;
  26251. // recompute sc for this edge
  26252. if (-d < 0.0) {
  26253. sN = 0.0;
  26254. }
  26255. else if (-d > a) {
  26256. sN = sD;
  26257. }
  26258. else {
  26259. sN = -d;
  26260. sD = a;
  26261. }
  26262. }
  26263. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  26264. tN = tD;
  26265. // recompute sc for this edge
  26266. if ((-d + b) < 0.0) {
  26267. sN = 0;
  26268. }
  26269. else if ((-d + b) > a) {
  26270. sN = sD;
  26271. }
  26272. else {
  26273. sN = (-d + b);
  26274. sD = a;
  26275. }
  26276. }
  26277. // finally do the division to get sc and tc
  26278. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  26279. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  26280. // get the difference of the two closest points
  26281. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  26282. v.scaleToRef(tc, qtc);
  26283. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  26284. u.scaleToRef(sc, qsc);
  26285. qsc.addInPlace(w);
  26286. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  26287. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  26288. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  26289. if (isIntersected) {
  26290. return qsc.length();
  26291. }
  26292. return -1;
  26293. };
  26294. /**
  26295. * Update the ray from viewport position
  26296. * @param x position
  26297. * @param y y position
  26298. * @param viewportWidth viewport width
  26299. * @param viewportHeight viewport height
  26300. * @param world world matrix
  26301. * @param view view matrix
  26302. * @param projection projection matrix
  26303. * @returns this ray updated
  26304. */
  26305. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  26306. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  26307. return this;
  26308. };
  26309. // Statics
  26310. /**
  26311. * Creates a ray with origin and direction of 0,0,0
  26312. * @returns the new ray
  26313. */
  26314. Ray.Zero = function () {
  26315. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  26316. };
  26317. /**
  26318. * Creates a new ray from screen space and viewport
  26319. * @param x position
  26320. * @param y y position
  26321. * @param viewportWidth viewport width
  26322. * @param viewportHeight viewport height
  26323. * @param world world matrix
  26324. * @param view view matrix
  26325. * @param projection projection matrix
  26326. * @returns new ray
  26327. */
  26328. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  26329. var result = Ray.Zero();
  26330. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  26331. };
  26332. /**
  26333. * 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
  26334. * transformed to the given world matrix.
  26335. * @param origin The origin point
  26336. * @param end The end point
  26337. * @param world a matrix to transform the ray to. Default is the identity matrix.
  26338. * @returns the new ray
  26339. */
  26340. Ray.CreateNewFromTo = function (origin, end, world) {
  26341. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  26342. var direction = end.subtract(origin);
  26343. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  26344. direction.normalize();
  26345. return Ray.Transform(new Ray(origin, direction, length), world);
  26346. };
  26347. /**
  26348. * Transforms a ray by a matrix
  26349. * @param ray ray to transform
  26350. * @param matrix matrix to apply
  26351. * @returns the resulting new ray
  26352. */
  26353. Ray.Transform = function (ray, matrix) {
  26354. 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));
  26355. Ray.TransformToRef(ray, matrix, result);
  26356. return result;
  26357. };
  26358. /**
  26359. * Transforms a ray by a matrix
  26360. * @param ray ray to transform
  26361. * @param matrix matrix to apply
  26362. * @param result ray to store result in
  26363. */
  26364. Ray.TransformToRef = function (ray, matrix, result) {
  26365. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  26366. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  26367. result.length = ray.length;
  26368. var dir = result.direction;
  26369. var len = dir.length();
  26370. if (!(len === 0 || len === 1)) {
  26371. var num = 1.0 / len;
  26372. dir.x *= num;
  26373. dir.y *= num;
  26374. dir.z *= num;
  26375. result.length *= len;
  26376. }
  26377. };
  26378. /**
  26379. * Unproject a ray from screen space to object space
  26380. * @param sourceX defines the screen space x coordinate to use
  26381. * @param sourceY defines the screen space y coordinate to use
  26382. * @param viewportWidth defines the current width of the viewport
  26383. * @param viewportHeight defines the current height of the viewport
  26384. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  26385. * @param view defines the view matrix to use
  26386. * @param projection defines the projection matrix to use
  26387. */
  26388. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  26389. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  26390. world.multiplyToRef(view, matrix);
  26391. matrix.multiplyToRef(projection, matrix);
  26392. matrix.invert();
  26393. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  26394. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  26395. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  26396. nearScreenSource.z = -1.0;
  26397. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  26398. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  26399. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  26400. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  26401. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  26402. this.origin.copyFrom(nearVec3);
  26403. farVec3.subtractToRef(nearVec3, this.direction);
  26404. this.direction.normalize();
  26405. };
  26406. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26407. Ray.smallnum = 0.00000001;
  26408. Ray.rayl = 10e8;
  26409. return Ray;
  26410. }());
  26411. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  26412. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26413. var result = Ray.Zero();
  26414. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  26415. return result;
  26416. };
  26417. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  26418. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26419. var engine = this.getEngine();
  26420. if (!camera) {
  26421. if (!this.activeCamera) {
  26422. throw new Error("Active camera not set");
  26423. }
  26424. camera = this.activeCamera;
  26425. }
  26426. var cameraViewport = camera.viewport;
  26427. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26428. // Moving coordinates to local viewport world
  26429. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26430. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26431. 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());
  26432. return this;
  26433. };
  26434. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  26435. var result = Ray.Zero();
  26436. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  26437. return result;
  26438. };
  26439. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  26440. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26441. return this;
  26442. }
  26443. var engine = this.getEngine();
  26444. if (!camera) {
  26445. if (!this.activeCamera) {
  26446. throw new Error("Active camera not set");
  26447. }
  26448. camera = this.activeCamera;
  26449. }
  26450. var cameraViewport = camera.viewport;
  26451. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26452. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26453. // Moving coordinates to local viewport world
  26454. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26455. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26456. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  26457. return this;
  26458. };
  26459. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck, trianglePredicate) {
  26460. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26461. return null;
  26462. }
  26463. var pickingInfo = null;
  26464. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26465. var mesh = this.meshes[meshIndex];
  26466. if (predicate) {
  26467. if (!predicate(mesh)) {
  26468. continue;
  26469. }
  26470. }
  26471. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26472. continue;
  26473. }
  26474. var world = mesh.getWorldMatrix();
  26475. var ray = rayFunction(world);
  26476. var result = mesh.intersects(ray, fastCheck, trianglePredicate);
  26477. if (!result || !result.hit) {
  26478. continue;
  26479. }
  26480. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  26481. continue;
  26482. }
  26483. pickingInfo = result;
  26484. if (fastCheck) {
  26485. break;
  26486. }
  26487. }
  26488. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  26489. };
  26490. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate, trianglePredicate) {
  26491. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26492. return null;
  26493. }
  26494. var pickingInfos = new Array();
  26495. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26496. var mesh = this.meshes[meshIndex];
  26497. if (predicate) {
  26498. if (!predicate(mesh)) {
  26499. continue;
  26500. }
  26501. }
  26502. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26503. continue;
  26504. }
  26505. var world = mesh.getWorldMatrix();
  26506. var ray = rayFunction(world);
  26507. var result = mesh.intersects(ray, false, trianglePredicate);
  26508. if (!result || !result.hit) {
  26509. continue;
  26510. }
  26511. pickingInfos.push(result);
  26512. }
  26513. return pickingInfos;
  26514. };
  26515. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  26516. var _this = this;
  26517. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26518. return null;
  26519. }
  26520. var result = this._internalPick(function (world) {
  26521. if (!_this._tempPickingRay) {
  26522. _this._tempPickingRay = Ray.Zero();
  26523. }
  26524. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  26525. return _this._tempPickingRay;
  26526. }, predicate, fastCheck, trianglePredicate);
  26527. if (result) {
  26528. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  26529. }
  26530. return result;
  26531. };
  26532. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  26533. var _this = this;
  26534. var result = this._internalPick(function (world) {
  26535. if (!_this._pickWithRayInverseMatrix) {
  26536. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26537. }
  26538. world.invertToRef(_this._pickWithRayInverseMatrix);
  26539. if (!_this._cachedRayForTransform) {
  26540. _this._cachedRayForTransform = Ray.Zero();
  26541. }
  26542. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26543. return _this._cachedRayForTransform;
  26544. }, predicate, fastCheck, trianglePredicate);
  26545. if (result) {
  26546. result.ray = ray;
  26547. }
  26548. return result;
  26549. };
  26550. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  26551. var _this = this;
  26552. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate, trianglePredicate);
  26553. };
  26554. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  26555. var _this = this;
  26556. return this._internalMultiPick(function (world) {
  26557. if (!_this._pickWithRayInverseMatrix) {
  26558. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26559. }
  26560. world.invertToRef(_this._pickWithRayInverseMatrix);
  26561. if (!_this._cachedRayForTransform) {
  26562. _this._cachedRayForTransform = Ray.Zero();
  26563. }
  26564. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26565. return _this._cachedRayForTransform;
  26566. }, predicate, trianglePredicate);
  26567. };
  26568. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  26569. if (length === void 0) { length = 100; }
  26570. if (!transform) {
  26571. transform = this.getWorldMatrix();
  26572. }
  26573. if (!origin) {
  26574. origin = this.position;
  26575. }
  26576. 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);
  26577. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  26578. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  26579. return new Ray(origin, direction, length);
  26580. };
  26581. /***/ }),
  26582. /***/ "./Debug/axesViewer.ts":
  26583. /*!*****************************!*\
  26584. !*** ./Debug/axesViewer.ts ***!
  26585. \*****************************/
  26586. /*! exports provided: AxesViewer */
  26587. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26588. "use strict";
  26589. __webpack_require__.r(__webpack_exports__);
  26590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  26591. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26592. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26593. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  26594. /**
  26595. * The Axes viewer will show 3 axes in a specific point in space
  26596. */
  26597. var AxesViewer = /** @class */ (function () {
  26598. /**
  26599. * Creates a new AxesViewer
  26600. * @param scene defines the hosting scene
  26601. * @param scaleLines defines a number used to scale line length (1 by default)
  26602. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  26603. * @param xAxis defines the node hierarchy used to render the x-axis
  26604. * @param yAxis defines the node hierarchy used to render the y-axis
  26605. * @param zAxis defines the node hierarchy used to render the z-axis
  26606. */
  26607. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  26608. if (scaleLines === void 0) { scaleLines = 1; }
  26609. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  26610. this._scaleLinesFactor = 4;
  26611. this._instanced = false;
  26612. /**
  26613. * Gets or sets a number used to scale line length
  26614. */
  26615. this.scaleLines = 1;
  26616. this.scaleLines = scaleLines;
  26617. if (!xAxis) {
  26618. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26619. redColoredMaterial.disableLighting = true;
  26620. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  26621. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  26622. }
  26623. if (!yAxis) {
  26624. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26625. greenColoredMaterial.disableLighting = true;
  26626. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  26627. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  26628. }
  26629. if (!zAxis) {
  26630. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26631. blueColoredMaterial.disableLighting = true;
  26632. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  26633. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  26634. }
  26635. this._xAxis = xAxis;
  26636. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26637. this._yAxis = yAxis;
  26638. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26639. this._zAxis = zAxis;
  26640. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26641. if (renderingGroupId != null) {
  26642. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  26643. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  26644. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  26645. }
  26646. this.scene = scene;
  26647. 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());
  26648. }
  26649. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  26650. /** Gets the node hierarchy used to render x-axis */
  26651. get: function () {
  26652. return this._xAxis;
  26653. },
  26654. enumerable: true,
  26655. configurable: true
  26656. });
  26657. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  26658. /** Gets the node hierarchy used to render y-axis */
  26659. get: function () {
  26660. return this._yAxis;
  26661. },
  26662. enumerable: true,
  26663. configurable: true
  26664. });
  26665. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  26666. /** Gets the node hierarchy used to render z-axis */
  26667. get: function () {
  26668. return this._zAxis;
  26669. },
  26670. enumerable: true,
  26671. configurable: true
  26672. });
  26673. /**
  26674. * Force the viewer to update
  26675. * @param position defines the position of the viewer
  26676. * @param xaxis defines the x axis of the viewer
  26677. * @param yaxis defines the y axis of the viewer
  26678. * @param zaxis defines the z axis of the viewer
  26679. */
  26680. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  26681. this._xAxis.position.copyFrom(position);
  26682. this._xAxis.setDirection(xaxis);
  26683. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26684. this._yAxis.position.copyFrom(position);
  26685. this._yAxis.setDirection(yaxis);
  26686. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26687. this._zAxis.position.copyFrom(position);
  26688. this._zAxis.setDirection(zaxis);
  26689. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26690. };
  26691. /**
  26692. * Creates an instance of this axes viewer.
  26693. * @returns a new axes viewer with instanced meshes
  26694. */
  26695. AxesViewer.prototype.createInstance = function () {
  26696. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  26697. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  26698. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  26699. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  26700. axesViewer._instanced = true;
  26701. return axesViewer;
  26702. };
  26703. /** Releases resources */
  26704. AxesViewer.prototype.dispose = function () {
  26705. if (this._xAxis) {
  26706. this._xAxis.dispose(false, !this._instanced);
  26707. delete this._xAxis;
  26708. }
  26709. if (this._yAxis) {
  26710. this._yAxis.dispose(false, !this._instanced);
  26711. delete this._yAxis;
  26712. }
  26713. if (this._zAxis) {
  26714. this._zAxis.dispose(false, !this._instanced);
  26715. delete this._zAxis;
  26716. }
  26717. delete this.scene;
  26718. };
  26719. AxesViewer._SetRenderingGroupId = function (node, id) {
  26720. node.getChildMeshes().forEach(function (mesh) {
  26721. mesh.renderingGroupId = id;
  26722. });
  26723. };
  26724. return AxesViewer;
  26725. }());
  26726. /***/ }),
  26727. /***/ "./Debug/boneAxesViewer.ts":
  26728. /*!*********************************!*\
  26729. !*** ./Debug/boneAxesViewer.ts ***!
  26730. \*********************************/
  26731. /*! exports provided: BoneAxesViewer */
  26732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26733. "use strict";
  26734. __webpack_require__.r(__webpack_exports__);
  26735. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  26736. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26737. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  26738. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26739. /**
  26740. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  26741. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  26742. */
  26743. var BoneAxesViewer = /** @class */ (function (_super) {
  26744. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  26745. /**
  26746. * Creates a new BoneAxesViewer
  26747. * @param scene defines the hosting scene
  26748. * @param bone defines the target bone
  26749. * @param mesh defines the target mesh
  26750. * @param scaleLines defines a scaling factor for line length (1 by default)
  26751. */
  26752. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  26753. if (scaleLines === void 0) { scaleLines = 1; }
  26754. var _this = _super.call(this, scene, scaleLines) || this;
  26755. /** Gets current position */
  26756. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26757. /** Gets direction of X axis */
  26758. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26759. /** Gets direction of Y axis */
  26760. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26761. /** Gets direction of Z axis */
  26762. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26763. _this.mesh = mesh;
  26764. _this.bone = bone;
  26765. return _this;
  26766. }
  26767. /**
  26768. * Force the viewer to update
  26769. */
  26770. BoneAxesViewer.prototype.update = function () {
  26771. if (!this.mesh || !this.bone) {
  26772. return;
  26773. }
  26774. var bone = this.bone;
  26775. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  26776. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  26777. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  26778. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  26779. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  26780. };
  26781. /** Releases resources */
  26782. BoneAxesViewer.prototype.dispose = function () {
  26783. if (this.mesh) {
  26784. this.mesh = null;
  26785. this.bone = null;
  26786. _super.prototype.dispose.call(this);
  26787. }
  26788. };
  26789. return BoneAxesViewer;
  26790. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  26791. /***/ }),
  26792. /***/ "./Debug/debugLayer.ts":
  26793. /*!*****************************!*\
  26794. !*** ./Debug/debugLayer.ts ***!
  26795. \*****************************/
  26796. /*! exports provided: DebugLayer */
  26797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26798. "use strict";
  26799. __webpack_require__.r(__webpack_exports__);
  26800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  26801. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26802. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  26803. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  26804. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  26805. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  26806. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  26807. get: function () {
  26808. if (!this._debugLayer) {
  26809. this._debugLayer = new DebugLayer(this);
  26810. }
  26811. return this._debugLayer;
  26812. },
  26813. enumerable: true,
  26814. configurable: true
  26815. });
  26816. /**
  26817. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26818. * what is happening in your scene
  26819. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26820. */
  26821. var DebugLayer = /** @class */ (function () {
  26822. /**
  26823. * Instantiates a new debug layer.
  26824. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26825. * what is happening in your scene
  26826. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26827. * @param scene Defines the scene to inspect
  26828. */
  26829. function DebugLayer(scene) {
  26830. var _this = this;
  26831. this.BJSINSPECTOR = this._getGlobalInspector();
  26832. /**
  26833. * Observable triggered when a property is changed through the inspector.
  26834. */
  26835. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  26836. this._scene = scene;
  26837. this._scene.onDisposeObservable.add(function () {
  26838. // Debug layer
  26839. if (_this._scene._debugLayer) {
  26840. _this._scene._debugLayer.hide();
  26841. }
  26842. });
  26843. }
  26844. /** Creates the inspector window. */
  26845. DebugLayer.prototype._createInspector = function (config) {
  26846. if (this.isVisible()) {
  26847. return;
  26848. }
  26849. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  26850. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  26851. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  26852. };
  26853. /**
  26854. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  26855. * @param entity defines the entity to select
  26856. * @param lineContainerTitle defines the specific block to highlight
  26857. */
  26858. DebugLayer.prototype.select = function (entity, lineContainerTitle) {
  26859. if (this.BJSINSPECTOR) {
  26860. this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(lineContainerTitle);
  26861. this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(entity);
  26862. }
  26863. };
  26864. /** Get the inspector from bundle or global */
  26865. DebugLayer.prototype._getGlobalInspector = function () {
  26866. // UMD Global name detection from Webpack Bundle UMD Name.
  26867. if (typeof INSPECTOR !== 'undefined') {
  26868. return INSPECTOR;
  26869. }
  26870. // In case of module let s check the global emitted from the Inspector entry point.
  26871. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  26872. return BABYLON;
  26873. }
  26874. return undefined;
  26875. };
  26876. /**
  26877. * Get if the inspector is visible or not.
  26878. * @returns true if visible otherwise, false
  26879. */
  26880. DebugLayer.prototype.isVisible = function () {
  26881. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  26882. };
  26883. /**
  26884. * Hide the inspector and close its window.
  26885. */
  26886. DebugLayer.prototype.hide = function () {
  26887. if (this.BJSINSPECTOR) {
  26888. this.BJSINSPECTOR.Inspector.Hide();
  26889. }
  26890. };
  26891. /**
  26892. * Launch the debugLayer.
  26893. * @param config Define the configuration of the inspector
  26894. * @return a promise fulfilled when the debug layer is visible
  26895. */
  26896. DebugLayer.prototype.show = function (config) {
  26897. var _this = this;
  26898. return new Promise(function (resolve, reject) {
  26899. if (typeof _this.BJSINSPECTOR == 'undefined') {
  26900. var inspectorUrl = config && config.inspectorURL ? config.inspectorURL : DebugLayer.InspectorURL;
  26901. // Load inspector and add it to the DOM
  26902. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(inspectorUrl, function () {
  26903. _this._createInspector(config);
  26904. resolve(_this);
  26905. });
  26906. }
  26907. else {
  26908. // Otherwise creates the inspector
  26909. _this._createInspector(config);
  26910. resolve(_this);
  26911. }
  26912. });
  26913. };
  26914. /**
  26915. * Define the url to get the inspector script from.
  26916. * By default it uses the babylonjs CDN.
  26917. * @ignoreNaming
  26918. */
  26919. DebugLayer.InspectorURL = "https://unpkg.com/babylonjs-inspector@" + _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].Version + "/babylon.inspector.bundle.js";
  26920. return DebugLayer;
  26921. }());
  26922. /***/ }),
  26923. /***/ "./Debug/index.ts":
  26924. /*!************************!*\
  26925. !*** ./Debug/index.ts ***!
  26926. \************************/
  26927. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  26928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26929. "use strict";
  26930. __webpack_require__.r(__webpack_exports__);
  26931. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  26932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  26933. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  26934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  26935. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  26936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  26937. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  26938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  26939. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  26940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  26941. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  26942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  26943. /***/ }),
  26944. /***/ "./Debug/physicsViewer.ts":
  26945. /*!********************************!*\
  26946. !*** ./Debug/physicsViewer.ts ***!
  26947. \********************************/
  26948. /*! exports provided: PhysicsViewer */
  26949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26950. "use strict";
  26951. __webpack_require__.r(__webpack_exports__);
  26952. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  26953. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26954. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  26955. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  26956. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26957. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  26958. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26959. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  26960. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26961. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  26962. /**
  26963. * Used to show the physics impostor around the specific mesh
  26964. */
  26965. var PhysicsViewer = /** @class */ (function () {
  26966. /**
  26967. * Creates a new PhysicsViewer
  26968. * @param scene defines the hosting scene
  26969. */
  26970. function PhysicsViewer(scene) {
  26971. /** @hidden */
  26972. this._impostors = [];
  26973. /** @hidden */
  26974. this._meshes = [];
  26975. /** @hidden */
  26976. this._numMeshes = 0;
  26977. this._debugMeshMeshes = new Array();
  26978. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  26979. var physicEngine = this._scene.getPhysicsEngine();
  26980. if (physicEngine) {
  26981. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  26982. }
  26983. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"](this._scene, false);
  26984. this._utilityLayer.pickUtilitySceneFirst = false;
  26985. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26986. }
  26987. /** @hidden */
  26988. PhysicsViewer.prototype._updateDebugMeshes = function () {
  26989. var plugin = this._physicsEnginePlugin;
  26990. for (var i = 0; i < this._numMeshes; i++) {
  26991. var impostor = this._impostors[i];
  26992. if (!impostor) {
  26993. continue;
  26994. }
  26995. if (impostor.isDisposed) {
  26996. this.hideImpostor(this._impostors[i--]);
  26997. }
  26998. else {
  26999. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].MeshImpostor) {
  27000. continue;
  27001. }
  27002. var mesh = this._meshes[i];
  27003. if (mesh && plugin) {
  27004. plugin.syncMeshWithImpostor(mesh, impostor);
  27005. }
  27006. }
  27007. }
  27008. };
  27009. /**
  27010. * Renders a specified physic impostor
  27011. * @param impostor defines the impostor to render
  27012. * @param targetMesh defines the mesh represented by the impostor
  27013. * @returns the new debug mesh used to render the impostor
  27014. */
  27015. PhysicsViewer.prototype.showImpostor = function (impostor, targetMesh) {
  27016. if (!this._scene) {
  27017. return null;
  27018. }
  27019. for (var i = 0; i < this._numMeshes; i++) {
  27020. if (this._impostors[i] == impostor) {
  27021. return null;
  27022. }
  27023. }
  27024. var debugMesh = this._getDebugMesh(impostor, targetMesh);
  27025. if (debugMesh) {
  27026. this._impostors[this._numMeshes] = impostor;
  27027. this._meshes[this._numMeshes] = debugMesh;
  27028. if (this._numMeshes === 0) {
  27029. this._renderFunction = this._updateDebugMeshes.bind(this);
  27030. this._scene.registerBeforeRender(this._renderFunction);
  27031. }
  27032. this._numMeshes++;
  27033. }
  27034. return debugMesh;
  27035. };
  27036. /**
  27037. * Hides a specified physic impostor
  27038. * @param impostor defines the impostor to hide
  27039. */
  27040. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  27041. if (!impostor || !this._scene || !this._utilityLayer) {
  27042. return;
  27043. }
  27044. var removed = false;
  27045. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  27046. for (var i = 0; i < this._numMeshes; i++) {
  27047. if (this._impostors[i] == impostor) {
  27048. var mesh = this._meshes[i];
  27049. if (!mesh) {
  27050. continue;
  27051. }
  27052. utilityLayerScene.removeMesh(mesh);
  27053. mesh.dispose();
  27054. var index = this._debugMeshMeshes.indexOf(mesh);
  27055. if (index > -1) {
  27056. this._debugMeshMeshes.splice(index, 1);
  27057. }
  27058. this._numMeshes--;
  27059. if (this._numMeshes > 0) {
  27060. this._meshes[i] = this._meshes[this._numMeshes];
  27061. this._impostors[i] = this._impostors[this._numMeshes];
  27062. this._meshes[this._numMeshes] = null;
  27063. this._impostors[this._numMeshes] = null;
  27064. }
  27065. else {
  27066. this._meshes[0] = null;
  27067. this._impostors[0] = null;
  27068. }
  27069. removed = true;
  27070. break;
  27071. }
  27072. }
  27073. if (removed && this._numMeshes === 0) {
  27074. this._scene.unregisterBeforeRender(this._renderFunction);
  27075. }
  27076. };
  27077. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  27078. if (!this._debugMaterial) {
  27079. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]('', scene);
  27080. this._debugMaterial.wireframe = true;
  27081. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].White();
  27082. this._debugMaterial.disableLighting = true;
  27083. }
  27084. return this._debugMaterial;
  27085. };
  27086. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  27087. if (!this._debugBoxMesh) {
  27088. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  27089. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  27090. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  27091. this._debugBoxMesh.setEnabled(false);
  27092. }
  27093. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  27094. };
  27095. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  27096. if (!this._debugSphereMesh) {
  27097. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  27098. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  27099. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  27100. this._debugSphereMesh.setEnabled(false);
  27101. }
  27102. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  27103. };
  27104. PhysicsViewer.prototype._getDebugCylinderMesh = function (scene) {
  27105. if (!this._debugCylinderMesh) {
  27106. this._debugCylinderMesh = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_8__["CylinderBuilder"].CreateCylinder('physicsBodyCylinderViewMesh', { diameterTop: 1, diameterBottom: 1, height: 1 }, scene);
  27107. this._debugCylinderMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  27108. this._debugCylinderMesh.material = this._getDebugMaterial(scene);
  27109. this._debugCylinderMesh.setEnabled(false);
  27110. }
  27111. return this._debugCylinderMesh.createInstance('physicsBodyBoxViewInstance');
  27112. };
  27113. PhysicsViewer.prototype._getDebugMeshMesh = function (mesh, scene) {
  27114. var wireframeOver = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](mesh.name, scene, null, mesh);
  27115. wireframeOver.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  27116. wireframeOver.setParent(mesh);
  27117. wireframeOver.material = this._getDebugMaterial(scene);
  27118. this._debugMeshMeshes.push(wireframeOver);
  27119. return wireframeOver;
  27120. };
  27121. PhysicsViewer.prototype._getDebugMesh = function (impostor, targetMesh) {
  27122. var _this = this;
  27123. if (!this._utilityLayer) {
  27124. return null;
  27125. }
  27126. // Only create child impostor debug meshes when evaluating the parent
  27127. if (targetMesh && targetMesh.parent && targetMesh.parent.physicsImpostor) {
  27128. return null;
  27129. }
  27130. var mesh = null;
  27131. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  27132. switch (impostor.type) {
  27133. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].BoxImpostor:
  27134. mesh = this._getDebugBoxMesh(utilityLayerScene);
  27135. impostor.getBoxSizeToRef(mesh.scaling);
  27136. break;
  27137. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].SphereImpostor:
  27138. mesh = this._getDebugSphereMesh(utilityLayerScene);
  27139. var radius = impostor.getRadius();
  27140. mesh.scaling.x = radius * 2;
  27141. mesh.scaling.y = radius * 2;
  27142. mesh.scaling.z = radius * 2;
  27143. break;
  27144. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].MeshImpostor:
  27145. if (targetMesh) {
  27146. mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);
  27147. }
  27148. break;
  27149. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].NoImpostor:
  27150. if (targetMesh) {
  27151. // Handle compound impostors
  27152. var childMeshes = targetMesh.getChildMeshes().filter(function (c) { return c.physicsImpostor ? 1 : 0; });
  27153. childMeshes.forEach(function (m) {
  27154. var a = _this._getDebugBoxMesh(utilityLayerScene);
  27155. a.parent = m;
  27156. });
  27157. }
  27158. break;
  27159. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].CylinderImpostor:
  27160. mesh = this._getDebugCylinderMesh(utilityLayerScene);
  27161. var bi = impostor.object.getBoundingInfo();
  27162. mesh.scaling.x = bi.boundingBox.maximum.x - bi.boundingBox.minimum.x;
  27163. mesh.scaling.y = bi.boundingBox.maximum.y - bi.boundingBox.minimum.y;
  27164. mesh.scaling.z = bi.boundingBox.maximum.z - bi.boundingBox.minimum.z;
  27165. break;
  27166. }
  27167. return mesh;
  27168. };
  27169. /** Releases all resources */
  27170. PhysicsViewer.prototype.dispose = function () {
  27171. var count = this._numMeshes;
  27172. for (var index = 0; index < count; index++) {
  27173. this.hideImpostor(this._impostors[0]);
  27174. }
  27175. if (this._debugBoxMesh) {
  27176. this._debugBoxMesh.dispose();
  27177. }
  27178. if (this._debugSphereMesh) {
  27179. this._debugSphereMesh.dispose();
  27180. }
  27181. if (this._debugCylinderMesh) {
  27182. this._debugCylinderMesh.dispose();
  27183. }
  27184. if (this._debugMaterial) {
  27185. this._debugMaterial.dispose();
  27186. }
  27187. this._impostors.length = 0;
  27188. this._scene = null;
  27189. this._physicsEnginePlugin = null;
  27190. if (this._utilityLayer) {
  27191. this._utilityLayer.dispose();
  27192. this._utilityLayer = null;
  27193. }
  27194. };
  27195. return PhysicsViewer;
  27196. }());
  27197. /***/ }),
  27198. /***/ "./Debug/rayHelper.ts":
  27199. /*!****************************!*\
  27200. !*** ./Debug/rayHelper.ts ***!
  27201. \****************************/
  27202. /*! exports provided: RayHelper */
  27203. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27204. "use strict";
  27205. __webpack_require__.r(__webpack_exports__);
  27206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  27207. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27208. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  27209. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  27210. /**
  27211. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  27212. * in order to better appreciate the issue one might have.
  27213. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  27214. */
  27215. var RayHelper = /** @class */ (function () {
  27216. /**
  27217. * Instantiate a new ray helper.
  27218. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  27219. * in order to better appreciate the issue one might have.
  27220. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  27221. * @param ray Defines the ray we are currently tryin to visualize
  27222. */
  27223. function RayHelper(ray) {
  27224. this.ray = ray;
  27225. }
  27226. /**
  27227. * Helper function to create a colored helper in a scene in one line.
  27228. * @param ray Defines the ray we are currently tryin to visualize
  27229. * @param scene Defines the scene the ray is used in
  27230. * @param color Defines the color we want to see the ray in
  27231. * @returns The newly created ray helper.
  27232. */
  27233. RayHelper.CreateAndShow = function (ray, scene, color) {
  27234. var helper = new RayHelper(ray);
  27235. helper.show(scene, color);
  27236. return helper;
  27237. };
  27238. /**
  27239. * Shows the ray we are willing to debug.
  27240. * @param scene Defines the scene the ray needs to be rendered in
  27241. * @param color Defines the color the ray needs to be rendered in
  27242. */
  27243. RayHelper.prototype.show = function (scene, color) {
  27244. if (!this._renderFunction && this.ray) {
  27245. var ray = this.ray;
  27246. this._renderFunction = this._render.bind(this);
  27247. this._scene = scene;
  27248. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  27249. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  27250. if (this._renderFunction) {
  27251. this._scene.registerBeforeRender(this._renderFunction);
  27252. }
  27253. }
  27254. if (color && this._renderLine) {
  27255. this._renderLine.color.copyFrom(color);
  27256. }
  27257. };
  27258. /**
  27259. * Hides the ray we are debugging.
  27260. */
  27261. RayHelper.prototype.hide = function () {
  27262. if (this._renderFunction && this._scene) {
  27263. this._scene.unregisterBeforeRender(this._renderFunction);
  27264. this._scene = null;
  27265. this._renderFunction = null;
  27266. if (this._renderLine) {
  27267. this._renderLine.dispose();
  27268. this._renderLine = null;
  27269. }
  27270. this._renderPoints = [];
  27271. }
  27272. };
  27273. RayHelper.prototype._render = function () {
  27274. var ray = this.ray;
  27275. if (!ray) {
  27276. return;
  27277. }
  27278. var point = this._renderPoints[1];
  27279. var len = Math.min(ray.length, 1000000);
  27280. point.copyFrom(ray.direction);
  27281. point.scaleInPlace(len);
  27282. point.addInPlace(ray.origin);
  27283. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  27284. };
  27285. /**
  27286. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  27287. * @param mesh Defines the mesh we want the helper attached to
  27288. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  27289. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  27290. * @param length Defines the length of the ray
  27291. */
  27292. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  27293. this._attachedToMesh = mesh;
  27294. var ray = this.ray;
  27295. if (!ray) {
  27296. return;
  27297. }
  27298. if (!ray.direction) {
  27299. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27300. }
  27301. if (!ray.origin) {
  27302. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27303. }
  27304. if (length) {
  27305. ray.length = length;
  27306. }
  27307. if (!meshSpaceOrigin) {
  27308. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27309. }
  27310. if (!meshSpaceDirection) {
  27311. // -1 so that this will work with Mesh.lookAt
  27312. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  27313. }
  27314. if (!this._meshSpaceDirection) {
  27315. this._meshSpaceDirection = meshSpaceDirection.clone();
  27316. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  27317. }
  27318. else {
  27319. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  27320. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  27321. }
  27322. if (!this._updateToMeshFunction) {
  27323. this._updateToMeshFunction = this._updateToMesh.bind(this);
  27324. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  27325. }
  27326. this._updateToMesh();
  27327. };
  27328. /**
  27329. * Detach the ray helper from the mesh it has previously been attached to.
  27330. */
  27331. RayHelper.prototype.detachFromMesh = function () {
  27332. if (this._attachedToMesh) {
  27333. if (this._updateToMeshFunction) {
  27334. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  27335. }
  27336. this._attachedToMesh = null;
  27337. this._updateToMeshFunction = null;
  27338. }
  27339. };
  27340. RayHelper.prototype._updateToMesh = function () {
  27341. var ray = this.ray;
  27342. if (!this._attachedToMesh || !ray) {
  27343. return;
  27344. }
  27345. if (this._attachedToMesh._isDisposed) {
  27346. this.detachFromMesh();
  27347. return;
  27348. }
  27349. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  27350. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  27351. };
  27352. /**
  27353. * Dispose the helper and release its associated resources.
  27354. */
  27355. RayHelper.prototype.dispose = function () {
  27356. this.hide();
  27357. this.detachFromMesh();
  27358. this.ray = null;
  27359. };
  27360. return RayHelper;
  27361. }());
  27362. /***/ }),
  27363. /***/ "./Debug/skeletonViewer.ts":
  27364. /*!*********************************!*\
  27365. !*** ./Debug/skeletonViewer.ts ***!
  27366. \*********************************/
  27367. /*! exports provided: SkeletonViewer */
  27368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27369. "use strict";
  27370. __webpack_require__.r(__webpack_exports__);
  27371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  27372. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27373. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  27374. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  27375. /**
  27376. * Class used to render a debug view of a given skeleton
  27377. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  27378. */
  27379. var SkeletonViewer = /** @class */ (function () {
  27380. /**
  27381. * Creates a new SkeletonViewer
  27382. * @param skeleton defines the skeleton to render
  27383. * @param mesh defines the mesh attached to the skeleton
  27384. * @param scene defines the hosting scene
  27385. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  27386. * @param renderingGroupId defines the rendering group id to use with the viewer
  27387. */
  27388. function SkeletonViewer(
  27389. /** defines the skeleton to render */
  27390. skeleton,
  27391. /** defines the mesh attached to the skeleton */
  27392. mesh, scene,
  27393. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  27394. autoUpdateBonesMatrices,
  27395. /** defines the rendering group id to use with the viewer */
  27396. renderingGroupId) {
  27397. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  27398. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  27399. this.skeleton = skeleton;
  27400. this.mesh = mesh;
  27401. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  27402. this.renderingGroupId = renderingGroupId;
  27403. /** Gets or sets the color used to render the skeleton */
  27404. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  27405. this._debugLines = new Array();
  27406. this._isEnabled = false;
  27407. this._scene = scene;
  27408. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  27409. this._utilityLayer.pickUtilitySceneFirst = false;
  27410. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  27411. this.update();
  27412. this._renderFunction = this.update.bind(this);
  27413. }
  27414. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  27415. /**
  27416. * Returns the mesh used to render the bones
  27417. */
  27418. get: function () {
  27419. return this._debugMesh;
  27420. },
  27421. enumerable: true,
  27422. configurable: true
  27423. });
  27424. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  27425. get: function () {
  27426. return this._isEnabled;
  27427. },
  27428. /** Gets or sets a boolean indicating if the viewer is enabled */
  27429. set: function (value) {
  27430. if (this._isEnabled === value) {
  27431. return;
  27432. }
  27433. this._isEnabled = value;
  27434. if (value) {
  27435. this._scene.registerBeforeRender(this._renderFunction);
  27436. }
  27437. else {
  27438. this._scene.unregisterBeforeRender(this._renderFunction);
  27439. }
  27440. },
  27441. enumerable: true,
  27442. configurable: true
  27443. });
  27444. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  27445. if (x === void 0) { x = 0; }
  27446. if (y === void 0) { y = 0; }
  27447. if (z === void 0) { z = 0; }
  27448. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  27449. var parentBone = bone.getParent();
  27450. tmat.copyFrom(bone.getLocalMatrix());
  27451. if (x !== 0 || y !== 0 || z !== 0) {
  27452. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  27453. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  27454. tmat2.setTranslationFromFloats(x, y, z);
  27455. tmat2.multiplyToRef(tmat, tmat);
  27456. }
  27457. if (parentBone) {
  27458. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  27459. }
  27460. tmat.multiplyToRef(meshMat, tmat);
  27461. position.x = tmat.m[12];
  27462. position.y = tmat.m[13];
  27463. position.z = tmat.m[14];
  27464. };
  27465. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  27466. var len = bones.length;
  27467. var mesh = this.mesh._effectiveMesh;
  27468. var meshPos = mesh.position;
  27469. for (var i = 0; i < len; i++) {
  27470. var bone = bones[i];
  27471. var points = this._debugLines[i];
  27472. if (!points) {
  27473. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27474. this._debugLines[i] = points;
  27475. }
  27476. this._getBonePosition(points[0], bone, meshMat);
  27477. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  27478. points[0].subtractInPlace(meshPos);
  27479. points[1].subtractInPlace(meshPos);
  27480. }
  27481. };
  27482. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  27483. var len = bones.length;
  27484. var boneNum = 0;
  27485. var mesh = this.mesh._effectiveMesh;
  27486. var meshPos = mesh.position;
  27487. for (var i = len - 1; i >= 0; i--) {
  27488. var childBone = bones[i];
  27489. var parentBone = childBone.getParent();
  27490. if (!parentBone) {
  27491. continue;
  27492. }
  27493. var points = this._debugLines[boneNum];
  27494. if (!points) {
  27495. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27496. this._debugLines[boneNum] = points;
  27497. }
  27498. childBone.getAbsolutePositionToRef(mesh, points[0]);
  27499. parentBone.getAbsolutePositionToRef(mesh, points[1]);
  27500. points[0].subtractInPlace(meshPos);
  27501. points[1].subtractInPlace(meshPos);
  27502. boneNum++;
  27503. }
  27504. };
  27505. /** Update the viewer to sync with current skeleton state */
  27506. SkeletonViewer.prototype.update = function () {
  27507. if (!this._utilityLayer) {
  27508. return;
  27509. }
  27510. if (this.autoUpdateBonesMatrices) {
  27511. this.skeleton.computeAbsoluteTransforms();
  27512. }
  27513. var mesh = this.mesh._effectiveMesh;
  27514. if (this.skeleton.bones[0].length === undefined) {
  27515. this._getLinesForBonesNoLength(this.skeleton.bones, mesh.getWorldMatrix());
  27516. }
  27517. else {
  27518. this._getLinesForBonesWithLength(this.skeleton.bones, mesh.getWorldMatrix());
  27519. }
  27520. var targetScene = this._utilityLayer.utilityLayerScene;
  27521. if (!this._debugMesh) {
  27522. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  27523. this._debugMesh.renderingGroupId = this.renderingGroupId;
  27524. }
  27525. else {
  27526. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  27527. }
  27528. this._debugMesh.position.copyFrom(this.mesh.position);
  27529. this._debugMesh.color = this.color;
  27530. };
  27531. /** Release associated resources */
  27532. SkeletonViewer.prototype.dispose = function () {
  27533. this.isEnabled = false;
  27534. if (this._debugMesh) {
  27535. this.isEnabled = false;
  27536. this._debugMesh.dispose();
  27537. this._debugMesh = null;
  27538. }
  27539. if (this._utilityLayer) {
  27540. this._utilityLayer.dispose();
  27541. this._utilityLayer = null;
  27542. }
  27543. };
  27544. return SkeletonViewer;
  27545. }());
  27546. /***/ }),
  27547. /***/ "./Engines/Extensions/engine.cubeTexture.ts":
  27548. /*!**************************************************!*\
  27549. !*** ./Engines/Extensions/engine.cubeTexture.ts ***!
  27550. \**************************************************/
  27551. /*! no exports provided */
  27552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27553. "use strict";
  27554. __webpack_require__.r(__webpack_exports__);
  27555. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  27556. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27557. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27558. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  27559. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  27560. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype._createDepthStencilCubeTexture = function (size, options) {
  27561. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"].DATASOURCE_UNKNOWN);
  27562. internalTexture.isCube = true;
  27563. if (this.webGLVersion === 1) {
  27564. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  27565. return internalTexture;
  27566. }
  27567. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  27568. var gl = this._gl;
  27569. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  27570. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  27571. // Create the depth/stencil buffer
  27572. for (var face = 0; face < 6; face++) {
  27573. if (internalOptions.generateStencil) {
  27574. 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);
  27575. }
  27576. else {
  27577. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  27578. }
  27579. }
  27580. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  27581. return internalTexture;
  27582. };
  27583. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  27584. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  27585. var onload = function (data) {
  27586. loadedFiles[index] = data;
  27587. loadedFiles._internalCount++;
  27588. if (loadedFiles._internalCount === 6) {
  27589. onfinish(loadedFiles);
  27590. }
  27591. };
  27592. var onerror = function (request, exception) {
  27593. if (onErrorCallBack && request) {
  27594. onErrorCallBack(request.status + " " + request.statusText, exception);
  27595. }
  27596. };
  27597. this._loadFile(url, onload, undefined, undefined, true, onerror);
  27598. };
  27599. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  27600. if (onError === void 0) { onError = null; }
  27601. var loadedFiles = [];
  27602. loadedFiles._internalCount = 0;
  27603. for (var index = 0; index < 6; index++) {
  27604. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  27605. }
  27606. };
  27607. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  27608. if (onError === void 0) { onError = null; }
  27609. var loadedImages = [];
  27610. loadedImages._internalCount = 0;
  27611. for (var index = 0; index < 6; index++) {
  27612. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  27613. }
  27614. };
  27615. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  27616. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  27617. var img;
  27618. var onload = function () {
  27619. loadedImages[index] = img;
  27620. loadedImages._internalCount++;
  27621. if (scene) {
  27622. scene._removePendingData(img);
  27623. }
  27624. if (loadedImages._internalCount === 6) {
  27625. onfinish(loadedImages);
  27626. }
  27627. };
  27628. var onerror = function (message, exception) {
  27629. if (scene) {
  27630. scene._removePendingData(img);
  27631. }
  27632. if (onErrorCallBack) {
  27633. onErrorCallBack(message, exception);
  27634. }
  27635. };
  27636. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  27637. if (scene) {
  27638. scene._addPendingData(img);
  27639. }
  27640. };
  27641. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  27642. var _this = this;
  27643. if (onLoad === void 0) { onLoad = null; }
  27644. if (onError === void 0) { onError = null; }
  27645. if (forcedExtension === void 0) { forcedExtension = null; }
  27646. if (createPolynomials === void 0) { createPolynomials = false; }
  27647. if (lodScale === void 0) { lodScale = 0; }
  27648. if (lodOffset === void 0) { lodOffset = 0; }
  27649. if (fallback === void 0) { fallback = null; }
  27650. if (excludeLoaders === void 0) { excludeLoaders = []; }
  27651. var gl = this._gl;
  27652. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"].DATASOURCE_CUBE);
  27653. texture.isCube = true;
  27654. texture.url = rootUrl;
  27655. texture.generateMipMaps = !noMipmap;
  27656. texture._lodGenerationScale = lodScale;
  27657. texture._lodGenerationOffset = lodOffset;
  27658. if (!this._doNotHandleContextLost) {
  27659. texture._extension = forcedExtension;
  27660. texture._files = files;
  27661. }
  27662. var lastDot = rootUrl.lastIndexOf('.');
  27663. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  27664. var loader = null;
  27665. for (var _i = 0, _a = _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders; _i < _a.length; _i++) {
  27666. var availableLoader = _a[_i];
  27667. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  27668. loader = availableLoader;
  27669. break;
  27670. }
  27671. }
  27672. var onInternalError = function (request, exception) {
  27673. if (loader) {
  27674. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  27675. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn(loader.constructor.name + " failed when trying to load " + texture.url + ", falling back to the next supported loader");
  27676. if (fallbackUrl) {
  27677. excludeLoaders.push(loader);
  27678. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  27679. return;
  27680. }
  27681. }
  27682. if (onError && request) {
  27683. onError(request.status + " " + request.statusText, exception);
  27684. }
  27685. };
  27686. if (loader) {
  27687. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  27688. var onloaddata = function (data) {
  27689. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  27690. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  27691. };
  27692. if (files && files.length === 6) {
  27693. if (loader.supportCascades) {
  27694. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  27695. }
  27696. else {
  27697. if (onError) {
  27698. onError("Textures type does not support cascades.");
  27699. }
  27700. else {
  27701. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("Texture loader does not support cascades.");
  27702. }
  27703. }
  27704. }
  27705. else {
  27706. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  27707. }
  27708. }
  27709. else {
  27710. if (!files) {
  27711. throw new Error("Cannot load cubemap because files were not defined");
  27712. }
  27713. this._cascadeLoadImgs(scene, function (imgs) {
  27714. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  27715. var height = width;
  27716. _this._prepareWorkingCanvas();
  27717. if (!_this._workingCanvas || !_this._workingContext) {
  27718. return;
  27719. }
  27720. _this._workingCanvas.width = width;
  27721. _this._workingCanvas.height = height;
  27722. var faces = [
  27723. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  27724. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  27725. ];
  27726. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  27727. _this._unpackFlipY(false);
  27728. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  27729. for (var index = 0; index < faces.length; index++) {
  27730. if (imgs[index].width !== width || imgs[index].height !== height) {
  27731. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  27732. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  27733. }
  27734. else {
  27735. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, imgs[index]);
  27736. }
  27737. }
  27738. if (!noMipmap) {
  27739. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  27740. }
  27741. _this._setCubeMapTextureParams(!noMipmap);
  27742. texture.width = width;
  27743. texture.height = height;
  27744. texture.isReady = true;
  27745. if (format) {
  27746. texture.format = format;
  27747. }
  27748. texture.onLoadedObservable.notifyObservers(texture);
  27749. texture.onLoadedObservable.clear();
  27750. if (onLoad) {
  27751. onLoad();
  27752. }
  27753. }, files, onError);
  27754. }
  27755. this._internalTexturesCache.push(texture);
  27756. return texture;
  27757. };
  27758. /***/ }),
  27759. /***/ "./Engines/Extensions/engine.multiRender.ts":
  27760. /*!**************************************************!*\
  27761. !*** ./Engines/Extensions/engine.multiRender.ts ***!
  27762. \**************************************************/
  27763. /*! no exports provided */
  27764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27765. "use strict";
  27766. __webpack_require__.r(__webpack_exports__);
  27767. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27768. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27769. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  27770. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  27771. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  27772. this._currentRenderTarget = null;
  27773. // If MSAA, we need to bitblt back to main texture
  27774. var gl = this._gl;
  27775. if (textures[0]._MSAAFramebuffer) {
  27776. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  27777. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  27778. var attachments = textures[0]._attachments;
  27779. if (!attachments) {
  27780. attachments = new Array(textures.length);
  27781. textures[0]._attachments = attachments;
  27782. }
  27783. for (var i = 0; i < textures.length; i++) {
  27784. var texture = textures[i];
  27785. for (var j = 0; j < attachments.length; j++) {
  27786. attachments[j] = gl.NONE;
  27787. }
  27788. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  27789. gl.readBuffer(attachments[i]);
  27790. gl.drawBuffers(attachments);
  27791. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  27792. }
  27793. for (var i = 0; i < attachments.length; i++) {
  27794. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  27795. }
  27796. gl.drawBuffers(attachments);
  27797. }
  27798. for (var i = 0; i < textures.length; i++) {
  27799. var texture = textures[i];
  27800. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  27801. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  27802. gl.generateMipmap(gl.TEXTURE_2D);
  27803. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  27804. }
  27805. }
  27806. if (onBeforeUnbind) {
  27807. if (textures[0]._MSAAFramebuffer) {
  27808. // Bind the correct framebuffer
  27809. this._bindUnboundFramebuffer(textures[0]._framebuffer);
  27810. }
  27811. onBeforeUnbind();
  27812. }
  27813. this._bindUnboundFramebuffer(null);
  27814. };
  27815. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createMultipleRenderTarget = function (size, options) {
  27816. var generateMipMaps = false;
  27817. var generateDepthBuffer = true;
  27818. var generateStencilBuffer = false;
  27819. var generateDepthTexture = false;
  27820. var textureCount = 1;
  27821. var defaultType = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_UNSIGNED_INT;
  27822. var defaultSamplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  27823. var types = new Array();
  27824. var samplingModes = new Array();
  27825. if (options !== undefined) {
  27826. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  27827. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  27828. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  27829. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  27830. textureCount = options.textureCount || 1;
  27831. if (options.types) {
  27832. types = options.types;
  27833. }
  27834. if (options.samplingModes) {
  27835. samplingModes = options.samplingModes;
  27836. }
  27837. }
  27838. var gl = this._gl;
  27839. // Create the framebuffer
  27840. var framebuffer = gl.createFramebuffer();
  27841. this._bindUnboundFramebuffer(framebuffer);
  27842. var width = size.width || size;
  27843. var height = size.height || size;
  27844. var textures = [];
  27845. var attachments = [];
  27846. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  27847. for (var i = 0; i < textureCount; i++) {
  27848. var samplingMode = samplingModes[i] || defaultSamplingMode;
  27849. var type = types[i] || defaultType;
  27850. if (type === _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  27851. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  27852. samplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURE_NEAREST_SAMPLINGMODE;
  27853. }
  27854. else if (type === _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  27855. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  27856. samplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURE_NEAREST_SAMPLINGMODE;
  27857. }
  27858. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  27859. if (type === _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  27860. type = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_UNSIGNED_INT;
  27861. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  27862. }
  27863. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  27864. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  27865. textures.push(texture);
  27866. attachments.push(attachment);
  27867. gl.activeTexture(gl["TEXTURE" + i]);
  27868. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  27869. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  27870. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  27871. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  27872. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  27873. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  27874. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  27875. if (generateMipMaps) {
  27876. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  27877. }
  27878. // Unbind
  27879. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  27880. texture._framebuffer = framebuffer;
  27881. texture._depthStencilBuffer = depthStencilBuffer;
  27882. texture.baseWidth = width;
  27883. texture.baseHeight = height;
  27884. texture.width = width;
  27885. texture.height = height;
  27886. texture.isReady = true;
  27887. texture.samples = 1;
  27888. texture.generateMipMaps = generateMipMaps;
  27889. texture.samplingMode = samplingMode;
  27890. texture.type = type;
  27891. texture._generateDepthBuffer = generateDepthBuffer;
  27892. texture._generateStencilBuffer = generateStencilBuffer;
  27893. texture._attachments = attachments;
  27894. this._internalTexturesCache.push(texture);
  27895. }
  27896. if (generateDepthTexture && this._caps.depthTextureExtension) {
  27897. // Depth texture
  27898. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  27899. gl.activeTexture(gl.TEXTURE0);
  27900. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  27901. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  27902. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  27903. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  27904. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  27905. 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);
  27906. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  27907. depthTexture._framebuffer = framebuffer;
  27908. depthTexture.baseWidth = width;
  27909. depthTexture.baseHeight = height;
  27910. depthTexture.width = width;
  27911. depthTexture.height = height;
  27912. depthTexture.isReady = true;
  27913. depthTexture.samples = 1;
  27914. depthTexture.generateMipMaps = generateMipMaps;
  27915. depthTexture.samplingMode = gl.NEAREST;
  27916. depthTexture._generateDepthBuffer = generateDepthBuffer;
  27917. depthTexture._generateStencilBuffer = generateStencilBuffer;
  27918. textures.push(depthTexture);
  27919. this._internalTexturesCache.push(depthTexture);
  27920. }
  27921. gl.drawBuffers(attachments);
  27922. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  27923. this._bindUnboundFramebuffer(null);
  27924. this.resetTextureCache();
  27925. return textures;
  27926. };
  27927. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  27928. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  27929. return 1;
  27930. }
  27931. if (textures[0].samples === samples) {
  27932. return samples;
  27933. }
  27934. var gl = this._gl;
  27935. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  27936. // Dispose previous render buffers
  27937. if (textures[0]._depthStencilBuffer) {
  27938. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  27939. textures[0]._depthStencilBuffer = null;
  27940. }
  27941. if (textures[0]._MSAAFramebuffer) {
  27942. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  27943. textures[0]._MSAAFramebuffer = null;
  27944. }
  27945. for (var i = 0; i < textures.length; i++) {
  27946. if (textures[i]._MSAARenderBuffer) {
  27947. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  27948. textures[i]._MSAARenderBuffer = null;
  27949. }
  27950. }
  27951. if (samples > 1) {
  27952. var framebuffer = gl.createFramebuffer();
  27953. if (!framebuffer) {
  27954. throw new Error("Unable to create multi sampled framebuffer");
  27955. }
  27956. this._bindUnboundFramebuffer(framebuffer);
  27957. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  27958. var attachments = [];
  27959. for (var i = 0; i < textures.length; i++) {
  27960. var texture = textures[i];
  27961. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  27962. var colorRenderbuffer = gl.createRenderbuffer();
  27963. if (!colorRenderbuffer) {
  27964. throw new Error("Unable to create multi sampled framebuffer");
  27965. }
  27966. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  27967. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  27968. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  27969. texture._MSAAFramebuffer = framebuffer;
  27970. texture._MSAARenderBuffer = colorRenderbuffer;
  27971. texture.samples = samples;
  27972. texture._depthStencilBuffer = depthStencilBuffer;
  27973. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  27974. attachments.push(attachment);
  27975. }
  27976. gl.drawBuffers(attachments);
  27977. }
  27978. else {
  27979. this._bindUnboundFramebuffer(textures[0]._framebuffer);
  27980. }
  27981. this._bindUnboundFramebuffer(null);
  27982. return samples;
  27983. };
  27984. /***/ }),
  27985. /***/ "./Engines/Extensions/engine.multiview.ts":
  27986. /*!************************************************!*\
  27987. !*** ./Engines/Extensions/engine.multiview.ts ***!
  27988. \************************************************/
  27989. /*! no exports provided */
  27990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27991. "use strict";
  27992. __webpack_require__.r(__webpack_exports__);
  27993. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  27994. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27995. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  27996. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27997. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  27998. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  27999. /* harmony import */ var _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/MultiviewRenderTarget */ "./Materials/Textures/MultiviewRenderTarget.ts");
  28000. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.createMultiviewRenderTargetTexture = function (width, height) {
  28001. var gl = this._gl;
  28002. if (!this.getCaps().multiview) {
  28003. throw "Multiview is not supported";
  28004. }
  28005. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  28006. internalTexture.width = width;
  28007. internalTexture.height = height;
  28008. internalTexture._framebuffer = gl.createFramebuffer();
  28009. internalTexture._colorTextureArray = gl.createTexture();
  28010. gl.bindTexture(gl.TEXTURE_2D_ARRAY, internalTexture._colorTextureArray);
  28011. gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.RGBA8, width, height, 2);
  28012. internalTexture._depthStencilTextureArray = gl.createTexture();
  28013. gl.bindTexture(gl.TEXTURE_2D_ARRAY, internalTexture._depthStencilTextureArray);
  28014. gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.DEPTH32F_STENCIL8, width, height, 2);
  28015. internalTexture.isReady = true;
  28016. return internalTexture;
  28017. };
  28018. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.bindMultiviewFramebuffer = function (multiviewTexture) {
  28019. var gl = this._gl;
  28020. var ext = this.getCaps().multiview;
  28021. this.bindFramebuffer(multiviewTexture, undefined, undefined, undefined, true);
  28022. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, multiviewTexture._framebuffer);
  28023. if (multiviewTexture._colorTextureArray && multiviewTexture._depthStencilTextureArray) {
  28024. ext.framebufferTextureMultiviewOVR(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, multiviewTexture._colorTextureArray, 0, 0, 2);
  28025. ext.framebufferTextureMultiviewOVR(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, multiviewTexture._depthStencilTextureArray, 0, 0, 2);
  28026. }
  28027. else {
  28028. throw "Invalid multiview frame buffer";
  28029. }
  28030. };
  28031. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._useMultiviewToSingleView = false;
  28032. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._multiviewTexture = null;
  28033. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._resizeOrCreateMultiviewTexture = function (width, height) {
  28034. if (!this._multiviewTexture) {
  28035. this._multiviewTexture = new _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__["MultiviewRenderTarget"](this.getScene(), { width: width, height: height });
  28036. }
  28037. else if (this._multiviewTexture.getRenderWidth() != width || this._multiviewTexture.getRenderHeight() != height) {
  28038. this._multiviewTexture.dispose();
  28039. this._multiviewTexture = new _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__["MultiviewRenderTarget"](this.getScene(), { width: width, height: height });
  28040. }
  28041. };
  28042. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._transformMatrixR = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  28043. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._multiviewSceneUbo = null;
  28044. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._createMultiviewUbo = function () {
  28045. this._multiviewSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_5__["UniformBuffer"](this.getEngine(), undefined, true);
  28046. this._multiviewSceneUbo.addUniform("viewProjection", 16);
  28047. this._multiviewSceneUbo.addUniform("viewProjectionR", 16);
  28048. this._multiviewSceneUbo.addUniform("view", 16);
  28049. };
  28050. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._updateMultiviewUbo = function (viewR, projectionR) {
  28051. if (viewR && projectionR) {
  28052. viewR.multiplyToRef(projectionR, this._transformMatrixR);
  28053. }
  28054. if (viewR && projectionR) {
  28055. viewR.multiplyToRef(projectionR, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  28056. _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
  28057. }
  28058. if (this._multiviewSceneUbo) {
  28059. this._multiviewSceneUbo.updateMatrix("viewProjection", this.getTransformMatrix());
  28060. this._multiviewSceneUbo.updateMatrix("viewProjectionR", this._transformMatrixR);
  28061. this._multiviewSceneUbo.updateMatrix("view", this._viewMatrix);
  28062. this._multiviewSceneUbo.update();
  28063. }
  28064. };
  28065. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._renderMultiviewToSingleView = function (camera) {
  28066. // Multiview is only able to be displayed directly for API's such as webXR
  28067. // This displays a multiview image by rendering to the multiview image and then
  28068. // copying the result into the sub cameras instead of rendering them and proceeding as normal from there
  28069. // Render to a multiview texture
  28070. 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));
  28071. if (!this._multiviewSceneUbo) {
  28072. this._createMultiviewUbo();
  28073. }
  28074. camera.outputRenderTarget = camera._multiviewTexture;
  28075. this._renderForCamera(camera);
  28076. camera.outputRenderTarget = null;
  28077. // Consume the multiview texture through a shader for each eye
  28078. for (var index = 0; index < camera._rigCameras.length; index++) {
  28079. var engine = this.getEngine();
  28080. this._activeCamera = camera._rigCameras[index];
  28081. engine.setViewport(this._activeCamera.viewport);
  28082. if (this.postProcessManager) {
  28083. this.postProcessManager._prepareFrame();
  28084. this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate);
  28085. }
  28086. }
  28087. };
  28088. /***/ }),
  28089. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  28090. /*!*****************************************************!*\
  28091. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  28092. \*****************************************************/
  28093. /*! exports provided: _OcclusionDataStorage */
  28094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28095. "use strict";
  28096. __webpack_require__.r(__webpack_exports__);
  28097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  28098. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  28099. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  28100. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  28101. /** @hidden */
  28102. var _OcclusionDataStorage = /** @class */ (function () {
  28103. function _OcclusionDataStorage() {
  28104. /** @hidden */
  28105. this.occlusionInternalRetryCounter = 0;
  28106. /** @hidden */
  28107. this.isOcclusionQueryInProgress = false;
  28108. /** @hidden */
  28109. this.isOccluded = false;
  28110. /** @hidden */
  28111. this.occlusionRetryCount = -1;
  28112. /** @hidden */
  28113. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  28114. /** @hidden */
  28115. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  28116. }
  28117. return _OcclusionDataStorage;
  28118. }());
  28119. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  28120. return this._gl.createQuery();
  28121. };
  28122. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  28123. this._gl.deleteQuery(query);
  28124. return this;
  28125. };
  28126. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  28127. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  28128. };
  28129. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  28130. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  28131. };
  28132. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  28133. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  28134. this._gl.beginQuery(glAlgorithm, query);
  28135. return this;
  28136. };
  28137. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  28138. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  28139. this._gl.endQuery(glAlgorithm);
  28140. return this;
  28141. };
  28142. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  28143. var timerQuery = this.getCaps().timerQuery;
  28144. if (timerQuery.createQueryEXT) {
  28145. return timerQuery.createQueryEXT();
  28146. }
  28147. return this.createQuery();
  28148. };
  28149. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  28150. var timerQuery = this.getCaps().timerQuery;
  28151. if (timerQuery.deleteQueryEXT) {
  28152. timerQuery.deleteQueryEXT(query);
  28153. return;
  28154. }
  28155. this.deleteQuery(query);
  28156. };
  28157. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  28158. var timerQuery = this.getCaps().timerQuery;
  28159. if (timerQuery.getQueryObjectEXT) {
  28160. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  28161. }
  28162. return this.getQueryResult(query);
  28163. };
  28164. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  28165. var timerQuery = this.getCaps().timerQuery;
  28166. if (timerQuery.getQueryObjectEXT) {
  28167. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  28168. }
  28169. return this.isQueryResultAvailable(query);
  28170. };
  28171. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  28172. var caps = this.getCaps();
  28173. var timerQuery = caps.timerQuery;
  28174. if (!timerQuery) {
  28175. return null;
  28176. }
  28177. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  28178. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  28179. if (caps.canUseTimestampForTimerQuery) {
  28180. token._startTimeQuery = this._createTimeQuery();
  28181. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  28182. }
  28183. else {
  28184. if (this._currentNonTimestampToken) {
  28185. return this._currentNonTimestampToken;
  28186. }
  28187. token._timeElapsedQuery = this._createTimeQuery();
  28188. if (timerQuery.beginQueryEXT) {
  28189. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  28190. }
  28191. else {
  28192. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  28193. }
  28194. this._currentNonTimestampToken = token;
  28195. }
  28196. return token;
  28197. };
  28198. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  28199. var caps = this.getCaps();
  28200. var timerQuery = caps.timerQuery;
  28201. if (!timerQuery || !token) {
  28202. return -1;
  28203. }
  28204. if (caps.canUseTimestampForTimerQuery) {
  28205. if (!token._startTimeQuery) {
  28206. return -1;
  28207. }
  28208. if (!token._endTimeQuery) {
  28209. token._endTimeQuery = this._createTimeQuery();
  28210. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  28211. }
  28212. }
  28213. else if (!token._timeElapsedQueryEnded) {
  28214. if (!token._timeElapsedQuery) {
  28215. return -1;
  28216. }
  28217. if (timerQuery.endQueryEXT) {
  28218. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  28219. }
  28220. else {
  28221. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  28222. }
  28223. token._timeElapsedQueryEnded = true;
  28224. }
  28225. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  28226. var available = false;
  28227. if (token._endTimeQuery) {
  28228. available = this._getTimeQueryAvailability(token._endTimeQuery);
  28229. }
  28230. else if (token._timeElapsedQuery) {
  28231. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  28232. }
  28233. if (available && !disjoint) {
  28234. var result = 0;
  28235. if (caps.canUseTimestampForTimerQuery) {
  28236. if (!token._startTimeQuery || !token._endTimeQuery) {
  28237. return -1;
  28238. }
  28239. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  28240. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  28241. result = timeEnd - timeStart;
  28242. this._deleteTimeQuery(token._startTimeQuery);
  28243. this._deleteTimeQuery(token._endTimeQuery);
  28244. token._startTimeQuery = null;
  28245. token._endTimeQuery = null;
  28246. }
  28247. else {
  28248. if (!token._timeElapsedQuery) {
  28249. return -1;
  28250. }
  28251. result = this._getTimeQueryResult(token._timeElapsedQuery);
  28252. this._deleteTimeQuery(token._timeElapsedQuery);
  28253. token._timeElapsedQuery = null;
  28254. token._timeElapsedQueryEnded = false;
  28255. this._currentNonTimestampToken = null;
  28256. }
  28257. return result;
  28258. }
  28259. return -1;
  28260. };
  28261. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  28262. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  28263. };
  28264. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  28265. get: function () {
  28266. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  28267. },
  28268. enumerable: false,
  28269. configurable: true
  28270. });
  28271. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  28272. get: function () {
  28273. if (!this.__occlusionDataStorage) {
  28274. this.__occlusionDataStorage = new _OcclusionDataStorage();
  28275. }
  28276. return this.__occlusionDataStorage;
  28277. },
  28278. enumerable: false,
  28279. configurable: true
  28280. });
  28281. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  28282. get: function () {
  28283. return this._occlusionDataStorage.isOccluded;
  28284. },
  28285. set: function (value) {
  28286. this._occlusionDataStorage.isOccluded = value;
  28287. },
  28288. enumerable: true,
  28289. configurable: true
  28290. });
  28291. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  28292. get: function () {
  28293. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  28294. },
  28295. set: function (value) {
  28296. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  28297. },
  28298. enumerable: true,
  28299. configurable: true
  28300. });
  28301. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  28302. get: function () {
  28303. return this._occlusionDataStorage.occlusionType;
  28304. },
  28305. set: function (value) {
  28306. this._occlusionDataStorage.occlusionType = value;
  28307. },
  28308. enumerable: true,
  28309. configurable: true
  28310. });
  28311. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  28312. get: function () {
  28313. return this._occlusionDataStorage.occlusionRetryCount;
  28314. },
  28315. set: function (value) {
  28316. this._occlusionDataStorage.occlusionRetryCount = value;
  28317. },
  28318. enumerable: true,
  28319. configurable: true
  28320. });
  28321. // We also need to update AbstractMesh as there is a portion of the code there
  28322. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  28323. var dataStorage = this._occlusionDataStorage;
  28324. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  28325. dataStorage.isOccluded = false;
  28326. return false;
  28327. }
  28328. var engine = this.getEngine();
  28329. if (engine.webGLVersion < 2) {
  28330. dataStorage.isOccluded = false;
  28331. return false;
  28332. }
  28333. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  28334. dataStorage.isOccluded = false;
  28335. return false;
  28336. }
  28337. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  28338. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  28339. if (isOcclusionQueryAvailable) {
  28340. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  28341. dataStorage.isOcclusionQueryInProgress = false;
  28342. dataStorage.occlusionInternalRetryCounter = 0;
  28343. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  28344. }
  28345. else {
  28346. dataStorage.occlusionInternalRetryCounter++;
  28347. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  28348. dataStorage.isOcclusionQueryInProgress = false;
  28349. dataStorage.occlusionInternalRetryCounter = 0;
  28350. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  28351. // if strict continue the last state of the object.
  28352. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  28353. }
  28354. else {
  28355. return false;
  28356. }
  28357. }
  28358. }
  28359. var scene = this.getScene();
  28360. if (scene.getBoundingBoxRenderer) {
  28361. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  28362. if (!this._occlusionQuery) {
  28363. this._occlusionQuery = engine.createQuery();
  28364. }
  28365. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  28366. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  28367. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  28368. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  28369. }
  28370. return dataStorage.isOccluded;
  28371. };
  28372. /***/ }),
  28373. /***/ "./Engines/Extensions/engine.rawTexture.ts":
  28374. /*!*************************************************!*\
  28375. !*** ./Engines/Extensions/engine.rawTexture.ts ***!
  28376. \*************************************************/
  28377. /*! no exports provided */
  28378. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28379. "use strict";
  28380. __webpack_require__.r(__webpack_exports__);
  28381. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  28382. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  28383. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  28384. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  28385. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  28386. if (compression === void 0) { compression = null; }
  28387. if (type === void 0) { type = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_UNSIGNED_INT; }
  28388. if (!texture) {
  28389. return;
  28390. }
  28391. // Babylon's internalSizedFomat but gl's texImage2D internalFormat
  28392. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  28393. // Babylon's internalFormat but gl's texImage2D format
  28394. var internalFormat = this._getInternalFormat(format);
  28395. var textureType = this._getWebGLTextureType(type);
  28396. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  28397. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  28398. if (!this._doNotHandleContextLost) {
  28399. texture._bufferView = data;
  28400. texture.format = format;
  28401. texture.type = type;
  28402. texture.invertY = invertY;
  28403. texture._compression = compression;
  28404. }
  28405. if (texture.width % 4 !== 0) {
  28406. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  28407. }
  28408. if (compression && data) {
  28409. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  28410. }
  28411. else {
  28412. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  28413. }
  28414. if (texture.generateMipMaps) {
  28415. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  28416. }
  28417. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  28418. // this.resetTextureCache();
  28419. texture.isReady = true;
  28420. };
  28421. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  28422. if (compression === void 0) { compression = null; }
  28423. if (type === void 0) { type = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_UNSIGNED_INT; }
  28424. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"].DATASOURCE_RAW);
  28425. texture.baseWidth = width;
  28426. texture.baseHeight = height;
  28427. texture.width = width;
  28428. texture.height = height;
  28429. texture.format = format;
  28430. texture.generateMipMaps = generateMipMaps;
  28431. texture.samplingMode = samplingMode;
  28432. texture.invertY = invertY;
  28433. texture._compression = compression;
  28434. texture.type = type;
  28435. if (!this._doNotHandleContextLost) {
  28436. texture._bufferView = data;
  28437. }
  28438. this.updateRawTexture(texture, data, format, invertY, compression, type);
  28439. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  28440. // Filters
  28441. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  28442. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  28443. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  28444. if (generateMipMaps) {
  28445. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  28446. }
  28447. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  28448. this._internalTexturesCache.push(texture);
  28449. return texture;
  28450. };
  28451. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  28452. if (compression === void 0) { compression = null; }
  28453. var gl = this._gl;
  28454. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"].DATASOURCE_CUBERAW);
  28455. texture.isCube = true;
  28456. texture.format = format;
  28457. texture.type = type;
  28458. if (!this._doNotHandleContextLost) {
  28459. texture._bufferViewArray = data;
  28460. }
  28461. var textureType = this._getWebGLTextureType(type);
  28462. var internalFormat = this._getInternalFormat(format);
  28463. if (internalFormat === gl.RGB) {
  28464. internalFormat = gl.RGBA;
  28465. }
  28466. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  28467. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  28468. generateMipMaps = false;
  28469. samplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURE_NEAREST_SAMPLINGMODE;
  28470. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  28471. }
  28472. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  28473. generateMipMaps = false;
  28474. samplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURE_NEAREST_SAMPLINGMODE;
  28475. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  28476. }
  28477. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  28478. generateMipMaps = false;
  28479. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  28480. }
  28481. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  28482. generateMipMaps = false;
  28483. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  28484. }
  28485. var width = size;
  28486. var height = width;
  28487. texture.width = width;
  28488. texture.height = height;
  28489. // Double check on POT to generate Mips.
  28490. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].IsExponentOfTwo(texture.height));
  28491. if (!isPot) {
  28492. generateMipMaps = false;
  28493. }
  28494. // Upload data if needed. The texture won't be ready until then.
  28495. if (data) {
  28496. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  28497. }
  28498. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  28499. // Filters
  28500. if (data && generateMipMaps) {
  28501. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  28502. }
  28503. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  28504. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  28505. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  28506. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  28507. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  28508. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  28509. texture.generateMipMaps = generateMipMaps;
  28510. return texture;
  28511. };
  28512. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  28513. if (compression === void 0) { compression = null; }
  28514. if (level === void 0) { level = 0; }
  28515. texture._bufferViewArray = data;
  28516. texture.format = format;
  28517. texture.type = type;
  28518. texture.invertY = invertY;
  28519. texture._compression = compression;
  28520. var gl = this._gl;
  28521. var textureType = this._getWebGLTextureType(type);
  28522. var internalFormat = this._getInternalFormat(format);
  28523. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  28524. var needConversion = false;
  28525. if (internalFormat === gl.RGB) {
  28526. internalFormat = gl.RGBA;
  28527. needConversion = true;
  28528. }
  28529. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  28530. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  28531. if (texture.width % 4 !== 0) {
  28532. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  28533. }
  28534. // Data are known to be in +X +Y +Z -X -Y -Z
  28535. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  28536. var faceData = data[faceIndex];
  28537. if (compression) {
  28538. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  28539. }
  28540. else {
  28541. if (needConversion) {
  28542. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  28543. }
  28544. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  28545. }
  28546. }
  28547. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].IsExponentOfTwo(texture.height));
  28548. if (isPot && texture.generateMipMaps && level === 0) {
  28549. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  28550. }
  28551. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  28552. // this.resetTextureCache();
  28553. texture.isReady = true;
  28554. };
  28555. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  28556. var _this = this;
  28557. if (onLoad === void 0) { onLoad = null; }
  28558. if (onError === void 0) { onError = null; }
  28559. if (samplingMode === void 0) { samplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  28560. if (invertY === void 0) { invertY = false; }
  28561. var gl = this._gl;
  28562. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  28563. scene._addPendingData(texture);
  28564. texture.url = url;
  28565. this._internalTexturesCache.push(texture);
  28566. var onerror = function (request, exception) {
  28567. scene._removePendingData(texture);
  28568. if (onError && request) {
  28569. onError(request.status + " " + request.statusText, exception);
  28570. }
  28571. };
  28572. var internalCallback = function (data) {
  28573. var width = texture.width;
  28574. var faceDataArrays = callback(data);
  28575. if (!faceDataArrays) {
  28576. return;
  28577. }
  28578. if (mipmapGenerator) {
  28579. var textureType = _this._getWebGLTextureType(type);
  28580. var internalFormat = _this._getInternalFormat(format);
  28581. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  28582. var needConversion = false;
  28583. if (internalFormat === gl.RGB) {
  28584. internalFormat = gl.RGBA;
  28585. needConversion = true;
  28586. }
  28587. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  28588. _this._unpackFlipY(false);
  28589. var mipData = mipmapGenerator(faceDataArrays);
  28590. for (var level = 0; level < mipData.length; level++) {
  28591. var mipSize = width >> level;
  28592. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  28593. var mipFaceData = mipData[level][faceIndex];
  28594. if (needConversion) {
  28595. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  28596. }
  28597. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  28598. }
  28599. }
  28600. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  28601. }
  28602. else {
  28603. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  28604. }
  28605. texture.isReady = true;
  28606. // this.resetTextureCache();
  28607. scene._removePendingData(texture);
  28608. if (onLoad) {
  28609. onLoad();
  28610. }
  28611. };
  28612. this._loadFile(url, function (data) {
  28613. internalCallback(data);
  28614. }, undefined, scene.offlineProvider, true, onerror);
  28615. return texture;
  28616. };
  28617. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  28618. if (compression === void 0) { compression = null; }
  28619. if (textureType === void 0) { textureType = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_UNSIGNED_INT; }
  28620. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_1__["InternalTexture"].DATASOURCE_RAW3D);
  28621. texture.baseWidth = width;
  28622. texture.baseHeight = height;
  28623. texture.baseDepth = depth;
  28624. texture.width = width;
  28625. texture.height = height;
  28626. texture.depth = depth;
  28627. texture.format = format;
  28628. texture.type = textureType;
  28629. texture.generateMipMaps = generateMipMaps;
  28630. texture.samplingMode = samplingMode;
  28631. texture.is3D = true;
  28632. if (!this._doNotHandleContextLost) {
  28633. texture._bufferView = data;
  28634. }
  28635. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  28636. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  28637. // Filters
  28638. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  28639. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  28640. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  28641. if (generateMipMaps) {
  28642. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  28643. }
  28644. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  28645. this._internalTexturesCache.push(texture);
  28646. return texture;
  28647. };
  28648. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  28649. if (compression === void 0) { compression = null; }
  28650. if (textureType === void 0) { textureType = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].TEXTURETYPE_UNSIGNED_INT; }
  28651. var internalType = this._getWebGLTextureType(textureType);
  28652. var internalFormat = this._getInternalFormat(format);
  28653. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  28654. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  28655. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  28656. if (!this._doNotHandleContextLost) {
  28657. texture._bufferView = data;
  28658. texture.format = format;
  28659. texture.invertY = invertY;
  28660. texture._compression = compression;
  28661. }
  28662. if (texture.width % 4 !== 0) {
  28663. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  28664. }
  28665. if (compression && data) {
  28666. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  28667. }
  28668. else {
  28669. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  28670. }
  28671. if (texture.generateMipMaps) {
  28672. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  28673. }
  28674. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  28675. // this.resetTextureCache();
  28676. texture.isReady = true;
  28677. };
  28678. /***/ }),
  28679. /***/ "./Engines/Extensions/engine.renderTarget.ts":
  28680. /*!***************************************************!*\
  28681. !*** ./Engines/Extensions/engine.renderTarget.ts ***!
  28682. \***************************************************/
  28683. /*! no exports provided */
  28684. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28685. "use strict";
  28686. __webpack_require__.r(__webpack_exports__);
  28687. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  28688. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  28689. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  28690. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  28691. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.createRenderTargetCubeTexture = function (size, options) {
  28692. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ generateMipMaps: true, generateDepthBuffer: true, generateStencilBuffer: false, type: _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURETYPE_UNSIGNED_INT, samplingMode: _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURE_TRILINEAR_SAMPLINGMODE, format: _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTUREFORMAT_RGBA }, options);
  28693. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  28694. if (fullOptions.type === _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  28695. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  28696. fullOptions.samplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURE_NEAREST_SAMPLINGMODE;
  28697. }
  28698. else if (fullOptions.type === _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  28699. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  28700. fullOptions.samplingMode = _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURE_NEAREST_SAMPLINGMODE;
  28701. }
  28702. var gl = this._gl;
  28703. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"].DATASOURCE_RENDERTARGET);
  28704. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  28705. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  28706. if (fullOptions.type === _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  28707. fullOptions.type = _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTURETYPE_UNSIGNED_INT;
  28708. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  28709. }
  28710. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  28711. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  28712. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  28713. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  28714. for (var face = 0; face < 6; face++) {
  28715. 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);
  28716. }
  28717. // Create the framebuffer
  28718. var framebuffer = gl.createFramebuffer();
  28719. this._bindUnboundFramebuffer(framebuffer);
  28720. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  28721. // MipMaps
  28722. if (fullOptions.generateMipMaps) {
  28723. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  28724. }
  28725. // Unbind
  28726. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  28727. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  28728. this._bindUnboundFramebuffer(null);
  28729. texture._framebuffer = framebuffer;
  28730. texture.width = size;
  28731. texture.height = size;
  28732. texture.isReady = true;
  28733. texture.isCube = true;
  28734. texture.samples = 1;
  28735. texture.generateMipMaps = fullOptions.generateMipMaps;
  28736. texture.samplingMode = fullOptions.samplingMode;
  28737. texture.type = fullOptions.type;
  28738. texture.format = fullOptions.format;
  28739. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  28740. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  28741. this._internalTexturesCache.push(texture);
  28742. return texture;
  28743. };
  28744. /***/ }),
  28745. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  28746. /*!********************************************************!*\
  28747. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  28748. \********************************************************/
  28749. /*! exports provided: _forceTransformFeedbackToBundle */
  28750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28751. "use strict";
  28752. __webpack_require__.r(__webpack_exports__);
  28753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  28754. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  28755. /** @hidden */
  28756. var _forceTransformFeedbackToBundle = true;
  28757. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  28758. return this._gl.createTransformFeedback();
  28759. };
  28760. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  28761. this._gl.deleteTransformFeedback(value);
  28762. };
  28763. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  28764. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  28765. };
  28766. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  28767. if (usePoints === void 0) { usePoints = true; }
  28768. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  28769. };
  28770. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  28771. this._gl.endTransformFeedback();
  28772. };
  28773. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  28774. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  28775. };
  28776. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  28777. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value ? value.underlyingResource : null);
  28778. };
  28779. /***/ }),
  28780. /***/ "./Engines/Extensions/engine.webVR.ts":
  28781. /*!********************************************!*\
  28782. !*** ./Engines/Extensions/engine.webVR.ts ***!
  28783. \********************************************/
  28784. /*! no exports provided */
  28785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28786. "use strict";
  28787. __webpack_require__.r(__webpack_exports__);
  28788. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  28789. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  28790. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  28791. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  28792. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/domManagement */ "./Misc/domManagement.ts");
  28793. Object.defineProperty(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype, "isInVRExclusivePointerMode", {
  28794. get: function () {
  28795. return this._vrExclusivePointerMode;
  28796. },
  28797. enumerable: true,
  28798. configurable: true
  28799. });
  28800. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._prepareVRComponent = function () {
  28801. this._vrSupported = false;
  28802. this._vrExclusivePointerMode = false;
  28803. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  28804. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  28805. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  28806. };
  28807. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isVRDevicePresent = function () {
  28808. return !!this._vrDisplay;
  28809. };
  28810. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getVRDevice = function () {
  28811. return this._vrDisplay;
  28812. };
  28813. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.initWebVR = function () {
  28814. this.initWebVRAsync();
  28815. return this.onVRDisplayChangedObservable;
  28816. };
  28817. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.initWebVRAsync = function () {
  28818. var _this = this;
  28819. var notifyObservers = function () {
  28820. var eventArgs = {
  28821. vrDisplay: _this._vrDisplay,
  28822. vrSupported: _this._vrSupported
  28823. };
  28824. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  28825. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  28826. };
  28827. if (!this._onVrDisplayConnect) {
  28828. this._onVrDisplayConnect = function (event) {
  28829. _this._vrDisplay = event.display;
  28830. notifyObservers();
  28831. };
  28832. this._onVrDisplayDisconnect = function () {
  28833. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  28834. _this._vrDisplay = undefined;
  28835. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  28836. notifyObservers();
  28837. };
  28838. this._onVrDisplayPresentChange = function () {
  28839. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  28840. };
  28841. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  28842. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  28843. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  28844. }
  28845. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  28846. this._webVRInitPromise.then(notifyObservers);
  28847. return this._webVRInitPromise;
  28848. };
  28849. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getVRDisplaysAsync = function () {
  28850. var _this = this;
  28851. return new Promise(function (res) {
  28852. if (navigator.getVRDisplays) {
  28853. navigator.getVRDisplays().then(function (devices) {
  28854. _this._vrSupported = true;
  28855. // note that devices may actually be an empty array. This is fine;
  28856. // we expect this._vrDisplay to be undefined in this case.
  28857. _this._vrDisplay = devices[0];
  28858. res({
  28859. vrDisplay: _this._vrDisplay,
  28860. vrSupported: _this._vrSupported
  28861. });
  28862. });
  28863. }
  28864. else {
  28865. _this._vrDisplay = undefined;
  28866. _this._vrSupported = false;
  28867. res({
  28868. vrDisplay: _this._vrDisplay,
  28869. vrSupported: _this._vrSupported
  28870. });
  28871. }
  28872. });
  28873. };
  28874. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.enableVR = function () {
  28875. var _this = this;
  28876. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  28877. var onResolved = function () {
  28878. _this.onVRRequestPresentComplete.notifyObservers(true);
  28879. _this._onVRFullScreenTriggered();
  28880. };
  28881. var onRejected = function () {
  28882. _this.onVRRequestPresentComplete.notifyObservers(false);
  28883. };
  28884. this.onVRRequestPresentStart.notifyObservers(this);
  28885. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  28886. }
  28887. };
  28888. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._onVRFullScreenTriggered = function () {
  28889. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28890. //get the old size before we change
  28891. this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Size"](this.getRenderWidth(), this.getRenderHeight());
  28892. this._oldHardwareScaleFactor = this.getHardwareScalingLevel();
  28893. //get the width and height, change the render size
  28894. var leftEye = this._vrDisplay.getEyeParameters('left');
  28895. this.setHardwareScalingLevel(1);
  28896. this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  28897. }
  28898. else {
  28899. this.setHardwareScalingLevel(this._oldHardwareScaleFactor);
  28900. this.setSize(this._oldSize.width, this._oldSize.height);
  28901. }
  28902. };
  28903. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.disableVR = function () {
  28904. var _this = this;
  28905. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28906. this._vrDisplay.exitPresent()
  28907. .then(function () { return _this._onVRFullScreenTriggered(); })
  28908. .catch(function () { return _this._onVRFullScreenTriggered(); });
  28909. }
  28910. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_4__["DomManagement"].IsWindowObjectExist()) {
  28911. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  28912. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  28913. if (this._onVrDisplayConnect) {
  28914. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  28915. if (this._onVrDisplayDisconnect) {
  28916. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  28917. }
  28918. if (this._onVrDisplayPresentChange) {
  28919. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  28920. }
  28921. this._onVrDisplayConnect = null;
  28922. this._onVrDisplayDisconnect = null;
  28923. }
  28924. }
  28925. };
  28926. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._connectVREvents = function (canvas, document) {
  28927. this._onVRDisplayPointerRestricted = function () {
  28928. if (canvas) {
  28929. canvas.requestPointerLock();
  28930. }
  28931. };
  28932. this._onVRDisplayPointerUnrestricted = function () {
  28933. if (!document.exitPointerLock) {
  28934. return;
  28935. }
  28936. document.exitPointerLock();
  28937. };
  28938. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_4__["DomManagement"].IsWindowObjectExist()) {
  28939. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  28940. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  28941. }
  28942. };
  28943. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._submitVRFrame = function () {
  28944. // Submit frame to the vr device, if enabled
  28945. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28946. // TODO: We should only submit the frame if we read frameData successfully.
  28947. try {
  28948. this._vrDisplay.submitFrame();
  28949. }
  28950. catch (e) {
  28951. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Warn("webVR submitFrame has had an unexpected failure: " + e);
  28952. }
  28953. }
  28954. };
  28955. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isVRPresenting = function () {
  28956. return this._vrDisplay && this._vrDisplay.isPresenting;
  28957. };
  28958. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._requestVRFrame = function () {
  28959. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  28960. };
  28961. /***/ }),
  28962. /***/ "./Engines/Extensions/index.ts":
  28963. /*!*************************************!*\
  28964. !*** ./Engines/Extensions/index.ts ***!
  28965. \*************************************/
  28966. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  28967. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28968. "use strict";
  28969. __webpack_require__.r(__webpack_exports__);
  28970. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  28971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  28972. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  28973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  28974. /***/ }),
  28975. /***/ "./Engines/WebGL/webGLPipelineContext.ts":
  28976. /*!***********************************************!*\
  28977. !*** ./Engines/WebGL/webGLPipelineContext.ts ***!
  28978. \***********************************************/
  28979. /*! exports provided: WebGLPipelineContext */
  28980. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28981. "use strict";
  28982. __webpack_require__.r(__webpack_exports__);
  28983. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebGLPipelineContext", function() { return WebGLPipelineContext; });
  28984. /** @hidden */
  28985. var WebGLPipelineContext = /** @class */ (function () {
  28986. function WebGLPipelineContext() {
  28987. }
  28988. Object.defineProperty(WebGLPipelineContext.prototype, "isAsync", {
  28989. get: function () {
  28990. return this.isParallelCompiled;
  28991. },
  28992. enumerable: true,
  28993. configurable: true
  28994. });
  28995. Object.defineProperty(WebGLPipelineContext.prototype, "isReady", {
  28996. get: function () {
  28997. if (this.program) {
  28998. if (this.isParallelCompiled) {
  28999. return this.engine._isRenderingStateCompiled(this);
  29000. }
  29001. return true;
  29002. }
  29003. return false;
  29004. },
  29005. enumerable: true,
  29006. configurable: true
  29007. });
  29008. WebGLPipelineContext.prototype._handlesSpectorRebuildCallback = function (onCompiled) {
  29009. if (onCompiled && this.program) {
  29010. onCompiled(this.program);
  29011. }
  29012. };
  29013. return WebGLPipelineContext;
  29014. }());
  29015. /***/ }),
  29016. /***/ "./Engines/constants.ts":
  29017. /*!******************************!*\
  29018. !*** ./Engines/constants.ts ***!
  29019. \******************************/
  29020. /*! exports provided: Constants */
  29021. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29022. "use strict";
  29023. __webpack_require__.r(__webpack_exports__);
  29024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  29025. /** Defines the cross module used constants to avoid circular dependncies */
  29026. var Constants = /** @class */ (function () {
  29027. function Constants() {
  29028. }
  29029. /** Defines that alpha blending is disabled */
  29030. Constants.ALPHA_DISABLE = 0;
  29031. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29032. Constants.ALPHA_ADD = 1;
  29033. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29034. Constants.ALPHA_COMBINE = 2;
  29035. /** Defines that alpha blending to DEST - SRC * DEST */
  29036. Constants.ALPHA_SUBTRACT = 3;
  29037. /** Defines that alpha blending to SRC * DEST */
  29038. Constants.ALPHA_MULTIPLY = 4;
  29039. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29040. Constants.ALPHA_MAXIMIZED = 5;
  29041. /** Defines that alpha blending to SRC + DEST */
  29042. Constants.ALPHA_ONEONE = 6;
  29043. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29044. Constants.ALPHA_PREMULTIPLIED = 7;
  29045. /**
  29046. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29047. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29048. */
  29049. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  29050. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29051. Constants.ALPHA_INTERPOLATE = 9;
  29052. /**
  29053. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29054. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29055. */
  29056. Constants.ALPHA_SCREENMODE = 10;
  29057. /** Defines that the ressource is not delayed*/
  29058. Constants.DELAYLOADSTATE_NONE = 0;
  29059. /** Defines that the ressource was successfully delay loaded */
  29060. Constants.DELAYLOADSTATE_LOADED = 1;
  29061. /** Defines that the ressource is currently delay loading */
  29062. Constants.DELAYLOADSTATE_LOADING = 2;
  29063. /** Defines that the ressource is delayed and has not started loading */
  29064. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  29065. // Depht or Stencil test Constants.
  29066. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29067. Constants.NEVER = 0x0200;
  29068. /** 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 */
  29069. Constants.ALWAYS = 0x0207;
  29070. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29071. Constants.LESS = 0x0201;
  29072. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29073. Constants.EQUAL = 0x0202;
  29074. /** 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 */
  29075. Constants.LEQUAL = 0x0203;
  29076. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29077. Constants.GREATER = 0x0204;
  29078. /** 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 */
  29079. Constants.GEQUAL = 0x0206;
  29080. /** 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 */
  29081. Constants.NOTEQUAL = 0x0205;
  29082. // Stencil Actions Constants.
  29083. /** Passed to stencilOperation to specify that stencil value must be kept */
  29084. Constants.KEEP = 0x1E00;
  29085. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29086. Constants.REPLACE = 0x1E01;
  29087. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29088. Constants.INCR = 0x1E02;
  29089. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29090. Constants.DECR = 0x1E03;
  29091. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29092. Constants.INVERT = 0x150A;
  29093. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29094. Constants.INCR_WRAP = 0x8507;
  29095. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29096. Constants.DECR_WRAP = 0x8508;
  29097. /** Texture is not repeating outside of 0..1 UVs */
  29098. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  29099. /** Texture is repeating outside of 0..1 UVs */
  29100. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  29101. /** Texture is repeating and mirrored */
  29102. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  29103. /** ALPHA */
  29104. Constants.TEXTUREFORMAT_ALPHA = 0;
  29105. /** LUMINANCE */
  29106. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  29107. /** LUMINANCE_ALPHA */
  29108. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  29109. /** RGB */
  29110. Constants.TEXTUREFORMAT_RGB = 4;
  29111. /** RGBA */
  29112. Constants.TEXTUREFORMAT_RGBA = 5;
  29113. /** RED */
  29114. Constants.TEXTUREFORMAT_RED = 6;
  29115. /** RED (2nd reference) */
  29116. Constants.TEXTUREFORMAT_R = 6;
  29117. /** RG */
  29118. Constants.TEXTUREFORMAT_RG = 7;
  29119. /** RED_INTEGER */
  29120. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  29121. /** RED_INTEGER (2nd reference) */
  29122. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  29123. /** RG_INTEGER */
  29124. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  29125. /** RGB_INTEGER */
  29126. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  29127. /** RGBA_INTEGER */
  29128. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  29129. /** UNSIGNED_BYTE */
  29130. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  29131. /** UNSIGNED_BYTE (2nd reference) */
  29132. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  29133. /** FLOAT */
  29134. Constants.TEXTURETYPE_FLOAT = 1;
  29135. /** HALF_FLOAT */
  29136. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  29137. /** BYTE */
  29138. Constants.TEXTURETYPE_BYTE = 3;
  29139. /** SHORT */
  29140. Constants.TEXTURETYPE_SHORT = 4;
  29141. /** UNSIGNED_SHORT */
  29142. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  29143. /** INT */
  29144. Constants.TEXTURETYPE_INT = 6;
  29145. /** UNSIGNED_INT */
  29146. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  29147. /** UNSIGNED_SHORT_4_4_4_4 */
  29148. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  29149. /** UNSIGNED_SHORT_5_5_5_1 */
  29150. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  29151. /** UNSIGNED_SHORT_5_6_5 */
  29152. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  29153. /** UNSIGNED_INT_2_10_10_10_REV */
  29154. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  29155. /** UNSIGNED_INT_24_8 */
  29156. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  29157. /** UNSIGNED_INT_10F_11F_11F_REV */
  29158. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  29159. /** UNSIGNED_INT_5_9_9_9_REV */
  29160. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  29161. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29162. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  29163. /** nearest is mag = nearest and min = nearest and mip = linear */
  29164. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  29165. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29166. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  29167. /** Trilinear is mag = linear and min = linear and mip = linear */
  29168. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  29169. /** nearest is mag = nearest and min = nearest and mip = linear */
  29170. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  29171. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29172. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  29173. /** Trilinear is mag = linear and min = linear and mip = linear */
  29174. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  29175. /** mag = nearest and min = nearest and mip = nearest */
  29176. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  29177. /** mag = nearest and min = linear and mip = nearest */
  29178. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  29179. /** mag = nearest and min = linear and mip = linear */
  29180. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  29181. /** mag = nearest and min = linear and mip = none */
  29182. Constants.TEXTURE_NEAREST_LINEAR = 7;
  29183. /** mag = nearest and min = nearest and mip = none */
  29184. Constants.TEXTURE_NEAREST_NEAREST = 8;
  29185. /** mag = linear and min = nearest and mip = nearest */
  29186. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  29187. /** mag = linear and min = nearest and mip = linear */
  29188. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  29189. /** mag = linear and min = linear and mip = none */
  29190. Constants.TEXTURE_LINEAR_LINEAR = 11;
  29191. /** mag = linear and min = nearest and mip = none */
  29192. Constants.TEXTURE_LINEAR_NEAREST = 12;
  29193. /** Explicit coordinates mode */
  29194. Constants.TEXTURE_EXPLICIT_MODE = 0;
  29195. /** Spherical coordinates mode */
  29196. Constants.TEXTURE_SPHERICAL_MODE = 1;
  29197. /** Planar coordinates mode */
  29198. Constants.TEXTURE_PLANAR_MODE = 2;
  29199. /** Cubic coordinates mode */
  29200. Constants.TEXTURE_CUBIC_MODE = 3;
  29201. /** Projection coordinates mode */
  29202. Constants.TEXTURE_PROJECTION_MODE = 4;
  29203. /** Skybox coordinates mode */
  29204. Constants.TEXTURE_SKYBOX_MODE = 5;
  29205. /** Inverse Cubic coordinates mode */
  29206. Constants.TEXTURE_INVCUBIC_MODE = 6;
  29207. /** Equirectangular coordinates mode */
  29208. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  29209. /** Equirectangular Fixed coordinates mode */
  29210. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  29211. /** Equirectangular Fixed Mirrored coordinates mode */
  29212. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  29213. // Texture rescaling mode
  29214. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29215. Constants.SCALEMODE_FLOOR = 1;
  29216. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29217. Constants.SCALEMODE_NEAREST = 2;
  29218. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29219. Constants.SCALEMODE_CEILING = 3;
  29220. /**
  29221. * The dirty texture flag value
  29222. */
  29223. Constants.MATERIAL_TextureDirtyFlag = 1;
  29224. /**
  29225. * The dirty light flag value
  29226. */
  29227. Constants.MATERIAL_LightDirtyFlag = 2;
  29228. /**
  29229. * The dirty fresnel flag value
  29230. */
  29231. Constants.MATERIAL_FresnelDirtyFlag = 4;
  29232. /**
  29233. * The dirty attribute flag value
  29234. */
  29235. Constants.MATERIAL_AttributesDirtyFlag = 8;
  29236. /**
  29237. * The dirty misc flag value
  29238. */
  29239. Constants.MATERIAL_MiscDirtyFlag = 16;
  29240. /**
  29241. * The all dirty flag value
  29242. */
  29243. Constants.MATERIAL_AllDirtyFlag = 31;
  29244. /**
  29245. * Returns the triangle fill mode
  29246. */
  29247. Constants.MATERIAL_TriangleFillMode = 0;
  29248. /**
  29249. * Returns the wireframe mode
  29250. */
  29251. Constants.MATERIAL_WireFrameFillMode = 1;
  29252. /**
  29253. * Returns the point fill mode
  29254. */
  29255. Constants.MATERIAL_PointFillMode = 2;
  29256. /**
  29257. * Returns the point list draw mode
  29258. */
  29259. Constants.MATERIAL_PointListDrawMode = 3;
  29260. /**
  29261. * Returns the line list draw mode
  29262. */
  29263. Constants.MATERIAL_LineListDrawMode = 4;
  29264. /**
  29265. * Returns the line loop draw mode
  29266. */
  29267. Constants.MATERIAL_LineLoopDrawMode = 5;
  29268. /**
  29269. * Returns the line strip draw mode
  29270. */
  29271. Constants.MATERIAL_LineStripDrawMode = 6;
  29272. /**
  29273. * Returns the triangle strip draw mode
  29274. */
  29275. Constants.MATERIAL_TriangleStripDrawMode = 7;
  29276. /**
  29277. * Returns the triangle fan draw mode
  29278. */
  29279. Constants.MATERIAL_TriangleFanDrawMode = 8;
  29280. /**
  29281. * Stores the clock-wise side orientation
  29282. */
  29283. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  29284. /**
  29285. * Stores the counter clock-wise side orientation
  29286. */
  29287. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  29288. /**
  29289. * Nothing
  29290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29291. */
  29292. Constants.ACTION_NothingTrigger = 0;
  29293. /**
  29294. * On pick
  29295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29296. */
  29297. Constants.ACTION_OnPickTrigger = 1;
  29298. /**
  29299. * On left pick
  29300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29301. */
  29302. Constants.ACTION_OnLeftPickTrigger = 2;
  29303. /**
  29304. * On right pick
  29305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29306. */
  29307. Constants.ACTION_OnRightPickTrigger = 3;
  29308. /**
  29309. * On center pick
  29310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29311. */
  29312. Constants.ACTION_OnCenterPickTrigger = 4;
  29313. /**
  29314. * On pick down
  29315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29316. */
  29317. Constants.ACTION_OnPickDownTrigger = 5;
  29318. /**
  29319. * On double pick
  29320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29321. */
  29322. Constants.ACTION_OnDoublePickTrigger = 6;
  29323. /**
  29324. * On pick up
  29325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29326. */
  29327. Constants.ACTION_OnPickUpTrigger = 7;
  29328. /**
  29329. * On pick out.
  29330. * This trigger will only be raised if you also declared a OnPickDown
  29331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29332. */
  29333. Constants.ACTION_OnPickOutTrigger = 16;
  29334. /**
  29335. * On long press
  29336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29337. */
  29338. Constants.ACTION_OnLongPressTrigger = 8;
  29339. /**
  29340. * On pointer over
  29341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29342. */
  29343. Constants.ACTION_OnPointerOverTrigger = 9;
  29344. /**
  29345. * On pointer out
  29346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29347. */
  29348. Constants.ACTION_OnPointerOutTrigger = 10;
  29349. /**
  29350. * On every frame
  29351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29352. */
  29353. Constants.ACTION_OnEveryFrameTrigger = 11;
  29354. /**
  29355. * On intersection enter
  29356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29357. */
  29358. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  29359. /**
  29360. * On intersection exit
  29361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29362. */
  29363. Constants.ACTION_OnIntersectionExitTrigger = 13;
  29364. /**
  29365. * On key down
  29366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29367. */
  29368. Constants.ACTION_OnKeyDownTrigger = 14;
  29369. /**
  29370. * On key up
  29371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  29372. */
  29373. Constants.ACTION_OnKeyUpTrigger = 15;
  29374. /**
  29375. * Billboard mode will only apply to Y axis
  29376. */
  29377. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  29378. /**
  29379. * Billboard mode will apply to all axes
  29380. */
  29381. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  29382. /**
  29383. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  29384. */
  29385. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  29386. /**
  29387. * Gets or sets base Assets URL
  29388. */
  29389. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  29390. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  29391. * Test order :
  29392. * Is the bounding sphere outside the frustum ?
  29393. * If not, are the bounding box vertices outside the frustum ?
  29394. * It not, then the cullable object is in the frustum.
  29395. */
  29396. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  29397. /** Culling strategy : Bounding Sphere Only.
  29398. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  29399. * It's also less accurate than the standard because some not visible objects can still be selected.
  29400. * Test : is the bounding sphere outside the frustum ?
  29401. * If not, then the cullable object is in the frustum.
  29402. */
  29403. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  29404. /** Culling strategy : Optimistic Inclusion.
  29405. * This in an inclusion test first, then the standard exclusion test.
  29406. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  29407. * 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.
  29408. * Anyway, it's as accurate as the standard strategy.
  29409. * Test :
  29410. * Is the cullable object bounding sphere center in the frustum ?
  29411. * If not, apply the default culling strategy.
  29412. */
  29413. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  29414. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29415. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29416. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29417. * 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.
  29418. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29419. * Test :
  29420. * Is the cullable object bounding sphere center in the frustum ?
  29421. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29422. */
  29423. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  29424. /**
  29425. * No logging while loading
  29426. */
  29427. Constants.SCENELOADER_NO_LOGGING = 0;
  29428. /**
  29429. * Minimal logging while loading
  29430. */
  29431. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  29432. /**
  29433. * Summary logging while loading
  29434. */
  29435. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  29436. /**
  29437. * Detailled logging while loading
  29438. */
  29439. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  29440. return Constants;
  29441. }());
  29442. /***/ }),
  29443. /***/ "./Engines/engine.ts":
  29444. /*!***************************!*\
  29445. !*** ./Engines/engine.ts ***!
  29446. \***************************/
  29447. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  29448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29449. "use strict";
  29450. __webpack_require__.r(__webpack_exports__);
  29451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  29452. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  29453. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  29454. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  29455. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  29456. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  29457. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  29458. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  29459. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  29460. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  29461. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  29462. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  29463. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  29464. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  29465. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  29466. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  29467. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  29468. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  29469. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  29470. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  29471. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  29472. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  29473. /* harmony import */ var _WebGL_webGLPipelineContext__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./WebGL/webGLPipelineContext */ "./Engines/WebGL/webGLPipelineContext.ts");
  29474. /* harmony import */ var _Meshes_WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Meshes/WebGL/webGLDataBuffer */ "./Meshes/WebGL/webGLDataBuffer.ts");
  29475. /**
  29476. * Keeps track of all the buffer info used in engine.
  29477. */
  29478. var BufferPointer = /** @class */ (function () {
  29479. function BufferPointer() {
  29480. }
  29481. return BufferPointer;
  29482. }());
  29483. /**
  29484. * Interface for attribute information associated with buffer instanciation
  29485. */
  29486. var InstancingAttributeInfo = /** @class */ (function () {
  29487. function InstancingAttributeInfo() {
  29488. }
  29489. return InstancingAttributeInfo;
  29490. }());
  29491. /**
  29492. * Define options used to create a depth texture
  29493. */
  29494. var DepthTextureCreationOptions = /** @class */ (function () {
  29495. function DepthTextureCreationOptions() {
  29496. }
  29497. return DepthTextureCreationOptions;
  29498. }());
  29499. /**
  29500. * Class used to describe the capabilities of the engine relatively to the current browser
  29501. */
  29502. var EngineCapabilities = /** @class */ (function () {
  29503. function EngineCapabilities() {
  29504. }
  29505. return EngineCapabilities;
  29506. }());
  29507. /**
  29508. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29509. */
  29510. var Engine = /** @class */ (function () {
  29511. /**
  29512. * Creates a new engine
  29513. * @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
  29514. * @param antialias defines enable antialiasing (default: false)
  29515. * @param options defines further options to be sent to the getContext() function
  29516. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29517. */
  29518. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  29519. var _this = this;
  29520. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  29521. // Public members
  29522. /**
  29523. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29524. */
  29525. this.forcePOTTextures = false;
  29526. /**
  29527. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29528. */
  29529. this.isFullscreen = false;
  29530. /**
  29531. * Gets a boolean indicating if the pointer is currently locked
  29532. */
  29533. this.isPointerLock = false;
  29534. /**
  29535. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29536. */
  29537. this.cullBackFaces = true;
  29538. /**
  29539. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29540. */
  29541. this.renderEvenInBackground = true;
  29542. /**
  29543. * Gets or sets a boolean indicating that cache can be kept between frames
  29544. */
  29545. this.preventCacheWipeBetweenFrames = false;
  29546. /**
  29547. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29548. **/
  29549. this.enableOfflineSupport = false;
  29550. /**
  29551. * 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)
  29552. **/
  29553. this.disableManifestCheck = false;
  29554. /**
  29555. * Gets the list of created scenes
  29556. */
  29557. this.scenes = new Array();
  29558. /**
  29559. * Event raised when a new scene is created
  29560. */
  29561. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  29562. /**
  29563. * Gets the list of created postprocesses
  29564. */
  29565. this.postProcesses = new Array();
  29566. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29567. this.validateShaderPrograms = false;
  29568. // Observables
  29569. /**
  29570. * Observable event triggered each time the rendering canvas is resized
  29571. */
  29572. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  29573. /**
  29574. * Observable event triggered each time the canvas loses focus
  29575. */
  29576. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  29577. /**
  29578. * Observable event triggered each time the canvas gains focus
  29579. */
  29580. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  29581. /**
  29582. * Observable event triggered each time the canvas receives pointerout event
  29583. */
  29584. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  29585. /**
  29586. * Observable event triggered before each texture is initialized
  29587. */
  29588. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  29589. // Uniform buffers list
  29590. /**
  29591. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29592. */
  29593. this.disableUniformBuffers = false;
  29594. /** @hidden */
  29595. this._uniformBuffers = new Array();
  29596. // Observables
  29597. /**
  29598. * Observable raised when the engine begins a new frame
  29599. */
  29600. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  29601. /**
  29602. * If set, will be used to request the next animation frame for the render loop
  29603. */
  29604. this.customAnimationFrameRequester = null;
  29605. /**
  29606. * Observable raised when the engine ends the current frame
  29607. */
  29608. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  29609. /**
  29610. * Observable raised when the engine is about to compile a shader
  29611. */
  29612. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  29613. /**
  29614. * Observable raised when the engine has jsut compiled a shader
  29615. */
  29616. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  29617. this._windowIsBackground = false;
  29618. this._webGLVersion = 1.0;
  29619. this._highPrecisionShadersAllowed = true;
  29620. /** @hidden */
  29621. this._badOS = false;
  29622. /** @hidden */
  29623. this._badDesktopOS = false;
  29624. this._colorWrite = true;
  29625. /** @hidden */
  29626. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  29627. this._renderingQueueLaunched = false;
  29628. this._activeRenderLoops = new Array();
  29629. // Deterministic lockstepMaxSteps
  29630. this._deterministicLockstep = false;
  29631. this._lockstepMaxSteps = 4;
  29632. // Lost context
  29633. /**
  29634. * Observable signaled when a context lost event is raised
  29635. */
  29636. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  29637. /**
  29638. * Observable signaled when a context restored event is raised
  29639. */
  29640. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  29641. this._contextWasLost = false;
  29642. /** @hidden */
  29643. this._doNotHandleContextLost = false;
  29644. // FPS
  29645. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  29646. this._fps = 60;
  29647. this._deltaTime = 0;
  29648. /**
  29649. * Turn this value on if you want to pause FPS computation when in background
  29650. */
  29651. this.disablePerformanceMonitorInBackground = false;
  29652. /**
  29653. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29654. */
  29655. this.disableVertexArrayObjects = false;
  29656. // States
  29657. /** @hidden */
  29658. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_11__["_DepthCullingState"]();
  29659. /** @hidden */
  29660. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_11__["_StencilState"]();
  29661. /** @hidden */
  29662. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_11__["_AlphaState"]();
  29663. /** @hidden */
  29664. this._alphaMode = Engine.ALPHA_DISABLE;
  29665. // Cache
  29666. /** @hidden */
  29667. this._internalTexturesCache = new Array();
  29668. /** @hidden */
  29669. this._activeChannel = 0;
  29670. this._currentTextureChannel = -1;
  29671. /** @hidden */
  29672. this._boundTexturesCache = {};
  29673. this._compiledEffects = {};
  29674. this._vertexAttribArraysEnabled = [];
  29675. this._uintIndicesCurrentlySet = false;
  29676. this._currentBoundBuffer = new Array();
  29677. /** @hidden */
  29678. this._currentFramebuffer = null;
  29679. this._currentBufferPointers = new Array();
  29680. this._currentInstanceLocations = new Array();
  29681. this._currentInstanceBuffers = new Array();
  29682. this._vaoRecordInProgress = false;
  29683. this._mustWipeVertexAttributes = false;
  29684. this._nextFreeTextureSlots = new Array();
  29685. this._maxSimultaneousTextures = 0;
  29686. this._activeRequests = new Array();
  29687. // Hardware supported Compressed Textures
  29688. this._texturesSupported = new Array();
  29689. /**
  29690. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29691. */
  29692. this.premultipliedAlpha = true;
  29693. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  29694. this._unpackFlipYCached = null;
  29695. /**
  29696. * In case you are sharing the context with other applications, it might
  29697. * be interested to not cache the unpack flip y state to ensure a consistent
  29698. * value would be set.
  29699. */
  29700. this.enableUnpackFlipYCached = true;
  29701. this._boundUniforms = {};
  29702. // Register promises
  29703. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  29704. var canvas = null;
  29705. Engine.Instances.push(this);
  29706. if (!canvasOrContext) {
  29707. return;
  29708. }
  29709. options = options || {};
  29710. if (canvasOrContext.getContext) {
  29711. canvas = canvasOrContext;
  29712. this._renderingCanvas = canvas;
  29713. if (antialias != null) {
  29714. options.antialias = antialias;
  29715. }
  29716. if (options.deterministicLockstep === undefined) {
  29717. options.deterministicLockstep = false;
  29718. }
  29719. if (options.lockstepMaxSteps === undefined) {
  29720. options.lockstepMaxSteps = 4;
  29721. }
  29722. if (options.preserveDrawingBuffer === undefined) {
  29723. options.preserveDrawingBuffer = false;
  29724. }
  29725. if (options.audioEngine === undefined) {
  29726. options.audioEngine = true;
  29727. }
  29728. if (options.stencil === undefined) {
  29729. options.stencil = true;
  29730. }
  29731. if (options.premultipliedAlpha === false) {
  29732. this.premultipliedAlpha = false;
  29733. }
  29734. this._deterministicLockstep = options.deterministicLockstep;
  29735. this._lockstepMaxSteps = options.lockstepMaxSteps;
  29736. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  29737. // Exceptions
  29738. if (navigator && navigator.userAgent) {
  29739. var ua = navigator.userAgent;
  29740. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  29741. var exception = _a[_i];
  29742. var key = exception.key;
  29743. var targets = exception.targets;
  29744. var check = new RegExp(key);
  29745. if (check.test(ua)) {
  29746. if (exception.capture && exception.captureConstraint) {
  29747. var capture = exception.capture;
  29748. var constraint = exception.captureConstraint;
  29749. var regex = new RegExp(capture);
  29750. var matches = regex.exec(ua);
  29751. if (matches && matches.length > 0) {
  29752. var capturedValue = parseInt(matches[matches.length - 1]);
  29753. if (capturedValue >= constraint) {
  29754. continue;
  29755. }
  29756. }
  29757. }
  29758. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  29759. var target = targets_1[_b];
  29760. switch (target) {
  29761. case "uniformBuffer":
  29762. this.disableUniformBuffers = true;
  29763. break;
  29764. case "vao":
  29765. this.disableVertexArrayObjects = true;
  29766. break;
  29767. }
  29768. }
  29769. }
  29770. }
  29771. }
  29772. // GL
  29773. if (!options.disableWebGL2Support) {
  29774. try {
  29775. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  29776. if (this._gl) {
  29777. this._webGLVersion = 2.0;
  29778. // Prevent weird browsers to lie :-)
  29779. if (!this._gl.deleteQuery) {
  29780. this._webGLVersion = 1.0;
  29781. }
  29782. }
  29783. }
  29784. catch (e) {
  29785. // Do nothing
  29786. }
  29787. }
  29788. if (!this._gl) {
  29789. if (!canvas) {
  29790. throw new Error("The provided canvas is null or undefined.");
  29791. }
  29792. try {
  29793. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  29794. }
  29795. catch (e) {
  29796. throw new Error("WebGL not supported");
  29797. }
  29798. }
  29799. if (!this._gl) {
  29800. throw new Error("WebGL not supported");
  29801. }
  29802. // Ensures a consistent color space unpacking of textures cross browser.
  29803. this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);
  29804. this._onCanvasFocus = function () {
  29805. _this.onCanvasFocusObservable.notifyObservers(_this);
  29806. };
  29807. this._onCanvasBlur = function () {
  29808. _this.onCanvasBlurObservable.notifyObservers(_this);
  29809. };
  29810. canvas.addEventListener("focus", this._onCanvasFocus);
  29811. canvas.addEventListener("blur", this._onCanvasBlur);
  29812. this._onBlur = function () {
  29813. if (_this.disablePerformanceMonitorInBackground) {
  29814. _this._performanceMonitor.disable();
  29815. }
  29816. _this._windowIsBackground = true;
  29817. };
  29818. this._onFocus = function () {
  29819. if (_this.disablePerformanceMonitorInBackground) {
  29820. _this._performanceMonitor.enable();
  29821. }
  29822. _this._windowIsBackground = false;
  29823. };
  29824. this._onCanvasPointerOut = function (ev) {
  29825. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  29826. };
  29827. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  29828. window.addEventListener("blur", this._onBlur);
  29829. window.addEventListener("focus", this._onFocus);
  29830. }
  29831. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  29832. // Context lost
  29833. if (!this._doNotHandleContextLost) {
  29834. this._onContextLost = function (evt) {
  29835. evt.preventDefault();
  29836. _this._contextWasLost = true;
  29837. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("WebGL context lost.");
  29838. _this.onContextLostObservable.notifyObservers(_this);
  29839. };
  29840. this._onContextRestored = function () {
  29841. // Adding a timeout to avoid race condition at browser level
  29842. setTimeout(function () {
  29843. // Rebuild gl context
  29844. _this._initGLContext();
  29845. // Rebuild effects
  29846. _this._rebuildEffects();
  29847. // Rebuild textures
  29848. _this._rebuildInternalTextures();
  29849. // Rebuild buffers
  29850. _this._rebuildBuffers();
  29851. // Cache
  29852. _this.wipeCaches(true);
  29853. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("WebGL context successfully restored.");
  29854. _this.onContextRestoredObservable.notifyObservers(_this);
  29855. _this._contextWasLost = false;
  29856. }, 0);
  29857. };
  29858. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  29859. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  29860. }
  29861. if (!options.doNotHandleTouchAction) {
  29862. this._disableTouchAction();
  29863. }
  29864. }
  29865. else {
  29866. this._gl = canvasOrContext;
  29867. this._renderingCanvas = this._gl.canvas;
  29868. if (this._gl.renderbufferStorageMultisample) {
  29869. this._webGLVersion = 2.0;
  29870. }
  29871. var attributes = this._gl.getContextAttributes();
  29872. if (attributes) {
  29873. options.stencil = attributes.stencil;
  29874. }
  29875. }
  29876. if (options.useHighPrecisionFloats !== undefined) {
  29877. this._highPrecisionShadersAllowed = options.useHighPrecisionFloats;
  29878. }
  29879. // Viewport
  29880. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  29881. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  29882. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  29883. this.resize();
  29884. this._isStencilEnable = options.stencil ? true : false;
  29885. this._initGLContext();
  29886. if (canvas) {
  29887. var anyDoc_1 = document;
  29888. // Fullscreen
  29889. this._onFullscreenChange = function () {
  29890. if (anyDoc_1.fullscreen !== undefined) {
  29891. _this.isFullscreen = anyDoc_1.fullscreen;
  29892. }
  29893. else if (anyDoc_1.mozFullScreen !== undefined) {
  29894. _this.isFullscreen = anyDoc_1.mozFullScreen;
  29895. }
  29896. else if (anyDoc_1.webkitIsFullScreen !== undefined) {
  29897. _this.isFullscreen = anyDoc_1.webkitIsFullScreen;
  29898. }
  29899. else if (anyDoc_1.msIsFullScreen !== undefined) {
  29900. _this.isFullscreen = anyDoc_1.msIsFullScreen;
  29901. }
  29902. // Pointer lock
  29903. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  29904. canvas.requestPointerLock = canvas.requestPointerLock ||
  29905. canvas.msRequestPointerLock ||
  29906. canvas.mozRequestPointerLock ||
  29907. canvas.webkitRequestPointerLock;
  29908. if (canvas.requestPointerLock) {
  29909. canvas.requestPointerLock();
  29910. }
  29911. }
  29912. };
  29913. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  29914. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  29915. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  29916. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  29917. // Pointer lock
  29918. this._onPointerLockChange = function () {
  29919. _this.isPointerLock = (anyDoc_1.mozPointerLockElement === canvas ||
  29920. anyDoc_1.webkitPointerLockElement === canvas ||
  29921. anyDoc_1.msPointerLockElement === canvas ||
  29922. anyDoc_1.pointerLockElement === canvas);
  29923. };
  29924. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  29925. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  29926. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  29927. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  29928. this._connectVREvents(canvas, anyDoc_1);
  29929. }
  29930. // Create Audio Engine if needed.
  29931. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  29932. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  29933. }
  29934. // Prepare buffer pointers
  29935. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  29936. this._currentBufferPointers[i] = new BufferPointer();
  29937. }
  29938. // Load WebVR Devices
  29939. this._prepareVRComponent();
  29940. if (options.autoEnableWebVR) {
  29941. this.initWebVR();
  29942. }
  29943. // Detect if we are running on a faulty buggy OS.
  29944. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  29945. // Detect if we are running on a faulty buggy desktop OS.
  29946. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  29947. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  29948. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  29949. }
  29950. Object.defineProperty(Engine, "Instances", {
  29951. /** Gets the list of created engines */
  29952. get: function () {
  29953. return _engineStore__WEBPACK_IMPORTED_MODULE_15__["EngineStore"].Instances;
  29954. },
  29955. enumerable: true,
  29956. configurable: true
  29957. });
  29958. Object.defineProperty(Engine, "LastCreatedEngine", {
  29959. /**
  29960. * Gets the latest created engine
  29961. */
  29962. get: function () {
  29963. return _engineStore__WEBPACK_IMPORTED_MODULE_15__["EngineStore"].LastCreatedEngine;
  29964. },
  29965. enumerable: true,
  29966. configurable: true
  29967. });
  29968. Object.defineProperty(Engine, "LastCreatedScene", {
  29969. /**
  29970. * Gets the latest created scene
  29971. */
  29972. get: function () {
  29973. return _engineStore__WEBPACK_IMPORTED_MODULE_15__["EngineStore"].LastCreatedScene;
  29974. },
  29975. enumerable: true,
  29976. configurable: true
  29977. });
  29978. /**
  29979. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29980. * @param flag defines which part of the materials must be marked as dirty
  29981. * @param predicate defines a predicate used to filter which materials should be affected
  29982. */
  29983. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  29984. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  29985. var engine = Engine.Instances[engineIndex];
  29986. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  29987. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  29988. }
  29989. }
  29990. };
  29991. Object.defineProperty(Engine, "NpmPackage", {
  29992. /**
  29993. * Returns the current npm package of the sdk
  29994. */
  29995. // Not mixed with Version for tooling purpose.
  29996. get: function () {
  29997. return "babylonjs@4.0.3";
  29998. },
  29999. enumerable: true,
  30000. configurable: true
  30001. });
  30002. Object.defineProperty(Engine, "Version", {
  30003. /**
  30004. * Returns the current version of the framework
  30005. */
  30006. get: function () {
  30007. return "4.0.3";
  30008. },
  30009. enumerable: true,
  30010. configurable: true
  30011. });
  30012. Object.defineProperty(Engine.prototype, "description", {
  30013. /**
  30014. * Returns a string describing the current engine
  30015. */
  30016. get: function () {
  30017. var description = "WebGL" + this.webGLVersion;
  30018. if (this._caps.parallelShaderCompile) {
  30019. description += " - Parallel shader compilation";
  30020. }
  30021. return description;
  30022. },
  30023. enumerable: true,
  30024. configurable: true
  30025. });
  30026. Object.defineProperty(Engine, "ShadersRepository", {
  30027. /**
  30028. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30029. */
  30030. get: function () {
  30031. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  30032. },
  30033. set: function (value) {
  30034. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  30035. },
  30036. enumerable: true,
  30037. configurable: true
  30038. });
  30039. /**
  30040. * Method called to create the default loading screen.
  30041. * This can be overriden in your own app.
  30042. * @param canvas The rendering canvas element
  30043. * @returns The loading screen
  30044. */
  30045. Engine.DefaultLoadingScreenFactory = function (canvas) {
  30046. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_17__["_DevTools"].WarnImport("LoadingScreen");
  30047. };
  30048. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  30049. /**
  30050. * Gets a boolean indicating that the engine supports uniform buffers
  30051. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30052. */
  30053. get: function () {
  30054. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  30055. },
  30056. enumerable: true,
  30057. configurable: true
  30058. });
  30059. Object.defineProperty(Engine.prototype, "_shouldUseHighPrecisionShader", {
  30060. /** @hidden */
  30061. get: function () {
  30062. return this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed;
  30063. },
  30064. enumerable: true,
  30065. configurable: true
  30066. });
  30067. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  30068. /**
  30069. * Gets a boolean indicating that only power of 2 textures are supported
  30070. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30071. */
  30072. get: function () {
  30073. return this._webGLVersion < 2 || this.forcePOTTextures;
  30074. },
  30075. enumerable: true,
  30076. configurable: true
  30077. });
  30078. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  30079. /**
  30080. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30081. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30082. */
  30083. get: function () {
  30084. return this._doNotHandleContextLost;
  30085. },
  30086. set: function (value) {
  30087. this._doNotHandleContextLost = value;
  30088. },
  30089. enumerable: true,
  30090. configurable: true
  30091. });
  30092. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  30093. /**
  30094. * Gets the performance monitor attached to this engine
  30095. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30096. */
  30097. get: function () {
  30098. return this._performanceMonitor;
  30099. },
  30100. enumerable: true,
  30101. configurable: true
  30102. });
  30103. Object.defineProperty(Engine.prototype, "texturesSupported", {
  30104. /**
  30105. * Gets the list of texture formats supported
  30106. */
  30107. get: function () {
  30108. return this._texturesSupported;
  30109. },
  30110. enumerable: true,
  30111. configurable: true
  30112. });
  30113. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  30114. /**
  30115. * Gets the list of texture formats in use
  30116. */
  30117. get: function () {
  30118. return this._textureFormatInUse;
  30119. },
  30120. enumerable: true,
  30121. configurable: true
  30122. });
  30123. Object.defineProperty(Engine.prototype, "currentViewport", {
  30124. /**
  30125. * Gets the current viewport
  30126. */
  30127. get: function () {
  30128. return this._cachedViewport;
  30129. },
  30130. enumerable: true,
  30131. configurable: true
  30132. });
  30133. Object.defineProperty(Engine.prototype, "emptyTexture", {
  30134. /**
  30135. * Gets the default empty texture
  30136. */
  30137. get: function () {
  30138. if (!this._emptyTexture) {
  30139. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  30140. }
  30141. return this._emptyTexture;
  30142. },
  30143. enumerable: true,
  30144. configurable: true
  30145. });
  30146. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  30147. /**
  30148. * Gets the default empty 3D texture
  30149. */
  30150. get: function () {
  30151. if (!this._emptyTexture3D) {
  30152. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  30153. }
  30154. return this._emptyTexture3D;
  30155. },
  30156. enumerable: true,
  30157. configurable: true
  30158. });
  30159. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  30160. /**
  30161. * Gets the default empty cube texture
  30162. */
  30163. get: function () {
  30164. if (!this._emptyCubeTexture) {
  30165. var faceData = new Uint8Array(4);
  30166. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  30167. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  30168. }
  30169. return this._emptyCubeTexture;
  30170. },
  30171. enumerable: true,
  30172. configurable: true
  30173. });
  30174. // WebVR
  30175. /**
  30176. * Initializes a webVR display and starts listening to display change events
  30177. * The onVRDisplayChangedObservable will be notified upon these changes
  30178. * @returns The onVRDisplayChangedObservable
  30179. */
  30180. Engine.prototype.initWebVR = function () {
  30181. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_17__["_DevTools"].WarnImport("WebVRCamera");
  30182. };
  30183. /** @hidden */
  30184. Engine.prototype._prepareVRComponent = function () {
  30185. // Do nothing as the engine side effect will overload it
  30186. };
  30187. /** @hidden */
  30188. Engine.prototype._connectVREvents = function (canvas, document) {
  30189. // Do nothing as the engine side effect will overload it
  30190. };
  30191. /** @hidden */
  30192. Engine.prototype._submitVRFrame = function () {
  30193. // Do nothing as the engine side effect will overload it
  30194. };
  30195. /**
  30196. * Call this function to leave webVR mode
  30197. * Will do nothing if webVR is not supported or if there is no webVR device
  30198. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30199. */
  30200. Engine.prototype.disableVR = function () {
  30201. // Do nothing as the engine side effect will overload it
  30202. };
  30203. /**
  30204. * Gets a boolean indicating that the system is in VR mode and is presenting
  30205. * @returns true if VR mode is engaged
  30206. */
  30207. Engine.prototype.isVRPresenting = function () {
  30208. return false;
  30209. };
  30210. /** @hidden */
  30211. Engine.prototype._requestVRFrame = function () {
  30212. // Do nothing as the engine side effect will overload it
  30213. };
  30214. Engine.prototype._disableTouchAction = function () {
  30215. if (!this._renderingCanvas) {
  30216. return;
  30217. }
  30218. this._renderingCanvas.setAttribute("touch-action", "none");
  30219. this._renderingCanvas.style.touchAction = "none";
  30220. this._renderingCanvas.style.msTouchAction = "none";
  30221. };
  30222. Engine.prototype._rebuildInternalTextures = function () {
  30223. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  30224. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  30225. var internalTexture = currentState_1[_i];
  30226. internalTexture._rebuild();
  30227. }
  30228. };
  30229. Engine.prototype._rebuildEffects = function () {
  30230. for (var key in this._compiledEffects) {
  30231. var effect = this._compiledEffects[key];
  30232. effect._prepareEffect();
  30233. }
  30234. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  30235. };
  30236. /**
  30237. * Gets a boolean indicating if all created effects are ready
  30238. * @returns true if all effects are ready
  30239. */
  30240. Engine.prototype.areAllEffectsReady = function () {
  30241. for (var key in this._compiledEffects) {
  30242. var effect = this._compiledEffects[key];
  30243. if (!effect.isReady()) {
  30244. return false;
  30245. }
  30246. }
  30247. return true;
  30248. };
  30249. Engine.prototype._rebuildBuffers = function () {
  30250. // Index / Vertex
  30251. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  30252. var scene = _a[_i];
  30253. scene.resetCachedMaterial();
  30254. scene._rebuildGeometries();
  30255. scene._rebuildTextures();
  30256. }
  30257. // Uniforms
  30258. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  30259. var uniformBuffer = _c[_b];
  30260. uniformBuffer._rebuild();
  30261. }
  30262. };
  30263. Engine.prototype._initGLContext = function () {
  30264. // Caps
  30265. this._caps = new EngineCapabilities();
  30266. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  30267. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  30268. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  30269. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  30270. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  30271. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  30272. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  30273. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  30274. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  30275. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  30276. // Infos
  30277. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  30278. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  30279. if (rendererInfo != null) {
  30280. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  30281. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  30282. }
  30283. if (!this._glVendor) {
  30284. this._glVendor = "Unknown vendor";
  30285. }
  30286. if (!this._glRenderer) {
  30287. this._glRenderer = "Unknown renderer";
  30288. }
  30289. // Constants
  30290. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  30291. if (this._gl.RGBA16F !== 0x881A) {
  30292. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  30293. }
  30294. if (this._gl.RGBA32F !== 0x8814) {
  30295. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  30296. }
  30297. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  30298. this._gl.DEPTH24_STENCIL8 = 35056;
  30299. }
  30300. // Extensions
  30301. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  30302. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  30303. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  30304. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  30305. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  30306. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  30307. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  30308. 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');
  30309. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  30310. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  30311. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  30312. this._caps.highPrecisionShaderSupported = false;
  30313. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  30314. if (this._caps.timerQuery) {
  30315. if (this._webGLVersion === 1) {
  30316. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  30317. }
  30318. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  30319. }
  30320. // Checks if some of the format renders first to allow the use of webgl inspector.
  30321. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  30322. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  30323. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  30324. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  30325. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  30326. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  30327. if (this._webGLVersion > 1) {
  30328. this._gl.HALF_FLOAT_OES = 0x140B;
  30329. }
  30330. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  30331. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  30332. this._caps.multiview = this._gl.getExtension('OVR_multiview2');
  30333. // Draw buffers
  30334. if (this._webGLVersion > 1) {
  30335. this._caps.drawBuffersExtension = true;
  30336. }
  30337. else {
  30338. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  30339. if (drawBuffersExtension !== null) {
  30340. this._caps.drawBuffersExtension = true;
  30341. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  30342. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  30343. for (var i = 0; i < 16; i++) {
  30344. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  30345. }
  30346. }
  30347. else {
  30348. this._caps.drawBuffersExtension = false;
  30349. }
  30350. }
  30351. // Shader compiler threads
  30352. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  30353. // Depth Texture
  30354. if (this._webGLVersion > 1) {
  30355. this._caps.depthTextureExtension = true;
  30356. }
  30357. else {
  30358. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  30359. if (depthTextureExtension != null) {
  30360. this._caps.depthTextureExtension = true;
  30361. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  30362. }
  30363. }
  30364. // Vertex array object
  30365. if (this.disableVertexArrayObjects) {
  30366. this._caps.vertexArrayObject = false;
  30367. }
  30368. else if (this._webGLVersion > 1) {
  30369. this._caps.vertexArrayObject = true;
  30370. }
  30371. else {
  30372. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  30373. if (vertexArrayObjectExtension != null) {
  30374. this._caps.vertexArrayObject = true;
  30375. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  30376. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  30377. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  30378. }
  30379. else {
  30380. this._caps.vertexArrayObject = false;
  30381. }
  30382. }
  30383. // Instances count
  30384. if (this._webGLVersion > 1) {
  30385. this._caps.instancedArrays = true;
  30386. }
  30387. else {
  30388. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  30389. if (instanceExtension != null) {
  30390. this._caps.instancedArrays = true;
  30391. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  30392. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  30393. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  30394. }
  30395. else {
  30396. this._caps.instancedArrays = false;
  30397. }
  30398. }
  30399. // Intelligently add supported compressed formats in order to check for.
  30400. // Check for ASTC support first as it is most powerful and to be very cross platform.
  30401. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  30402. // Likely no hardware which supports both PVR & DXT, so order matters little.
  30403. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  30404. if (this._caps.astc) {
  30405. this.texturesSupported.push('-astc.ktx');
  30406. }
  30407. if (this._caps.s3tc) {
  30408. this.texturesSupported.push('-dxt.ktx');
  30409. }
  30410. if (this._caps.pvrtc) {
  30411. this.texturesSupported.push('-pvrtc.ktx');
  30412. }
  30413. if (this._caps.etc2) {
  30414. this.texturesSupported.push('-etc2.ktx');
  30415. }
  30416. if (this._caps.etc1) {
  30417. this.texturesSupported.push('-etc1.ktx');
  30418. }
  30419. if (this._gl.getShaderPrecisionFormat) {
  30420. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  30421. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  30422. if (vertex_highp && fragment_highp) {
  30423. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  30424. }
  30425. }
  30426. // Depth buffer
  30427. this.setDepthBuffer(true);
  30428. this.setDepthFunctionToLessOrEqual();
  30429. this.setDepthWrite(true);
  30430. // Texture maps
  30431. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  30432. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  30433. this._nextFreeTextureSlots.push(slot);
  30434. }
  30435. };
  30436. Object.defineProperty(Engine.prototype, "webGLVersion", {
  30437. /**
  30438. * Gets version of the current webGL context
  30439. */
  30440. get: function () {
  30441. return this._webGLVersion;
  30442. },
  30443. enumerable: true,
  30444. configurable: true
  30445. });
  30446. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  30447. /**
  30448. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30449. */
  30450. get: function () {
  30451. return this._isStencilEnable;
  30452. },
  30453. enumerable: true,
  30454. configurable: true
  30455. });
  30456. /** @hidden */
  30457. Engine.prototype._prepareWorkingCanvas = function () {
  30458. if (this._workingCanvas) {
  30459. return;
  30460. }
  30461. this._workingCanvas = document.createElement("canvas");
  30462. var context = this._workingCanvas.getContext("2d");
  30463. if (context) {
  30464. this._workingContext = context;
  30465. }
  30466. };
  30467. /**
  30468. * Reset the texture cache to empty state
  30469. */
  30470. Engine.prototype.resetTextureCache = function () {
  30471. for (var key in this._boundTexturesCache) {
  30472. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  30473. continue;
  30474. }
  30475. this._boundTexturesCache[key] = null;
  30476. }
  30477. this._currentTextureChannel = -1;
  30478. };
  30479. /**
  30480. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30481. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30482. * @returns true if engine is in deterministic lock step mode
  30483. */
  30484. Engine.prototype.isDeterministicLockStep = function () {
  30485. return this._deterministicLockstep;
  30486. };
  30487. /**
  30488. * Gets the max steps when engine is running in deterministic lock step
  30489. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30490. * @returns the max steps
  30491. */
  30492. Engine.prototype.getLockstepMaxSteps = function () {
  30493. return this._lockstepMaxSteps;
  30494. };
  30495. /**
  30496. * Gets an object containing information about the current webGL context
  30497. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30498. */
  30499. Engine.prototype.getGlInfo = function () {
  30500. return {
  30501. vendor: this._glVendor,
  30502. renderer: this._glRenderer,
  30503. version: this._glVersion
  30504. };
  30505. };
  30506. /**
  30507. * Gets current aspect ratio
  30508. * @param camera defines the camera to use to get the aspect ratio
  30509. * @param useScreen defines if screen size must be used (or the current render target if any)
  30510. * @returns a number defining the aspect ratio
  30511. */
  30512. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  30513. if (useScreen === void 0) { useScreen = false; }
  30514. var viewport = camera.viewport;
  30515. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  30516. };
  30517. /**
  30518. * Gets current screen aspect ratio
  30519. * @returns a number defining the aspect ratio
  30520. */
  30521. Engine.prototype.getScreenAspectRatio = function () {
  30522. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  30523. };
  30524. /**
  30525. * Gets the current render width
  30526. * @param useScreen defines if screen size must be used (or the current render target if any)
  30527. * @returns a number defining the current render width
  30528. */
  30529. Engine.prototype.getRenderWidth = function (useScreen) {
  30530. if (useScreen === void 0) { useScreen = false; }
  30531. if (!useScreen && this._currentRenderTarget) {
  30532. return this._currentRenderTarget.width;
  30533. }
  30534. return this._gl.drawingBufferWidth;
  30535. };
  30536. /**
  30537. * Gets the current render height
  30538. * @param useScreen defines if screen size must be used (or the current render target if any)
  30539. * @returns a number defining the current render height
  30540. */
  30541. Engine.prototype.getRenderHeight = function (useScreen) {
  30542. if (useScreen === void 0) { useScreen = false; }
  30543. if (!useScreen && this._currentRenderTarget) {
  30544. return this._currentRenderTarget.height;
  30545. }
  30546. return this._gl.drawingBufferHeight;
  30547. };
  30548. /**
  30549. * Gets the HTML canvas attached with the current webGL context
  30550. * @returns a HTML canvas
  30551. */
  30552. Engine.prototype.getRenderingCanvas = function () {
  30553. return this._renderingCanvas;
  30554. };
  30555. /**
  30556. * Gets the client rect of the HTML canvas attached with the current webGL context
  30557. * @returns a client rectanglee
  30558. */
  30559. Engine.prototype.getRenderingCanvasClientRect = function () {
  30560. if (!this._renderingCanvas) {
  30561. return null;
  30562. }
  30563. return this._renderingCanvas.getBoundingClientRect();
  30564. };
  30565. /**
  30566. * Defines the hardware scaling level.
  30567. * By default the hardware scaling level is computed from the window device ratio.
  30568. * 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.
  30569. * @param level defines the level to use
  30570. */
  30571. Engine.prototype.setHardwareScalingLevel = function (level) {
  30572. this._hardwareScalingLevel = level;
  30573. this.resize();
  30574. };
  30575. /**
  30576. * Gets the current hardware scaling level.
  30577. * By default the hardware scaling level is computed from the window device ratio.
  30578. * 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.
  30579. * @returns a number indicating the current hardware scaling level
  30580. */
  30581. Engine.prototype.getHardwareScalingLevel = function () {
  30582. return this._hardwareScalingLevel;
  30583. };
  30584. /**
  30585. * Gets the list of loaded textures
  30586. * @returns an array containing all loaded textures
  30587. */
  30588. Engine.prototype.getLoadedTexturesCache = function () {
  30589. return this._internalTexturesCache;
  30590. };
  30591. /**
  30592. * Gets the object containing all engine capabilities
  30593. * @returns the EngineCapabilities object
  30594. */
  30595. Engine.prototype.getCaps = function () {
  30596. return this._caps;
  30597. };
  30598. /**
  30599. * Gets the current depth function
  30600. * @returns a number defining the depth function
  30601. */
  30602. Engine.prototype.getDepthFunction = function () {
  30603. return this._depthCullingState.depthFunc;
  30604. };
  30605. /**
  30606. * Sets the current depth function
  30607. * @param depthFunc defines the function to use
  30608. */
  30609. Engine.prototype.setDepthFunction = function (depthFunc) {
  30610. this._depthCullingState.depthFunc = depthFunc;
  30611. };
  30612. /**
  30613. * Sets the current depth function to GREATER
  30614. */
  30615. Engine.prototype.setDepthFunctionToGreater = function () {
  30616. this._depthCullingState.depthFunc = this._gl.GREATER;
  30617. };
  30618. /**
  30619. * Sets the current depth function to GEQUAL
  30620. */
  30621. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  30622. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  30623. };
  30624. /**
  30625. * Sets the current depth function to LESS
  30626. */
  30627. Engine.prototype.setDepthFunctionToLess = function () {
  30628. this._depthCullingState.depthFunc = this._gl.LESS;
  30629. };
  30630. /**
  30631. * Caches the the state of the stencil buffer
  30632. */
  30633. Engine.prototype.cacheStencilState = function () {
  30634. this._cachedStencilBuffer = this.getStencilBuffer();
  30635. this._cachedStencilFunction = this.getStencilFunction();
  30636. this._cachedStencilMask = this.getStencilMask();
  30637. this._cachedStencilOperationPass = this.getStencilOperationPass();
  30638. this._cachedStencilOperationFail = this.getStencilOperationFail();
  30639. this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail();
  30640. this._cachedStencilReference = this.getStencilFunctionReference();
  30641. };
  30642. /**
  30643. * Restores the state of the stencil buffer
  30644. */
  30645. Engine.prototype.restoreStencilState = function () {
  30646. this.setStencilFunction(this._cachedStencilFunction);
  30647. this.setStencilMask(this._cachedStencilMask);
  30648. this.setStencilBuffer(this._cachedStencilBuffer);
  30649. this.setStencilOperationPass(this._cachedStencilOperationPass);
  30650. this.setStencilOperationFail(this._cachedStencilOperationFail);
  30651. this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail);
  30652. this.setStencilFunctionReference(this._cachedStencilReference);
  30653. };
  30654. /**
  30655. * Sets the current depth function to LEQUAL
  30656. */
  30657. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  30658. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  30659. };
  30660. /**
  30661. * Gets a boolean indicating if stencil buffer is enabled
  30662. * @returns the current stencil buffer state
  30663. */
  30664. Engine.prototype.getStencilBuffer = function () {
  30665. return this._stencilState.stencilTest;
  30666. };
  30667. /**
  30668. * Enable or disable the stencil buffer
  30669. * @param enable defines if the stencil buffer must be enabled or disabled
  30670. */
  30671. Engine.prototype.setStencilBuffer = function (enable) {
  30672. this._stencilState.stencilTest = enable;
  30673. };
  30674. /**
  30675. * Gets the current stencil mask
  30676. * @returns a number defining the new stencil mask to use
  30677. */
  30678. Engine.prototype.getStencilMask = function () {
  30679. return this._stencilState.stencilMask;
  30680. };
  30681. /**
  30682. * Sets the current stencil mask
  30683. * @param mask defines the new stencil mask to use
  30684. */
  30685. Engine.prototype.setStencilMask = function (mask) {
  30686. this._stencilState.stencilMask = mask;
  30687. };
  30688. /**
  30689. * Gets the current stencil function
  30690. * @returns a number defining the stencil function to use
  30691. */
  30692. Engine.prototype.getStencilFunction = function () {
  30693. return this._stencilState.stencilFunc;
  30694. };
  30695. /**
  30696. * Gets the current stencil reference value
  30697. * @returns a number defining the stencil reference value to use
  30698. */
  30699. Engine.prototype.getStencilFunctionReference = function () {
  30700. return this._stencilState.stencilFuncRef;
  30701. };
  30702. /**
  30703. * Gets the current stencil mask
  30704. * @returns a number defining the stencil mask to use
  30705. */
  30706. Engine.prototype.getStencilFunctionMask = function () {
  30707. return this._stencilState.stencilFuncMask;
  30708. };
  30709. /**
  30710. * Sets the current stencil function
  30711. * @param stencilFunc defines the new stencil function to use
  30712. */
  30713. Engine.prototype.setStencilFunction = function (stencilFunc) {
  30714. this._stencilState.stencilFunc = stencilFunc;
  30715. };
  30716. /**
  30717. * Sets the current stencil reference
  30718. * @param reference defines the new stencil reference to use
  30719. */
  30720. Engine.prototype.setStencilFunctionReference = function (reference) {
  30721. this._stencilState.stencilFuncRef = reference;
  30722. };
  30723. /**
  30724. * Sets the current stencil mask
  30725. * @param mask defines the new stencil mask to use
  30726. */
  30727. Engine.prototype.setStencilFunctionMask = function (mask) {
  30728. this._stencilState.stencilFuncMask = mask;
  30729. };
  30730. /**
  30731. * Gets the current stencil operation when stencil fails
  30732. * @returns a number defining stencil operation to use when stencil fails
  30733. */
  30734. Engine.prototype.getStencilOperationFail = function () {
  30735. return this._stencilState.stencilOpStencilFail;
  30736. };
  30737. /**
  30738. * Gets the current stencil operation when depth fails
  30739. * @returns a number defining stencil operation to use when depth fails
  30740. */
  30741. Engine.prototype.getStencilOperationDepthFail = function () {
  30742. return this._stencilState.stencilOpDepthFail;
  30743. };
  30744. /**
  30745. * Gets the current stencil operation when stencil passes
  30746. * @returns a number defining stencil operation to use when stencil passes
  30747. */
  30748. Engine.prototype.getStencilOperationPass = function () {
  30749. return this._stencilState.stencilOpStencilDepthPass;
  30750. };
  30751. /**
  30752. * Sets the stencil operation to use when stencil fails
  30753. * @param operation defines the stencil operation to use when stencil fails
  30754. */
  30755. Engine.prototype.setStencilOperationFail = function (operation) {
  30756. this._stencilState.stencilOpStencilFail = operation;
  30757. };
  30758. /**
  30759. * Sets the stencil operation to use when depth fails
  30760. * @param operation defines the stencil operation to use when depth fails
  30761. */
  30762. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  30763. this._stencilState.stencilOpDepthFail = operation;
  30764. };
  30765. /**
  30766. * Sets the stencil operation to use when stencil passes
  30767. * @param operation defines the stencil operation to use when stencil passes
  30768. */
  30769. Engine.prototype.setStencilOperationPass = function (operation) {
  30770. this._stencilState.stencilOpStencilDepthPass = operation;
  30771. };
  30772. /**
  30773. * Sets a boolean indicating if the dithering state is enabled or disabled
  30774. * @param value defines the dithering state
  30775. */
  30776. Engine.prototype.setDitheringState = function (value) {
  30777. if (value) {
  30778. this._gl.enable(this._gl.DITHER);
  30779. }
  30780. else {
  30781. this._gl.disable(this._gl.DITHER);
  30782. }
  30783. };
  30784. /**
  30785. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30786. * @param value defines the rasterizer state
  30787. */
  30788. Engine.prototype.setRasterizerState = function (value) {
  30789. if (value) {
  30790. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  30791. }
  30792. else {
  30793. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  30794. }
  30795. };
  30796. /**
  30797. * stop executing a render loop function and remove it from the execution array
  30798. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30799. */
  30800. Engine.prototype.stopRenderLoop = function (renderFunction) {
  30801. if (!renderFunction) {
  30802. this._activeRenderLoops = [];
  30803. return;
  30804. }
  30805. var index = this._activeRenderLoops.indexOf(renderFunction);
  30806. if (index >= 0) {
  30807. this._activeRenderLoops.splice(index, 1);
  30808. }
  30809. };
  30810. /** @hidden */
  30811. Engine.prototype._renderLoop = function () {
  30812. if (!this._contextWasLost) {
  30813. var shouldRender = true;
  30814. if (!this.renderEvenInBackground && this._windowIsBackground) {
  30815. shouldRender = false;
  30816. }
  30817. if (shouldRender) {
  30818. // Start new frame
  30819. this.beginFrame();
  30820. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  30821. var renderFunction = this._activeRenderLoops[index];
  30822. renderFunction();
  30823. }
  30824. // Present
  30825. this.endFrame();
  30826. }
  30827. }
  30828. if (this._activeRenderLoops.length > 0) {
  30829. // Register new frame
  30830. if (this.customAnimationFrameRequester) {
  30831. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  30832. this._frameHandler = this.customAnimationFrameRequester.requestID;
  30833. }
  30834. else if (this.isVRPresenting()) {
  30835. this._requestVRFrame();
  30836. }
  30837. else {
  30838. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  30839. }
  30840. }
  30841. else {
  30842. this._renderingQueueLaunched = false;
  30843. }
  30844. };
  30845. /**
  30846. * Register and execute a render loop. The engine can have more than one render function
  30847. * @param renderFunction defines the function to continuously execute
  30848. */
  30849. Engine.prototype.runRenderLoop = function (renderFunction) {
  30850. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  30851. return;
  30852. }
  30853. this._activeRenderLoops.push(renderFunction);
  30854. if (!this._renderingQueueLaunched) {
  30855. this._renderingQueueLaunched = true;
  30856. this._bindedRenderFunction = this._renderLoop.bind(this);
  30857. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  30858. }
  30859. };
  30860. /**
  30861. * Toggle full screen mode
  30862. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30863. */
  30864. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  30865. if (this.isFullscreen) {
  30866. this.exitFullscreen();
  30867. }
  30868. else {
  30869. this.enterFullscreen(requestPointerLock);
  30870. }
  30871. };
  30872. /**
  30873. * Enters full screen mode
  30874. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30875. */
  30876. Engine.prototype.enterFullscreen = function (requestPointerLock) {
  30877. if (!this.isFullscreen) {
  30878. this._pointerLockRequested = requestPointerLock;
  30879. if (this._renderingCanvas) {
  30880. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  30881. }
  30882. }
  30883. };
  30884. /**
  30885. * Exits full screen mode
  30886. */
  30887. Engine.prototype.exitFullscreen = function () {
  30888. if (this.isFullscreen) {
  30889. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  30890. }
  30891. };
  30892. /**
  30893. * Clear the current render buffer or the current render target (if any is set up)
  30894. * @param color defines the color to use
  30895. * @param backBuffer defines if the back buffer must be cleared
  30896. * @param depth defines if the depth buffer must be cleared
  30897. * @param stencil defines if the stencil buffer must be cleared
  30898. */
  30899. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  30900. if (stencil === void 0) { stencil = false; }
  30901. this.applyStates();
  30902. var mode = 0;
  30903. if (backBuffer && color) {
  30904. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  30905. mode |= this._gl.COLOR_BUFFER_BIT;
  30906. }
  30907. if (depth) {
  30908. this._gl.clearDepth(1.0);
  30909. mode |= this._gl.DEPTH_BUFFER_BIT;
  30910. }
  30911. if (stencil) {
  30912. this._gl.clearStencil(0);
  30913. mode |= this._gl.STENCIL_BUFFER_BIT;
  30914. }
  30915. this._gl.clear(mode);
  30916. };
  30917. /**
  30918. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30919. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30920. * @param y defines the y-coordinate of the corner of the clear rectangle
  30921. * @param width defines the width of the clear rectangle
  30922. * @param height defines the height of the clear rectangle
  30923. * @param clearColor defines the clear color
  30924. */
  30925. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  30926. this.enableScissor(x, y, width, height);
  30927. this.clear(clearColor, true, true, true);
  30928. this.disableScissor();
  30929. };
  30930. /**
  30931. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30932. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30933. * @param y defines the y-coordinate of the corner of the clear rectangle
  30934. * @param width defines the width of the clear rectangle
  30935. * @param height defines the height of the clear rectangle
  30936. */
  30937. Engine.prototype.enableScissor = function (x, y, width, height) {
  30938. var gl = this._gl;
  30939. // Change state
  30940. gl.enable(gl.SCISSOR_TEST);
  30941. gl.scissor(x, y, width, height);
  30942. };
  30943. /**
  30944. * Disable previously set scissor test rectangle
  30945. */
  30946. Engine.prototype.disableScissor = function () {
  30947. var gl = this._gl;
  30948. gl.disable(gl.SCISSOR_TEST);
  30949. };
  30950. /** @hidden */
  30951. Engine.prototype._viewport = function (x, y, width, height) {
  30952. if (x !== this._viewportCached.x ||
  30953. y !== this._viewportCached.y ||
  30954. width !== this._viewportCached.z ||
  30955. height !== this._viewportCached.w) {
  30956. this._viewportCached.x = x;
  30957. this._viewportCached.y = y;
  30958. this._viewportCached.z = width;
  30959. this._viewportCached.w = height;
  30960. this._gl.viewport(x, y, width, height);
  30961. }
  30962. };
  30963. /**
  30964. * Set the WebGL's viewport
  30965. * @param viewport defines the viewport element to be used
  30966. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30967. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30968. */
  30969. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  30970. var width = requiredWidth || this.getRenderWidth();
  30971. var height = requiredHeight || this.getRenderHeight();
  30972. var x = viewport.x || 0;
  30973. var y = viewport.y || 0;
  30974. this._cachedViewport = viewport;
  30975. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  30976. };
  30977. /**
  30978. * Directly set the WebGL Viewport
  30979. * @param x defines the x coordinate of the viewport (in screen space)
  30980. * @param y defines the y coordinate of the viewport (in screen space)
  30981. * @param width defines the width of the viewport (in screen space)
  30982. * @param height defines the height of the viewport (in screen space)
  30983. * @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
  30984. */
  30985. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  30986. var currentViewport = this._cachedViewport;
  30987. this._cachedViewport = null;
  30988. this._viewport(x, y, width, height);
  30989. return currentViewport;
  30990. };
  30991. /**
  30992. * Begin a new frame
  30993. */
  30994. Engine.prototype.beginFrame = function () {
  30995. this.onBeginFrameObservable.notifyObservers(this);
  30996. this._measureFps();
  30997. };
  30998. /**
  30999. * Enf the current frame
  31000. */
  31001. Engine.prototype.endFrame = function () {
  31002. // Force a flush in case we are using a bad OS.
  31003. if (this._badOS) {
  31004. this.flushFramebuffer();
  31005. }
  31006. this._submitVRFrame();
  31007. this.onEndFrameObservable.notifyObservers(this);
  31008. };
  31009. /**
  31010. * Resize the view according to the canvas' size
  31011. */
  31012. Engine.prototype.resize = function () {
  31013. // We're not resizing the size of the canvas while in VR mode & presenting
  31014. if (!this.isVRPresenting()) {
  31015. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  31016. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  31017. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  31018. }
  31019. };
  31020. /**
  31021. * Force a specific size of the canvas
  31022. * @param width defines the new canvas' width
  31023. * @param height defines the new canvas' height
  31024. */
  31025. Engine.prototype.setSize = function (width, height) {
  31026. if (!this._renderingCanvas) {
  31027. return;
  31028. }
  31029. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  31030. return;
  31031. }
  31032. this._renderingCanvas.width = width;
  31033. this._renderingCanvas.height = height;
  31034. for (var index = 0; index < this.scenes.length; index++) {
  31035. var scene = this.scenes[index];
  31036. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  31037. var cam = scene.cameras[camIndex];
  31038. cam._currentRenderId = 0;
  31039. }
  31040. }
  31041. if (this.onResizeObservable.hasObservers) {
  31042. this.onResizeObservable.notifyObservers(this);
  31043. }
  31044. };
  31045. /**
  31046. * Binds the frame buffer to the specified texture.
  31047. * @param texture The texture to render to or null for the default canvas
  31048. * @param faceIndex The face of the texture to render to in case of cube texture
  31049. * @param requiredWidth The width of the target to render to
  31050. * @param requiredHeight The height of the target to render to
  31051. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31052. * @param depthStencilTexture The depth stencil texture to use to render
  31053. * @param lodLevel defines le lod level to bind to the frame buffer
  31054. */
  31055. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  31056. if (lodLevel === void 0) { lodLevel = 0; }
  31057. if (this._currentRenderTarget) {
  31058. this.unBindFramebuffer(this._currentRenderTarget);
  31059. }
  31060. this._currentRenderTarget = texture;
  31061. this._bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  31062. var gl = this._gl;
  31063. if (texture.isCube) {
  31064. if (faceIndex === undefined) {
  31065. faceIndex = 0;
  31066. }
  31067. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  31068. if (depthStencilTexture) {
  31069. if (depthStencilTexture._generateStencilBuffer) {
  31070. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  31071. }
  31072. else {
  31073. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  31074. }
  31075. }
  31076. }
  31077. if (this._cachedViewport && !forceFullscreenViewport) {
  31078. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  31079. }
  31080. else {
  31081. if (!requiredWidth) {
  31082. requiredWidth = texture.width;
  31083. if (lodLevel) {
  31084. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  31085. }
  31086. }
  31087. if (!requiredHeight) {
  31088. requiredHeight = texture.height;
  31089. if (lodLevel) {
  31090. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  31091. }
  31092. }
  31093. this._viewport(0, 0, requiredWidth, requiredHeight);
  31094. }
  31095. this.wipeCaches();
  31096. };
  31097. /** @hidden */
  31098. Engine.prototype._bindUnboundFramebuffer = function (framebuffer) {
  31099. if (this._currentFramebuffer !== framebuffer) {
  31100. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  31101. this._currentFramebuffer = framebuffer;
  31102. }
  31103. };
  31104. /**
  31105. * Unbind the current render target texture from the webGL context
  31106. * @param texture defines the render target texture to unbind
  31107. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31108. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31109. */
  31110. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  31111. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  31112. this._currentRenderTarget = null;
  31113. // If MSAA, we need to bitblt back to main texture
  31114. var gl = this._gl;
  31115. if (texture._MSAAFramebuffer) {
  31116. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  31117. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  31118. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  31119. }
  31120. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  31121. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31122. gl.generateMipmap(gl.TEXTURE_2D);
  31123. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31124. }
  31125. if (onBeforeUnbind) {
  31126. if (texture._MSAAFramebuffer) {
  31127. // Bind the correct framebuffer
  31128. this._bindUnboundFramebuffer(texture._framebuffer);
  31129. }
  31130. onBeforeUnbind();
  31131. }
  31132. this._bindUnboundFramebuffer(null);
  31133. };
  31134. /**
  31135. * Force the mipmap generation for the given render target texture
  31136. * @param texture defines the render target texture to use
  31137. */
  31138. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  31139. if (texture.generateMipMaps) {
  31140. var gl = this._gl;
  31141. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31142. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  31143. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31144. }
  31145. };
  31146. /**
  31147. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31148. */
  31149. Engine.prototype.flushFramebuffer = function () {
  31150. this._gl.flush();
  31151. };
  31152. /**
  31153. * Unbind the current render target and bind the default framebuffer
  31154. */
  31155. Engine.prototype.restoreDefaultFramebuffer = function () {
  31156. if (this._currentRenderTarget) {
  31157. this.unBindFramebuffer(this._currentRenderTarget);
  31158. }
  31159. else {
  31160. this._bindUnboundFramebuffer(null);
  31161. }
  31162. if (this._cachedViewport) {
  31163. this.setViewport(this._cachedViewport);
  31164. }
  31165. this.wipeCaches();
  31166. };
  31167. // UBOs
  31168. /**
  31169. * Create an uniform buffer
  31170. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31171. * @param elements defines the content of the uniform buffer
  31172. * @returns the webGL uniform buffer
  31173. */
  31174. Engine.prototype.createUniformBuffer = function (elements) {
  31175. var ubo = this._gl.createBuffer();
  31176. if (!ubo) {
  31177. throw new Error("Unable to create uniform buffer");
  31178. }
  31179. var result = new _Meshes_WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_19__["WebGLDataBuffer"](ubo);
  31180. this.bindUniformBuffer(result);
  31181. if (elements instanceof Float32Array) {
  31182. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  31183. }
  31184. else {
  31185. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  31186. }
  31187. this.bindUniformBuffer(null);
  31188. result.references = 1;
  31189. return result;
  31190. };
  31191. /**
  31192. * Create a dynamic uniform buffer
  31193. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31194. * @param elements defines the content of the uniform buffer
  31195. * @returns the webGL uniform buffer
  31196. */
  31197. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  31198. var ubo = this._gl.createBuffer();
  31199. if (!ubo) {
  31200. throw new Error("Unable to create dynamic uniform buffer");
  31201. }
  31202. var result = new _Meshes_WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_19__["WebGLDataBuffer"](ubo);
  31203. this.bindUniformBuffer(result);
  31204. if (elements instanceof Float32Array) {
  31205. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  31206. }
  31207. else {
  31208. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  31209. }
  31210. this.bindUniformBuffer(null);
  31211. result.references = 1;
  31212. return result;
  31213. };
  31214. /**
  31215. * Update an existing uniform buffer
  31216. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31217. * @param uniformBuffer defines the target uniform buffer
  31218. * @param elements defines the content to update
  31219. * @param offset defines the offset in the uniform buffer where update should start
  31220. * @param count defines the size of the data to update
  31221. */
  31222. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  31223. this.bindUniformBuffer(uniformBuffer);
  31224. if (offset === undefined) {
  31225. offset = 0;
  31226. }
  31227. if (count === undefined) {
  31228. if (elements instanceof Float32Array) {
  31229. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  31230. }
  31231. else {
  31232. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  31233. }
  31234. }
  31235. else {
  31236. if (elements instanceof Float32Array) {
  31237. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  31238. }
  31239. else {
  31240. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  31241. }
  31242. }
  31243. this.bindUniformBuffer(null);
  31244. };
  31245. // VBOs
  31246. Engine.prototype._resetVertexBufferBinding = function () {
  31247. this.bindArrayBuffer(null);
  31248. this._cachedVertexBuffers = null;
  31249. };
  31250. /**
  31251. * Creates a vertex buffer
  31252. * @param data the data for the vertex buffer
  31253. * @returns the new WebGL static buffer
  31254. */
  31255. Engine.prototype.createVertexBuffer = function (data) {
  31256. var vbo = this._gl.createBuffer();
  31257. if (!vbo) {
  31258. throw new Error("Unable to create vertex buffer");
  31259. }
  31260. var dataBuffer = new _Meshes_WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_19__["WebGLDataBuffer"](vbo);
  31261. this.bindArrayBuffer(dataBuffer);
  31262. if (data instanceof Array) {
  31263. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  31264. }
  31265. else {
  31266. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  31267. }
  31268. this._resetVertexBufferBinding();
  31269. dataBuffer.references = 1;
  31270. return dataBuffer;
  31271. };
  31272. /**
  31273. * Creates a dynamic vertex buffer
  31274. * @param data the data for the dynamic vertex buffer
  31275. * @returns the new WebGL dynamic buffer
  31276. */
  31277. Engine.prototype.createDynamicVertexBuffer = function (data) {
  31278. var vbo = this._gl.createBuffer();
  31279. if (!vbo) {
  31280. throw new Error("Unable to create dynamic vertex buffer");
  31281. }
  31282. var result = new _Meshes_WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_19__["WebGLDataBuffer"](vbo);
  31283. this.bindArrayBuffer(result);
  31284. if (data instanceof Array) {
  31285. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  31286. }
  31287. else {
  31288. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  31289. }
  31290. this._resetVertexBufferBinding();
  31291. result.references = 1;
  31292. return result;
  31293. };
  31294. /**
  31295. * Update a dynamic index buffer
  31296. * @param indexBuffer defines the target index buffer
  31297. * @param indices defines the data to update
  31298. * @param offset defines the offset in the target index buffer where update should start
  31299. */
  31300. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  31301. if (offset === void 0) { offset = 0; }
  31302. // Force cache update
  31303. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  31304. this.bindIndexBuffer(indexBuffer);
  31305. var arrayBuffer;
  31306. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  31307. arrayBuffer = indices;
  31308. }
  31309. else {
  31310. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  31311. }
  31312. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  31313. this._resetIndexBufferBinding();
  31314. };
  31315. /**
  31316. * Updates a dynamic vertex buffer.
  31317. * @param vertexBuffer the vertex buffer to update
  31318. * @param data the data used to update the vertex buffer
  31319. * @param byteOffset the byte offset of the data
  31320. * @param byteLength the byte length of the data
  31321. */
  31322. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  31323. this.bindArrayBuffer(vertexBuffer);
  31324. if (byteOffset === undefined) {
  31325. byteOffset = 0;
  31326. }
  31327. if (byteLength === undefined) {
  31328. if (data instanceof Array) {
  31329. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  31330. }
  31331. else {
  31332. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  31333. }
  31334. }
  31335. else {
  31336. if (data instanceof Array) {
  31337. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  31338. }
  31339. else {
  31340. if (data instanceof ArrayBuffer) {
  31341. data = new Uint8Array(data, byteOffset, byteLength);
  31342. }
  31343. else {
  31344. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  31345. }
  31346. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  31347. }
  31348. }
  31349. this._resetVertexBufferBinding();
  31350. };
  31351. Engine.prototype._resetIndexBufferBinding = function () {
  31352. this.bindIndexBuffer(null);
  31353. this._cachedIndexBuffer = null;
  31354. };
  31355. /**
  31356. * Creates a new index buffer
  31357. * @param indices defines the content of the index buffer
  31358. * @param updatable defines if the index buffer must be updatable
  31359. * @returns a new webGL buffer
  31360. */
  31361. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  31362. var vbo = this._gl.createBuffer();
  31363. var dataBuffer = new _Meshes_WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_19__["WebGLDataBuffer"](vbo);
  31364. if (!vbo) {
  31365. throw new Error("Unable to create index buffer");
  31366. }
  31367. this.bindIndexBuffer(dataBuffer);
  31368. // Check for 32 bits indices
  31369. var arrayBuffer;
  31370. var need32Bits = false;
  31371. if (indices instanceof Uint16Array) {
  31372. arrayBuffer = indices;
  31373. }
  31374. else {
  31375. //check 32 bit support
  31376. if (this._caps.uintIndices) {
  31377. if (indices instanceof Uint32Array) {
  31378. arrayBuffer = indices;
  31379. need32Bits = true;
  31380. }
  31381. else {
  31382. //number[] or Int32Array, check if 32 bit is necessary
  31383. for (var index = 0; index < indices.length; index++) {
  31384. if (indices[index] > 65535) {
  31385. need32Bits = true;
  31386. break;
  31387. }
  31388. }
  31389. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  31390. }
  31391. }
  31392. else {
  31393. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  31394. arrayBuffer = new Uint16Array(indices);
  31395. }
  31396. }
  31397. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  31398. this._resetIndexBufferBinding();
  31399. dataBuffer.references = 1;
  31400. dataBuffer.is32Bits = need32Bits;
  31401. return dataBuffer;
  31402. };
  31403. /**
  31404. * Bind a webGL buffer to the webGL context
  31405. * @param buffer defines the buffer to bind
  31406. */
  31407. Engine.prototype.bindArrayBuffer = function (buffer) {
  31408. if (!this._vaoRecordInProgress) {
  31409. this._unbindVertexArrayObject();
  31410. }
  31411. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  31412. };
  31413. /**
  31414. * Bind an uniform buffer to the current webGL context
  31415. * @param buffer defines the buffer to bind
  31416. */
  31417. Engine.prototype.bindUniformBuffer = function (buffer) {
  31418. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer ? buffer.underlyingResource : null);
  31419. };
  31420. /**
  31421. * Bind a buffer to the current webGL context at a given location
  31422. * @param buffer defines the buffer to bind
  31423. * @param location defines the index where to bind the buffer
  31424. */
  31425. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  31426. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer ? buffer.underlyingResource : null);
  31427. };
  31428. /**
  31429. * Bind a specific block at a given index in a specific shader program
  31430. * @param pipelineContext defines the pipeline context to use
  31431. * @param blockName defines the block name
  31432. * @param index defines the index where to bind the block
  31433. */
  31434. Engine.prototype.bindUniformBlock = function (pipelineContext, blockName, index) {
  31435. var program = pipelineContext.program;
  31436. var uniformLocation = this._gl.getUniformBlockIndex(program, blockName);
  31437. this._gl.uniformBlockBinding(program, uniformLocation, index);
  31438. };
  31439. Engine.prototype.bindIndexBuffer = function (buffer) {
  31440. if (!this._vaoRecordInProgress) {
  31441. this._unbindVertexArrayObject();
  31442. }
  31443. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  31444. };
  31445. Engine.prototype.bindBuffer = function (buffer, target) {
  31446. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  31447. this._gl.bindBuffer(target, buffer ? buffer.underlyingResource : null);
  31448. this._currentBoundBuffer[target] = buffer;
  31449. }
  31450. };
  31451. /**
  31452. * update the bound buffer with the given data
  31453. * @param data defines the data to update
  31454. */
  31455. Engine.prototype.updateArrayBuffer = function (data) {
  31456. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  31457. };
  31458. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  31459. var pointer = this._currentBufferPointers[indx];
  31460. var changed = false;
  31461. if (!pointer.active) {
  31462. changed = true;
  31463. pointer.active = true;
  31464. pointer.index = indx;
  31465. pointer.size = size;
  31466. pointer.type = type;
  31467. pointer.normalized = normalized;
  31468. pointer.stride = stride;
  31469. pointer.offset = offset;
  31470. pointer.buffer = buffer;
  31471. }
  31472. else {
  31473. if (pointer.buffer !== buffer) {
  31474. pointer.buffer = buffer;
  31475. changed = true;
  31476. }
  31477. if (pointer.size !== size) {
  31478. pointer.size = size;
  31479. changed = true;
  31480. }
  31481. if (pointer.type !== type) {
  31482. pointer.type = type;
  31483. changed = true;
  31484. }
  31485. if (pointer.normalized !== normalized) {
  31486. pointer.normalized = normalized;
  31487. changed = true;
  31488. }
  31489. if (pointer.stride !== stride) {
  31490. pointer.stride = stride;
  31491. changed = true;
  31492. }
  31493. if (pointer.offset !== offset) {
  31494. pointer.offset = offset;
  31495. changed = true;
  31496. }
  31497. }
  31498. if (changed || this._vaoRecordInProgress) {
  31499. this.bindArrayBuffer(buffer);
  31500. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  31501. }
  31502. };
  31503. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  31504. if (indexBuffer == null) {
  31505. return;
  31506. }
  31507. if (this._cachedIndexBuffer !== indexBuffer) {
  31508. this._cachedIndexBuffer = indexBuffer;
  31509. this.bindIndexBuffer(indexBuffer);
  31510. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  31511. }
  31512. };
  31513. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  31514. var attributes = effect.getAttributesNames();
  31515. if (!this._vaoRecordInProgress) {
  31516. this._unbindVertexArrayObject();
  31517. }
  31518. this.unbindAllAttributes();
  31519. for (var index = 0; index < attributes.length; index++) {
  31520. var order = effect.getAttributeLocation(index);
  31521. if (order >= 0) {
  31522. var vertexBuffer = vertexBuffers[attributes[index]];
  31523. if (!vertexBuffer) {
  31524. continue;
  31525. }
  31526. this._gl.enableVertexAttribArray(order);
  31527. if (!this._vaoRecordInProgress) {
  31528. this._vertexAttribArraysEnabled[order] = true;
  31529. }
  31530. var buffer = vertexBuffer.getBuffer();
  31531. if (buffer) {
  31532. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  31533. if (vertexBuffer.getIsInstanced()) {
  31534. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  31535. if (!this._vaoRecordInProgress) {
  31536. this._currentInstanceLocations.push(order);
  31537. this._currentInstanceBuffers.push(buffer);
  31538. }
  31539. }
  31540. }
  31541. }
  31542. }
  31543. };
  31544. /**
  31545. * Records a vertex array object
  31546. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31547. * @param vertexBuffers defines the list of vertex buffers to store
  31548. * @param indexBuffer defines the index buffer to store
  31549. * @param effect defines the effect to store
  31550. * @returns the new vertex array object
  31551. */
  31552. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  31553. var vao = this._gl.createVertexArray();
  31554. this._vaoRecordInProgress = true;
  31555. this._gl.bindVertexArray(vao);
  31556. this._mustWipeVertexAttributes = true;
  31557. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  31558. this.bindIndexBuffer(indexBuffer);
  31559. this._vaoRecordInProgress = false;
  31560. this._gl.bindVertexArray(null);
  31561. return vao;
  31562. };
  31563. /**
  31564. * Bind a specific vertex array object
  31565. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31566. * @param vertexArrayObject defines the vertex array object to bind
  31567. * @param indexBuffer defines the index buffer to bind
  31568. */
  31569. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  31570. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  31571. this._cachedVertexArrayObject = vertexArrayObject;
  31572. this._gl.bindVertexArray(vertexArrayObject);
  31573. this._cachedVertexBuffers = null;
  31574. this._cachedIndexBuffer = null;
  31575. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  31576. this._mustWipeVertexAttributes = true;
  31577. }
  31578. };
  31579. /**
  31580. * Bind webGl buffers directly to the webGL context
  31581. * @param vertexBuffer defines the vertex buffer to bind
  31582. * @param indexBuffer defines the index buffer to bind
  31583. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31584. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31585. * @param effect defines the effect associated with the vertex buffer
  31586. */
  31587. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  31588. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  31589. this._cachedVertexBuffers = vertexBuffer;
  31590. this._cachedEffectForVertexBuffers = effect;
  31591. var attributesCount = effect.getAttributesCount();
  31592. this._unbindVertexArrayObject();
  31593. this.unbindAllAttributes();
  31594. var offset = 0;
  31595. for (var index = 0; index < attributesCount; index++) {
  31596. if (index < vertexDeclaration.length) {
  31597. var order = effect.getAttributeLocation(index);
  31598. if (order >= 0) {
  31599. this._gl.enableVertexAttribArray(order);
  31600. this._vertexAttribArraysEnabled[order] = true;
  31601. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  31602. }
  31603. offset += vertexDeclaration[index] * 4;
  31604. }
  31605. }
  31606. }
  31607. this._bindIndexBufferWithCache(indexBuffer);
  31608. };
  31609. Engine.prototype._unbindVertexArrayObject = function () {
  31610. if (!this._cachedVertexArrayObject) {
  31611. return;
  31612. }
  31613. this._cachedVertexArrayObject = null;
  31614. this._gl.bindVertexArray(null);
  31615. };
  31616. /**
  31617. * Bind a list of vertex buffers to the webGL context
  31618. * @param vertexBuffers defines the list of vertex buffers to bind
  31619. * @param indexBuffer defines the index buffer to bind
  31620. * @param effect defines the effect associated with the vertex buffers
  31621. */
  31622. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  31623. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  31624. this._cachedVertexBuffers = vertexBuffers;
  31625. this._cachedEffectForVertexBuffers = effect;
  31626. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  31627. }
  31628. this._bindIndexBufferWithCache(indexBuffer);
  31629. };
  31630. /**
  31631. * Unbind all instance attributes
  31632. */
  31633. Engine.prototype.unbindInstanceAttributes = function () {
  31634. var boundBuffer;
  31635. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  31636. var instancesBuffer = this._currentInstanceBuffers[i];
  31637. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  31638. boundBuffer = instancesBuffer;
  31639. this.bindArrayBuffer(instancesBuffer);
  31640. }
  31641. var offsetLocation = this._currentInstanceLocations[i];
  31642. this._gl.vertexAttribDivisor(offsetLocation, 0);
  31643. }
  31644. this._currentInstanceBuffers.length = 0;
  31645. this._currentInstanceLocations.length = 0;
  31646. };
  31647. /**
  31648. * Release and free the memory of a vertex array object
  31649. * @param vao defines the vertex array object to delete
  31650. */
  31651. Engine.prototype.releaseVertexArrayObject = function (vao) {
  31652. this._gl.deleteVertexArray(vao);
  31653. };
  31654. /** @hidden */
  31655. Engine.prototype._releaseBuffer = function (buffer) {
  31656. buffer.references--;
  31657. if (buffer.references === 0) {
  31658. this._gl.deleteBuffer(buffer.underlyingResource);
  31659. return true;
  31660. }
  31661. return false;
  31662. };
  31663. /**
  31664. * Creates a webGL buffer to use with instanciation
  31665. * @param capacity defines the size of the buffer
  31666. * @returns the webGL buffer
  31667. */
  31668. Engine.prototype.createInstancesBuffer = function (capacity) {
  31669. var buffer = this._gl.createBuffer();
  31670. if (!buffer) {
  31671. throw new Error("Unable to create instance buffer");
  31672. }
  31673. var result = new _Meshes_WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_19__["WebGLDataBuffer"](buffer);
  31674. result.capacity = capacity;
  31675. this.bindArrayBuffer(result);
  31676. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  31677. return result;
  31678. };
  31679. /**
  31680. * Delete a webGL buffer used with instanciation
  31681. * @param buffer defines the webGL buffer to delete
  31682. */
  31683. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  31684. this._gl.deleteBuffer(buffer);
  31685. };
  31686. /**
  31687. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31688. * @param instancesBuffer defines the webGL buffer to update and bind
  31689. * @param data defines the data to store in the buffer
  31690. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31691. */
  31692. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  31693. this.bindArrayBuffer(instancesBuffer);
  31694. if (data) {
  31695. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  31696. }
  31697. if (offsetLocations[0].index !== undefined) {
  31698. var stride = 0;
  31699. for (var i = 0; i < offsetLocations.length; i++) {
  31700. var ai = offsetLocations[i];
  31701. stride += ai.attributeSize * 4;
  31702. }
  31703. for (var i = 0; i < offsetLocations.length; i++) {
  31704. var ai = offsetLocations[i];
  31705. if (!this._vertexAttribArraysEnabled[ai.index]) {
  31706. this._gl.enableVertexAttribArray(ai.index);
  31707. this._vertexAttribArraysEnabled[ai.index] = true;
  31708. }
  31709. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  31710. this._gl.vertexAttribDivisor(ai.index, 1);
  31711. this._currentInstanceLocations.push(ai.index);
  31712. this._currentInstanceBuffers.push(instancesBuffer);
  31713. }
  31714. }
  31715. else {
  31716. for (var index = 0; index < 4; index++) {
  31717. var offsetLocation = offsetLocations[index];
  31718. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  31719. this._gl.enableVertexAttribArray(offsetLocation);
  31720. this._vertexAttribArraysEnabled[offsetLocation] = true;
  31721. }
  31722. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  31723. this._gl.vertexAttribDivisor(offsetLocation, 1);
  31724. this._currentInstanceLocations.push(offsetLocation);
  31725. this._currentInstanceBuffers.push(instancesBuffer);
  31726. }
  31727. }
  31728. };
  31729. /**
  31730. * Apply all cached states (depth, culling, stencil and alpha)
  31731. */
  31732. Engine.prototype.applyStates = function () {
  31733. this._depthCullingState.apply(this._gl);
  31734. this._stencilState.apply(this._gl);
  31735. this._alphaState.apply(this._gl);
  31736. };
  31737. /**
  31738. * Send a draw order
  31739. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31740. * @param indexStart defines the starting index
  31741. * @param indexCount defines the number of index to draw
  31742. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31743. */
  31744. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  31745. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  31746. };
  31747. /**
  31748. * Draw a list of points
  31749. * @param verticesStart defines the index of first vertex to draw
  31750. * @param verticesCount defines the count of vertices to draw
  31751. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31752. */
  31753. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  31754. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  31755. };
  31756. /**
  31757. * Draw a list of unindexed primitives
  31758. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31759. * @param verticesStart defines the index of first vertex to draw
  31760. * @param verticesCount defines the count of vertices to draw
  31761. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31762. */
  31763. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  31764. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  31765. };
  31766. /**
  31767. * Draw a list of indexed primitives
  31768. * @param fillMode defines the primitive to use
  31769. * @param indexStart defines the starting index
  31770. * @param indexCount defines the number of index to draw
  31771. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31772. */
  31773. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  31774. // Apply states
  31775. this.applyStates();
  31776. this._drawCalls.addCount(1, false);
  31777. // Render
  31778. var drawMode = this._drawMode(fillMode);
  31779. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  31780. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  31781. if (instancesCount) {
  31782. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  31783. }
  31784. else {
  31785. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  31786. }
  31787. };
  31788. /**
  31789. * Draw a list of unindexed primitives
  31790. * @param fillMode defines the primitive to use
  31791. * @param verticesStart defines the index of first vertex to draw
  31792. * @param verticesCount defines the count of vertices to draw
  31793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31794. */
  31795. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  31796. // Apply states
  31797. this.applyStates();
  31798. this._drawCalls.addCount(1, false);
  31799. var drawMode = this._drawMode(fillMode);
  31800. if (instancesCount) {
  31801. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  31802. }
  31803. else {
  31804. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  31805. }
  31806. };
  31807. Engine.prototype._drawMode = function (fillMode) {
  31808. switch (fillMode) {
  31809. // Triangle views
  31810. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  31811. return this._gl.TRIANGLES;
  31812. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  31813. return this._gl.POINTS;
  31814. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  31815. return this._gl.LINES;
  31816. // Draw modes
  31817. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  31818. return this._gl.POINTS;
  31819. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  31820. return this._gl.LINES;
  31821. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  31822. return this._gl.LINE_LOOP;
  31823. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  31824. return this._gl.LINE_STRIP;
  31825. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  31826. return this._gl.TRIANGLE_STRIP;
  31827. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  31828. return this._gl.TRIANGLE_FAN;
  31829. default:
  31830. return this._gl.TRIANGLES;
  31831. }
  31832. };
  31833. // Shaders
  31834. /** @hidden */
  31835. Engine.prototype._releaseEffect = function (effect) {
  31836. if (this._compiledEffects[effect._key]) {
  31837. delete this._compiledEffects[effect._key];
  31838. this._deletePipelineContext(effect.getPipelineContext());
  31839. }
  31840. };
  31841. /** @hidden */
  31842. Engine.prototype._deletePipelineContext = function (pipelineContext) {
  31843. var webGLPipelineContext = pipelineContext;
  31844. if (webGLPipelineContext && webGLPipelineContext.program) {
  31845. webGLPipelineContext.program.__SPECTOR_rebuildProgram = null;
  31846. if (webGLPipelineContext.transformFeedback) {
  31847. this.deleteTransformFeedback(webGLPipelineContext.transformFeedback);
  31848. webGLPipelineContext.transformFeedback = null;
  31849. }
  31850. this._gl.deleteProgram(webGLPipelineContext.program);
  31851. }
  31852. };
  31853. /**
  31854. * Create a new effect (used to store vertex/fragment shaders)
  31855. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31856. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31857. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31858. * @param samplers defines an array of string used to represent textures
  31859. * @param defines defines the string containing the defines to use to compile the shaders
  31860. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31861. * @param onCompiled defines a function to call when the effect creation is successful
  31862. * @param onError defines a function to call when the effect creation has failed
  31863. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31864. * @returns the new Effect
  31865. */
  31866. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  31867. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  31868. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  31869. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  31870. if (this._compiledEffects[name]) {
  31871. var compiledEffect = this._compiledEffects[name];
  31872. if (onCompiled && compiledEffect.isReady()) {
  31873. onCompiled(compiledEffect);
  31874. }
  31875. return compiledEffect;
  31876. }
  31877. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  31878. effect._key = name;
  31879. this._compiledEffects[name] = effect;
  31880. return effect;
  31881. };
  31882. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  31883. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  31884. };
  31885. Engine.prototype._compileRawShader = function (source, type) {
  31886. var gl = this._gl;
  31887. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  31888. if (!shader) {
  31889. throw new Error("Something went wrong while compile the shader.");
  31890. }
  31891. gl.shaderSource(shader, source);
  31892. gl.compileShader(shader);
  31893. return shader;
  31894. };
  31895. /**
  31896. * Directly creates a webGL program
  31897. * @param pipelineContext defines the pipeline context to attach to
  31898. * @param vertexCode defines the vertex shader code to use
  31899. * @param fragmentCode defines the fragment shader code to use
  31900. * @param context defines the webGL context to use (if not set, the current one will be used)
  31901. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31902. * @returns the new webGL program
  31903. */
  31904. Engine.prototype.createRawShaderProgram = function (pipelineContext, vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  31905. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  31906. context = context || this._gl;
  31907. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  31908. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  31909. return this._createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings);
  31910. };
  31911. /**
  31912. * Creates a webGL program
  31913. * @param pipelineContext defines the pipeline context to attach to
  31914. * @param vertexCode defines the vertex shader code to use
  31915. * @param fragmentCode defines the fragment shader code to use
  31916. * @param defines defines the string containing the defines to use to compile the shaders
  31917. * @param context defines the webGL context to use (if not set, the current one will be used)
  31918. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31919. * @returns the new webGL program
  31920. */
  31921. Engine.prototype.createShaderProgram = function (pipelineContext, vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  31922. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  31923. context = context || this._gl;
  31924. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  31925. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  31926. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  31927. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  31928. var program = this._createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings);
  31929. this.onAfterShaderCompilationObservable.notifyObservers(this);
  31930. return program;
  31931. };
  31932. /**
  31933. * Creates a new pipeline context
  31934. * @returns the new pipeline
  31935. */
  31936. Engine.prototype.createPipelineContext = function () {
  31937. var pipelineContext = new _WebGL_webGLPipelineContext__WEBPACK_IMPORTED_MODULE_18__["WebGLPipelineContext"]();
  31938. pipelineContext.engine = this;
  31939. if (this._caps.parallelShaderCompile) {
  31940. pipelineContext.isParallelCompiled = true;
  31941. }
  31942. return pipelineContext;
  31943. };
  31944. Engine.prototype._createShaderProgram = function (pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  31945. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  31946. var shaderProgram = context.createProgram();
  31947. pipelineContext.program = shaderProgram;
  31948. if (!shaderProgram) {
  31949. throw new Error("Unable to create program");
  31950. }
  31951. context.attachShader(shaderProgram, vertexShader);
  31952. context.attachShader(shaderProgram, fragmentShader);
  31953. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  31954. var transformFeedback = this.createTransformFeedback();
  31955. this.bindTransformFeedback(transformFeedback);
  31956. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  31957. pipelineContext.transformFeedback = transformFeedback;
  31958. }
  31959. context.linkProgram(shaderProgram);
  31960. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  31961. this.bindTransformFeedback(null);
  31962. }
  31963. pipelineContext.context = context;
  31964. pipelineContext.vertexShader = vertexShader;
  31965. pipelineContext.fragmentShader = fragmentShader;
  31966. if (!pipelineContext.isParallelCompiled) {
  31967. this._finalizePipelineContext(pipelineContext);
  31968. }
  31969. return shaderProgram;
  31970. };
  31971. Engine.prototype._finalizePipelineContext = function (pipelineContext) {
  31972. var context = pipelineContext.context;
  31973. var vertexShader = pipelineContext.vertexShader;
  31974. var fragmentShader = pipelineContext.fragmentShader;
  31975. var program = pipelineContext.program;
  31976. var linked = context.getProgramParameter(program, context.LINK_STATUS);
  31977. if (!linked) { // Get more info
  31978. // Vertex
  31979. if (!this._gl.getShaderParameter(vertexShader, this._gl.COMPILE_STATUS)) {
  31980. var log = this._gl.getShaderInfoLog(vertexShader);
  31981. if (log) {
  31982. throw new Error(log);
  31983. }
  31984. }
  31985. // Fragment
  31986. if (!this._gl.getShaderParameter(fragmentShader, this._gl.COMPILE_STATUS)) {
  31987. var log = this._gl.getShaderInfoLog(fragmentShader);
  31988. if (log) {
  31989. throw new Error(log);
  31990. }
  31991. }
  31992. var error = context.getProgramInfoLog(program);
  31993. if (error) {
  31994. throw new Error(error);
  31995. }
  31996. }
  31997. if (this.validateShaderPrograms) {
  31998. context.validateProgram(program);
  31999. var validated = context.getProgramParameter(program, context.VALIDATE_STATUS);
  32000. if (!validated) {
  32001. var error = context.getProgramInfoLog(program);
  32002. if (error) {
  32003. throw new Error(error);
  32004. }
  32005. }
  32006. }
  32007. context.deleteShader(vertexShader);
  32008. context.deleteShader(fragmentShader);
  32009. pipelineContext.vertexShader = undefined;
  32010. pipelineContext.fragmentShader = undefined;
  32011. if (pipelineContext.onCompiled) {
  32012. pipelineContext.onCompiled();
  32013. pipelineContext.onCompiled = undefined;
  32014. }
  32015. };
  32016. /** @hidden */
  32017. Engine.prototype._preparePipelineContext = function (pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rebuildRebind, defines, transformFeedbackVaryings) {
  32018. var webGLRenderingState = pipelineContext;
  32019. if (createAsRaw) {
  32020. webGLRenderingState.program = this.createRawShaderProgram(webGLRenderingState, vertexSourceCode, fragmentSourceCode, undefined, transformFeedbackVaryings);
  32021. }
  32022. else {
  32023. webGLRenderingState.program = this.createShaderProgram(webGLRenderingState, vertexSourceCode, fragmentSourceCode, defines, undefined, transformFeedbackVaryings);
  32024. }
  32025. webGLRenderingState.program.__SPECTOR_rebuildProgram = rebuildRebind;
  32026. };
  32027. /** @hidden */
  32028. Engine.prototype._isRenderingStateCompiled = function (pipelineContext) {
  32029. var webGLPipelineContext = pipelineContext;
  32030. if (this._gl.getProgramParameter(webGLPipelineContext.program, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  32031. this._finalizePipelineContext(webGLPipelineContext);
  32032. return true;
  32033. }
  32034. return false;
  32035. };
  32036. /** @hidden */
  32037. Engine.prototype._executeWhenRenderingStateIsCompiled = function (pipelineContext, action) {
  32038. var webGLPipelineContext = pipelineContext;
  32039. if (!webGLPipelineContext.isParallelCompiled) {
  32040. action();
  32041. return;
  32042. }
  32043. webGLPipelineContext.onCompiled = action;
  32044. };
  32045. /**
  32046. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32047. * @param pipelineContext defines the pipeline context to use
  32048. * @param uniformsNames defines the list of uniform names
  32049. * @returns an array of webGL uniform locations
  32050. */
  32051. Engine.prototype.getUniforms = function (pipelineContext, uniformsNames) {
  32052. var results = new Array();
  32053. var webGLPipelineContext = pipelineContext;
  32054. for (var index = 0; index < uniformsNames.length; index++) {
  32055. results.push(this._gl.getUniformLocation(webGLPipelineContext.program, uniformsNames[index]));
  32056. }
  32057. return results;
  32058. };
  32059. /**
  32060. * Gets the lsit of active attributes for a given webGL program
  32061. * @param pipelineContext defines the pipeline context to use
  32062. * @param attributesNames defines the list of attribute names to get
  32063. * @returns an array of indices indicating the offset of each attribute
  32064. */
  32065. Engine.prototype.getAttributes = function (pipelineContext, attributesNames) {
  32066. var results = [];
  32067. var webGLPipelineContext = pipelineContext;
  32068. for (var index = 0; index < attributesNames.length; index++) {
  32069. try {
  32070. results.push(this._gl.getAttribLocation(webGLPipelineContext.program, attributesNames[index]));
  32071. }
  32072. catch (e) {
  32073. results.push(-1);
  32074. }
  32075. }
  32076. return results;
  32077. };
  32078. /**
  32079. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32080. * @param effect defines the effect to activate
  32081. */
  32082. Engine.prototype.enableEffect = function (effect) {
  32083. if (!effect || effect === this._currentEffect) {
  32084. return;
  32085. }
  32086. // Use program
  32087. this.bindSamplers(effect);
  32088. this._currentEffect = effect;
  32089. if (effect.onBind) {
  32090. effect.onBind(effect);
  32091. }
  32092. if (effect._onBindObservable) {
  32093. effect._onBindObservable.notifyObservers(effect);
  32094. }
  32095. };
  32096. /**
  32097. * Set the value of an uniform to an array of int32
  32098. * @param uniform defines the webGL uniform location where to store the value
  32099. * @param array defines the array of int32 to store
  32100. */
  32101. Engine.prototype.setIntArray = function (uniform, array) {
  32102. if (!uniform) {
  32103. return;
  32104. }
  32105. this._gl.uniform1iv(uniform, array);
  32106. };
  32107. /**
  32108. * Set the value of an uniform to an array of int32 (stored as vec2)
  32109. * @param uniform defines the webGL uniform location where to store the value
  32110. * @param array defines the array of int32 to store
  32111. */
  32112. Engine.prototype.setIntArray2 = function (uniform, array) {
  32113. if (!uniform || array.length % 2 !== 0) {
  32114. return;
  32115. }
  32116. this._gl.uniform2iv(uniform, array);
  32117. };
  32118. /**
  32119. * Set the value of an uniform to an array of int32 (stored as vec3)
  32120. * @param uniform defines the webGL uniform location where to store the value
  32121. * @param array defines the array of int32 to store
  32122. */
  32123. Engine.prototype.setIntArray3 = function (uniform, array) {
  32124. if (!uniform || array.length % 3 !== 0) {
  32125. return;
  32126. }
  32127. this._gl.uniform3iv(uniform, array);
  32128. };
  32129. /**
  32130. * Set the value of an uniform to an array of int32 (stored as vec4)
  32131. * @param uniform defines the webGL uniform location where to store the value
  32132. * @param array defines the array of int32 to store
  32133. */
  32134. Engine.prototype.setIntArray4 = function (uniform, array) {
  32135. if (!uniform || array.length % 4 !== 0) {
  32136. return;
  32137. }
  32138. this._gl.uniform4iv(uniform, array);
  32139. };
  32140. /**
  32141. * Set the value of an uniform to an array of float32
  32142. * @param uniform defines the webGL uniform location where to store the value
  32143. * @param array defines the array of float32 to store
  32144. */
  32145. Engine.prototype.setFloatArray = function (uniform, array) {
  32146. if (!uniform) {
  32147. return;
  32148. }
  32149. this._gl.uniform1fv(uniform, array);
  32150. };
  32151. /**
  32152. * Set the value of an uniform to an array of float32 (stored as vec2)
  32153. * @param uniform defines the webGL uniform location where to store the value
  32154. * @param array defines the array of float32 to store
  32155. */
  32156. Engine.prototype.setFloatArray2 = function (uniform, array) {
  32157. if (!uniform || array.length % 2 !== 0) {
  32158. return;
  32159. }
  32160. this._gl.uniform2fv(uniform, array);
  32161. };
  32162. /**
  32163. * Set the value of an uniform to an array of float32 (stored as vec3)
  32164. * @param uniform defines the webGL uniform location where to store the value
  32165. * @param array defines the array of float32 to store
  32166. */
  32167. Engine.prototype.setFloatArray3 = function (uniform, array) {
  32168. if (!uniform || array.length % 3 !== 0) {
  32169. return;
  32170. }
  32171. this._gl.uniform3fv(uniform, array);
  32172. };
  32173. /**
  32174. * Set the value of an uniform to an array of float32 (stored as vec4)
  32175. * @param uniform defines the webGL uniform location where to store the value
  32176. * @param array defines the array of float32 to store
  32177. */
  32178. Engine.prototype.setFloatArray4 = function (uniform, array) {
  32179. if (!uniform || array.length % 4 !== 0) {
  32180. return;
  32181. }
  32182. this._gl.uniform4fv(uniform, array);
  32183. };
  32184. /**
  32185. * Set the value of an uniform to an array of number
  32186. * @param uniform defines the webGL uniform location where to store the value
  32187. * @param array defines the array of number to store
  32188. */
  32189. Engine.prototype.setArray = function (uniform, array) {
  32190. if (!uniform) {
  32191. return;
  32192. }
  32193. this._gl.uniform1fv(uniform, array);
  32194. };
  32195. /**
  32196. * Set the value of an uniform to an array of number (stored as vec2)
  32197. * @param uniform defines the webGL uniform location where to store the value
  32198. * @param array defines the array of number to store
  32199. */
  32200. Engine.prototype.setArray2 = function (uniform, array) {
  32201. if (!uniform || array.length % 2 !== 0) {
  32202. return;
  32203. }
  32204. this._gl.uniform2fv(uniform, array);
  32205. };
  32206. /**
  32207. * Set the value of an uniform to an array of number (stored as vec3)
  32208. * @param uniform defines the webGL uniform location where to store the value
  32209. * @param array defines the array of number to store
  32210. */
  32211. Engine.prototype.setArray3 = function (uniform, array) {
  32212. if (!uniform || array.length % 3 !== 0) {
  32213. return;
  32214. }
  32215. this._gl.uniform3fv(uniform, array);
  32216. };
  32217. /**
  32218. * Set the value of an uniform to an array of number (stored as vec4)
  32219. * @param uniform defines the webGL uniform location where to store the value
  32220. * @param array defines the array of number to store
  32221. */
  32222. Engine.prototype.setArray4 = function (uniform, array) {
  32223. if (!uniform || array.length % 4 !== 0) {
  32224. return;
  32225. }
  32226. this._gl.uniform4fv(uniform, array);
  32227. };
  32228. /**
  32229. * Set the value of an uniform to an array of float32 (stored as matrices)
  32230. * @param uniform defines the webGL uniform location where to store the value
  32231. * @param matrices defines the array of float32 to store
  32232. */
  32233. Engine.prototype.setMatrices = function (uniform, matrices) {
  32234. if (!uniform) {
  32235. return;
  32236. }
  32237. this._gl.uniformMatrix4fv(uniform, false, matrices);
  32238. };
  32239. /**
  32240. * Set the value of an uniform to a matrix
  32241. * @param uniform defines the webGL uniform location where to store the value
  32242. * @param matrix defines the matrix to store
  32243. */
  32244. Engine.prototype.setMatrix = function (uniform, matrix) {
  32245. if (!uniform) {
  32246. return;
  32247. }
  32248. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  32249. };
  32250. /**
  32251. * Set the value of an uniform to a matrix (3x3)
  32252. * @param uniform defines the webGL uniform location where to store the value
  32253. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32254. */
  32255. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  32256. if (!uniform) {
  32257. return;
  32258. }
  32259. this._gl.uniformMatrix3fv(uniform, false, matrix);
  32260. };
  32261. /**
  32262. * Set the value of an uniform to a matrix (2x2)
  32263. * @param uniform defines the webGL uniform location where to store the value
  32264. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32265. */
  32266. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  32267. if (!uniform) {
  32268. return;
  32269. }
  32270. this._gl.uniformMatrix2fv(uniform, false, matrix);
  32271. };
  32272. /**
  32273. * Set the value of an uniform to a number (int)
  32274. * @param uniform defines the webGL uniform location where to store the value
  32275. * @param value defines the int number to store
  32276. */
  32277. Engine.prototype.setInt = function (uniform, value) {
  32278. if (!uniform) {
  32279. return;
  32280. }
  32281. this._gl.uniform1i(uniform, value);
  32282. };
  32283. /**
  32284. * Set the value of an uniform to a number (float)
  32285. * @param uniform defines the webGL uniform location where to store the value
  32286. * @param value defines the float number to store
  32287. */
  32288. Engine.prototype.setFloat = function (uniform, value) {
  32289. if (!uniform) {
  32290. return;
  32291. }
  32292. this._gl.uniform1f(uniform, value);
  32293. };
  32294. /**
  32295. * Set the value of an uniform to a vec2
  32296. * @param uniform defines the webGL uniform location where to store the value
  32297. * @param x defines the 1st component of the value
  32298. * @param y defines the 2nd component of the value
  32299. */
  32300. Engine.prototype.setFloat2 = function (uniform, x, y) {
  32301. if (!uniform) {
  32302. return;
  32303. }
  32304. this._gl.uniform2f(uniform, x, y);
  32305. };
  32306. /**
  32307. * Set the value of an uniform to a vec3
  32308. * @param uniform defines the webGL uniform location where to store the value
  32309. * @param x defines the 1st component of the value
  32310. * @param y defines the 2nd component of the value
  32311. * @param z defines the 3rd component of the value
  32312. */
  32313. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  32314. if (!uniform) {
  32315. return;
  32316. }
  32317. this._gl.uniform3f(uniform, x, y, z);
  32318. };
  32319. /**
  32320. * Set the value of an uniform to a boolean
  32321. * @param uniform defines the webGL uniform location where to store the value
  32322. * @param bool defines the boolean to store
  32323. */
  32324. Engine.prototype.setBool = function (uniform, bool) {
  32325. if (!uniform) {
  32326. return;
  32327. }
  32328. this._gl.uniform1i(uniform, bool);
  32329. };
  32330. /**
  32331. * Set the value of an uniform to a vec4
  32332. * @param uniform defines the webGL uniform location where to store the value
  32333. * @param x defines the 1st component of the value
  32334. * @param y defines the 2nd component of the value
  32335. * @param z defines the 3rd component of the value
  32336. * @param w defines the 4th component of the value
  32337. */
  32338. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  32339. if (!uniform) {
  32340. return;
  32341. }
  32342. this._gl.uniform4f(uniform, x, y, z, w);
  32343. };
  32344. /**
  32345. * Set the value of an uniform to a Color3
  32346. * @param uniform defines the webGL uniform location where to store the value
  32347. * @param color3 defines the color to store
  32348. */
  32349. Engine.prototype.setColor3 = function (uniform, color3) {
  32350. if (!uniform) {
  32351. return;
  32352. }
  32353. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  32354. };
  32355. /**
  32356. * Set the value of an uniform to a Color3 and an alpha value
  32357. * @param uniform defines the webGL uniform location where to store the value
  32358. * @param color3 defines the color to store
  32359. * @param alpha defines the alpha component to store
  32360. */
  32361. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  32362. if (!uniform) {
  32363. return;
  32364. }
  32365. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  32366. };
  32367. /**
  32368. * Sets a Color4 on a uniform variable
  32369. * @param uniform defines the uniform location
  32370. * @param color4 defines the value to be set
  32371. */
  32372. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  32373. if (!uniform) {
  32374. return;
  32375. }
  32376. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  32377. };
  32378. // States
  32379. /**
  32380. * Set various states to the webGL context
  32381. * @param culling defines backface culling state
  32382. * @param zOffset defines the value to apply to zOffset (0 by default)
  32383. * @param force defines if states must be applied even if cache is up to date
  32384. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32385. */
  32386. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  32387. if (zOffset === void 0) { zOffset = 0; }
  32388. if (reverseSide === void 0) { reverseSide = false; }
  32389. // Culling
  32390. if (this._depthCullingState.cull !== culling || force) {
  32391. this._depthCullingState.cull = culling;
  32392. }
  32393. // Cull face
  32394. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  32395. if (this._depthCullingState.cullFace !== cullFace || force) {
  32396. this._depthCullingState.cullFace = cullFace;
  32397. }
  32398. // Z offset
  32399. this.setZOffset(zOffset);
  32400. // Front face
  32401. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  32402. if (this._depthCullingState.frontFace !== frontFace || force) {
  32403. this._depthCullingState.frontFace = frontFace;
  32404. }
  32405. };
  32406. /**
  32407. * Set the z offset to apply to current rendering
  32408. * @param value defines the offset to apply
  32409. */
  32410. Engine.prototype.setZOffset = function (value) {
  32411. this._depthCullingState.zOffset = value;
  32412. };
  32413. /**
  32414. * Gets the current value of the zOffset
  32415. * @returns the current zOffset state
  32416. */
  32417. Engine.prototype.getZOffset = function () {
  32418. return this._depthCullingState.zOffset;
  32419. };
  32420. /**
  32421. * Enable or disable depth buffering
  32422. * @param enable defines the state to set
  32423. */
  32424. Engine.prototype.setDepthBuffer = function (enable) {
  32425. this._depthCullingState.depthTest = enable;
  32426. };
  32427. /**
  32428. * Gets a boolean indicating if depth writing is enabled
  32429. * @returns the current depth writing state
  32430. */
  32431. Engine.prototype.getDepthWrite = function () {
  32432. return this._depthCullingState.depthMask;
  32433. };
  32434. /**
  32435. * Enable or disable depth writing
  32436. * @param enable defines the state to set
  32437. */
  32438. Engine.prototype.setDepthWrite = function (enable) {
  32439. this._depthCullingState.depthMask = enable;
  32440. };
  32441. /**
  32442. * Enable or disable color writing
  32443. * @param enable defines the state to set
  32444. */
  32445. Engine.prototype.setColorWrite = function (enable) {
  32446. this._gl.colorMask(enable, enable, enable, enable);
  32447. this._colorWrite = enable;
  32448. };
  32449. /**
  32450. * Gets a boolean indicating if color writing is enabled
  32451. * @returns the current color writing state
  32452. */
  32453. Engine.prototype.getColorWrite = function () {
  32454. return this._colorWrite;
  32455. };
  32456. /**
  32457. * Sets alpha constants used by some alpha blending modes
  32458. * @param r defines the red component
  32459. * @param g defines the green component
  32460. * @param b defines the blue component
  32461. * @param a defines the alpha component
  32462. */
  32463. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  32464. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  32465. };
  32466. /**
  32467. * Sets the current alpha mode
  32468. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32469. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32470. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32471. */
  32472. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  32473. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  32474. if (this._alphaMode === mode) {
  32475. return;
  32476. }
  32477. switch (mode) {
  32478. case Engine.ALPHA_DISABLE:
  32479. this._alphaState.alphaBlend = false;
  32480. break;
  32481. case Engine.ALPHA_PREMULTIPLIED:
  32482. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  32483. this._alphaState.alphaBlend = true;
  32484. break;
  32485. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  32486. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  32487. this._alphaState.alphaBlend = true;
  32488. break;
  32489. case Engine.ALPHA_COMBINE:
  32490. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  32491. this._alphaState.alphaBlend = true;
  32492. break;
  32493. case Engine.ALPHA_ONEONE:
  32494. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  32495. this._alphaState.alphaBlend = true;
  32496. break;
  32497. case Engine.ALPHA_ADD:
  32498. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  32499. this._alphaState.alphaBlend = true;
  32500. break;
  32501. case Engine.ALPHA_SUBTRACT:
  32502. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  32503. this._alphaState.alphaBlend = true;
  32504. break;
  32505. case Engine.ALPHA_MULTIPLY:
  32506. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  32507. this._alphaState.alphaBlend = true;
  32508. break;
  32509. case Engine.ALPHA_MAXIMIZED:
  32510. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  32511. this._alphaState.alphaBlend = true;
  32512. break;
  32513. case Engine.ALPHA_INTERPOLATE:
  32514. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  32515. this._alphaState.alphaBlend = true;
  32516. break;
  32517. case Engine.ALPHA_SCREENMODE:
  32518. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  32519. this._alphaState.alphaBlend = true;
  32520. break;
  32521. }
  32522. if (!noDepthWriteChange) {
  32523. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  32524. }
  32525. this._alphaMode = mode;
  32526. };
  32527. /**
  32528. * Gets the current alpha mode
  32529. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32530. * @returns the current alpha mode
  32531. */
  32532. Engine.prototype.getAlphaMode = function () {
  32533. return this._alphaMode;
  32534. };
  32535. // Textures
  32536. /**
  32537. * Clears the list of texture accessible through engine.
  32538. * This can help preventing texture load conflict due to name collision.
  32539. */
  32540. Engine.prototype.clearInternalTexturesCache = function () {
  32541. this._internalTexturesCache = [];
  32542. };
  32543. /**
  32544. * Force the entire cache to be cleared
  32545. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32546. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32547. */
  32548. Engine.prototype.wipeCaches = function (bruteForce) {
  32549. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  32550. return;
  32551. }
  32552. this._currentEffect = null;
  32553. this._viewportCached.x = 0;
  32554. this._viewportCached.y = 0;
  32555. this._viewportCached.z = 0;
  32556. this._viewportCached.w = 0;
  32557. if (bruteForce) {
  32558. this.resetTextureCache();
  32559. this._currentProgram = null;
  32560. this._stencilState.reset();
  32561. this._depthCullingState.reset();
  32562. this.setDepthFunctionToLessOrEqual();
  32563. this._alphaState.reset();
  32564. this._unpackFlipYCached = null;
  32565. }
  32566. this._resetVertexBufferBinding();
  32567. this._cachedIndexBuffer = null;
  32568. this._cachedEffectForVertexBuffers = null;
  32569. this._unbindVertexArrayObject();
  32570. this.bindIndexBuffer(null);
  32571. };
  32572. /**
  32573. * Set the compressed texture format to use, based on the formats you have, and the formats
  32574. * supported by the hardware / browser.
  32575. *
  32576. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32577. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32578. * to API arguments needed to compressed textures. This puts the burden on the container
  32579. * generator to house the arcane code for determining these for current & future formats.
  32580. *
  32581. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32582. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32583. *
  32584. * Note: The result of this call is not taken into account when a texture is base64.
  32585. *
  32586. * @param formatsAvailable defines the list of those format families you have created
  32587. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32588. *
  32589. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32590. * @returns The extension selected.
  32591. */
  32592. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  32593. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  32594. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  32595. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  32596. return this._textureFormatInUse = this._texturesSupported[i];
  32597. }
  32598. }
  32599. }
  32600. // actively set format to nothing, to allow this to be called more than once
  32601. // and possibly fail the 2nd time
  32602. this._textureFormatInUse = null;
  32603. return null;
  32604. };
  32605. /** @hidden */
  32606. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  32607. var gl = this._gl;
  32608. var magFilter = gl.NEAREST;
  32609. var minFilter = gl.NEAREST;
  32610. switch (samplingMode) {
  32611. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  32612. magFilter = gl.LINEAR;
  32613. if (generateMipMaps) {
  32614. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  32615. }
  32616. else {
  32617. minFilter = gl.LINEAR;
  32618. }
  32619. break;
  32620. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  32621. magFilter = gl.LINEAR;
  32622. if (generateMipMaps) {
  32623. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  32624. }
  32625. else {
  32626. minFilter = gl.LINEAR;
  32627. }
  32628. break;
  32629. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  32630. magFilter = gl.NEAREST;
  32631. if (generateMipMaps) {
  32632. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  32633. }
  32634. else {
  32635. minFilter = gl.NEAREST;
  32636. }
  32637. break;
  32638. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  32639. magFilter = gl.NEAREST;
  32640. if (generateMipMaps) {
  32641. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  32642. }
  32643. else {
  32644. minFilter = gl.NEAREST;
  32645. }
  32646. break;
  32647. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  32648. magFilter = gl.NEAREST;
  32649. if (generateMipMaps) {
  32650. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  32651. }
  32652. else {
  32653. minFilter = gl.LINEAR;
  32654. }
  32655. break;
  32656. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  32657. magFilter = gl.NEAREST;
  32658. if (generateMipMaps) {
  32659. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  32660. }
  32661. else {
  32662. minFilter = gl.LINEAR;
  32663. }
  32664. break;
  32665. case Engine.TEXTURE_NEAREST_LINEAR:
  32666. magFilter = gl.NEAREST;
  32667. minFilter = gl.LINEAR;
  32668. break;
  32669. case Engine.TEXTURE_NEAREST_NEAREST:
  32670. magFilter = gl.NEAREST;
  32671. minFilter = gl.NEAREST;
  32672. break;
  32673. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  32674. magFilter = gl.LINEAR;
  32675. if (generateMipMaps) {
  32676. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  32677. }
  32678. else {
  32679. minFilter = gl.NEAREST;
  32680. }
  32681. break;
  32682. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  32683. magFilter = gl.LINEAR;
  32684. if (generateMipMaps) {
  32685. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  32686. }
  32687. else {
  32688. minFilter = gl.NEAREST;
  32689. }
  32690. break;
  32691. case Engine.TEXTURE_LINEAR_LINEAR:
  32692. magFilter = gl.LINEAR;
  32693. minFilter = gl.LINEAR;
  32694. break;
  32695. case Engine.TEXTURE_LINEAR_NEAREST:
  32696. magFilter = gl.LINEAR;
  32697. minFilter = gl.NEAREST;
  32698. break;
  32699. }
  32700. return {
  32701. min: minFilter,
  32702. mag: magFilter
  32703. };
  32704. };
  32705. /** @hidden */
  32706. Engine.prototype._createTexture = function () {
  32707. var texture = this._gl.createTexture();
  32708. if (!texture) {
  32709. throw new Error("Unable to create texture");
  32710. }
  32711. return texture;
  32712. };
  32713. /**
  32714. * Usually called from Texture.ts.
  32715. * Passed information to create a WebGLTexture
  32716. * @param urlArg defines a value which contains one of the following:
  32717. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32718. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32719. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32720. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32721. * @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)
  32722. * @param scene needed for loading to the correct scene
  32723. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32724. * @param onLoad optional callback to be called upon successful completion
  32725. * @param onError optional callback to be called upon failure
  32726. * @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
  32727. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32728. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32729. * @param forcedExtension defines the extension to use to pick the right loader
  32730. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32731. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32732. */
  32733. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  32734. var _this = this;
  32735. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32736. if (onLoad === void 0) { onLoad = null; }
  32737. if (onError === void 0) { onError = null; }
  32738. if (buffer === void 0) { buffer = null; }
  32739. if (fallback === void 0) { fallback = null; }
  32740. if (format === void 0) { format = null; }
  32741. if (forcedExtension === void 0) { forcedExtension = null; }
  32742. if (excludeLoaders === void 0) { excludeLoaders = []; }
  32743. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  32744. var fromData = url.substr(0, 5) === "data:";
  32745. var fromBlob = url.substr(0, 5) === "blob:";
  32746. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  32747. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_URL);
  32748. // establish the file extension, if possible
  32749. var lastDot = url.lastIndexOf('.');
  32750. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  32751. var loader = null;
  32752. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  32753. var availableLoader = _a[_i];
  32754. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  32755. loader = availableLoader;
  32756. break;
  32757. }
  32758. }
  32759. if (loader) {
  32760. url = loader.transformUrl(url, this._textureFormatInUse);
  32761. }
  32762. if (scene) {
  32763. scene._addPendingData(texture);
  32764. }
  32765. texture.url = url;
  32766. texture.generateMipMaps = !noMipmap;
  32767. texture.samplingMode = samplingMode;
  32768. texture.invertY = invertY;
  32769. if (!this._doNotHandleContextLost) {
  32770. // Keep a link to the buffer only if we plan to handle context lost
  32771. texture._buffer = buffer;
  32772. }
  32773. var onLoadObserver = null;
  32774. if (onLoad && !fallback) {
  32775. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  32776. }
  32777. if (!fallback) {
  32778. this._internalTexturesCache.push(texture);
  32779. }
  32780. var onInternalError = function (message, exception) {
  32781. if (scene) {
  32782. scene._removePendingData(texture);
  32783. }
  32784. var customFallback = false;
  32785. if (loader) {
  32786. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  32787. if (fallbackUrl) {
  32788. // Add Back
  32789. customFallback = true;
  32790. excludeLoaders.push(loader);
  32791. _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");
  32792. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  32793. }
  32794. }
  32795. if (!customFallback) {
  32796. if (onLoadObserver) {
  32797. texture.onLoadedObservable.remove(onLoadObserver);
  32798. }
  32799. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  32800. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  32801. }
  32802. }
  32803. if (onError) {
  32804. onError(message || "Unknown error", exception);
  32805. }
  32806. };
  32807. // processing for non-image formats
  32808. if (loader) {
  32809. var callback = function (data) {
  32810. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  32811. if (loadFailed) {
  32812. onInternalError("TextureLoader failed to load data");
  32813. }
  32814. else {
  32815. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  32816. done();
  32817. return false;
  32818. }, samplingMode);
  32819. }
  32820. });
  32821. };
  32822. if (!buffer) {
  32823. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  32824. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  32825. });
  32826. }
  32827. else {
  32828. callback(buffer);
  32829. }
  32830. }
  32831. else {
  32832. var onload = function (img) {
  32833. if (fromBlob && !_this._doNotHandleContextLost) {
  32834. // We need to store the image if we need to rebuild the texture
  32835. // in case of a webgl context lost
  32836. texture._buffer = img;
  32837. }
  32838. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  32839. var gl = _this._gl;
  32840. var isPot = (img.width === potWidth && img.height === potHeight);
  32841. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  32842. if (isPot) {
  32843. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  32844. return false;
  32845. }
  32846. var maxTextureSize = _this._caps.maxTextureSize;
  32847. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  32848. _this._prepareWorkingCanvas();
  32849. if (!_this._workingCanvas || !_this._workingContext) {
  32850. return false;
  32851. }
  32852. _this._workingCanvas.width = potWidth;
  32853. _this._workingCanvas.height = potHeight;
  32854. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  32855. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  32856. texture.width = potWidth;
  32857. texture.height = potHeight;
  32858. return false;
  32859. }
  32860. else {
  32861. // Using shaders when possible to rescale because canvas.drawImage is lossy
  32862. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_TEMP);
  32863. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  32864. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  32865. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  32866. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  32867. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32868. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32869. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  32870. _this._releaseTexture(source_1);
  32871. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32872. continuationCallback();
  32873. });
  32874. }
  32875. return true;
  32876. }, samplingMode);
  32877. };
  32878. if (!fromData || isBase64) {
  32879. if (buffer instanceof HTMLImageElement) {
  32880. onload(buffer);
  32881. }
  32882. else {
  32883. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  32884. }
  32885. }
  32886. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  32887. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  32888. }
  32889. else {
  32890. onload(buffer);
  32891. }
  32892. }
  32893. return texture;
  32894. };
  32895. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  32896. var _this = this;
  32897. var rtt = this.createRenderTargetTexture({
  32898. width: destination.width,
  32899. height: destination.height,
  32900. }, {
  32901. generateMipMaps: false,
  32902. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  32903. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  32904. generateDepthBuffer: false,
  32905. generateStencilBuffer: false
  32906. });
  32907. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  32908. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  32909. }
  32910. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  32911. _this._rescalePostProcess.onApply = function (effect) {
  32912. effect._bindTexture("textureSampler", source);
  32913. };
  32914. var hostingScene = scene;
  32915. if (!hostingScene) {
  32916. hostingScene = _this.scenes[_this.scenes.length - 1];
  32917. }
  32918. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  32919. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  32920. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  32921. _this.unBindFramebuffer(rtt);
  32922. _this._releaseTexture(rtt);
  32923. if (onComplete) {
  32924. onComplete();
  32925. }
  32926. });
  32927. };
  32928. /**
  32929. * Creates a raw texture
  32930. * @param data defines the data to store in the texture
  32931. * @param width defines the width of the texture
  32932. * @param height defines the height of the texture
  32933. * @param format defines the format of the data
  32934. * @param generateMipMaps defines if the engine should generate the mip levels
  32935. * @param invertY defines if data must be stored with Y axis inverted
  32936. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32937. * @param compression defines the compression used (null by default)
  32938. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32939. * @returns the raw texture inside an InternalTexture
  32940. */
  32941. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  32942. if (compression === void 0) { compression = null; }
  32943. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32944. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_17__["_DevTools"].WarnImport("Engine.RawTexture");
  32945. };
  32946. /** @hidden */
  32947. Engine.prototype._unpackFlipY = function (value) {
  32948. if (this._unpackFlipYCached !== value) {
  32949. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  32950. if (this.enableUnpackFlipYCached) {
  32951. this._unpackFlipYCached = value;
  32952. }
  32953. }
  32954. };
  32955. /** @hidden */
  32956. Engine.prototype._getUnpackAlignement = function () {
  32957. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  32958. };
  32959. /**
  32960. * Creates a dynamic texture
  32961. * @param width defines the width of the texture
  32962. * @param height defines the height of the texture
  32963. * @param generateMipMaps defines if the engine should generate the mip levels
  32964. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32965. * @returns the dynamic texture inside an InternalTexture
  32966. */
  32967. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  32968. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_DYNAMIC);
  32969. texture.baseWidth = width;
  32970. texture.baseHeight = height;
  32971. if (generateMipMaps) {
  32972. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  32973. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  32974. }
  32975. // this.resetTextureCache();
  32976. texture.width = width;
  32977. texture.height = height;
  32978. texture.isReady = false;
  32979. texture.generateMipMaps = generateMipMaps;
  32980. texture.samplingMode = samplingMode;
  32981. this.updateTextureSamplingMode(samplingMode, texture);
  32982. this._internalTexturesCache.push(texture);
  32983. return texture;
  32984. };
  32985. /**
  32986. * Update the sampling mode of a given texture
  32987. * @param samplingMode defines the required sampling mode
  32988. * @param texture defines the texture to update
  32989. */
  32990. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  32991. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  32992. if (texture.isCube) {
  32993. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  32994. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32995. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32996. }
  32997. else if (texture.is3D) {
  32998. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  32999. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  33000. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33001. }
  33002. else {
  33003. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  33004. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  33005. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33006. }
  33007. texture.samplingMode = samplingMode;
  33008. };
  33009. /**
  33010. * Update the content of a dynamic texture
  33011. * @param texture defines the texture to update
  33012. * @param canvas defines the canvas containing the source
  33013. * @param invertY defines if data must be stored with Y axis inverted
  33014. * @param premulAlpha defines if alpha is stored as premultiplied
  33015. * @param format defines the format of the data
  33016. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  33017. */
  33018. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  33019. if (premulAlpha === void 0) { premulAlpha = false; }
  33020. if (forceBindTexture === void 0) { forceBindTexture = false; }
  33021. if (!texture) {
  33022. return;
  33023. }
  33024. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  33025. this._unpackFlipY(invertY);
  33026. if (premulAlpha) {
  33027. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  33028. }
  33029. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  33030. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  33031. if (texture.generateMipMaps) {
  33032. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  33033. }
  33034. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33035. if (premulAlpha) {
  33036. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  33037. }
  33038. texture.isReady = true;
  33039. };
  33040. /**
  33041. * Update a video texture
  33042. * @param texture defines the texture to update
  33043. * @param video defines the video element to use
  33044. * @param invertY defines if data must be stored with Y axis inverted
  33045. */
  33046. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  33047. if (!texture || texture._isDisabled) {
  33048. return;
  33049. }
  33050. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  33051. this._unpackFlipY(!invertY); // Video are upside down by default
  33052. try {
  33053. // Testing video texture support
  33054. if (this._videoTextureSupported === undefined) {
  33055. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  33056. if (this._gl.getError() !== 0) {
  33057. this._videoTextureSupported = false;
  33058. }
  33059. else {
  33060. this._videoTextureSupported = true;
  33061. }
  33062. }
  33063. // Copy video through the current working canvas if video texture is not supported
  33064. if (!this._videoTextureSupported) {
  33065. if (!texture._workingCanvas) {
  33066. texture._workingCanvas = document.createElement("canvas");
  33067. var context = texture._workingCanvas.getContext("2d");
  33068. if (!context) {
  33069. throw new Error("Unable to get 2d context");
  33070. }
  33071. texture._workingContext = context;
  33072. texture._workingCanvas.width = texture.width;
  33073. texture._workingCanvas.height = texture.height;
  33074. }
  33075. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  33076. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  33077. }
  33078. else {
  33079. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  33080. }
  33081. if (texture.generateMipMaps) {
  33082. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  33083. }
  33084. if (!wasPreviouslyBound) {
  33085. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33086. }
  33087. // this.resetTextureCache();
  33088. texture.isReady = true;
  33089. }
  33090. catch (ex) {
  33091. // Something unexpected
  33092. // Let's disable the texture
  33093. texture._isDisabled = true;
  33094. }
  33095. };
  33096. /**
  33097. * Updates a depth texture Comparison Mode and Function.
  33098. * If the comparison Function is equal to 0, the mode will be set to none.
  33099. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33100. * @param texture The texture to set the comparison function for
  33101. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33102. */
  33103. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  33104. if (this.webGLVersion === 1) {
  33105. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Error("WebGL 1 does not support texture comparison.");
  33106. return;
  33107. }
  33108. var gl = this._gl;
  33109. if (texture.isCube) {
  33110. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  33111. if (comparisonFunction === 0) {
  33112. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  33113. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  33114. }
  33115. else {
  33116. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  33117. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  33118. }
  33119. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33120. }
  33121. else {
  33122. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  33123. if (comparisonFunction === 0) {
  33124. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  33125. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  33126. }
  33127. else {
  33128. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  33129. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  33130. }
  33131. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33132. }
  33133. texture._comparisonFunction = comparisonFunction;
  33134. };
  33135. /** @hidden */
  33136. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  33137. var width = size.width || size;
  33138. var height = size.height || size;
  33139. internalTexture.baseWidth = width;
  33140. internalTexture.baseHeight = height;
  33141. internalTexture.width = width;
  33142. internalTexture.height = height;
  33143. internalTexture.isReady = true;
  33144. internalTexture.samples = 1;
  33145. internalTexture.generateMipMaps = false;
  33146. internalTexture._generateDepthBuffer = true;
  33147. internalTexture._generateStencilBuffer = generateStencil;
  33148. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  33149. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  33150. internalTexture._comparisonFunction = comparisonFunction;
  33151. var gl = this._gl;
  33152. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  33153. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  33154. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  33155. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  33156. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  33157. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  33158. if (comparisonFunction === 0) {
  33159. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  33160. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  33161. }
  33162. else {
  33163. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  33164. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  33165. }
  33166. };
  33167. /**
  33168. * Creates a depth stencil texture.
  33169. * This is only available in WebGL 2 or with the depth texture extension available.
  33170. * @param size The size of face edge in the texture.
  33171. * @param options The options defining the texture.
  33172. * @returns The texture
  33173. */
  33174. Engine.prototype.createDepthStencilTexture = function (size, options) {
  33175. if (options.isCube) {
  33176. var width = size.width || size;
  33177. return this._createDepthStencilCubeTexture(width, options);
  33178. }
  33179. else {
  33180. return this._createDepthStencilTexture(size, options);
  33181. }
  33182. };
  33183. /**
  33184. * Creates a depth stencil texture.
  33185. * This is only available in WebGL 2 or with the depth texture extension available.
  33186. * @param size The size of face edge in the texture.
  33187. * @param options The options defining the texture.
  33188. * @returns The texture
  33189. */
  33190. Engine.prototype._createDepthStencilTexture = function (size, options) {
  33191. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  33192. if (!this._caps.depthTextureExtension) {
  33193. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  33194. return internalTexture;
  33195. }
  33196. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  33197. var gl = this._gl;
  33198. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  33199. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  33200. if (this.webGLVersion > 1) {
  33201. if (internalOptions.generateStencil) {
  33202. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  33203. }
  33204. else {
  33205. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  33206. }
  33207. }
  33208. else {
  33209. if (internalOptions.generateStencil) {
  33210. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  33211. }
  33212. else {
  33213. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  33214. }
  33215. }
  33216. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  33217. return internalTexture;
  33218. };
  33219. /**
  33220. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33221. * @param renderTarget The render target to set the frame buffer for
  33222. */
  33223. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  33224. // Create the framebuffer
  33225. var internalTexture = renderTarget.getInternalTexture();
  33226. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  33227. return;
  33228. }
  33229. var gl = this._gl;
  33230. var depthStencilTexture = renderTarget.depthStencilTexture;
  33231. this._bindUnboundFramebuffer(internalTexture._framebuffer);
  33232. if (depthStencilTexture.isCube) {
  33233. if (depthStencilTexture._generateStencilBuffer) {
  33234. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  33235. }
  33236. else {
  33237. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  33238. }
  33239. }
  33240. else {
  33241. if (depthStencilTexture._generateStencilBuffer) {
  33242. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  33243. }
  33244. else {
  33245. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  33246. }
  33247. }
  33248. this._bindUnboundFramebuffer(null);
  33249. };
  33250. /**
  33251. * Creates a new render target texture
  33252. * @param size defines the size of the texture
  33253. * @param options defines the options used to create the texture
  33254. * @returns a new render target texture stored in an InternalTexture
  33255. */
  33256. Engine.prototype.createRenderTargetTexture = function (size, options) {
  33257. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_16__["RenderTargetCreationOptions"]();
  33258. if (options !== undefined && typeof options === "object") {
  33259. fullOptions.generateMipMaps = options.generateMipMaps;
  33260. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  33261. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  33262. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  33263. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  33264. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  33265. }
  33266. else {
  33267. fullOptions.generateMipMaps = options;
  33268. fullOptions.generateDepthBuffer = true;
  33269. fullOptions.generateStencilBuffer = false;
  33270. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  33271. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  33272. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  33273. }
  33274. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  33275. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  33276. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  33277. }
  33278. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  33279. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  33280. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  33281. }
  33282. var gl = this._gl;
  33283. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_RENDERTARGET);
  33284. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  33285. var width = size.width || size;
  33286. var height = size.height || size;
  33287. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  33288. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  33289. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  33290. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  33291. }
  33292. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  33293. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  33294. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  33295. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  33296. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  33297. // Create the framebuffer
  33298. var currentFrameBuffer = this._currentFramebuffer;
  33299. var framebuffer = gl.createFramebuffer();
  33300. this._bindUnboundFramebuffer(framebuffer);
  33301. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  33302. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  33303. if (fullOptions.generateMipMaps) {
  33304. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  33305. }
  33306. // Unbind
  33307. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  33308. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  33309. this._bindUnboundFramebuffer(currentFrameBuffer);
  33310. texture._framebuffer = framebuffer;
  33311. texture.baseWidth = width;
  33312. texture.baseHeight = height;
  33313. texture.width = width;
  33314. texture.height = height;
  33315. texture.isReady = true;
  33316. texture.samples = 1;
  33317. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  33318. texture.samplingMode = fullOptions.samplingMode;
  33319. texture.type = fullOptions.type;
  33320. texture.format = fullOptions.format;
  33321. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  33322. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  33323. // this.resetTextureCache();
  33324. this._internalTexturesCache.push(texture);
  33325. return texture;
  33326. };
  33327. /** @hidden */
  33328. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  33329. if (samples === void 0) { samples = 1; }
  33330. var depthStencilBuffer = null;
  33331. var gl = this._gl;
  33332. // Create the depth/stencil buffer
  33333. if (generateStencilBuffer) {
  33334. depthStencilBuffer = gl.createRenderbuffer();
  33335. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  33336. if (samples > 1) {
  33337. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  33338. }
  33339. else {
  33340. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  33341. }
  33342. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  33343. }
  33344. else if (generateDepthBuffer) {
  33345. depthStencilBuffer = gl.createRenderbuffer();
  33346. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  33347. if (samples > 1) {
  33348. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  33349. }
  33350. else {
  33351. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  33352. }
  33353. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  33354. }
  33355. return depthStencilBuffer;
  33356. };
  33357. /**
  33358. * Updates the sample count of a render target texture
  33359. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33360. * @param texture defines the texture to update
  33361. * @param samples defines the sample count to set
  33362. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33363. */
  33364. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  33365. if (this.webGLVersion < 2 || !texture) {
  33366. return 1;
  33367. }
  33368. if (texture.samples === samples) {
  33369. return samples;
  33370. }
  33371. var gl = this._gl;
  33372. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  33373. // Dispose previous render buffers
  33374. if (texture._depthStencilBuffer) {
  33375. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  33376. texture._depthStencilBuffer = null;
  33377. }
  33378. if (texture._MSAAFramebuffer) {
  33379. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  33380. texture._MSAAFramebuffer = null;
  33381. }
  33382. if (texture._MSAARenderBuffer) {
  33383. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  33384. texture._MSAARenderBuffer = null;
  33385. }
  33386. if (samples > 1) {
  33387. var framebuffer = gl.createFramebuffer();
  33388. if (!framebuffer) {
  33389. throw new Error("Unable to create multi sampled framebuffer");
  33390. }
  33391. texture._MSAAFramebuffer = framebuffer;
  33392. this._bindUnboundFramebuffer(texture._MSAAFramebuffer);
  33393. var colorRenderbuffer = gl.createRenderbuffer();
  33394. if (!colorRenderbuffer) {
  33395. throw new Error("Unable to create multi sampled framebuffer");
  33396. }
  33397. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  33398. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  33399. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  33400. texture._MSAARenderBuffer = colorRenderbuffer;
  33401. }
  33402. else {
  33403. this._bindUnboundFramebuffer(texture._framebuffer);
  33404. }
  33405. texture.samples = samples;
  33406. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  33407. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  33408. this._bindUnboundFramebuffer(null);
  33409. return samples;
  33410. };
  33411. /** @hidden */
  33412. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  33413. if (faceIndex === void 0) { faceIndex = 0; }
  33414. if (lod === void 0) { lod = 0; }
  33415. var gl = this._gl;
  33416. var target = gl.TEXTURE_2D;
  33417. if (texture.isCube) {
  33418. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  33419. }
  33420. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  33421. };
  33422. /** @hidden */
  33423. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  33424. if (faceIndex === void 0) { faceIndex = 0; }
  33425. if (lod === void 0) { lod = 0; }
  33426. var gl = this._gl;
  33427. var textureType = this._getWebGLTextureType(texture.type);
  33428. var format = this._getInternalFormat(texture.format);
  33429. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  33430. this._unpackFlipY(texture.invertY);
  33431. var target = gl.TEXTURE_2D;
  33432. if (texture.isCube) {
  33433. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  33434. }
  33435. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  33436. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  33437. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  33438. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  33439. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  33440. };
  33441. /** @hidden */
  33442. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  33443. if (faceIndex === void 0) { faceIndex = 0; }
  33444. if (lod === void 0) { lod = 0; }
  33445. var gl = this._gl;
  33446. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  33447. this._bindTextureDirectly(bindTarget, texture, true);
  33448. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  33449. this._bindTextureDirectly(bindTarget, null, true);
  33450. };
  33451. /** @hidden */
  33452. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  33453. if (faceIndex === void 0) { faceIndex = 0; }
  33454. if (lod === void 0) { lod = 0; }
  33455. var gl = this._gl;
  33456. var textureType = this._getWebGLTextureType(texture.type);
  33457. var format = this._getInternalFormat(texture.format);
  33458. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  33459. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  33460. this._bindTextureDirectly(bindTarget, texture, true);
  33461. this._unpackFlipY(texture.invertY);
  33462. var target = gl.TEXTURE_2D;
  33463. if (texture.isCube) {
  33464. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  33465. }
  33466. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  33467. this._bindTextureDirectly(bindTarget, null, true);
  33468. };
  33469. /**
  33470. * @hidden
  33471. */
  33472. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  33473. var gl = this._gl;
  33474. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  33475. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  33476. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  33477. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  33478. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  33479. };
  33480. /**
  33481. * Creates a new raw cube texture
  33482. * @param data defines the array of data to use to create each face
  33483. * @param size defines the size of the textures
  33484. * @param format defines the format of the data
  33485. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  33486. * @param generateMipMaps defines if the engine should generate the mip levels
  33487. * @param invertY defines if data must be stored with Y axis inverted
  33488. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33489. * @param compression defines the compression used (null by default)
  33490. * @returns the cube texture as an InternalTexture
  33491. */
  33492. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  33493. if (compression === void 0) { compression = null; }
  33494. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_17__["_DevTools"].WarnImport("Engine.RawTexture");
  33495. };
  33496. /**
  33497. * Creates a new raw 3D texture
  33498. * @param data defines the data used to create the texture
  33499. * @param width defines the width of the texture
  33500. * @param height defines the height of the texture
  33501. * @param depth defines the depth of the texture
  33502. * @param format defines the format of the texture
  33503. * @param generateMipMaps defines if the engine must generate mip levels
  33504. * @param invertY defines if data must be stored with Y axis inverted
  33505. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33506. * @param compression defines the compressed used (can be null)
  33507. * @param textureType defines the compressed used (can be null)
  33508. * @returns a new raw 3D texture (stored in an InternalTexture)
  33509. */
  33510. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  33511. if (compression === void 0) { compression = null; }
  33512. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  33513. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_17__["_DevTools"].WarnImport("Engine.RawTexture");
  33514. };
  33515. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  33516. var gl = this._gl;
  33517. if (!gl) {
  33518. return;
  33519. }
  33520. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  33521. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  33522. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  33523. if (!noMipmap && !isCompressed) {
  33524. gl.generateMipmap(gl.TEXTURE_2D);
  33525. }
  33526. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  33527. // this.resetTextureCache();
  33528. if (scene) {
  33529. scene._removePendingData(texture);
  33530. }
  33531. texture.onLoadedObservable.notifyObservers(texture);
  33532. texture.onLoadedObservable.clear();
  33533. };
  33534. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  33535. var _this = this;
  33536. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  33537. var maxTextureSize = this.getCaps().maxTextureSize;
  33538. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  33539. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  33540. var gl = this._gl;
  33541. if (!gl) {
  33542. return;
  33543. }
  33544. if (!texture._webGLTexture) {
  33545. // this.resetTextureCache();
  33546. if (scene) {
  33547. scene._removePendingData(texture);
  33548. }
  33549. return;
  33550. }
  33551. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  33552. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  33553. texture.baseWidth = width;
  33554. texture.baseHeight = height;
  33555. texture.width = potWidth;
  33556. texture.height = potHeight;
  33557. texture.isReady = true;
  33558. if (processFunction(potWidth, potHeight, function () {
  33559. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  33560. })) {
  33561. // Returning as texture needs extra async steps
  33562. return;
  33563. }
  33564. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  33565. };
  33566. /** @hidden */
  33567. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  33568. // Create new RGBA data container.
  33569. var rgbaData;
  33570. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  33571. rgbaData = new Float32Array(width * height * 4);
  33572. }
  33573. else {
  33574. rgbaData = new Uint32Array(width * height * 4);
  33575. }
  33576. // Convert each pixel.
  33577. for (var x = 0; x < width; x++) {
  33578. for (var y = 0; y < height; y++) {
  33579. var index = (y * width + x) * 3;
  33580. var newIndex = (y * width + x) * 4;
  33581. // Map Old Value to new value.
  33582. rgbaData[newIndex + 0] = rgbData[index + 0];
  33583. rgbaData[newIndex + 1] = rgbData[index + 1];
  33584. rgbaData[newIndex + 2] = rgbData[index + 2];
  33585. // Add fully opaque alpha channel.
  33586. rgbaData[newIndex + 3] = 1;
  33587. }
  33588. }
  33589. return rgbaData;
  33590. };
  33591. /** @hidden */
  33592. Engine.prototype._releaseFramebufferObjects = function (texture) {
  33593. var gl = this._gl;
  33594. if (texture._framebuffer) {
  33595. gl.deleteFramebuffer(texture._framebuffer);
  33596. texture._framebuffer = null;
  33597. }
  33598. if (texture._depthStencilBuffer) {
  33599. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  33600. texture._depthStencilBuffer = null;
  33601. }
  33602. if (texture._MSAAFramebuffer) {
  33603. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  33604. texture._MSAAFramebuffer = null;
  33605. }
  33606. if (texture._MSAARenderBuffer) {
  33607. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  33608. texture._MSAARenderBuffer = null;
  33609. }
  33610. };
  33611. /** @hidden */
  33612. Engine.prototype._releaseTexture = function (texture) {
  33613. var gl = this._gl;
  33614. this._releaseFramebufferObjects(texture);
  33615. gl.deleteTexture(texture._webGLTexture);
  33616. // Unbind channels
  33617. this.unbindAllTextures();
  33618. var index = this._internalTexturesCache.indexOf(texture);
  33619. if (index !== -1) {
  33620. this._internalTexturesCache.splice(index, 1);
  33621. }
  33622. // Integrated fixed lod samplers.
  33623. if (texture._lodTextureHigh) {
  33624. texture._lodTextureHigh.dispose();
  33625. }
  33626. if (texture._lodTextureMid) {
  33627. texture._lodTextureMid.dispose();
  33628. }
  33629. if (texture._lodTextureLow) {
  33630. texture._lodTextureLow.dispose();
  33631. }
  33632. // Set output texture of post process to null if the texture has been released/disposed
  33633. this.scenes.forEach(function (scene) {
  33634. scene.postProcesses.forEach(function (postProcess) {
  33635. if (postProcess._outputTexture == texture) {
  33636. postProcess._outputTexture = null;
  33637. }
  33638. });
  33639. scene.cameras.forEach(function (camera) {
  33640. camera._postProcesses.forEach(function (postProcess) {
  33641. if (postProcess) {
  33642. if (postProcess._outputTexture == texture) {
  33643. postProcess._outputTexture = null;
  33644. }
  33645. }
  33646. });
  33647. });
  33648. });
  33649. };
  33650. Engine.prototype.setProgram = function (program) {
  33651. if (this._currentProgram !== program) {
  33652. this._gl.useProgram(program);
  33653. this._currentProgram = program;
  33654. }
  33655. };
  33656. /**
  33657. * Binds an effect to the webGL context
  33658. * @param effect defines the effect to bind
  33659. */
  33660. Engine.prototype.bindSamplers = function (effect) {
  33661. var webGLPipelineContext = effect.getPipelineContext();
  33662. this.setProgram(webGLPipelineContext.program);
  33663. var samplers = effect.getSamplers();
  33664. for (var index = 0; index < samplers.length; index++) {
  33665. var uniform = effect.getUniform(samplers[index]);
  33666. if (uniform) {
  33667. this._boundUniforms[index] = uniform;
  33668. }
  33669. }
  33670. this._currentEffect = null;
  33671. };
  33672. Engine.prototype._activateCurrentTexture = function () {
  33673. if (this._currentTextureChannel !== this._activeChannel) {
  33674. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  33675. this._currentTextureChannel = this._activeChannel;
  33676. }
  33677. };
  33678. /** @hidden */
  33679. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  33680. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  33681. if (force === void 0) { force = false; }
  33682. var wasPreviouslyBound = false;
  33683. var isTextureForRendering = texture && texture._associatedChannel > -1;
  33684. if (forTextureDataUpdate && isTextureForRendering) {
  33685. this._activeChannel = texture._associatedChannel;
  33686. }
  33687. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  33688. if (currentTextureBound !== texture || force) {
  33689. this._activateCurrentTexture();
  33690. if (texture && texture.isMultiview) {
  33691. this._gl.bindTexture(target, texture ? texture._colorTextureArray : null);
  33692. }
  33693. else {
  33694. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  33695. }
  33696. this._boundTexturesCache[this._activeChannel] = texture;
  33697. if (texture) {
  33698. texture._associatedChannel = this._activeChannel;
  33699. }
  33700. }
  33701. else if (forTextureDataUpdate) {
  33702. wasPreviouslyBound = true;
  33703. this._activateCurrentTexture();
  33704. }
  33705. if (isTextureForRendering && !forTextureDataUpdate) {
  33706. this._bindSamplerUniformToChannel(texture._associatedChannel, this._activeChannel);
  33707. }
  33708. return wasPreviouslyBound;
  33709. };
  33710. /** @hidden */
  33711. Engine.prototype._bindTexture = function (channel, texture) {
  33712. if (channel === undefined) {
  33713. return;
  33714. }
  33715. if (texture) {
  33716. texture._associatedChannel = channel;
  33717. }
  33718. this._activeChannel = channel;
  33719. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  33720. };
  33721. /**
  33722. * Sets a texture to the webGL context from a postprocess
  33723. * @param channel defines the channel to use
  33724. * @param postProcess defines the source postprocess
  33725. */
  33726. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  33727. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  33728. };
  33729. /**
  33730. * Binds the output of the passed in post process to the texture channel specified
  33731. * @param channel The channel the texture should be bound to
  33732. * @param postProcess The post process which's output should be bound
  33733. */
  33734. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  33735. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  33736. };
  33737. /**
  33738. * Unbind all textures from the webGL context
  33739. */
  33740. Engine.prototype.unbindAllTextures = function () {
  33741. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  33742. this._activeChannel = channel;
  33743. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33744. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33745. if (this.webGLVersion > 1) {
  33746. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33747. }
  33748. }
  33749. };
  33750. /**
  33751. * Sets a texture to the according uniform.
  33752. * @param channel The texture channel
  33753. * @param uniform The uniform to set
  33754. * @param texture The texture to apply
  33755. */
  33756. Engine.prototype.setTexture = function (channel, uniform, texture) {
  33757. if (channel === undefined) {
  33758. return;
  33759. }
  33760. if (uniform) {
  33761. this._boundUniforms[channel] = uniform;
  33762. }
  33763. this._setTexture(channel, texture);
  33764. };
  33765. /**
  33766. * Sets a depth stencil texture from a render target to the according uniform.
  33767. * @param channel The texture channel
  33768. * @param uniform The uniform to set
  33769. * @param texture The render target texture containing the depth stencil texture to apply
  33770. */
  33771. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  33772. if (channel === undefined) {
  33773. return;
  33774. }
  33775. if (uniform) {
  33776. this._boundUniforms[channel] = uniform;
  33777. }
  33778. if (!texture || !texture.depthStencilTexture) {
  33779. this._setTexture(channel, null);
  33780. }
  33781. else {
  33782. this._setTexture(channel, texture, false, true);
  33783. }
  33784. };
  33785. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  33786. var uniform = this._boundUniforms[sourceSlot];
  33787. if (uniform._currentState === destination) {
  33788. return;
  33789. }
  33790. this._gl.uniform1i(uniform, destination);
  33791. uniform._currentState = destination;
  33792. };
  33793. Engine.prototype._getTextureWrapMode = function (mode) {
  33794. switch (mode) {
  33795. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  33796. return this._gl.REPEAT;
  33797. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  33798. return this._gl.CLAMP_TO_EDGE;
  33799. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  33800. return this._gl.MIRRORED_REPEAT;
  33801. }
  33802. return this._gl.REPEAT;
  33803. };
  33804. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  33805. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  33806. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  33807. // Not ready?
  33808. if (!texture) {
  33809. if (this._boundTexturesCache[channel] != null) {
  33810. this._activeChannel = channel;
  33811. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33812. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33813. if (this.webGLVersion > 1) {
  33814. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33815. }
  33816. }
  33817. return false;
  33818. }
  33819. // Video
  33820. if (texture.video) {
  33821. this._activeChannel = channel;
  33822. texture.update();
  33823. }
  33824. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  33825. texture.delayLoad();
  33826. return false;
  33827. }
  33828. var internalTexture;
  33829. if (depthStencilTexture) {
  33830. internalTexture = texture.depthStencilTexture;
  33831. }
  33832. else if (texture.isReady()) {
  33833. internalTexture = texture.getInternalTexture();
  33834. }
  33835. else if (texture.isCube) {
  33836. internalTexture = this.emptyCubeTexture;
  33837. }
  33838. else if (texture.is3D) {
  33839. internalTexture = this.emptyTexture3D;
  33840. }
  33841. else {
  33842. internalTexture = this.emptyTexture;
  33843. }
  33844. if (!isPartOfTextureArray && internalTexture) {
  33845. internalTexture._associatedChannel = channel;
  33846. }
  33847. var needToBind = true;
  33848. if (this._boundTexturesCache[channel] === internalTexture) {
  33849. if (!isPartOfTextureArray) {
  33850. this._bindSamplerUniformToChannel(internalTexture._associatedChannel, channel);
  33851. }
  33852. needToBind = false;
  33853. }
  33854. this._activeChannel = channel;
  33855. if (internalTexture && internalTexture.isMultiview) {
  33856. if (needToBind) {
  33857. this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, internalTexture, isPartOfTextureArray);
  33858. }
  33859. }
  33860. else if (internalTexture && internalTexture.is3D) {
  33861. if (needToBind) {
  33862. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  33863. }
  33864. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33865. internalTexture._cachedWrapU = texture.wrapU;
  33866. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33867. }
  33868. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33869. internalTexture._cachedWrapV = texture.wrapV;
  33870. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33871. }
  33872. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  33873. internalTexture._cachedWrapR = texture.wrapR;
  33874. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  33875. }
  33876. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  33877. }
  33878. else if (internalTexture && internalTexture.isCube) {
  33879. if (needToBind) {
  33880. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  33881. }
  33882. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  33883. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  33884. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  33885. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  33886. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  33887. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  33888. }
  33889. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  33890. }
  33891. else {
  33892. if (needToBind) {
  33893. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  33894. }
  33895. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33896. internalTexture._cachedWrapU = texture.wrapU;
  33897. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33898. }
  33899. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33900. internalTexture._cachedWrapV = texture.wrapV;
  33901. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33902. }
  33903. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  33904. }
  33905. return true;
  33906. };
  33907. /**
  33908. * Sets an array of texture to the webGL context
  33909. * @param channel defines the channel where the texture array must be set
  33910. * @param uniform defines the associated uniform location
  33911. * @param textures defines the array of textures to bind
  33912. */
  33913. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  33914. if (channel === undefined || !uniform) {
  33915. return;
  33916. }
  33917. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  33918. this._textureUnits = new Int32Array(textures.length);
  33919. }
  33920. for (var i = 0; i < textures.length; i++) {
  33921. var texture = textures[i].getInternalTexture();
  33922. if (texture) {
  33923. this._textureUnits[channel + i] = channel + i;
  33924. texture._associatedChannel = channel + i;
  33925. }
  33926. else {
  33927. this._textureUnits[channel + i] = -1;
  33928. }
  33929. }
  33930. this._gl.uniform1iv(uniform, this._textureUnits);
  33931. for (var index = 0; index < textures.length; index++) {
  33932. this._setTexture(this._textureUnits[index], textures[index], true);
  33933. }
  33934. };
  33935. /** @hidden */
  33936. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  33937. var internalTexture = texture.getInternalTexture();
  33938. if (!internalTexture) {
  33939. return;
  33940. }
  33941. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  33942. var value = texture.anisotropicFilteringLevel;
  33943. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  33944. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  33945. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  33946. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  33947. }
  33948. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  33949. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  33950. internalTexture._cachedAnisotropicFilteringLevel = value;
  33951. }
  33952. };
  33953. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  33954. this._bindTextureDirectly(target, texture, true, true);
  33955. this._gl.texParameterf(target, parameter, value);
  33956. };
  33957. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  33958. if (texture) {
  33959. this._bindTextureDirectly(target, texture, true, true);
  33960. }
  33961. this._gl.texParameteri(target, parameter, value);
  33962. };
  33963. /**
  33964. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33965. * @param x defines the x coordinate of the rectangle where pixels must be read
  33966. * @param y defines the y coordinate of the rectangle where pixels must be read
  33967. * @param width defines the width of the rectangle where pixels must be read
  33968. * @param height defines the height of the rectangle where pixels must be read
  33969. * @returns a Uint8Array containing RGBA colors
  33970. */
  33971. Engine.prototype.readPixels = function (x, y, width, height) {
  33972. var data = new Uint8Array(height * width * 4);
  33973. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  33974. return data;
  33975. };
  33976. /**
  33977. * Add an externaly attached data from its key.
  33978. * This method call will fail and return false, if such key already exists.
  33979. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33980. * @param key the unique key that identifies the data
  33981. * @param data the data object to associate to the key for this Engine instance
  33982. * @return true if no such key were already present and the data was added successfully, false otherwise
  33983. */
  33984. Engine.prototype.addExternalData = function (key, data) {
  33985. if (!this._externalData) {
  33986. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33987. }
  33988. return this._externalData.add(key, data);
  33989. };
  33990. /**
  33991. * Get an externaly attached data from its key
  33992. * @param key the unique key that identifies the data
  33993. * @return the associated data, if present (can be null), or undefined if not present
  33994. */
  33995. Engine.prototype.getExternalData = function (key) {
  33996. if (!this._externalData) {
  33997. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33998. }
  33999. return this._externalData.get(key);
  34000. };
  34001. /**
  34002. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34003. * @param key the unique key that identifies the data
  34004. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34005. * @return the associated data, can be null if the factory returned null.
  34006. */
  34007. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  34008. if (!this._externalData) {
  34009. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  34010. }
  34011. return this._externalData.getOrAddWithFactory(key, factory);
  34012. };
  34013. /**
  34014. * Remove an externaly attached data from the Engine instance
  34015. * @param key the unique key that identifies the data
  34016. * @return true if the data was successfully removed, false if it doesn't exist
  34017. */
  34018. Engine.prototype.removeExternalData = function (key) {
  34019. if (!this._externalData) {
  34020. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  34021. }
  34022. return this._externalData.remove(key);
  34023. };
  34024. /**
  34025. * Unbind all vertex attributes from the webGL context
  34026. */
  34027. Engine.prototype.unbindAllAttributes = function () {
  34028. if (this._mustWipeVertexAttributes) {
  34029. this._mustWipeVertexAttributes = false;
  34030. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  34031. this._gl.disableVertexAttribArray(i);
  34032. this._vertexAttribArraysEnabled[i] = false;
  34033. this._currentBufferPointers[i].active = false;
  34034. }
  34035. return;
  34036. }
  34037. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  34038. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  34039. continue;
  34040. }
  34041. this._gl.disableVertexAttribArray(i);
  34042. this._vertexAttribArraysEnabled[i] = false;
  34043. this._currentBufferPointers[i].active = false;
  34044. }
  34045. };
  34046. /**
  34047. * 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
  34048. */
  34049. Engine.prototype.releaseEffects = function () {
  34050. for (var name in this._compiledEffects) {
  34051. var webGLPipelineContext = this._compiledEffects[name].getPipelineContext();
  34052. this._deletePipelineContext(webGLPipelineContext);
  34053. }
  34054. this._compiledEffects = {};
  34055. };
  34056. /**
  34057. * Dispose and release all associated resources
  34058. */
  34059. Engine.prototype.dispose = function () {
  34060. this.hideLoadingUI();
  34061. this.stopRenderLoop();
  34062. this.onNewSceneAddedObservable.clear();
  34063. // Release postProcesses
  34064. while (this.postProcesses.length) {
  34065. this.postProcesses[0].dispose();
  34066. }
  34067. // Empty texture
  34068. if (this._emptyTexture) {
  34069. this._releaseTexture(this._emptyTexture);
  34070. this._emptyTexture = null;
  34071. }
  34072. if (this._emptyCubeTexture) {
  34073. this._releaseTexture(this._emptyCubeTexture);
  34074. this._emptyCubeTexture = null;
  34075. }
  34076. // Rescale PP
  34077. if (this._rescalePostProcess) {
  34078. this._rescalePostProcess.dispose();
  34079. }
  34080. // Release scenes
  34081. while (this.scenes.length) {
  34082. this.scenes[0].dispose();
  34083. }
  34084. // Release audio engine
  34085. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  34086. Engine.audioEngine.dispose();
  34087. }
  34088. // Release effects
  34089. this.releaseEffects();
  34090. // Unbind
  34091. this.unbindAllAttributes();
  34092. this._boundUniforms = [];
  34093. if (this._dummyFramebuffer) {
  34094. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  34095. }
  34096. //WebVR
  34097. this.disableVR();
  34098. // Events
  34099. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  34100. window.removeEventListener("blur", this._onBlur);
  34101. window.removeEventListener("focus", this._onFocus);
  34102. if (this._renderingCanvas) {
  34103. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  34104. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  34105. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  34106. if (!this._doNotHandleContextLost) {
  34107. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  34108. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  34109. }
  34110. }
  34111. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  34112. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  34113. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  34114. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  34115. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  34116. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  34117. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  34118. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  34119. }
  34120. // Remove from Instances
  34121. var index = Engine.Instances.indexOf(this);
  34122. if (index >= 0) {
  34123. Engine.Instances.splice(index, 1);
  34124. }
  34125. this._workingCanvas = null;
  34126. this._workingContext = null;
  34127. this._currentBufferPointers = [];
  34128. this._renderingCanvas = null;
  34129. this._currentProgram = null;
  34130. this._bindedRenderFunction = null;
  34131. this.onResizeObservable.clear();
  34132. this.onCanvasBlurObservable.clear();
  34133. this.onCanvasFocusObservable.clear();
  34134. this.onCanvasPointerOutObservable.clear();
  34135. this.onBeginFrameObservable.clear();
  34136. this.onEndFrameObservable.clear();
  34137. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  34138. // Abort active requests
  34139. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  34140. var request = _a[_i];
  34141. request.abort();
  34142. }
  34143. };
  34144. // Loading screen
  34145. /**
  34146. * Display the loading screen
  34147. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34148. */
  34149. Engine.prototype.displayLoadingUI = function () {
  34150. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  34151. return;
  34152. }
  34153. var loadingScreen = this.loadingScreen;
  34154. if (loadingScreen) {
  34155. loadingScreen.displayLoadingUI();
  34156. }
  34157. };
  34158. /**
  34159. * Hide the loading screen
  34160. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34161. */
  34162. Engine.prototype.hideLoadingUI = function () {
  34163. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  34164. return;
  34165. }
  34166. var loadingScreen = this._loadingScreen;
  34167. if (loadingScreen) {
  34168. loadingScreen.hideLoadingUI();
  34169. }
  34170. };
  34171. Object.defineProperty(Engine.prototype, "loadingScreen", {
  34172. /**
  34173. * Gets the current loading screen object
  34174. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34175. */
  34176. get: function () {
  34177. if (!this._loadingScreen && this._renderingCanvas) {
  34178. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  34179. }
  34180. return this._loadingScreen;
  34181. },
  34182. /**
  34183. * Sets the current loading screen object
  34184. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34185. */
  34186. set: function (loadingScreen) {
  34187. this._loadingScreen = loadingScreen;
  34188. },
  34189. enumerable: true,
  34190. configurable: true
  34191. });
  34192. Object.defineProperty(Engine.prototype, "loadingUIText", {
  34193. /**
  34194. * Sets the current loading screen text
  34195. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34196. */
  34197. set: function (text) {
  34198. this.loadingScreen.loadingUIText = text;
  34199. },
  34200. enumerable: true,
  34201. configurable: true
  34202. });
  34203. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  34204. /**
  34205. * Sets the current loading screen background color
  34206. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34207. */
  34208. set: function (color) {
  34209. this.loadingScreen.loadingUIBackgroundColor = color;
  34210. },
  34211. enumerable: true,
  34212. configurable: true
  34213. });
  34214. /**
  34215. * Attach a new callback raised when context lost event is fired
  34216. * @param callback defines the callback to call
  34217. */
  34218. Engine.prototype.attachContextLostEvent = function (callback) {
  34219. if (this._renderingCanvas) {
  34220. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  34221. }
  34222. };
  34223. /**
  34224. * Attach a new callback raised when context restored event is fired
  34225. * @param callback defines the callback to call
  34226. */
  34227. Engine.prototype.attachContextRestoredEvent = function (callback) {
  34228. if (this._renderingCanvas) {
  34229. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  34230. }
  34231. };
  34232. /**
  34233. * Gets the source code of the vertex shader associated with a specific webGL program
  34234. * @param program defines the program to use
  34235. * @returns a string containing the source code of the vertex shader associated with the program
  34236. */
  34237. Engine.prototype.getVertexShaderSource = function (program) {
  34238. var shaders = this._gl.getAttachedShaders(program);
  34239. if (!shaders) {
  34240. return null;
  34241. }
  34242. return this._gl.getShaderSource(shaders[0]);
  34243. };
  34244. /**
  34245. * Gets the source code of the fragment shader associated with a specific webGL program
  34246. * @param program defines the program to use
  34247. * @returns a string containing the source code of the fragment shader associated with the program
  34248. */
  34249. Engine.prototype.getFragmentShaderSource = function (program) {
  34250. var shaders = this._gl.getAttachedShaders(program);
  34251. if (!shaders) {
  34252. return null;
  34253. }
  34254. return this._gl.getShaderSource(shaders[1]);
  34255. };
  34256. /**
  34257. * Get the current error code of the webGL context
  34258. * @returns the error code
  34259. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34260. */
  34261. Engine.prototype.getError = function () {
  34262. return this._gl.getError();
  34263. };
  34264. // FPS
  34265. /**
  34266. * Gets the current framerate
  34267. * @returns a number representing the framerate
  34268. */
  34269. Engine.prototype.getFps = function () {
  34270. return this._fps;
  34271. };
  34272. /**
  34273. * Gets the time spent between current and previous frame
  34274. * @returns a number representing the delta time in ms
  34275. */
  34276. Engine.prototype.getDeltaTime = function () {
  34277. return this._deltaTime;
  34278. };
  34279. Engine.prototype._measureFps = function () {
  34280. this._performanceMonitor.sampleFrame();
  34281. this._fps = this._performanceMonitor.averageFPS;
  34282. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  34283. };
  34284. /** @hidden */
  34285. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  34286. if (faceIndex === void 0) { faceIndex = -1; }
  34287. if (level === void 0) { level = 0; }
  34288. if (buffer === void 0) { buffer = null; }
  34289. var gl = this._gl;
  34290. if (!this._dummyFramebuffer) {
  34291. var dummy = gl.createFramebuffer();
  34292. if (!dummy) {
  34293. throw new Error("Unable to create dummy framebuffer");
  34294. }
  34295. this._dummyFramebuffer = dummy;
  34296. }
  34297. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  34298. if (faceIndex > -1) {
  34299. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  34300. }
  34301. else {
  34302. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  34303. }
  34304. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  34305. switch (readType) {
  34306. case gl.UNSIGNED_BYTE:
  34307. if (!buffer) {
  34308. buffer = new Uint8Array(4 * width * height);
  34309. }
  34310. readType = gl.UNSIGNED_BYTE;
  34311. break;
  34312. default:
  34313. if (!buffer) {
  34314. buffer = new Float32Array(4 * width * height);
  34315. }
  34316. readType = gl.FLOAT;
  34317. break;
  34318. }
  34319. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  34320. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  34321. return buffer;
  34322. };
  34323. Engine.prototype._canRenderToFloatFramebuffer = function () {
  34324. if (this._webGLVersion > 1) {
  34325. return this._caps.colorBufferFloat;
  34326. }
  34327. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  34328. };
  34329. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  34330. if (this._webGLVersion > 1) {
  34331. return this._caps.colorBufferFloat;
  34332. }
  34333. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  34334. };
  34335. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  34336. Engine.prototype._canRenderToFramebuffer = function (type) {
  34337. var gl = this._gl;
  34338. //clear existing errors
  34339. while (gl.getError() !== gl.NO_ERROR) { }
  34340. var successful = true;
  34341. var texture = gl.createTexture();
  34342. gl.bindTexture(gl.TEXTURE_2D, texture);
  34343. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  34344. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  34345. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  34346. var fb = gl.createFramebuffer();
  34347. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  34348. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  34349. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  34350. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  34351. successful = successful && (gl.getError() === gl.NO_ERROR);
  34352. //try render by clearing frame buffer's color buffer
  34353. if (successful) {
  34354. gl.clear(gl.COLOR_BUFFER_BIT);
  34355. successful = successful && (gl.getError() === gl.NO_ERROR);
  34356. }
  34357. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  34358. if (successful) {
  34359. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  34360. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  34361. var readFormat = gl.RGBA;
  34362. var readType = gl.UNSIGNED_BYTE;
  34363. var buffer = new Uint8Array(4);
  34364. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  34365. successful = successful && (gl.getError() === gl.NO_ERROR);
  34366. }
  34367. //clean up
  34368. gl.deleteTexture(texture);
  34369. gl.deleteFramebuffer(fb);
  34370. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  34371. //clear accumulated errors
  34372. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  34373. return successful;
  34374. };
  34375. /** @hidden */
  34376. Engine.prototype._getWebGLTextureType = function (type) {
  34377. if (this._webGLVersion === 1) {
  34378. switch (type) {
  34379. case Engine.TEXTURETYPE_FLOAT:
  34380. return this._gl.FLOAT;
  34381. case Engine.TEXTURETYPE_HALF_FLOAT:
  34382. return this._gl.HALF_FLOAT_OES;
  34383. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34384. return this._gl.UNSIGNED_BYTE;
  34385. }
  34386. return this._gl.UNSIGNED_BYTE;
  34387. }
  34388. switch (type) {
  34389. case Engine.TEXTURETYPE_BYTE:
  34390. return this._gl.BYTE;
  34391. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34392. return this._gl.UNSIGNED_BYTE;
  34393. case Engine.TEXTURETYPE_SHORT:
  34394. return this._gl.SHORT;
  34395. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  34396. return this._gl.UNSIGNED_SHORT;
  34397. case Engine.TEXTURETYPE_INT:
  34398. return this._gl.INT;
  34399. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  34400. return this._gl.UNSIGNED_INT;
  34401. case Engine.TEXTURETYPE_FLOAT:
  34402. return this._gl.FLOAT;
  34403. case Engine.TEXTURETYPE_HALF_FLOAT:
  34404. return this._gl.HALF_FLOAT;
  34405. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  34406. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  34407. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  34408. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  34409. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  34410. return this._gl.UNSIGNED_SHORT_5_6_5;
  34411. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  34412. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  34413. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  34414. return this._gl.UNSIGNED_INT_24_8;
  34415. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  34416. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  34417. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  34418. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  34419. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  34420. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  34421. }
  34422. return this._gl.UNSIGNED_BYTE;
  34423. };
  34424. /** @hidden */
  34425. Engine.prototype._getInternalFormat = function (format) {
  34426. var internalFormat = this._gl.RGBA;
  34427. switch (format) {
  34428. case Engine.TEXTUREFORMAT_ALPHA:
  34429. internalFormat = this._gl.ALPHA;
  34430. break;
  34431. case Engine.TEXTUREFORMAT_LUMINANCE:
  34432. internalFormat = this._gl.LUMINANCE;
  34433. break;
  34434. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  34435. internalFormat = this._gl.LUMINANCE_ALPHA;
  34436. break;
  34437. case Engine.TEXTUREFORMAT_RED:
  34438. internalFormat = this._gl.RED;
  34439. break;
  34440. case Engine.TEXTUREFORMAT_RG:
  34441. internalFormat = this._gl.RG;
  34442. break;
  34443. case Engine.TEXTUREFORMAT_RGB:
  34444. internalFormat = this._gl.RGB;
  34445. break;
  34446. case Engine.TEXTUREFORMAT_RGBA:
  34447. internalFormat = this._gl.RGBA;
  34448. break;
  34449. }
  34450. if (this._webGLVersion > 1) {
  34451. switch (format) {
  34452. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34453. internalFormat = this._gl.RED_INTEGER;
  34454. break;
  34455. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34456. internalFormat = this._gl.RG_INTEGER;
  34457. break;
  34458. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34459. internalFormat = this._gl.RGB_INTEGER;
  34460. break;
  34461. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34462. internalFormat = this._gl.RGBA_INTEGER;
  34463. break;
  34464. }
  34465. }
  34466. return internalFormat;
  34467. };
  34468. /** @hidden */
  34469. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  34470. if (this._webGLVersion === 1) {
  34471. if (format !== undefined) {
  34472. switch (format) {
  34473. case Engine.TEXTUREFORMAT_ALPHA:
  34474. return this._gl.ALPHA;
  34475. case Engine.TEXTUREFORMAT_LUMINANCE:
  34476. return this._gl.LUMINANCE;
  34477. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  34478. return this._gl.LUMINANCE_ALPHA;
  34479. }
  34480. }
  34481. return this._gl.RGBA;
  34482. }
  34483. switch (type) {
  34484. case Engine.TEXTURETYPE_BYTE:
  34485. switch (format) {
  34486. case Engine.TEXTUREFORMAT_RED:
  34487. return this._gl.R8_SNORM;
  34488. case Engine.TEXTUREFORMAT_RG:
  34489. return this._gl.RG8_SNORM;
  34490. case Engine.TEXTUREFORMAT_RGB:
  34491. return this._gl.RGB8_SNORM;
  34492. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34493. return this._gl.R8I;
  34494. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34495. return this._gl.RG8I;
  34496. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34497. return this._gl.RGB8I;
  34498. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34499. return this._gl.RGBA8I;
  34500. default:
  34501. return this._gl.RGBA8_SNORM;
  34502. }
  34503. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34504. switch (format) {
  34505. case Engine.TEXTUREFORMAT_RED:
  34506. return this._gl.R8;
  34507. case Engine.TEXTUREFORMAT_RG:
  34508. return this._gl.RG8;
  34509. case Engine.TEXTUREFORMAT_RGB:
  34510. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  34511. case Engine.TEXTUREFORMAT_RGBA:
  34512. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  34513. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34514. return this._gl.R8UI;
  34515. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34516. return this._gl.RG8UI;
  34517. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34518. return this._gl.RGB8UI;
  34519. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34520. return this._gl.RGBA8UI;
  34521. case Engine.TEXTUREFORMAT_ALPHA:
  34522. return this._gl.ALPHA;
  34523. case Engine.TEXTUREFORMAT_LUMINANCE:
  34524. return this._gl.LUMINANCE;
  34525. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  34526. return this._gl.LUMINANCE_ALPHA;
  34527. default:
  34528. return this._gl.RGBA8;
  34529. }
  34530. case Engine.TEXTURETYPE_SHORT:
  34531. switch (format) {
  34532. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34533. return this._gl.R16I;
  34534. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34535. return this._gl.RG16I;
  34536. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34537. return this._gl.RGB16I;
  34538. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34539. return this._gl.RGBA16I;
  34540. default:
  34541. return this._gl.RGBA16I;
  34542. }
  34543. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  34544. switch (format) {
  34545. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34546. return this._gl.R16UI;
  34547. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34548. return this._gl.RG16UI;
  34549. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34550. return this._gl.RGB16UI;
  34551. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34552. return this._gl.RGBA16UI;
  34553. default:
  34554. return this._gl.RGBA16UI;
  34555. }
  34556. case Engine.TEXTURETYPE_INT:
  34557. switch (format) {
  34558. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34559. return this._gl.R32I;
  34560. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34561. return this._gl.RG32I;
  34562. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34563. return this._gl.RGB32I;
  34564. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34565. return this._gl.RGBA32I;
  34566. default:
  34567. return this._gl.RGBA32I;
  34568. }
  34569. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  34570. switch (format) {
  34571. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34572. return this._gl.R32UI;
  34573. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34574. return this._gl.RG32UI;
  34575. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34576. return this._gl.RGB32UI;
  34577. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34578. return this._gl.RGBA32UI;
  34579. default:
  34580. return this._gl.RGBA32UI;
  34581. }
  34582. case Engine.TEXTURETYPE_FLOAT:
  34583. switch (format) {
  34584. case Engine.TEXTUREFORMAT_RED:
  34585. return this._gl.R32F; // By default. Other possibility is R16F.
  34586. case Engine.TEXTUREFORMAT_RG:
  34587. return this._gl.RG32F; // By default. Other possibility is RG16F.
  34588. case Engine.TEXTUREFORMAT_RGB:
  34589. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  34590. case Engine.TEXTUREFORMAT_RGBA:
  34591. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  34592. default:
  34593. return this._gl.RGBA32F;
  34594. }
  34595. case Engine.TEXTURETYPE_HALF_FLOAT:
  34596. switch (format) {
  34597. case Engine.TEXTUREFORMAT_RED:
  34598. return this._gl.R16F;
  34599. case Engine.TEXTUREFORMAT_RG:
  34600. return this._gl.RG16F;
  34601. case Engine.TEXTUREFORMAT_RGB:
  34602. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  34603. case Engine.TEXTUREFORMAT_RGBA:
  34604. return this._gl.RGBA16F;
  34605. default:
  34606. return this._gl.RGBA16F;
  34607. }
  34608. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  34609. return this._gl.RGB565;
  34610. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  34611. return this._gl.R11F_G11F_B10F;
  34612. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  34613. return this._gl.RGB9_E5;
  34614. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  34615. return this._gl.RGBA4;
  34616. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  34617. return this._gl.RGB5_A1;
  34618. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  34619. switch (format) {
  34620. case Engine.TEXTUREFORMAT_RGBA:
  34621. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  34622. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34623. return this._gl.RGB10_A2UI;
  34624. default:
  34625. return this._gl.RGB10_A2;
  34626. }
  34627. }
  34628. return this._gl.RGBA8;
  34629. };
  34630. /** @hidden */
  34631. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  34632. if (type === Engine.TEXTURETYPE_FLOAT) {
  34633. return this._gl.RGBA32F;
  34634. }
  34635. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  34636. return this._gl.RGBA16F;
  34637. }
  34638. return this._gl.RGBA8;
  34639. };
  34640. /** @hidden */
  34641. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  34642. var _this = this;
  34643. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  34644. this._activeRequests.push(request);
  34645. request.onCompleteObservable.add(function (request) {
  34646. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  34647. });
  34648. return request;
  34649. };
  34650. /** @hidden */
  34651. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  34652. var _this = this;
  34653. return new Promise(function (resolve, reject) {
  34654. _this._loadFile(url, function (data) {
  34655. resolve(data);
  34656. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  34657. reject(exception);
  34658. });
  34659. });
  34660. };
  34661. // Statics
  34662. /**
  34663. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  34664. * @returns true if the engine can be created
  34665. * @ignorenaming
  34666. */
  34667. Engine.isSupported = function () {
  34668. try {
  34669. var tempcanvas = document.createElement("canvas");
  34670. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  34671. return gl != null && !!window.WebGLRenderingContext;
  34672. }
  34673. catch (e) {
  34674. return false;
  34675. }
  34676. };
  34677. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34678. Engine.ExceptionList = [
  34679. { key: "Chrome\/63\.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  34680. { key: "Firefox\/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34681. { key: "Firefox\/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34682. { key: "Chrome\/72.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34683. { key: "Chrome\/73.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34684. { key: "Chrome\/74.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34685. { key: "Mac OS.+Chrome\/71", capture: null, captureConstraint: null, targets: ["vao"] },
  34686. { key: "Mac OS.+Chrome\/72", capture: null, captureConstraint: null, targets: ["vao"] }
  34687. ];
  34688. /**
  34689. * Hidden
  34690. */
  34691. Engine._TextureLoaders = [];
  34692. // Const statics
  34693. /** Defines that alpha blending is disabled */
  34694. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE;
  34695. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34696. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_ADD;
  34697. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34698. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE;
  34699. /** Defines that alpha blending to DEST - SRC * DEST */
  34700. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_SUBTRACT;
  34701. /** Defines that alpha blending to SRC * DEST */
  34702. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_MULTIPLY;
  34703. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34704. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_MAXIMIZED;
  34705. /** Defines that alpha blending to SRC + DEST */
  34706. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_ONEONE;
  34707. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34708. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_PREMULTIPLIED;
  34709. /**
  34710. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34711. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34712. */
  34713. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  34714. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34715. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_INTERPOLATE;
  34716. /**
  34717. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34718. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34719. */
  34720. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_SCREENMODE;
  34721. /** Defines that the ressource is not delayed*/
  34722. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_NONE;
  34723. /** Defines that the ressource was successfully delay loaded */
  34724. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_LOADED;
  34725. /** Defines that the ressource is currently delay loading */
  34726. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_LOADING;
  34727. /** Defines that the ressource is delayed and has not started loading */
  34728. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_NOTLOADED;
  34729. // Depht or Stencil test Constants.
  34730. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34731. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].NEVER;
  34732. /** 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 */
  34733. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALWAYS;
  34734. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34735. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].LESS;
  34736. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34737. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].EQUAL;
  34738. /** 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 */
  34739. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].LEQUAL;
  34740. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34741. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].GREATER;
  34742. /** 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 */
  34743. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].GEQUAL;
  34744. /** 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 */
  34745. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].NOTEQUAL;
  34746. // Stencil Actions Constants.
  34747. /** Passed to stencilOperation to specify that stencil value must be kept */
  34748. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].KEEP;
  34749. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34750. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].REPLACE;
  34751. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34752. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].INCR;
  34753. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34754. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DECR;
  34755. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34756. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].INVERT;
  34757. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34758. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].INCR_WRAP;
  34759. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34760. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DECR_WRAP;
  34761. /** Texture is not repeating outside of 0..1 UVs */
  34762. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  34763. /** Texture is repeating outside of 0..1 UVs */
  34764. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  34765. /** Texture is repeating and mirrored */
  34766. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  34767. /** ALPHA */
  34768. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_ALPHA;
  34769. /** LUMINANCE */
  34770. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_LUMINANCE;
  34771. /** LUMINANCE_ALPHA */
  34772. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  34773. /** RGB */
  34774. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGB;
  34775. /** RGBA */
  34776. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGBA;
  34777. /** RED */
  34778. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RED;
  34779. /** RED (2nd reference) */
  34780. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_R;
  34781. /** RG */
  34782. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RG;
  34783. /** RED_INTEGER */
  34784. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  34785. /** RED_INTEGER (2nd reference) */
  34786. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_R_INTEGER;
  34787. /** RG_INTEGER */
  34788. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  34789. /** RGB_INTEGER */
  34790. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  34791. /** RGBA_INTEGER */
  34792. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  34793. /** UNSIGNED_BYTE */
  34794. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  34795. /** UNSIGNED_BYTE (2nd reference) */
  34796. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34797. /** FLOAT */
  34798. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_FLOAT;
  34799. /** HALF_FLOAT */
  34800. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_HALF_FLOAT;
  34801. /** BYTE */
  34802. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_BYTE;
  34803. /** SHORT */
  34804. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_SHORT;
  34805. /** UNSIGNED_SHORT */
  34806. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  34807. /** INT */
  34808. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_INT;
  34809. /** UNSIGNED_INT */
  34810. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  34811. /** UNSIGNED_SHORT_4_4_4_4 */
  34812. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  34813. /** UNSIGNED_SHORT_5_5_5_1 */
  34814. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  34815. /** UNSIGNED_SHORT_5_6_5 */
  34816. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  34817. /** UNSIGNED_INT_2_10_10_10_REV */
  34818. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  34819. /** UNSIGNED_INT_24_8 */
  34820. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  34821. /** UNSIGNED_INT_10F_11F_11F_REV */
  34822. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  34823. /** UNSIGNED_INT_5_9_9_9_REV */
  34824. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  34825. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34826. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  34827. /** nearest is mag = nearest and min = nearest and mip = linear */
  34828. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  34829. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34830. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  34831. /** Trilinear is mag = linear and min = linear and mip = linear */
  34832. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34833. /** nearest is mag = nearest and min = nearest and mip = linear */
  34834. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  34835. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34836. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  34837. /** Trilinear is mag = linear and min = linear and mip = linear */
  34838. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  34839. /** mag = nearest and min = nearest and mip = nearest */
  34840. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  34841. /** mag = nearest and min = linear and mip = nearest */
  34842. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  34843. /** mag = nearest and min = linear and mip = linear */
  34844. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  34845. /** mag = nearest and min = linear and mip = none */
  34846. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_LINEAR;
  34847. /** mag = nearest and min = nearest and mip = none */
  34848. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_NEAREST;
  34849. /** mag = linear and min = nearest and mip = nearest */
  34850. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  34851. /** mag = linear and min = nearest and mip = linear */
  34852. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  34853. /** mag = linear and min = linear and mip = none */
  34854. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_LINEAR;
  34855. /** mag = linear and min = nearest and mip = none */
  34856. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_NEAREST;
  34857. /** Explicit coordinates mode */
  34858. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_EXPLICIT_MODE;
  34859. /** Spherical coordinates mode */
  34860. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_SPHERICAL_MODE;
  34861. /** Planar coordinates mode */
  34862. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_PLANAR_MODE;
  34863. /** Cubic coordinates mode */
  34864. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_CUBIC_MODE;
  34865. /** Projection coordinates mode */
  34866. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_PROJECTION_MODE;
  34867. /** Skybox coordinates mode */
  34868. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_SKYBOX_MODE;
  34869. /** Inverse Cubic coordinates mode */
  34870. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_INVCUBIC_MODE;
  34871. /** Equirectangular coordinates mode */
  34872. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  34873. /** Equirectangular Fixed coordinates mode */
  34874. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  34875. /** Equirectangular Fixed Mirrored coordinates mode */
  34876. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  34877. // Texture rescaling mode
  34878. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34879. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].SCALEMODE_FLOOR;
  34880. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34881. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].SCALEMODE_NEAREST;
  34882. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34883. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].SCALEMODE_CEILING;
  34884. // Updatable statics so stick with vars here
  34885. /**
  34886. * Gets or sets the epsilon value used by collision engine
  34887. */
  34888. Engine.CollisionsEpsilon = 0.001;
  34889. /**
  34890. * Method called to create the default rescale post process on each engine.
  34891. */
  34892. Engine._RescalePostProcessFactory = null;
  34893. return Engine;
  34894. }());
  34895. /***/ }),
  34896. /***/ "./Engines/engineStore.ts":
  34897. /*!********************************!*\
  34898. !*** ./Engines/engineStore.ts ***!
  34899. \********************************/
  34900. /*! exports provided: EngineStore */
  34901. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34902. "use strict";
  34903. __webpack_require__.r(__webpack_exports__);
  34904. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  34905. /**
  34906. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34907. * during the life time of the application.
  34908. */
  34909. var EngineStore = /** @class */ (function () {
  34910. function EngineStore() {
  34911. }
  34912. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  34913. /**
  34914. * Gets the latest created engine
  34915. */
  34916. get: function () {
  34917. if (this.Instances.length === 0) {
  34918. return null;
  34919. }
  34920. return this.Instances[this.Instances.length - 1];
  34921. },
  34922. enumerable: true,
  34923. configurable: true
  34924. });
  34925. Object.defineProperty(EngineStore, "LastCreatedScene", {
  34926. /**
  34927. * Gets the latest created scene
  34928. */
  34929. get: function () {
  34930. return this._LastCreatedScene;
  34931. },
  34932. enumerable: true,
  34933. configurable: true
  34934. });
  34935. /** Gets the list of created engines */
  34936. EngineStore.Instances = new Array();
  34937. /** @hidden */
  34938. EngineStore._LastCreatedScene = null;
  34939. return EngineStore;
  34940. }());
  34941. /***/ }),
  34942. /***/ "./Engines/index.ts":
  34943. /*!**************************!*\
  34944. !*** ./Engines/index.ts ***!
  34945. \**************************/
  34946. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, WebGLPipelineContext, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  34947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34948. "use strict";
  34949. __webpack_require__.r(__webpack_exports__);
  34950. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  34952. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  34953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  34954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  34955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  34956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  34957. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  34958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  34959. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  34960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  34961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  34962. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  34963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  34964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  34965. /* harmony import */ var _WebGL_webGLPipelineContext__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./WebGL/webGLPipelineContext */ "./Engines/WebGL/webGLPipelineContext.ts");
  34966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGLPipelineContext", function() { return _WebGL_webGLPipelineContext__WEBPACK_IMPORTED_MODULE_5__["WebGLPipelineContext"]; });
  34967. /***/ }),
  34968. /***/ "./Engines/nullEngine.ts":
  34969. /*!*******************************!*\
  34970. !*** ./Engines/nullEngine.ts ***!
  34971. \*******************************/
  34972. /*! exports provided: NullEngineOptions, NullEngine */
  34973. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34974. "use strict";
  34975. __webpack_require__.r(__webpack_exports__);
  34976. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  34977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  34978. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34979. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  34980. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  34981. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  34982. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  34983. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34984. /* harmony import */ var _Meshes_dataBuffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/dataBuffer */ "./Meshes/dataBuffer.ts");
  34985. /**
  34986. * Options to create the null engine
  34987. */
  34988. var NullEngineOptions = /** @class */ (function () {
  34989. function NullEngineOptions() {
  34990. /**
  34991. * Render width (Default: 512)
  34992. */
  34993. this.renderWidth = 512;
  34994. /**
  34995. * Render height (Default: 256)
  34996. */
  34997. this.renderHeight = 256;
  34998. /**
  34999. * Texture size (Default: 512)
  35000. */
  35001. this.textureSize = 512;
  35002. /**
  35003. * If delta time between frames should be constant
  35004. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35005. */
  35006. this.deterministicLockstep = false;
  35007. /**
  35008. * Maximum about of steps between frames (Default: 4)
  35009. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35010. */
  35011. this.lockstepMaxSteps = 4;
  35012. }
  35013. return NullEngineOptions;
  35014. }());
  35015. /**
  35016. * The null engine class provides support for headless version of babylon.js.
  35017. * This can be used in server side scenario or for testing purposes
  35018. */
  35019. var NullEngine = /** @class */ (function (_super) {
  35020. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  35021. function NullEngine(options) {
  35022. if (options === void 0) { options = new NullEngineOptions(); }
  35023. var _this = _super.call(this, null) || this;
  35024. if (options.deterministicLockstep === undefined) {
  35025. options.deterministicLockstep = false;
  35026. }
  35027. if (options.lockstepMaxSteps === undefined) {
  35028. options.lockstepMaxSteps = 4;
  35029. }
  35030. _this._options = options;
  35031. // Init caps
  35032. // We consider we are on a webgl1 capable device
  35033. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  35034. _this._caps.maxTexturesImageUnits = 16;
  35035. _this._caps.maxVertexTextureImageUnits = 16;
  35036. _this._caps.maxTextureSize = 512;
  35037. _this._caps.maxCubemapTextureSize = 512;
  35038. _this._caps.maxRenderTextureSize = 512;
  35039. _this._caps.maxVertexAttribs = 16;
  35040. _this._caps.maxVaryingVectors = 16;
  35041. _this._caps.maxFragmentUniformVectors = 16;
  35042. _this._caps.maxVertexUniformVectors = 16;
  35043. // Extensions
  35044. _this._caps.standardDerivatives = false;
  35045. _this._caps.astc = null;
  35046. _this._caps.s3tc = null;
  35047. _this._caps.pvrtc = null;
  35048. _this._caps.etc1 = null;
  35049. _this._caps.etc2 = null;
  35050. _this._caps.textureAnisotropicFilterExtension = null;
  35051. _this._caps.maxAnisotropy = 0;
  35052. _this._caps.uintIndices = false;
  35053. _this._caps.fragmentDepthSupported = false;
  35054. _this._caps.highPrecisionShaderSupported = true;
  35055. _this._caps.colorBufferFloat = false;
  35056. _this._caps.textureFloat = false;
  35057. _this._caps.textureFloatLinearFiltering = false;
  35058. _this._caps.textureFloatRender = false;
  35059. _this._caps.textureHalfFloat = false;
  35060. _this._caps.textureHalfFloatLinearFiltering = false;
  35061. _this._caps.textureHalfFloatRender = false;
  35062. _this._caps.textureLOD = false;
  35063. _this._caps.drawBuffersExtension = false;
  35064. _this._caps.depthTextureExtension = false;
  35065. _this._caps.vertexArrayObject = false;
  35066. _this._caps.instancedArrays = false;
  35067. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  35068. // Wrappers
  35069. var theCurrentGlobal = (typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : window);
  35070. if (typeof URL === "undefined") {
  35071. theCurrentGlobal.URL = {
  35072. createObjectURL: function () { },
  35073. revokeObjectURL: function () { }
  35074. };
  35075. }
  35076. if (typeof Blob === "undefined") {
  35077. theCurrentGlobal.Blob = function () { };
  35078. }
  35079. return _this;
  35080. }
  35081. /**
  35082. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35083. */
  35084. NullEngine.prototype.isDeterministicLockStep = function () {
  35085. return this._options.deterministicLockstep;
  35086. };
  35087. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  35088. NullEngine.prototype.getLockstepMaxSteps = function () {
  35089. return this._options.lockstepMaxSteps;
  35090. };
  35091. /**
  35092. * Sets hardware scaling, used to save performance if needed
  35093. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  35094. */
  35095. NullEngine.prototype.getHardwareScalingLevel = function () {
  35096. return 1.0;
  35097. };
  35098. NullEngine.prototype.createVertexBuffer = function (vertices) {
  35099. var buffer = new _Meshes_dataBuffer__WEBPACK_IMPORTED_MODULE_6__["DataBuffer"]();
  35100. buffer.references = 1;
  35101. return buffer;
  35102. };
  35103. NullEngine.prototype.createIndexBuffer = function (indices) {
  35104. var buffer = new _Meshes_dataBuffer__WEBPACK_IMPORTED_MODULE_6__["DataBuffer"]();
  35105. buffer.references = 1;
  35106. return buffer;
  35107. };
  35108. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  35109. if (stencil === void 0) { stencil = false; }
  35110. };
  35111. NullEngine.prototype.getRenderWidth = function (useScreen) {
  35112. if (useScreen === void 0) { useScreen = false; }
  35113. if (!useScreen && this._currentRenderTarget) {
  35114. return this._currentRenderTarget.width;
  35115. }
  35116. return this._options.renderWidth;
  35117. };
  35118. NullEngine.prototype.getRenderHeight = function (useScreen) {
  35119. if (useScreen === void 0) { useScreen = false; }
  35120. if (!useScreen && this._currentRenderTarget) {
  35121. return this._currentRenderTarget.height;
  35122. }
  35123. return this._options.renderHeight;
  35124. };
  35125. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  35126. this._cachedViewport = viewport;
  35127. };
  35128. NullEngine.prototype.createShaderProgram = function (pipelineContext, vertexCode, fragmentCode, defines, context) {
  35129. return {
  35130. __SPECTOR_rebuildProgram: null,
  35131. };
  35132. };
  35133. NullEngine.prototype.getUniforms = function (pipelineContext, uniformsNames) {
  35134. return [];
  35135. };
  35136. NullEngine.prototype.getAttributes = function (pipelineContext, attributesNames) {
  35137. return [];
  35138. };
  35139. NullEngine.prototype.bindSamplers = function (effect) {
  35140. this._currentEffect = null;
  35141. };
  35142. NullEngine.prototype.enableEffect = function (effect) {
  35143. this._currentEffect = effect;
  35144. if (effect.onBind) {
  35145. effect.onBind(effect);
  35146. }
  35147. if (effect._onBindObservable) {
  35148. effect._onBindObservable.notifyObservers(effect);
  35149. }
  35150. };
  35151. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  35152. if (zOffset === void 0) { zOffset = 0; }
  35153. if (reverseSide === void 0) { reverseSide = false; }
  35154. };
  35155. NullEngine.prototype.setIntArray = function (uniform, array) {
  35156. };
  35157. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  35158. };
  35159. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  35160. };
  35161. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  35162. };
  35163. NullEngine.prototype.setFloatArray = function (uniform, array) {
  35164. };
  35165. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  35166. };
  35167. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  35168. };
  35169. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  35170. };
  35171. NullEngine.prototype.setArray = function (uniform, array) {
  35172. };
  35173. NullEngine.prototype.setArray2 = function (uniform, array) {
  35174. };
  35175. NullEngine.prototype.setArray3 = function (uniform, array) {
  35176. };
  35177. NullEngine.prototype.setArray4 = function (uniform, array) {
  35178. };
  35179. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  35180. };
  35181. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  35182. };
  35183. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  35184. };
  35185. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  35186. };
  35187. NullEngine.prototype.setFloat = function (uniform, value) {
  35188. };
  35189. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  35190. };
  35191. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  35192. };
  35193. NullEngine.prototype.setBool = function (uniform, bool) {
  35194. };
  35195. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  35196. };
  35197. NullEngine.prototype.setColor3 = function (uniform, color3) {
  35198. };
  35199. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  35200. };
  35201. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  35202. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  35203. if (this._alphaMode === mode) {
  35204. return;
  35205. }
  35206. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  35207. if (!noDepthWriteChange) {
  35208. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  35209. }
  35210. this._alphaMode = mode;
  35211. };
  35212. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  35213. };
  35214. NullEngine.prototype.wipeCaches = function (bruteForce) {
  35215. if (this.preventCacheWipeBetweenFrames) {
  35216. return;
  35217. }
  35218. this.resetTextureCache();
  35219. this._currentEffect = null;
  35220. if (bruteForce) {
  35221. this._currentProgram = null;
  35222. this._stencilState.reset();
  35223. this._depthCullingState.reset();
  35224. this._alphaState.reset();
  35225. }
  35226. this._cachedVertexBuffers = null;
  35227. this._cachedIndexBuffer = null;
  35228. this._cachedEffectForVertexBuffers = null;
  35229. };
  35230. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  35231. };
  35232. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  35233. };
  35234. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  35235. };
  35236. /** @hidden */
  35237. NullEngine.prototype._createTexture = function () {
  35238. return {};
  35239. };
  35240. /** @hidden */
  35241. NullEngine.prototype._releaseTexture = function (texture) {
  35242. };
  35243. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  35244. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  35245. if (onLoad === void 0) { onLoad = null; }
  35246. if (onError === void 0) { onError = null; }
  35247. if (buffer === void 0) { buffer = null; }
  35248. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  35249. var url = String(urlArg);
  35250. texture.url = url;
  35251. texture.generateMipMaps = !noMipmap;
  35252. texture.samplingMode = samplingMode;
  35253. texture.invertY = invertY;
  35254. texture.baseWidth = this._options.textureSize;
  35255. texture.baseHeight = this._options.textureSize;
  35256. texture.width = this._options.textureSize;
  35257. texture.height = this._options.textureSize;
  35258. if (format) {
  35259. texture.format = format;
  35260. }
  35261. texture.isReady = true;
  35262. if (onLoad) {
  35263. onLoad();
  35264. }
  35265. this._internalTexturesCache.push(texture);
  35266. return texture;
  35267. };
  35268. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  35269. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  35270. if (options !== undefined && typeof options === "object") {
  35271. fullOptions.generateMipMaps = options.generateMipMaps;
  35272. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  35273. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  35274. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  35275. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  35276. }
  35277. else {
  35278. fullOptions.generateMipMaps = options;
  35279. fullOptions.generateDepthBuffer = true;
  35280. fullOptions.generateStencilBuffer = false;
  35281. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  35282. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  35283. }
  35284. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  35285. var width = size.width || size;
  35286. var height = size.height || size;
  35287. texture._depthStencilBuffer = {};
  35288. texture._framebuffer = {};
  35289. texture.baseWidth = width;
  35290. texture.baseHeight = height;
  35291. texture.width = width;
  35292. texture.height = height;
  35293. texture.isReady = true;
  35294. texture.samples = 1;
  35295. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  35296. texture.samplingMode = fullOptions.samplingMode;
  35297. texture.type = fullOptions.type;
  35298. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  35299. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  35300. this._internalTexturesCache.push(texture);
  35301. return texture;
  35302. };
  35303. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  35304. texture.samplingMode = samplingMode;
  35305. };
  35306. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  35307. if (this._currentRenderTarget) {
  35308. this.unBindFramebuffer(this._currentRenderTarget);
  35309. }
  35310. this._currentRenderTarget = texture;
  35311. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  35312. if (this._cachedViewport && !forceFullscreenViewport) {
  35313. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  35314. }
  35315. };
  35316. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  35317. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  35318. this._currentRenderTarget = null;
  35319. if (onBeforeUnbind) {
  35320. if (texture._MSAAFramebuffer) {
  35321. this._currentFramebuffer = texture._framebuffer;
  35322. }
  35323. onBeforeUnbind();
  35324. }
  35325. this._currentFramebuffer = null;
  35326. };
  35327. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  35328. var buffer = new _Meshes_dataBuffer__WEBPACK_IMPORTED_MODULE_6__["DataBuffer"]();
  35329. buffer.references = 1;
  35330. buffer.capacity = 1;
  35331. return buffer;
  35332. };
  35333. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  35334. if (premulAlpha === void 0) { premulAlpha = false; }
  35335. };
  35336. NullEngine.prototype.areAllEffectsReady = function () {
  35337. return true;
  35338. };
  35339. /**
  35340. * @hidden
  35341. * Get the current error code of the webGL context
  35342. * @returns the error code
  35343. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35344. */
  35345. NullEngine.prototype.getError = function () {
  35346. return 0;
  35347. };
  35348. /** @hidden */
  35349. NullEngine.prototype._getUnpackAlignement = function () {
  35350. return 1;
  35351. };
  35352. /** @hidden */
  35353. NullEngine.prototype._unpackFlipY = function (value) {
  35354. };
  35355. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  35356. if (offset === void 0) { offset = 0; }
  35357. };
  35358. /**
  35359. * Updates a dynamic vertex buffer.
  35360. * @param vertexBuffer the vertex buffer to update
  35361. * @param data the data used to update the vertex buffer
  35362. * @param byteOffset the byte offset of the data (optional)
  35363. * @param byteLength the byte length of the data (optional)
  35364. */
  35365. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  35366. };
  35367. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  35368. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  35369. this._boundTexturesCache[this._activeChannel] = texture;
  35370. return true;
  35371. }
  35372. return false;
  35373. };
  35374. /** @hidden */
  35375. NullEngine.prototype._bindTexture = function (channel, texture) {
  35376. if (channel < 0) {
  35377. return;
  35378. }
  35379. this._bindTextureDirectly(0, texture);
  35380. };
  35381. /** @hidden */
  35382. NullEngine.prototype._releaseBuffer = function (buffer) {
  35383. buffer.references--;
  35384. if (buffer.references === 0) {
  35385. return true;
  35386. }
  35387. return false;
  35388. };
  35389. NullEngine.prototype.releaseEffects = function () {
  35390. };
  35391. NullEngine.prototype.displayLoadingUI = function () {
  35392. };
  35393. NullEngine.prototype.hideLoadingUI = function () {
  35394. };
  35395. /** @hidden */
  35396. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  35397. if (faceIndex === void 0) { faceIndex = 0; }
  35398. if (lod === void 0) { lod = 0; }
  35399. };
  35400. /** @hidden */
  35401. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  35402. if (faceIndex === void 0) { faceIndex = 0; }
  35403. if (lod === void 0) { lod = 0; }
  35404. };
  35405. /** @hidden */
  35406. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  35407. if (faceIndex === void 0) { faceIndex = 0; }
  35408. if (lod === void 0) { lod = 0; }
  35409. };
  35410. /** @hidden */
  35411. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  35412. if (faceIndex === void 0) { faceIndex = 0; }
  35413. if (lod === void 0) { lod = 0; }
  35414. };
  35415. return NullEngine;
  35416. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  35417. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  35418. /***/ }),
  35419. /***/ "./Events/clipboardEvents.ts":
  35420. /*!***********************************!*\
  35421. !*** ./Events/clipboardEvents.ts ***!
  35422. \***********************************/
  35423. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  35424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35425. "use strict";
  35426. __webpack_require__.r(__webpack_exports__);
  35427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  35428. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  35429. /**
  35430. * Gather the list of clipboard event types as constants.
  35431. */
  35432. var ClipboardEventTypes = /** @class */ (function () {
  35433. function ClipboardEventTypes() {
  35434. }
  35435. /**
  35436. * The clipboard event is fired when a copy command is active (pressed).
  35437. */
  35438. ClipboardEventTypes.COPY = 0x01; //
  35439. /**
  35440. * The clipboard event is fired when a cut command is active (pressed).
  35441. */
  35442. ClipboardEventTypes.CUT = 0x02;
  35443. /**
  35444. * The clipboard event is fired when a paste command is active (pressed).
  35445. */
  35446. ClipboardEventTypes.PASTE = 0x03;
  35447. return ClipboardEventTypes;
  35448. }());
  35449. /**
  35450. * This class is used to store clipboard related info for the onClipboardObservable event.
  35451. */
  35452. var ClipboardInfo = /** @class */ (function () {
  35453. /**
  35454. *Creates an instance of ClipboardInfo.
  35455. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  35456. * @param event Defines the related dom event
  35457. */
  35458. function ClipboardInfo(
  35459. /**
  35460. * Defines the type of event (BABYLON.ClipboardEventTypes)
  35461. */
  35462. type,
  35463. /**
  35464. * Defines the related dom event
  35465. */
  35466. event) {
  35467. this.type = type;
  35468. this.event = event;
  35469. }
  35470. /**
  35471. * Get the clipboard event's type from the keycode.
  35472. * @param keyCode Defines the keyCode for the current keyboard event.
  35473. * @return {number}
  35474. */
  35475. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  35476. var charCode = keyCode;
  35477. //TODO: add codes for extended ASCII
  35478. switch (charCode) {
  35479. case 67: return ClipboardEventTypes.COPY;
  35480. case 86: return ClipboardEventTypes.PASTE;
  35481. case 88: return ClipboardEventTypes.CUT;
  35482. default: return -1;
  35483. }
  35484. };
  35485. return ClipboardInfo;
  35486. }());
  35487. /***/ }),
  35488. /***/ "./Events/index.ts":
  35489. /*!*************************!*\
  35490. !*** ./Events/index.ts ***!
  35491. \*************************/
  35492. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  35493. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35494. "use strict";
  35495. __webpack_require__.r(__webpack_exports__);
  35496. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  35497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  35498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  35499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  35500. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  35501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  35502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  35503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  35504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  35505. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  35506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  35507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  35508. /***/ }),
  35509. /***/ "./Events/keyboardEvents.ts":
  35510. /*!**********************************!*\
  35511. !*** ./Events/keyboardEvents.ts ***!
  35512. \**********************************/
  35513. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  35514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35515. "use strict";
  35516. __webpack_require__.r(__webpack_exports__);
  35517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  35518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  35519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  35520. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35521. /**
  35522. * Gather the list of keyboard event types as constants.
  35523. */
  35524. var KeyboardEventTypes = /** @class */ (function () {
  35525. function KeyboardEventTypes() {
  35526. }
  35527. /**
  35528. * The keydown event is fired when a key becomes active (pressed).
  35529. */
  35530. KeyboardEventTypes.KEYDOWN = 0x01;
  35531. /**
  35532. * The keyup event is fired when a key has been released.
  35533. */
  35534. KeyboardEventTypes.KEYUP = 0x02;
  35535. return KeyboardEventTypes;
  35536. }());
  35537. /**
  35538. * This class is used to store keyboard related info for the onKeyboardObservable event.
  35539. */
  35540. var KeyboardInfo = /** @class */ (function () {
  35541. /**
  35542. * Instantiates a new keyboard info.
  35543. * This class is used to store keyboard related info for the onKeyboardObservable event.
  35544. * @param type Defines the type of event (KeyboardEventTypes)
  35545. * @param event Defines the related dom event
  35546. */
  35547. function KeyboardInfo(
  35548. /**
  35549. * Defines the type of event (KeyboardEventTypes)
  35550. */
  35551. type,
  35552. /**
  35553. * Defines the related dom event
  35554. */
  35555. event) {
  35556. this.type = type;
  35557. this.event = event;
  35558. }
  35559. return KeyboardInfo;
  35560. }());
  35561. /**
  35562. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  35563. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  35564. */
  35565. var KeyboardInfoPre = /** @class */ (function (_super) {
  35566. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  35567. /**
  35568. * Instantiates a new keyboard pre info.
  35569. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  35570. * @param type Defines the type of event (KeyboardEventTypes)
  35571. * @param event Defines the related dom event
  35572. */
  35573. function KeyboardInfoPre(
  35574. /**
  35575. * Defines the type of event (KeyboardEventTypes)
  35576. */
  35577. type,
  35578. /**
  35579. * Defines the related dom event
  35580. */
  35581. event) {
  35582. var _this = _super.call(this, type, event) || this;
  35583. _this.type = type;
  35584. _this.event = event;
  35585. _this.skipOnPointerObservable = false;
  35586. return _this;
  35587. }
  35588. return KeyboardInfoPre;
  35589. }(KeyboardInfo));
  35590. /***/ }),
  35591. /***/ "./Events/pointerEvents.ts":
  35592. /*!*********************************!*\
  35593. !*** ./Events/pointerEvents.ts ***!
  35594. \*********************************/
  35595. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  35596. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35597. "use strict";
  35598. __webpack_require__.r(__webpack_exports__);
  35599. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  35600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  35601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  35602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  35603. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35604. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  35605. /**
  35606. * Gather the list of pointer event types as constants.
  35607. */
  35608. var PointerEventTypes = /** @class */ (function () {
  35609. function PointerEventTypes() {
  35610. }
  35611. /**
  35612. * 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.
  35613. */
  35614. PointerEventTypes.POINTERDOWN = 0x01;
  35615. /**
  35616. * The pointerup event is fired when a pointer is no longer active.
  35617. */
  35618. PointerEventTypes.POINTERUP = 0x02;
  35619. /**
  35620. * The pointermove event is fired when a pointer changes coordinates.
  35621. */
  35622. PointerEventTypes.POINTERMOVE = 0x04;
  35623. /**
  35624. * The pointerwheel event is fired when a mouse wheel has been rotated.
  35625. */
  35626. PointerEventTypes.POINTERWHEEL = 0x08;
  35627. /**
  35628. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  35629. */
  35630. PointerEventTypes.POINTERPICK = 0x10;
  35631. /**
  35632. * The pointertap event is fired when a the object has been touched and released without drag.
  35633. */
  35634. PointerEventTypes.POINTERTAP = 0x20;
  35635. /**
  35636. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  35637. */
  35638. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  35639. return PointerEventTypes;
  35640. }());
  35641. /**
  35642. * Base class of pointer info types.
  35643. */
  35644. var PointerInfoBase = /** @class */ (function () {
  35645. /**
  35646. * Instantiates the base class of pointers info.
  35647. * @param type Defines the type of event (PointerEventTypes)
  35648. * @param event Defines the related dom event
  35649. */
  35650. function PointerInfoBase(
  35651. /**
  35652. * Defines the type of event (PointerEventTypes)
  35653. */
  35654. type,
  35655. /**
  35656. * Defines the related dom event
  35657. */
  35658. event) {
  35659. this.type = type;
  35660. this.event = event;
  35661. }
  35662. return PointerInfoBase;
  35663. }());
  35664. /**
  35665. * This class is used to store pointer related info for the onPrePointerObservable event.
  35666. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  35667. */
  35668. var PointerInfoPre = /** @class */ (function (_super) {
  35669. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  35670. /**
  35671. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  35672. * @param type Defines the type of event (PointerEventTypes)
  35673. * @param event Defines the related dom event
  35674. * @param localX Defines the local x coordinates of the pointer when the event occured
  35675. * @param localY Defines the local y coordinates of the pointer when the event occured
  35676. */
  35677. function PointerInfoPre(type, event, localX, localY) {
  35678. var _this = _super.call(this, type, event) || this;
  35679. /**
  35680. * Ray from a pointer if availible (eg. 6dof controller)
  35681. */
  35682. _this.ray = null;
  35683. _this.skipOnPointerObservable = false;
  35684. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  35685. return _this;
  35686. }
  35687. return PointerInfoPre;
  35688. }(PointerInfoBase));
  35689. /**
  35690. * This type contains all the data related to a pointer event in Babylon.js.
  35691. * 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.
  35692. */
  35693. var PointerInfo = /** @class */ (function (_super) {
  35694. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  35695. /**
  35696. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  35697. * @param type Defines the type of event (PointerEventTypes)
  35698. * @param event Defines the related dom event
  35699. * @param pickInfo Defines the picking info associated to the info (if any)\
  35700. */
  35701. function PointerInfo(type, event,
  35702. /**
  35703. * Defines the picking info associated to the info (if any)\
  35704. */
  35705. pickInfo) {
  35706. var _this = _super.call(this, type, event) || this;
  35707. _this.pickInfo = pickInfo;
  35708. return _this;
  35709. }
  35710. return PointerInfo;
  35711. }(PointerInfoBase));
  35712. /***/ }),
  35713. /***/ "./Gamepads/Controllers/daydreamController.ts":
  35714. /*!****************************************************!*\
  35715. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  35716. \****************************************************/
  35717. /*! exports provided: DaydreamController */
  35718. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35719. "use strict";
  35720. __webpack_require__.r(__webpack_exports__);
  35721. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  35722. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35723. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35724. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35725. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35726. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35727. /**
  35728. * Google Daydream controller
  35729. */
  35730. var DaydreamController = /** @class */ (function (_super) {
  35731. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  35732. /**
  35733. * Creates a new DaydreamController from a gamepad
  35734. * @param vrGamepad the gamepad that the controller should be created from
  35735. */
  35736. function DaydreamController(vrGamepad) {
  35737. var _this = _super.call(this, vrGamepad) || this;
  35738. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  35739. return _this;
  35740. }
  35741. /**
  35742. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35743. * @param scene scene in which to add meshes
  35744. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35745. */
  35746. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35747. var _this = this;
  35748. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  35749. _this._defaultModel = newMeshes[1];
  35750. _this.attachToMesh(_this._defaultModel);
  35751. if (meshLoaded) {
  35752. meshLoaded(_this._defaultModel);
  35753. }
  35754. });
  35755. };
  35756. /**
  35757. * Called once for each button that changed state since the last frame
  35758. * @param buttonIdx Which button index changed
  35759. * @param state New state of the button
  35760. * @param changes Which properties on the state changed since last frame
  35761. */
  35762. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35763. // Daydream controller only has 1 GamepadButton (on the trackpad).
  35764. if (buttonIdx === 0) {
  35765. var observable = this.onTriggerStateChangedObservable;
  35766. if (observable) {
  35767. observable.notifyObservers(state);
  35768. }
  35769. }
  35770. else {
  35771. // If the app or home buttons are ever made available
  35772. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  35773. }
  35774. };
  35775. /**
  35776. * Base Url for the controller model.
  35777. */
  35778. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35779. /**
  35780. * File name for the controller model.
  35781. */
  35782. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  35783. /**
  35784. * Gamepad Id prefix used to identify Daydream Controller.
  35785. */
  35786. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  35787. return DaydreamController;
  35788. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35789. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35790. canCreate: function (gamepadInfo) {
  35791. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  35792. },
  35793. create: function (gamepadInfo) {
  35794. return new DaydreamController(gamepadInfo);
  35795. }
  35796. });
  35797. /***/ }),
  35798. /***/ "./Gamepads/Controllers/gearVRController.ts":
  35799. /*!**************************************************!*\
  35800. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  35801. \**************************************************/
  35802. /*! exports provided: GearVRController */
  35803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35804. "use strict";
  35805. __webpack_require__.r(__webpack_exports__);
  35806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  35807. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35808. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35809. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35810. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35811. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35812. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35813. /**
  35814. * Gear VR Controller
  35815. */
  35816. var GearVRController = /** @class */ (function (_super) {
  35817. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  35818. /**
  35819. * Creates a new GearVRController from a gamepad
  35820. * @param vrGamepad the gamepad that the controller should be created from
  35821. */
  35822. function GearVRController(vrGamepad) {
  35823. var _this = _super.call(this, vrGamepad) || this;
  35824. _this._buttonIndexToObservableNameMap = [
  35825. 'onPadStateChangedObservable',
  35826. 'onTriggerStateChangedObservable' // Trigger
  35827. ];
  35828. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  35829. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  35830. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  35831. _this._disableTrackPosition(_this._calculatedPosition);
  35832. return _this;
  35833. }
  35834. /**
  35835. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35836. * @param scene scene in which to add meshes
  35837. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35838. */
  35839. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35840. var _this = this;
  35841. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  35842. // Offset the controller so it will rotate around the users wrist
  35843. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  35844. newMeshes[1].parent = mesh;
  35845. newMeshes[1].position.z = -0.15;
  35846. _this._defaultModel = mesh;
  35847. _this.attachToMesh(_this._defaultModel);
  35848. if (meshLoaded) {
  35849. meshLoaded(_this._defaultModel);
  35850. }
  35851. });
  35852. };
  35853. /**
  35854. * Called once for each button that changed state since the last frame
  35855. * @param buttonIdx Which button index changed
  35856. * @param state New state of the button
  35857. * @param changes Which properties on the state changed since last frame
  35858. */
  35859. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35860. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  35861. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  35862. // Only emit events for buttons that we know how to map from index to observable
  35863. var observable = this[observableName];
  35864. if (observable) {
  35865. observable.notifyObservers(state);
  35866. }
  35867. }
  35868. };
  35869. /**
  35870. * Base Url for the controller model.
  35871. */
  35872. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35873. /**
  35874. * File name for the controller model.
  35875. */
  35876. GearVRController.MODEL_FILENAME = 'generic.babylon';
  35877. /**
  35878. * Gamepad Id prefix used to identify this controller.
  35879. */
  35880. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  35881. return GearVRController;
  35882. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  35883. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35884. canCreate: function (gamepadInfo) {
  35885. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  35886. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  35887. },
  35888. create: function (gamepadInfo) {
  35889. return new GearVRController(gamepadInfo);
  35890. }
  35891. });
  35892. /***/ }),
  35893. /***/ "./Gamepads/Controllers/genericController.ts":
  35894. /*!***************************************************!*\
  35895. !*** ./Gamepads/Controllers/genericController.ts ***!
  35896. \***************************************************/
  35897. /*! exports provided: GenericController */
  35898. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35899. "use strict";
  35900. __webpack_require__.r(__webpack_exports__);
  35901. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  35902. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35903. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35904. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35905. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35906. /**
  35907. * Generic Controller
  35908. */
  35909. var GenericController = /** @class */ (function (_super) {
  35910. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  35911. /**
  35912. * Creates a new GenericController from a gamepad
  35913. * @param vrGamepad the gamepad that the controller should be created from
  35914. */
  35915. function GenericController(vrGamepad) {
  35916. return _super.call(this, vrGamepad) || this;
  35917. }
  35918. /**
  35919. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35920. * @param scene scene in which to add meshes
  35921. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35922. */
  35923. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35924. var _this = this;
  35925. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  35926. _this._defaultModel = newMeshes[1];
  35927. _this.attachToMesh(_this._defaultModel);
  35928. if (meshLoaded) {
  35929. meshLoaded(_this._defaultModel);
  35930. }
  35931. });
  35932. };
  35933. /**
  35934. * Called once for each button that changed state since the last frame
  35935. * @param buttonIdx Which button index changed
  35936. * @param state New state of the button
  35937. * @param changes Which properties on the state changed since last frame
  35938. */
  35939. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35940. console.log("Button id: " + buttonIdx + "state: ");
  35941. console.dir(state);
  35942. };
  35943. /**
  35944. * Base Url for the controller model.
  35945. */
  35946. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35947. /**
  35948. * File name for the controller model.
  35949. */
  35950. GenericController.MODEL_FILENAME = 'generic.babylon';
  35951. return GenericController;
  35952. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35953. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  35954. /***/ }),
  35955. /***/ "./Gamepads/Controllers/index.ts":
  35956. /*!***************************************!*\
  35957. !*** ./Gamepads/Controllers/index.ts ***!
  35958. \***************************************/
  35959. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  35960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35961. "use strict";
  35962. __webpack_require__.r(__webpack_exports__);
  35963. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  35964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  35965. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  35966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  35967. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  35969. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  35970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  35971. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  35973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  35974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  35975. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  35976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  35977. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  35979. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  35980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  35981. /***/ }),
  35982. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  35983. /*!*******************************************************!*\
  35984. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  35985. \*******************************************************/
  35986. /*! exports provided: OculusTouchController */
  35987. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35988. "use strict";
  35989. __webpack_require__.r(__webpack_exports__);
  35990. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  35991. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35992. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35993. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35994. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35995. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35996. /**
  35997. * Oculus Touch Controller
  35998. */
  35999. var OculusTouchController = /** @class */ (function (_super) {
  36000. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  36001. /**
  36002. * Creates a new OculusTouchController from a gamepad
  36003. * @param vrGamepad the gamepad that the controller should be created from
  36004. */
  36005. function OculusTouchController(vrGamepad) {
  36006. var _this = _super.call(this, vrGamepad) || this;
  36007. /**
  36008. * Fired when the secondary trigger on this controller is modified
  36009. */
  36010. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36011. /**
  36012. * Fired when the thumb rest on this controller is modified
  36013. */
  36014. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36015. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  36016. return _this;
  36017. }
  36018. /**
  36019. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36020. * @param scene scene in which to add meshes
  36021. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36022. */
  36023. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  36024. var _this = this;
  36025. var meshName;
  36026. // Hand
  36027. if (this.hand === 'left') {
  36028. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  36029. }
  36030. else { // Right is the default if no hand is specified
  36031. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  36032. }
  36033. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  36034. /*
  36035. Parent Mesh name: oculus_touch_left
  36036. - body
  36037. - trigger
  36038. - thumbstick
  36039. - grip
  36040. - button_y
  36041. - button_x
  36042. - button_enter
  36043. */
  36044. _this._defaultModel = newMeshes[1];
  36045. _this.attachToMesh(_this._defaultModel);
  36046. if (meshLoaded) {
  36047. meshLoaded(_this._defaultModel);
  36048. }
  36049. });
  36050. };
  36051. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  36052. /**
  36053. * Fired when the A button on this controller is modified
  36054. */
  36055. get: function () {
  36056. if (this.hand === 'right') {
  36057. return this.onMainButtonStateChangedObservable;
  36058. }
  36059. else {
  36060. throw new Error('No A button on left hand');
  36061. }
  36062. },
  36063. enumerable: true,
  36064. configurable: true
  36065. });
  36066. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  36067. /**
  36068. * Fired when the B button on this controller is modified
  36069. */
  36070. get: function () {
  36071. if (this.hand === 'right') {
  36072. return this.onSecondaryButtonStateChangedObservable;
  36073. }
  36074. else {
  36075. throw new Error('No B button on left hand');
  36076. }
  36077. },
  36078. enumerable: true,
  36079. configurable: true
  36080. });
  36081. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  36082. /**
  36083. * Fired when the X button on this controller is modified
  36084. */
  36085. get: function () {
  36086. if (this.hand === 'left') {
  36087. return this.onMainButtonStateChangedObservable;
  36088. }
  36089. else {
  36090. throw new Error('No X button on right hand');
  36091. }
  36092. },
  36093. enumerable: true,
  36094. configurable: true
  36095. });
  36096. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  36097. /**
  36098. * Fired when the Y button on this controller is modified
  36099. */
  36100. get: function () {
  36101. if (this.hand === 'left') {
  36102. return this.onSecondaryButtonStateChangedObservable;
  36103. }
  36104. else {
  36105. throw new Error('No Y button on right hand');
  36106. }
  36107. },
  36108. enumerable: true,
  36109. configurable: true
  36110. });
  36111. /**
  36112. * Called once for each button that changed state since the last frame
  36113. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  36114. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  36115. * 2) secondary trigger (same)
  36116. * 3) A (right) X (left), touch, pressed = value
  36117. * 4) B / Y
  36118. * 5) thumb rest
  36119. * @param buttonIdx Which button index changed
  36120. * @param state New state of the button
  36121. * @param changes Which properties on the state changed since last frame
  36122. */
  36123. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36124. var notifyObject = state; //{ state: state, changes: changes };
  36125. var triggerDirection = this.hand === 'right' ? -1 : 1;
  36126. switch (buttonIdx) {
  36127. case 0:
  36128. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  36129. return;
  36130. case 1: // index trigger
  36131. if (this._defaultModel) {
  36132. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  36133. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  36134. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  36135. }
  36136. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  36137. return;
  36138. case 2: // secondary trigger
  36139. if (this._defaultModel) {
  36140. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  36141. }
  36142. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  36143. return;
  36144. case 3:
  36145. if (this._defaultModel) {
  36146. if (notifyObject.pressed) {
  36147. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  36148. }
  36149. else {
  36150. (this._defaultModel.getChildren()[1]).position.y = 0;
  36151. }
  36152. }
  36153. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  36154. return;
  36155. case 4:
  36156. if (this._defaultModel) {
  36157. if (notifyObject.pressed) {
  36158. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  36159. }
  36160. else {
  36161. (this._defaultModel.getChildren()[2]).position.y = 0;
  36162. }
  36163. }
  36164. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  36165. return;
  36166. case 5:
  36167. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  36168. return;
  36169. }
  36170. };
  36171. /**
  36172. * Base Url for the controller model.
  36173. */
  36174. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  36175. /**
  36176. * File name for the left controller model.
  36177. */
  36178. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  36179. /**
  36180. * File name for the right controller model.
  36181. */
  36182. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  36183. return OculusTouchController;
  36184. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  36185. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36186. canCreate: function (gamepadInfo) {
  36187. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  36188. },
  36189. create: function (gamepadInfo) {
  36190. return new OculusTouchController(gamepadInfo);
  36191. }
  36192. });
  36193. /***/ }),
  36194. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  36195. /*!*******************************************************!*\
  36196. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  36197. \*******************************************************/
  36198. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  36199. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36200. "use strict";
  36201. __webpack_require__.r(__webpack_exports__);
  36202. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  36203. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  36204. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  36205. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36206. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36207. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  36208. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  36209. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  36210. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  36211. /**
  36212. * Defines the types of pose enabled controllers that are supported
  36213. */
  36214. var PoseEnabledControllerType;
  36215. (function (PoseEnabledControllerType) {
  36216. /**
  36217. * HTC Vive
  36218. */
  36219. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  36220. /**
  36221. * Oculus Rift
  36222. */
  36223. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  36224. /**
  36225. * Windows mixed reality
  36226. */
  36227. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  36228. /**
  36229. * Samsung gear VR
  36230. */
  36231. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  36232. /**
  36233. * Google Daydream
  36234. */
  36235. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  36236. /**
  36237. * Generic
  36238. */
  36239. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  36240. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  36241. /**
  36242. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  36243. */
  36244. var PoseEnabledControllerHelper = /** @class */ (function () {
  36245. function PoseEnabledControllerHelper() {
  36246. }
  36247. /**
  36248. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  36249. * @param vrGamepad the gamepad to initialized
  36250. * @returns a vr controller of the type the gamepad identified as
  36251. */
  36252. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  36253. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  36254. var factory = _a[_i];
  36255. if (factory.canCreate(vrGamepad)) {
  36256. return factory.create(vrGamepad);
  36257. }
  36258. }
  36259. if (this._DefaultControllerFactory) {
  36260. return this._DefaultControllerFactory(vrGamepad);
  36261. }
  36262. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  36263. };
  36264. /** @hidden */
  36265. PoseEnabledControllerHelper._ControllerFactories = [];
  36266. /** @hidden */
  36267. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  36268. return PoseEnabledControllerHelper;
  36269. }());
  36270. /**
  36271. * Defines the PoseEnabledController object that contains state of a vr capable controller
  36272. */
  36273. var PoseEnabledController = /** @class */ (function (_super) {
  36274. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  36275. /**
  36276. * Creates a new PoseEnabledController from a gamepad
  36277. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  36278. */
  36279. function PoseEnabledController(browserGamepad) {
  36280. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  36281. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  36282. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36283. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36284. /**
  36285. * The device position in babylon space
  36286. */
  36287. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36288. /**
  36289. * The device rotation in babylon space
  36290. */
  36291. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36292. /**
  36293. * The scale factor of the device in babylon space
  36294. */
  36295. _this.deviceScaleFactor = 1;
  36296. // Used to convert 6dof controllers to 3dof
  36297. _this._trackPosition = true;
  36298. _this._maxRotationDistFromHeadset = Math.PI / 5;
  36299. _this._draggedRoomRotation = 0;
  36300. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36301. /**
  36302. * Internal, matrix used to convert room space to babylon space
  36303. * @hidden
  36304. */
  36305. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  36306. /**
  36307. * Node to be used when casting a ray from the controller
  36308. * @hidden
  36309. */
  36310. _this._pointingPoseNode = null;
  36311. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  36312. /**
  36313. * @hidden
  36314. */
  36315. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36316. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  36317. _this.controllerType = PoseEnabledControllerType.GENERIC;
  36318. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36319. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36320. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36321. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36322. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  36323. return _this;
  36324. }
  36325. /**
  36326. * @hidden
  36327. */
  36328. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  36329. if (this._trackPosition) {
  36330. this._calculatedPosition.copyFrom(fixedPosition);
  36331. this._trackPosition = false;
  36332. }
  36333. };
  36334. /**
  36335. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  36336. */
  36337. PoseEnabledController.prototype.update = function () {
  36338. _super.prototype.update.call(this);
  36339. this._updatePoseAndMesh();
  36340. };
  36341. /**
  36342. * Updates only the pose device and mesh without doing any button event checking
  36343. */
  36344. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  36345. var pose = this.browserGamepad.pose;
  36346. this.updateFromDevice(pose);
  36347. 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) {
  36348. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  36349. camera._computeDevicePosition();
  36350. this._deviceToWorld.setTranslation(camera.devicePosition);
  36351. if (camera.deviceRotationQuaternion) {
  36352. var camera = camera;
  36353. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  36354. // Find the radian distance away that the headset is from the controllers rotation
  36355. 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));
  36356. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  36357. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  36358. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  36359. this._draggedRoomRotation += rotationAmount;
  36360. // Rotate controller around headset
  36361. var sin = Math.sin(-rotationAmount);
  36362. var cos = Math.cos(-rotationAmount);
  36363. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  36364. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  36365. }
  36366. }
  36367. }
  36368. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  36369. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  36370. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  36371. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  36372. if (this._mesh) {
  36373. this._mesh.position.copyFrom(this.devicePosition);
  36374. if (this._mesh.rotationQuaternion) {
  36375. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  36376. }
  36377. }
  36378. };
  36379. /**
  36380. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  36381. * @param poseData raw pose fromthe device
  36382. */
  36383. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  36384. if (poseData) {
  36385. this.rawPose = poseData;
  36386. if (poseData.position) {
  36387. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  36388. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  36389. this._deviceRoomPosition.z *= -1;
  36390. }
  36391. if (this._trackPosition) {
  36392. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  36393. }
  36394. this._calculatedPosition.addInPlace(this.position);
  36395. }
  36396. var pose = this.rawPose;
  36397. if (poseData.orientation && pose.orientation) {
  36398. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  36399. if (this._mesh) {
  36400. if (this._mesh.getScene().useRightHandedSystem) {
  36401. this._deviceRoomRotationQuaternion.z *= -1;
  36402. this._deviceRoomRotationQuaternion.w *= -1;
  36403. }
  36404. else {
  36405. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  36406. }
  36407. }
  36408. // if the camera is set, rotate to the camera's rotation
  36409. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  36410. }
  36411. }
  36412. };
  36413. /**
  36414. * Attaches a mesh to the controller
  36415. * @param mesh the mesh to be attached
  36416. */
  36417. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  36418. if (this._mesh) {
  36419. this._mesh.parent = null;
  36420. }
  36421. this._mesh = mesh;
  36422. if (this._poseControlledCamera) {
  36423. this._mesh.parent = this._poseControlledCamera;
  36424. }
  36425. if (!this._mesh.rotationQuaternion) {
  36426. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36427. }
  36428. // 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
  36429. this._updatePoseAndMesh();
  36430. if (this._pointingPoseNode) {
  36431. var parents = [];
  36432. var obj = this._pointingPoseNode;
  36433. while (obj.parent) {
  36434. parents.push(obj.parent);
  36435. obj = obj.parent;
  36436. }
  36437. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  36438. }
  36439. this._meshAttachedObservable.notifyObservers(mesh);
  36440. };
  36441. /**
  36442. * Attaches the controllers mesh to a camera
  36443. * @param camera the camera the mesh should be attached to
  36444. */
  36445. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  36446. this._poseControlledCamera = camera;
  36447. if (this._mesh) {
  36448. this._mesh.parent = this._poseControlledCamera;
  36449. }
  36450. };
  36451. /**
  36452. * Disposes of the controller
  36453. */
  36454. PoseEnabledController.prototype.dispose = function () {
  36455. if (this._mesh) {
  36456. this._mesh.dispose();
  36457. }
  36458. this._mesh = null;
  36459. _super.prototype.dispose.call(this);
  36460. };
  36461. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  36462. /**
  36463. * The mesh that is attached to the controller
  36464. */
  36465. get: function () {
  36466. return this._mesh;
  36467. },
  36468. enumerable: true,
  36469. configurable: true
  36470. });
  36471. /**
  36472. * Gets the ray of the controller in the direction the controller is pointing
  36473. * @param length the length the resulting ray should be
  36474. * @returns a ray in the direction the controller is pointing
  36475. */
  36476. PoseEnabledController.prototype.getForwardRay = function (length) {
  36477. if (length === void 0) { length = 100; }
  36478. if (!this.mesh) {
  36479. 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);
  36480. }
  36481. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  36482. var origin = m.getTranslation();
  36483. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  36484. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  36485. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  36486. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  36487. };
  36488. /**
  36489. * Name of the child mesh that can be used to cast a ray from the controller
  36490. */
  36491. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  36492. return PoseEnabledController;
  36493. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  36494. /***/ }),
  36495. /***/ "./Gamepads/Controllers/viveController.ts":
  36496. /*!************************************************!*\
  36497. !*** ./Gamepads/Controllers/viveController.ts ***!
  36498. \************************************************/
  36499. /*! exports provided: ViveController */
  36500. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36501. "use strict";
  36502. __webpack_require__.r(__webpack_exports__);
  36503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  36504. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36505. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36506. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36507. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36508. /**
  36509. * Vive Controller
  36510. */
  36511. var ViveController = /** @class */ (function (_super) {
  36512. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  36513. /**
  36514. * Creates a new ViveController from a gamepad
  36515. * @param vrGamepad the gamepad that the controller should be created from
  36516. */
  36517. function ViveController(vrGamepad) {
  36518. var _this = _super.call(this, vrGamepad) || this;
  36519. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  36520. _this._invertLeftStickY = true;
  36521. return _this;
  36522. }
  36523. /**
  36524. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36525. * @param scene scene in which to add meshes
  36526. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36527. */
  36528. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  36529. var _this = this;
  36530. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  36531. /*
  36532. Parent Mesh name: ViveWand
  36533. - body
  36534. - r_gripper
  36535. - l_gripper
  36536. - menu_button
  36537. - system_button
  36538. - trackpad
  36539. - trigger
  36540. - LED
  36541. */
  36542. _this._defaultModel = newMeshes[1];
  36543. _this.attachToMesh(_this._defaultModel);
  36544. if (meshLoaded) {
  36545. meshLoaded(_this._defaultModel);
  36546. }
  36547. });
  36548. };
  36549. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  36550. /**
  36551. * Fired when the left button on this controller is modified
  36552. */
  36553. get: function () {
  36554. return this.onMainButtonStateChangedObservable;
  36555. },
  36556. enumerable: true,
  36557. configurable: true
  36558. });
  36559. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  36560. /**
  36561. * Fired when the right button on this controller is modified
  36562. */
  36563. get: function () {
  36564. return this.onMainButtonStateChangedObservable;
  36565. },
  36566. enumerable: true,
  36567. configurable: true
  36568. });
  36569. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  36570. /**
  36571. * Fired when the menu button on this controller is modified
  36572. */
  36573. get: function () {
  36574. return this.onSecondaryButtonStateChangedObservable;
  36575. },
  36576. enumerable: true,
  36577. configurable: true
  36578. });
  36579. /**
  36580. * Called once for each button that changed state since the last frame
  36581. * Vive mapping:
  36582. * 0: touchpad
  36583. * 1: trigger
  36584. * 2: left AND right buttons
  36585. * 3: menu button
  36586. * @param buttonIdx Which button index changed
  36587. * @param state New state of the button
  36588. * @param changes Which properties on the state changed since last frame
  36589. */
  36590. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36591. var notifyObject = state; //{ state: state, changes: changes };
  36592. switch (buttonIdx) {
  36593. case 0:
  36594. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  36595. return;
  36596. case 1: // index trigger
  36597. if (this._defaultModel) {
  36598. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  36599. }
  36600. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  36601. return;
  36602. case 2: // left AND right button
  36603. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  36604. return;
  36605. case 3:
  36606. if (this._defaultModel) {
  36607. if (notifyObject.pressed) {
  36608. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  36609. }
  36610. else {
  36611. (this._defaultModel.getChildren()[2]).position.y = 0;
  36612. }
  36613. }
  36614. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  36615. return;
  36616. }
  36617. };
  36618. /**
  36619. * Base Url for the controller model.
  36620. */
  36621. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  36622. /**
  36623. * File name for the controller model.
  36624. */
  36625. ViveController.MODEL_FILENAME = 'wand.babylon';
  36626. return ViveController;
  36627. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  36628. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36629. canCreate: function (gamepadInfo) {
  36630. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  36631. },
  36632. create: function (gamepadInfo) {
  36633. return new ViveController(gamepadInfo);
  36634. }
  36635. });
  36636. /***/ }),
  36637. /***/ "./Gamepads/Controllers/webVRController.ts":
  36638. /*!*************************************************!*\
  36639. !*** ./Gamepads/Controllers/webVRController.ts ***!
  36640. \*************************************************/
  36641. /*! exports provided: WebVRController */
  36642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36643. "use strict";
  36644. __webpack_require__.r(__webpack_exports__);
  36645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  36646. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36647. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36648. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36649. /**
  36650. * Defines the WebVRController object that represents controllers tracked in 3D space
  36651. */
  36652. var WebVRController = /** @class */ (function (_super) {
  36653. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  36654. /**
  36655. * Creates a new WebVRController from a gamepad
  36656. * @param vrGamepad the gamepad that the WebVRController should be created from
  36657. */
  36658. function WebVRController(vrGamepad) {
  36659. var _this = _super.call(this, vrGamepad) || this;
  36660. // Observables
  36661. /**
  36662. * Fired when the trigger state has changed
  36663. */
  36664. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36665. /**
  36666. * Fired when the main button state has changed
  36667. */
  36668. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36669. /**
  36670. * Fired when the secondary button state has changed
  36671. */
  36672. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36673. /**
  36674. * Fired when the pad state has changed
  36675. */
  36676. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36677. /**
  36678. * Fired when controllers stick values have changed
  36679. */
  36680. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36681. /**
  36682. * X and Y axis corrisponding to the controllers joystick
  36683. */
  36684. _this.pad = { x: 0, y: 0 };
  36685. // avoid GC, store state in a tmp object
  36686. _this._changes = {
  36687. pressChanged: false,
  36688. touchChanged: false,
  36689. valueChanged: false,
  36690. changed: false
  36691. };
  36692. _this._buttons = new Array(vrGamepad.buttons.length);
  36693. _this.hand = vrGamepad.hand;
  36694. return _this;
  36695. }
  36696. /**
  36697. * Fired when a controller button's state has changed
  36698. * @param callback the callback containing the button that was modified
  36699. */
  36700. WebVRController.prototype.onButtonStateChange = function (callback) {
  36701. this._onButtonStateChange = callback;
  36702. };
  36703. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  36704. /**
  36705. * The default controller model for the controller
  36706. */
  36707. get: function () {
  36708. return this._defaultModel;
  36709. },
  36710. enumerable: true,
  36711. configurable: true
  36712. });
  36713. /**
  36714. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  36715. */
  36716. WebVRController.prototype.update = function () {
  36717. _super.prototype.update.call(this);
  36718. for (var index = 0; index < this._buttons.length; index++) {
  36719. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  36720. }
  36721. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  36722. this.pad.x = this.leftStick.x;
  36723. this.pad.y = this.leftStick.y;
  36724. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  36725. }
  36726. };
  36727. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  36728. if (!newState) {
  36729. newState = {
  36730. pressed: false,
  36731. touched: false,
  36732. value: 0
  36733. };
  36734. }
  36735. if (!currentState) {
  36736. this._buttons[buttonIndex] = {
  36737. pressed: newState.pressed,
  36738. touched: newState.touched,
  36739. value: newState.value
  36740. };
  36741. return;
  36742. }
  36743. this._checkChanges(newState, currentState);
  36744. if (this._changes.changed) {
  36745. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  36746. this._handleButtonChange(buttonIndex, newState, this._changes);
  36747. }
  36748. this._buttons[buttonIndex].pressed = newState.pressed;
  36749. this._buttons[buttonIndex].touched = newState.touched;
  36750. // oculus triggers are never 0, thou not touched.
  36751. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  36752. };
  36753. WebVRController.prototype._checkChanges = function (newState, currentState) {
  36754. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  36755. this._changes.touchChanged = newState.touched !== currentState.touched;
  36756. this._changes.valueChanged = newState.value !== currentState.value;
  36757. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  36758. return this._changes;
  36759. };
  36760. /**
  36761. * Disposes of th webVRCOntroller
  36762. */
  36763. WebVRController.prototype.dispose = function () {
  36764. _super.prototype.dispose.call(this);
  36765. this.onTriggerStateChangedObservable.clear();
  36766. this.onMainButtonStateChangedObservable.clear();
  36767. this.onSecondaryButtonStateChangedObservable.clear();
  36768. this.onPadStateChangedObservable.clear();
  36769. this.onPadValuesChangedObservable.clear();
  36770. };
  36771. return WebVRController;
  36772. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  36773. /***/ }),
  36774. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  36775. /*!*********************************************************!*\
  36776. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  36777. \*********************************************************/
  36778. /*! exports provided: WindowsMotionController */
  36779. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36780. "use strict";
  36781. __webpack_require__.r(__webpack_exports__);
  36782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  36783. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36784. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  36785. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36786. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  36787. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  36788. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  36789. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36790. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36791. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  36792. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36793. /**
  36794. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  36795. */
  36796. var LoadedMeshInfo = /** @class */ (function () {
  36797. function LoadedMeshInfo() {
  36798. /**
  36799. * Map of the button meshes contained in the controller
  36800. */
  36801. this.buttonMeshes = {};
  36802. /**
  36803. * Map of the axis meshes contained in the controller
  36804. */
  36805. this.axisMeshes = {};
  36806. }
  36807. return LoadedMeshInfo;
  36808. }());
  36809. /**
  36810. * Defines the WindowsMotionController object that the state of the windows motion controller
  36811. */
  36812. var WindowsMotionController = /** @class */ (function (_super) {
  36813. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  36814. /**
  36815. * Creates a new WindowsMotionController from a gamepad
  36816. * @param vrGamepad the gamepad that the controller should be created from
  36817. */
  36818. function WindowsMotionController(vrGamepad) {
  36819. var _this = _super.call(this, vrGamepad) || this;
  36820. _this._mapping = {
  36821. // Semantic button names
  36822. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  36823. // A mapping of the button name to glTF model node name
  36824. // that should be transformed by button value.
  36825. buttonMeshNames: {
  36826. 'trigger': 'SELECT',
  36827. 'menu': 'MENU',
  36828. 'grip': 'GRASP',
  36829. 'thumbstick': 'THUMBSTICK_PRESS',
  36830. 'trackpad': 'TOUCHPAD_PRESS'
  36831. },
  36832. // This mapping is used to translate from the Motion Controller to Babylon semantics
  36833. buttonObservableNames: {
  36834. 'trigger': 'onTriggerStateChangedObservable',
  36835. 'menu': 'onSecondaryButtonStateChangedObservable',
  36836. 'grip': 'onMainButtonStateChangedObservable',
  36837. 'thumbstick': 'onPadStateChangedObservable',
  36838. 'trackpad': 'onTrackpadChangedObservable'
  36839. },
  36840. // A mapping of the axis name to glTF model node name
  36841. // that should be transformed by axis value.
  36842. // This array mirrors the browserGamepad.axes array, such that
  36843. // the mesh corresponding to axis 0 is in this array index 0.
  36844. axisMeshNames: [
  36845. 'THUMBSTICK_X',
  36846. 'THUMBSTICK_Y',
  36847. 'TOUCHPAD_TOUCH_X',
  36848. 'TOUCHPAD_TOUCH_Y'
  36849. ],
  36850. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  36851. };
  36852. /**
  36853. * Fired when the trackpad on this controller is clicked
  36854. */
  36855. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36856. /**
  36857. * Fired when the trackpad on this controller is modified
  36858. */
  36859. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36860. /**
  36861. * The current x and y values of this controller's trackpad
  36862. */
  36863. _this.trackpad = { x: 0, y: 0 };
  36864. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  36865. _this._loadedMeshInfo = null;
  36866. return _this;
  36867. }
  36868. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  36869. /**
  36870. * Fired when the trigger on this controller is modified
  36871. */
  36872. get: function () {
  36873. return this.onTriggerStateChangedObservable;
  36874. },
  36875. enumerable: true,
  36876. configurable: true
  36877. });
  36878. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  36879. /**
  36880. * Fired when the menu button on this controller is modified
  36881. */
  36882. get: function () {
  36883. return this.onSecondaryButtonStateChangedObservable;
  36884. },
  36885. enumerable: true,
  36886. configurable: true
  36887. });
  36888. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  36889. /**
  36890. * Fired when the grip button on this controller is modified
  36891. */
  36892. get: function () {
  36893. return this.onMainButtonStateChangedObservable;
  36894. },
  36895. enumerable: true,
  36896. configurable: true
  36897. });
  36898. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  36899. /**
  36900. * Fired when the thumbstick button on this controller is modified
  36901. */
  36902. get: function () {
  36903. return this.onPadStateChangedObservable;
  36904. },
  36905. enumerable: true,
  36906. configurable: true
  36907. });
  36908. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  36909. /**
  36910. * Fired when the touchpad button on this controller is modified
  36911. */
  36912. get: function () {
  36913. return this.onTrackpadChangedObservable;
  36914. },
  36915. enumerable: true,
  36916. configurable: true
  36917. });
  36918. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  36919. /**
  36920. * Fired when the touchpad values on this controller are modified
  36921. */
  36922. get: function () {
  36923. return this.onTrackpadValuesChangedObservable;
  36924. },
  36925. enumerable: true,
  36926. configurable: true
  36927. });
  36928. WindowsMotionController.prototype._updateTrackpad = function () {
  36929. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  36930. this.trackpad.x = this.browserGamepad["axes"][2];
  36931. this.trackpad.y = this.browserGamepad["axes"][3];
  36932. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  36933. }
  36934. };
  36935. /**
  36936. * Called once per frame by the engine.
  36937. */
  36938. WindowsMotionController.prototype.update = function () {
  36939. _super.prototype.update.call(this);
  36940. if (this.browserGamepad.axes) {
  36941. this._updateTrackpad();
  36942. // Only need to animate axes if there is a loaded mesh
  36943. if (this._loadedMeshInfo) {
  36944. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  36945. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  36946. }
  36947. }
  36948. }
  36949. };
  36950. /**
  36951. * Called once for each button that changed state since the last frame
  36952. * @param buttonIdx Which button index changed
  36953. * @param state New state of the button
  36954. * @param changes Which properties on the state changed since last frame
  36955. */
  36956. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36957. var buttonName = this._mapping.buttons[buttonIdx];
  36958. if (!buttonName) {
  36959. return;
  36960. }
  36961. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  36962. this._updateTrackpad();
  36963. // Only emit events for buttons that we know how to map from index to name
  36964. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  36965. if (observable) {
  36966. observable.notifyObservers(state);
  36967. }
  36968. this._lerpButtonTransform(buttonName, state.value);
  36969. };
  36970. /**
  36971. * Moves the buttons on the controller mesh based on their current state
  36972. * @param buttonName the name of the button to move
  36973. * @param buttonValue the value of the button which determines the buttons new position
  36974. */
  36975. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  36976. // If there is no loaded mesh, there is nothing to transform.
  36977. if (!this._loadedMeshInfo) {
  36978. return;
  36979. }
  36980. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  36981. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36982. return;
  36983. }
  36984. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  36985. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  36986. };
  36987. /**
  36988. * Moves the axis on the controller mesh based on its current state
  36989. * @param axis the index of the axis
  36990. * @param axisValue the value of the axis which determines the meshes new position
  36991. * @hidden
  36992. */
  36993. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  36994. if (!this._loadedMeshInfo) {
  36995. return;
  36996. }
  36997. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  36998. if (!meshInfo) {
  36999. return;
  37000. }
  37001. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  37002. return;
  37003. }
  37004. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  37005. var lerpValue = axisValue * 0.5 + 0.5;
  37006. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  37007. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  37008. };
  37009. /**
  37010. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  37011. * @param scene scene in which to add meshes
  37012. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  37013. */
  37014. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  37015. var _this = this;
  37016. if (forceDefault === void 0) { forceDefault = false; }
  37017. var path;
  37018. var filename;
  37019. // Checking if GLB loader is present
  37020. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  37021. // Determine the device specific folder based on the ID suffix
  37022. var device = 'default';
  37023. if (this.id && !forceDefault) {
  37024. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  37025. device = ((match && match[0]) || device);
  37026. }
  37027. // Hand
  37028. if (this.hand === 'left') {
  37029. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  37030. }
  37031. else { // Right is the default if no hand is specified
  37032. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  37033. }
  37034. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  37035. }
  37036. else {
  37037. _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");
  37038. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  37039. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  37040. }
  37041. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  37042. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  37043. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  37044. if (!_this._loadedMeshInfo) {
  37045. return;
  37046. }
  37047. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  37048. _this.attachToMesh(_this._defaultModel);
  37049. if (meshLoaded) {
  37050. meshLoaded(_this._defaultModel);
  37051. }
  37052. }, null, function (scene, message) {
  37053. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  37054. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  37055. if (!forceDefault) {
  37056. _this.initControllerMesh(scene, meshLoaded, true);
  37057. }
  37058. });
  37059. };
  37060. /**
  37061. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  37062. * can be transformed by button presses and axes values, based on this._mapping.
  37063. *
  37064. * @param scene scene in which the meshes exist
  37065. * @param meshes list of meshes that make up the controller model to process
  37066. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  37067. */
  37068. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  37069. var loadedMeshInfo = null;
  37070. // Create a new mesh to contain the glTF hierarchy
  37071. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  37072. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  37073. var childMesh = null;
  37074. for (var i = 0; i < meshes.length; i++) {
  37075. var mesh = meshes[i];
  37076. if (!mesh.parent) {
  37077. // Exclude controller meshes from picking results
  37078. mesh.isPickable = false;
  37079. // Handle root node, attach to the new parentMesh
  37080. childMesh = mesh;
  37081. break;
  37082. }
  37083. }
  37084. if (childMesh) {
  37085. childMesh.setParent(parentMesh);
  37086. // Create our mesh info. Note that this method will always return non-null.
  37087. loadedMeshInfo = this.createMeshInfo(parentMesh);
  37088. }
  37089. else {
  37090. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  37091. }
  37092. return loadedMeshInfo;
  37093. };
  37094. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  37095. var loadedMeshInfo = new LoadedMeshInfo();
  37096. var i;
  37097. loadedMeshInfo.rootNode = rootNode;
  37098. // Reset the caches
  37099. loadedMeshInfo.buttonMeshes = {};
  37100. loadedMeshInfo.axisMeshes = {};
  37101. // Button Meshes
  37102. for (i = 0; i < this._mapping.buttons.length; i++) {
  37103. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  37104. if (!buttonMeshName) {
  37105. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  37106. continue;
  37107. }
  37108. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  37109. if (!buttonMesh) {
  37110. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  37111. continue;
  37112. }
  37113. var buttonMeshInfo = {
  37114. index: i,
  37115. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  37116. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  37117. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  37118. };
  37119. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  37120. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  37121. }
  37122. else {
  37123. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  37124. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  37125. '(VALUE: ' + !!buttonMeshInfo.value +
  37126. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  37127. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  37128. ')');
  37129. }
  37130. }
  37131. // Axis Meshes
  37132. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  37133. var axisMeshName = this._mapping.axisMeshNames[i];
  37134. if (!axisMeshName) {
  37135. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  37136. continue;
  37137. }
  37138. var axisMesh = getChildByName(rootNode, axisMeshName);
  37139. if (!axisMesh) {
  37140. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  37141. continue;
  37142. }
  37143. var axisMeshInfo = {
  37144. index: i,
  37145. value: getImmediateChildByName(axisMesh, 'VALUE'),
  37146. min: getImmediateChildByName(axisMesh, 'MIN'),
  37147. max: getImmediateChildByName(axisMesh, 'MAX')
  37148. };
  37149. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  37150. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  37151. }
  37152. else {
  37153. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  37154. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  37155. '(VALUE: ' + !!axisMeshInfo.value +
  37156. ', MIN: ' + !!axisMeshInfo.min +
  37157. ', MAX:' + !!axisMeshInfo.max +
  37158. ')');
  37159. }
  37160. }
  37161. // Pointing Ray
  37162. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  37163. if (!loadedMeshInfo.pointingPoseNode) {
  37164. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  37165. }
  37166. else {
  37167. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  37168. }
  37169. return loadedMeshInfo;
  37170. // Look through all children recursively. This will return null if no mesh exists with the given name.
  37171. function getChildByName(node, name) {
  37172. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  37173. }
  37174. // Look through only immediate children. This will return null if no mesh exists with the given name.
  37175. function getImmediateChildByName(node, name) {
  37176. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  37177. }
  37178. };
  37179. /**
  37180. * Gets the ray of the controller in the direction the controller is pointing
  37181. * @param length the length the resulting ray should be
  37182. * @returns a ray in the direction the controller is pointing
  37183. */
  37184. WindowsMotionController.prototype.getForwardRay = function (length) {
  37185. if (length === void 0) { length = 100; }
  37186. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  37187. return _super.prototype.getForwardRay.call(this, length);
  37188. }
  37189. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  37190. var origin = m.getTranslation();
  37191. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  37192. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  37193. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  37194. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  37195. };
  37196. /**
  37197. * Disposes of the controller
  37198. */
  37199. WindowsMotionController.prototype.dispose = function () {
  37200. _super.prototype.dispose.call(this);
  37201. this.onTrackpadChangedObservable.clear();
  37202. };
  37203. /**
  37204. * The base url used to load the left and right controller models
  37205. */
  37206. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  37207. /**
  37208. * The name of the left controller model file
  37209. */
  37210. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  37211. /**
  37212. * The name of the right controller model file
  37213. */
  37214. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  37215. /**
  37216. * The controller name prefix for this controller type
  37217. */
  37218. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  37219. /**
  37220. * The controller id pattern for this controller type
  37221. */
  37222. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  37223. return WindowsMotionController;
  37224. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  37225. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  37226. canCreate: function (gamepadInfo) {
  37227. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  37228. },
  37229. create: function (gamepadInfo) {
  37230. return new WindowsMotionController(gamepadInfo);
  37231. }
  37232. });
  37233. /***/ }),
  37234. /***/ "./Gamepads/gamepad.ts":
  37235. /*!*****************************!*\
  37236. !*** ./Gamepads/gamepad.ts ***!
  37237. \*****************************/
  37238. /*! exports provided: StickValues, Gamepad, GenericPad */
  37239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37240. "use strict";
  37241. __webpack_require__.r(__webpack_exports__);
  37242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  37243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  37244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  37245. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37246. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37247. /**
  37248. * Represents a gamepad control stick position
  37249. */
  37250. var StickValues = /** @class */ (function () {
  37251. /**
  37252. * Initializes the gamepad x and y control stick values
  37253. * @param x The x component of the gamepad control stick value
  37254. * @param y The y component of the gamepad control stick value
  37255. */
  37256. function StickValues(
  37257. /**
  37258. * The x component of the control stick
  37259. */
  37260. x,
  37261. /**
  37262. * The y component of the control stick
  37263. */
  37264. y) {
  37265. this.x = x;
  37266. this.y = y;
  37267. }
  37268. return StickValues;
  37269. }());
  37270. /**
  37271. * Represents a gamepad
  37272. */
  37273. var Gamepad = /** @class */ (function () {
  37274. /**
  37275. * Initializes the gamepad
  37276. * @param id The id of the gamepad
  37277. * @param index The index of the gamepad
  37278. * @param browserGamepad The browser gamepad
  37279. * @param leftStickX The x component of the left joystick
  37280. * @param leftStickY The y component of the left joystick
  37281. * @param rightStickX The x component of the right joystick
  37282. * @param rightStickY The y component of the right joystick
  37283. */
  37284. function Gamepad(
  37285. /**
  37286. * The id of the gamepad
  37287. */
  37288. id,
  37289. /**
  37290. * The index of the gamepad
  37291. */
  37292. index,
  37293. /**
  37294. * The browser gamepad
  37295. */
  37296. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  37297. if (leftStickX === void 0) { leftStickX = 0; }
  37298. if (leftStickY === void 0) { leftStickY = 1; }
  37299. if (rightStickX === void 0) { rightStickX = 2; }
  37300. if (rightStickY === void 0) { rightStickY = 3; }
  37301. this.id = id;
  37302. this.index = index;
  37303. this.browserGamepad = browserGamepad;
  37304. this._leftStick = { x: 0, y: 0 };
  37305. this._rightStick = { x: 0, y: 0 };
  37306. /** @hidden */
  37307. this._isConnected = true;
  37308. /**
  37309. * Specifies whether the left control stick should be Y-inverted
  37310. */
  37311. this._invertLeftStickY = false;
  37312. this.type = Gamepad.GAMEPAD;
  37313. this._leftStickAxisX = leftStickX;
  37314. this._leftStickAxisY = leftStickY;
  37315. this._rightStickAxisX = rightStickX;
  37316. this._rightStickAxisY = rightStickY;
  37317. if (this.browserGamepad.axes.length >= 2) {
  37318. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  37319. }
  37320. if (this.browserGamepad.axes.length >= 4) {
  37321. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  37322. }
  37323. }
  37324. Object.defineProperty(Gamepad.prototype, "isConnected", {
  37325. /**
  37326. * Specifies if the gamepad has been connected
  37327. */
  37328. get: function () {
  37329. return this._isConnected;
  37330. },
  37331. enumerable: true,
  37332. configurable: true
  37333. });
  37334. /**
  37335. * Callback triggered when the left joystick has changed
  37336. * @param callback
  37337. */
  37338. Gamepad.prototype.onleftstickchanged = function (callback) {
  37339. this._onleftstickchanged = callback;
  37340. };
  37341. /**
  37342. * Callback triggered when the right joystick has changed
  37343. * @param callback
  37344. */
  37345. Gamepad.prototype.onrightstickchanged = function (callback) {
  37346. this._onrightstickchanged = callback;
  37347. };
  37348. Object.defineProperty(Gamepad.prototype, "leftStick", {
  37349. /**
  37350. * Gets the left joystick
  37351. */
  37352. get: function () {
  37353. return this._leftStick;
  37354. },
  37355. /**
  37356. * Sets the left joystick values
  37357. */
  37358. set: function (newValues) {
  37359. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  37360. this._onleftstickchanged(newValues);
  37361. }
  37362. this._leftStick = newValues;
  37363. },
  37364. enumerable: true,
  37365. configurable: true
  37366. });
  37367. Object.defineProperty(Gamepad.prototype, "rightStick", {
  37368. /**
  37369. * Gets the right joystick
  37370. */
  37371. get: function () {
  37372. return this._rightStick;
  37373. },
  37374. /**
  37375. * Sets the right joystick value
  37376. */
  37377. set: function (newValues) {
  37378. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  37379. this._onrightstickchanged(newValues);
  37380. }
  37381. this._rightStick = newValues;
  37382. },
  37383. enumerable: true,
  37384. configurable: true
  37385. });
  37386. /**
  37387. * Updates the gamepad joystick positions
  37388. */
  37389. Gamepad.prototype.update = function () {
  37390. if (this._leftStick) {
  37391. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  37392. if (this._invertLeftStickY) {
  37393. this.leftStick.y *= -1;
  37394. }
  37395. }
  37396. if (this._rightStick) {
  37397. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  37398. }
  37399. };
  37400. /**
  37401. * Disposes the gamepad
  37402. */
  37403. Gamepad.prototype.dispose = function () {
  37404. };
  37405. /**
  37406. * Represents a gamepad controller
  37407. */
  37408. Gamepad.GAMEPAD = 0;
  37409. /**
  37410. * Represents a generic controller
  37411. */
  37412. Gamepad.GENERIC = 1;
  37413. /**
  37414. * Represents an XBox controller
  37415. */
  37416. Gamepad.XBOX = 2;
  37417. /**
  37418. * Represents a pose-enabled controller
  37419. */
  37420. Gamepad.POSE_ENABLED = 3;
  37421. return Gamepad;
  37422. }());
  37423. /**
  37424. * Represents a generic gamepad
  37425. */
  37426. var GenericPad = /** @class */ (function (_super) {
  37427. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  37428. /**
  37429. * Initializes the generic gamepad
  37430. * @param id The id of the generic gamepad
  37431. * @param index The index of the generic gamepad
  37432. * @param browserGamepad The browser gamepad
  37433. */
  37434. function GenericPad(id, index, browserGamepad) {
  37435. var _this = _super.call(this, id, index, browserGamepad) || this;
  37436. /**
  37437. * Observable triggered when a button has been pressed
  37438. */
  37439. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37440. /**
  37441. * Observable triggered when a button has been released
  37442. */
  37443. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37444. _this.type = Gamepad.GENERIC;
  37445. _this._buttons = new Array(browserGamepad.buttons.length);
  37446. return _this;
  37447. }
  37448. /**
  37449. * Callback triggered when a button has been pressed
  37450. * @param callback Called when a button has been pressed
  37451. */
  37452. GenericPad.prototype.onbuttondown = function (callback) {
  37453. this._onbuttondown = callback;
  37454. };
  37455. /**
  37456. * Callback triggered when a button has been released
  37457. * @param callback Called when a button has been released
  37458. */
  37459. GenericPad.prototype.onbuttonup = function (callback) {
  37460. this._onbuttonup = callback;
  37461. };
  37462. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  37463. if (newValue !== currentValue) {
  37464. if (newValue === 1) {
  37465. if (this._onbuttondown) {
  37466. this._onbuttondown(buttonIndex);
  37467. }
  37468. this.onButtonDownObservable.notifyObservers(buttonIndex);
  37469. }
  37470. if (newValue === 0) {
  37471. if (this._onbuttonup) {
  37472. this._onbuttonup(buttonIndex);
  37473. }
  37474. this.onButtonUpObservable.notifyObservers(buttonIndex);
  37475. }
  37476. }
  37477. return newValue;
  37478. };
  37479. /**
  37480. * Updates the generic gamepad
  37481. */
  37482. GenericPad.prototype.update = function () {
  37483. _super.prototype.update.call(this);
  37484. for (var index = 0; index < this._buttons.length; index++) {
  37485. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  37486. }
  37487. };
  37488. /**
  37489. * Disposes the generic gamepad
  37490. */
  37491. GenericPad.prototype.dispose = function () {
  37492. _super.prototype.dispose.call(this);
  37493. this.onButtonDownObservable.clear();
  37494. this.onButtonUpObservable.clear();
  37495. };
  37496. return GenericPad;
  37497. }(Gamepad));
  37498. /***/ }),
  37499. /***/ "./Gamepads/gamepadManager.ts":
  37500. /*!************************************!*\
  37501. !*** ./Gamepads/gamepadManager.ts ***!
  37502. \************************************/
  37503. /*! exports provided: GamepadManager */
  37504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37505. "use strict";
  37506. __webpack_require__.r(__webpack_exports__);
  37507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  37508. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  37509. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37510. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  37511. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  37512. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37513. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37514. /**
  37515. * Manager for handling gamepads
  37516. */
  37517. var GamepadManager = /** @class */ (function () {
  37518. /**
  37519. * Initializes the gamepad manager
  37520. * @param _scene BabylonJS scene
  37521. */
  37522. function GamepadManager(_scene) {
  37523. var _this = this;
  37524. this._scene = _scene;
  37525. this._babylonGamepads = [];
  37526. this._oneGamepadConnected = false;
  37527. /** @hidden */
  37528. this._isMonitoring = false;
  37529. /**
  37530. * observable to be triggered when the gamepad controller has been disconnected
  37531. */
  37532. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37533. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  37534. this._gamepadEventSupported = false;
  37535. }
  37536. else {
  37537. this._gamepadEventSupported = 'GamepadEvent' in window;
  37538. this._gamepadSupport = (navigator.getGamepads ||
  37539. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  37540. }
  37541. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  37542. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  37543. for (var i in _this._babylonGamepads) {
  37544. var gamepad = _this._babylonGamepads[i];
  37545. if (gamepad && gamepad._isConnected) {
  37546. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  37547. }
  37548. }
  37549. });
  37550. this._onGamepadConnectedEvent = function (evt) {
  37551. var gamepad = evt.gamepad;
  37552. if (gamepad.index in _this._babylonGamepads) {
  37553. if (_this._babylonGamepads[gamepad.index].isConnected) {
  37554. return;
  37555. }
  37556. }
  37557. var newGamepad;
  37558. if (_this._babylonGamepads[gamepad.index]) {
  37559. newGamepad = _this._babylonGamepads[gamepad.index];
  37560. newGamepad.browserGamepad = gamepad;
  37561. newGamepad._isConnected = true;
  37562. }
  37563. else {
  37564. newGamepad = _this._addNewGamepad(gamepad);
  37565. }
  37566. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37567. _this._startMonitoringGamepads();
  37568. };
  37569. this._onGamepadDisconnectedEvent = function (evt) {
  37570. var gamepad = evt.gamepad;
  37571. // Remove the gamepad from the list of gamepads to monitor.
  37572. for (var i in _this._babylonGamepads) {
  37573. if (_this._babylonGamepads[i].index === gamepad.index) {
  37574. var disconnectedGamepad = _this._babylonGamepads[i];
  37575. disconnectedGamepad._isConnected = false;
  37576. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  37577. break;
  37578. }
  37579. }
  37580. };
  37581. if (this._gamepadSupport) {
  37582. //first add already-connected gamepads
  37583. this._updateGamepadObjects();
  37584. if (this._babylonGamepads.length) {
  37585. this._startMonitoringGamepads();
  37586. }
  37587. // Checking if the gamepad connected event is supported (like in Firefox)
  37588. if (this._gamepadEventSupported) {
  37589. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  37590. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  37591. }
  37592. else {
  37593. this._startMonitoringGamepads();
  37594. }
  37595. }
  37596. }
  37597. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  37598. /**
  37599. * The gamepads in the game pad manager
  37600. */
  37601. get: function () {
  37602. return this._babylonGamepads;
  37603. },
  37604. enumerable: true,
  37605. configurable: true
  37606. });
  37607. /**
  37608. * Get the gamepad controllers based on type
  37609. * @param type The type of gamepad controller
  37610. * @returns Nullable gamepad
  37611. */
  37612. GamepadManager.prototype.getGamepadByType = function (type) {
  37613. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  37614. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  37615. var gamepad = _a[_i];
  37616. if (gamepad && gamepad.type === type) {
  37617. return gamepad;
  37618. }
  37619. }
  37620. return null;
  37621. };
  37622. /**
  37623. * Disposes the gamepad manager
  37624. */
  37625. GamepadManager.prototype.dispose = function () {
  37626. if (this._gamepadEventSupported) {
  37627. if (this._onGamepadConnectedEvent) {
  37628. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  37629. }
  37630. if (this._onGamepadDisconnectedEvent) {
  37631. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  37632. }
  37633. this._onGamepadConnectedEvent = null;
  37634. this._onGamepadDisconnectedEvent = null;
  37635. }
  37636. this._babylonGamepads.forEach(function (gamepad) {
  37637. gamepad.dispose();
  37638. });
  37639. this.onGamepadConnectedObservable.clear();
  37640. this.onGamepadDisconnectedObservable.clear();
  37641. this._oneGamepadConnected = false;
  37642. this._stopMonitoringGamepads();
  37643. this._babylonGamepads = [];
  37644. };
  37645. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  37646. if (!this._oneGamepadConnected) {
  37647. this._oneGamepadConnected = true;
  37648. }
  37649. var newGamepad;
  37650. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  37651. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  37652. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  37653. }
  37654. // if pose is supported, use the (WebVR) pose enabled controller
  37655. else if (gamepad.pose) {
  37656. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  37657. }
  37658. else {
  37659. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  37660. }
  37661. this._babylonGamepads[newGamepad.index] = newGamepad;
  37662. return newGamepad;
  37663. };
  37664. GamepadManager.prototype._startMonitoringGamepads = function () {
  37665. if (!this._isMonitoring) {
  37666. this._isMonitoring = true;
  37667. //back-comp
  37668. if (!this._scene) {
  37669. this._checkGamepadsStatus();
  37670. }
  37671. }
  37672. };
  37673. GamepadManager.prototype._stopMonitoringGamepads = function () {
  37674. this._isMonitoring = false;
  37675. };
  37676. /** @hidden */
  37677. GamepadManager.prototype._checkGamepadsStatus = function () {
  37678. var _this = this;
  37679. // Hack to be compatible Chrome
  37680. this._updateGamepadObjects();
  37681. for (var i in this._babylonGamepads) {
  37682. var gamepad = this._babylonGamepads[i];
  37683. if (!gamepad || !gamepad.isConnected) {
  37684. continue;
  37685. }
  37686. gamepad.update();
  37687. }
  37688. if (this._isMonitoring && !this._scene) {
  37689. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  37690. }
  37691. };
  37692. // This function is called only on Chrome, which does not properly support
  37693. // connection/disconnection events and forces you to recopy again the gamepad object
  37694. GamepadManager.prototype._updateGamepadObjects = function () {
  37695. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  37696. for (var i = 0; i < gamepads.length; i++) {
  37697. var gamepad = gamepads[i];
  37698. if (gamepad) {
  37699. if (!this._babylonGamepads[gamepad.index]) {
  37700. var newGamepad = this._addNewGamepad(gamepad);
  37701. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37702. }
  37703. else {
  37704. // Forced to copy again this object for Chrome for unknown reason
  37705. this._babylonGamepads[i].browserGamepad = gamepad;
  37706. if (!this._babylonGamepads[i].isConnected) {
  37707. this._babylonGamepads[i]._isConnected = true;
  37708. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  37709. }
  37710. }
  37711. }
  37712. }
  37713. };
  37714. return GamepadManager;
  37715. }());
  37716. /***/ }),
  37717. /***/ "./Gamepads/gamepadSceneComponent.ts":
  37718. /*!*******************************************!*\
  37719. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  37720. \*******************************************/
  37721. /*! exports provided: GamepadSystemSceneComponent */
  37722. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37723. "use strict";
  37724. __webpack_require__.r(__webpack_exports__);
  37725. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  37726. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  37727. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  37728. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37729. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  37730. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  37731. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  37732. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  37733. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  37734. get: function () {
  37735. if (!this._gamepadManager) {
  37736. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  37737. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  37738. if (!component) {
  37739. component = new GamepadSystemSceneComponent(this);
  37740. this._addComponent(component);
  37741. }
  37742. }
  37743. return this._gamepadManager;
  37744. },
  37745. enumerable: true,
  37746. configurable: true
  37747. });
  37748. /**
  37749. * Adds a gamepad to the free camera inputs manager
  37750. */
  37751. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  37752. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  37753. return this;
  37754. };
  37755. /**
  37756. * Adds a gamepad to the arc rotate camera inputs manager
  37757. */
  37758. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  37759. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  37760. return this;
  37761. };
  37762. /**
  37763. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37764. */
  37765. var GamepadSystemSceneComponent = /** @class */ (function () {
  37766. /**
  37767. * Creates a new instance of the component for the given scene
  37768. * @param scene Defines the scene to register the component in
  37769. */
  37770. function GamepadSystemSceneComponent(scene) {
  37771. /**
  37772. * The component name helpfull to identify the component in the list of scene components.
  37773. */
  37774. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  37775. this.scene = scene;
  37776. }
  37777. /**
  37778. * Registers the component in a given scene
  37779. */
  37780. GamepadSystemSceneComponent.prototype.register = function () {
  37781. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  37782. };
  37783. /**
  37784. * Rebuilds the elements related to this component in case of
  37785. * context lost for instance.
  37786. */
  37787. GamepadSystemSceneComponent.prototype.rebuild = function () {
  37788. // Nothing to do for gamepads
  37789. };
  37790. /**
  37791. * Disposes the component and the associated ressources
  37792. */
  37793. GamepadSystemSceneComponent.prototype.dispose = function () {
  37794. var gamepadManager = this.scene._gamepadManager;
  37795. if (gamepadManager) {
  37796. gamepadManager.dispose();
  37797. this.scene._gamepadManager = null;
  37798. }
  37799. };
  37800. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  37801. var gamepadManager = this.scene._gamepadManager;
  37802. if (gamepadManager && gamepadManager._isMonitoring) {
  37803. gamepadManager._checkGamepadsStatus();
  37804. }
  37805. };
  37806. return GamepadSystemSceneComponent;
  37807. }());
  37808. /***/ }),
  37809. /***/ "./Gamepads/index.ts":
  37810. /*!***************************!*\
  37811. !*** ./Gamepads/index.ts ***!
  37812. \***************************/
  37813. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37814. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37815. "use strict";
  37816. __webpack_require__.r(__webpack_exports__);
  37817. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  37818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  37819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  37820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  37821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  37822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  37823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  37824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  37825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  37826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  37827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  37828. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  37830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  37831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  37832. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  37834. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  37835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  37836. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  37838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  37839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  37840. /***/ }),
  37841. /***/ "./Gamepads/xboxGamepad.ts":
  37842. /*!*********************************!*\
  37843. !*** ./Gamepads/xboxGamepad.ts ***!
  37844. \*********************************/
  37845. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37847. "use strict";
  37848. __webpack_require__.r(__webpack_exports__);
  37849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  37850. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  37851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  37852. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37853. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37854. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  37855. /**
  37856. * Defines supported buttons for XBox360 compatible gamepads
  37857. */
  37858. var Xbox360Button;
  37859. (function (Xbox360Button) {
  37860. /** A */
  37861. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  37862. /** B */
  37863. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  37864. /** X */
  37865. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  37866. /** Y */
  37867. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  37868. /** Start */
  37869. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  37870. /** Back */
  37871. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  37872. /** Left button */
  37873. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  37874. /** Right button */
  37875. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  37876. /** Left stick */
  37877. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  37878. /** Right stick */
  37879. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  37880. })(Xbox360Button || (Xbox360Button = {}));
  37881. /** Defines values for XBox360 DPad */
  37882. var Xbox360Dpad;
  37883. (function (Xbox360Dpad) {
  37884. /** Up */
  37885. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  37886. /** Down */
  37887. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  37888. /** Left */
  37889. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  37890. /** Right */
  37891. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  37892. })(Xbox360Dpad || (Xbox360Dpad = {}));
  37893. /**
  37894. * Defines a XBox360 gamepad
  37895. */
  37896. var Xbox360Pad = /** @class */ (function (_super) {
  37897. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  37898. /**
  37899. * Creates a new XBox360 gamepad object
  37900. * @param id defines the id of this gamepad
  37901. * @param index defines its index
  37902. * @param gamepad defines the internal HTML gamepad object
  37903. * @param xboxOne defines if it is a XBox One gamepad
  37904. */
  37905. function Xbox360Pad(id, index, gamepad, xboxOne) {
  37906. if (xboxOne === void 0) { xboxOne = false; }
  37907. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  37908. _this._leftTrigger = 0;
  37909. _this._rightTrigger = 0;
  37910. /** Observable raised when a button is pressed */
  37911. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37912. /** Observable raised when a button is released */
  37913. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37914. /** Observable raised when a pad is pressed */
  37915. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37916. /** Observable raised when a pad is released */
  37917. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37918. _this._buttonA = 0;
  37919. _this._buttonB = 0;
  37920. _this._buttonX = 0;
  37921. _this._buttonY = 0;
  37922. _this._buttonBack = 0;
  37923. _this._buttonStart = 0;
  37924. _this._buttonLB = 0;
  37925. _this._buttonRB = 0;
  37926. _this._buttonLeftStick = 0;
  37927. _this._buttonRightStick = 0;
  37928. _this._dPadUp = 0;
  37929. _this._dPadDown = 0;
  37930. _this._dPadLeft = 0;
  37931. _this._dPadRight = 0;
  37932. _this._isXboxOnePad = false;
  37933. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  37934. _this._isXboxOnePad = xboxOne;
  37935. return _this;
  37936. }
  37937. /**
  37938. * Defines the callback to call when left trigger is pressed
  37939. * @param callback defines the callback to use
  37940. */
  37941. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  37942. this._onlefttriggerchanged = callback;
  37943. };
  37944. /**
  37945. * Defines the callback to call when right trigger is pressed
  37946. * @param callback defines the callback to use
  37947. */
  37948. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  37949. this._onrighttriggerchanged = callback;
  37950. };
  37951. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  37952. /**
  37953. * Gets the left trigger value
  37954. */
  37955. get: function () {
  37956. return this._leftTrigger;
  37957. },
  37958. /**
  37959. * Sets the left trigger value
  37960. */
  37961. set: function (newValue) {
  37962. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  37963. this._onlefttriggerchanged(newValue);
  37964. }
  37965. this._leftTrigger = newValue;
  37966. },
  37967. enumerable: true,
  37968. configurable: true
  37969. });
  37970. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  37971. /**
  37972. * Gets the right trigger value
  37973. */
  37974. get: function () {
  37975. return this._rightTrigger;
  37976. },
  37977. /**
  37978. * Sets the right trigger value
  37979. */
  37980. set: function (newValue) {
  37981. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  37982. this._onrighttriggerchanged(newValue);
  37983. }
  37984. this._rightTrigger = newValue;
  37985. },
  37986. enumerable: true,
  37987. configurable: true
  37988. });
  37989. /**
  37990. * Defines the callback to call when a button is pressed
  37991. * @param callback defines the callback to use
  37992. */
  37993. Xbox360Pad.prototype.onbuttondown = function (callback) {
  37994. this._onbuttondown = callback;
  37995. };
  37996. /**
  37997. * Defines the callback to call when a button is released
  37998. * @param callback defines the callback to use
  37999. */
  38000. Xbox360Pad.prototype.onbuttonup = function (callback) {
  38001. this._onbuttonup = callback;
  38002. };
  38003. /**
  38004. * Defines the callback to call when a pad is pressed
  38005. * @param callback defines the callback to use
  38006. */
  38007. Xbox360Pad.prototype.ondpaddown = function (callback) {
  38008. this._ondpaddown = callback;
  38009. };
  38010. /**
  38011. * Defines the callback to call when a pad is released
  38012. * @param callback defines the callback to use
  38013. */
  38014. Xbox360Pad.prototype.ondpadup = function (callback) {
  38015. this._ondpadup = callback;
  38016. };
  38017. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  38018. if (newValue !== currentValue) {
  38019. if (newValue === 1) {
  38020. if (this._onbuttondown) {
  38021. this._onbuttondown(buttonType);
  38022. }
  38023. this.onButtonDownObservable.notifyObservers(buttonType);
  38024. }
  38025. if (newValue === 0) {
  38026. if (this._onbuttonup) {
  38027. this._onbuttonup(buttonType);
  38028. }
  38029. this.onButtonUpObservable.notifyObservers(buttonType);
  38030. }
  38031. }
  38032. return newValue;
  38033. };
  38034. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  38035. if (newValue !== currentValue) {
  38036. if (newValue === 1) {
  38037. if (this._ondpaddown) {
  38038. this._ondpaddown(buttonType);
  38039. }
  38040. this.onPadDownObservable.notifyObservers(buttonType);
  38041. }
  38042. if (newValue === 0) {
  38043. if (this._ondpadup) {
  38044. this._ondpadup(buttonType);
  38045. }
  38046. this.onPadUpObservable.notifyObservers(buttonType);
  38047. }
  38048. }
  38049. return newValue;
  38050. };
  38051. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  38052. /**
  38053. * Gets the value of the `A` button
  38054. */
  38055. get: function () {
  38056. return this._buttonA;
  38057. },
  38058. /**
  38059. * Sets the value of the `A` button
  38060. */
  38061. set: function (value) {
  38062. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  38063. },
  38064. enumerable: true,
  38065. configurable: true
  38066. });
  38067. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  38068. /**
  38069. * Gets the value of the `B` button
  38070. */
  38071. get: function () {
  38072. return this._buttonB;
  38073. },
  38074. /**
  38075. * Sets the value of the `B` button
  38076. */
  38077. set: function (value) {
  38078. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  38079. },
  38080. enumerable: true,
  38081. configurable: true
  38082. });
  38083. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  38084. /**
  38085. * Gets the value of the `X` button
  38086. */
  38087. get: function () {
  38088. return this._buttonX;
  38089. },
  38090. /**
  38091. * Sets the value of the `X` button
  38092. */
  38093. set: function (value) {
  38094. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  38095. },
  38096. enumerable: true,
  38097. configurable: true
  38098. });
  38099. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  38100. /**
  38101. * Gets the value of the `Y` button
  38102. */
  38103. get: function () {
  38104. return this._buttonY;
  38105. },
  38106. /**
  38107. * Sets the value of the `Y` button
  38108. */
  38109. set: function (value) {
  38110. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  38111. },
  38112. enumerable: true,
  38113. configurable: true
  38114. });
  38115. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  38116. /**
  38117. * Gets the value of the `Start` button
  38118. */
  38119. get: function () {
  38120. return this._buttonStart;
  38121. },
  38122. /**
  38123. * Sets the value of the `Start` button
  38124. */
  38125. set: function (value) {
  38126. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  38127. },
  38128. enumerable: true,
  38129. configurable: true
  38130. });
  38131. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  38132. /**
  38133. * Gets the value of the `Back` button
  38134. */
  38135. get: function () {
  38136. return this._buttonBack;
  38137. },
  38138. /**
  38139. * Sets the value of the `Back` button
  38140. */
  38141. set: function (value) {
  38142. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  38143. },
  38144. enumerable: true,
  38145. configurable: true
  38146. });
  38147. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  38148. /**
  38149. * Gets the value of the `Left` button
  38150. */
  38151. get: function () {
  38152. return this._buttonLB;
  38153. },
  38154. /**
  38155. * Sets the value of the `Left` button
  38156. */
  38157. set: function (value) {
  38158. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  38159. },
  38160. enumerable: true,
  38161. configurable: true
  38162. });
  38163. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  38164. /**
  38165. * Gets the value of the `Right` button
  38166. */
  38167. get: function () {
  38168. return this._buttonRB;
  38169. },
  38170. /**
  38171. * Sets the value of the `Right` button
  38172. */
  38173. set: function (value) {
  38174. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  38175. },
  38176. enumerable: true,
  38177. configurable: true
  38178. });
  38179. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  38180. /**
  38181. * Gets the value of the Left joystick
  38182. */
  38183. get: function () {
  38184. return this._buttonLeftStick;
  38185. },
  38186. /**
  38187. * Sets the value of the Left joystick
  38188. */
  38189. set: function (value) {
  38190. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  38191. },
  38192. enumerable: true,
  38193. configurable: true
  38194. });
  38195. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  38196. /**
  38197. * Gets the value of the Right joystick
  38198. */
  38199. get: function () {
  38200. return this._buttonRightStick;
  38201. },
  38202. /**
  38203. * Sets the value of the Right joystick
  38204. */
  38205. set: function (value) {
  38206. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  38207. },
  38208. enumerable: true,
  38209. configurable: true
  38210. });
  38211. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  38212. /**
  38213. * Gets the value of D-pad up
  38214. */
  38215. get: function () {
  38216. return this._dPadUp;
  38217. },
  38218. /**
  38219. * Sets the value of D-pad up
  38220. */
  38221. set: function (value) {
  38222. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  38223. },
  38224. enumerable: true,
  38225. configurable: true
  38226. });
  38227. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  38228. /**
  38229. * Gets the value of D-pad down
  38230. */
  38231. get: function () {
  38232. return this._dPadDown;
  38233. },
  38234. /**
  38235. * Sets the value of D-pad down
  38236. */
  38237. set: function (value) {
  38238. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  38239. },
  38240. enumerable: true,
  38241. configurable: true
  38242. });
  38243. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  38244. /**
  38245. * Gets the value of D-pad left
  38246. */
  38247. get: function () {
  38248. return this._dPadLeft;
  38249. },
  38250. /**
  38251. * Sets the value of D-pad left
  38252. */
  38253. set: function (value) {
  38254. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  38255. },
  38256. enumerable: true,
  38257. configurable: true
  38258. });
  38259. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  38260. /**
  38261. * Gets the value of D-pad right
  38262. */
  38263. get: function () {
  38264. return this._dPadRight;
  38265. },
  38266. /**
  38267. * Sets the value of D-pad right
  38268. */
  38269. set: function (value) {
  38270. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  38271. },
  38272. enumerable: true,
  38273. configurable: true
  38274. });
  38275. /**
  38276. * Force the gamepad to synchronize with device values
  38277. */
  38278. Xbox360Pad.prototype.update = function () {
  38279. _super.prototype.update.call(this);
  38280. if (this._isXboxOnePad) {
  38281. this.buttonA = this.browserGamepad.buttons[0].value;
  38282. this.buttonB = this.browserGamepad.buttons[1].value;
  38283. this.buttonX = this.browserGamepad.buttons[2].value;
  38284. this.buttonY = this.browserGamepad.buttons[3].value;
  38285. this.buttonLB = this.browserGamepad.buttons[4].value;
  38286. this.buttonRB = this.browserGamepad.buttons[5].value;
  38287. this.leftTrigger = this.browserGamepad.axes[2];
  38288. this.rightTrigger = this.browserGamepad.axes[5];
  38289. this.buttonBack = this.browserGamepad.buttons[9].value;
  38290. this.buttonStart = this.browserGamepad.buttons[8].value;
  38291. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  38292. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  38293. this.dPadUp = this.browserGamepad.buttons[11].value;
  38294. this.dPadDown = this.browserGamepad.buttons[12].value;
  38295. this.dPadLeft = this.browserGamepad.buttons[13].value;
  38296. this.dPadRight = this.browserGamepad.buttons[14].value;
  38297. }
  38298. else {
  38299. this.buttonA = this.browserGamepad.buttons[0].value;
  38300. this.buttonB = this.browserGamepad.buttons[1].value;
  38301. this.buttonX = this.browserGamepad.buttons[2].value;
  38302. this.buttonY = this.browserGamepad.buttons[3].value;
  38303. this.buttonLB = this.browserGamepad.buttons[4].value;
  38304. this.buttonRB = this.browserGamepad.buttons[5].value;
  38305. this.leftTrigger = this.browserGamepad.buttons[6].value;
  38306. this.rightTrigger = this.browserGamepad.buttons[7].value;
  38307. this.buttonBack = this.browserGamepad.buttons[8].value;
  38308. this.buttonStart = this.browserGamepad.buttons[9].value;
  38309. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  38310. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  38311. this.dPadUp = this.browserGamepad.buttons[12].value;
  38312. this.dPadDown = this.browserGamepad.buttons[13].value;
  38313. this.dPadLeft = this.browserGamepad.buttons[14].value;
  38314. this.dPadRight = this.browserGamepad.buttons[15].value;
  38315. }
  38316. };
  38317. /**
  38318. * Disposes the gamepad
  38319. */
  38320. Xbox360Pad.prototype.dispose = function () {
  38321. _super.prototype.dispose.call(this);
  38322. this.onButtonDownObservable.clear();
  38323. this.onButtonUpObservable.clear();
  38324. this.onPadDownObservable.clear();
  38325. this.onPadUpObservable.clear();
  38326. };
  38327. return Xbox360Pad;
  38328. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  38329. /***/ }),
  38330. /***/ "./Gizmos/axisDragGizmo.ts":
  38331. /*!*********************************!*\
  38332. !*** ./Gizmos/axisDragGizmo.ts ***!
  38333. \*********************************/
  38334. /*! exports provided: AxisDragGizmo */
  38335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38336. "use strict";
  38337. __webpack_require__.r(__webpack_exports__);
  38338. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  38339. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38340. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38341. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38342. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  38343. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  38344. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38345. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38346. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38347. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38348. /**
  38349. * Single axis drag gizmo
  38350. */
  38351. var AxisDragGizmo = /** @class */ (function (_super) {
  38352. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  38353. /**
  38354. * Creates an AxisDragGizmo
  38355. * @param gizmoLayer The utility layer the gizmo will be added to
  38356. * @param dragAxis The axis which the gizmo will be able to drag on
  38357. * @param color The color of the gizmo
  38358. */
  38359. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  38360. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38361. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38362. var _this = _super.call(this, gizmoLayer) || this;
  38363. _this._pointerObserver = null;
  38364. /**
  38365. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38366. */
  38367. _this.snapDistance = 0;
  38368. /**
  38369. * Event that fires each time the gizmo snaps to a new location.
  38370. * * snapDistance is the the change in distance
  38371. */
  38372. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38373. // Create Material
  38374. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38375. coloredMaterial.diffuseColor = color;
  38376. coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  38377. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38378. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38379. // Build mesh on root node
  38380. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  38381. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  38382. arrow.scaling.scaleInPlace(1 / 3);
  38383. arrow.parent = _this._rootMesh;
  38384. var currentSnapDragDistance = 0;
  38385. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38386. var tmpSnapEvent = { snapDistance: 0 };
  38387. // Add drag behavior to handle events when the gizmo is dragged
  38388. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38389. _this.dragBehavior.moveAttached = false;
  38390. _this._rootMesh.addBehavior(_this.dragBehavior);
  38391. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38392. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38393. _this.dragBehavior.onDragObservable.add(function (event) {
  38394. if (_this.attachedMesh) {
  38395. // Convert delta to local translation if it has a parent
  38396. if (_this.attachedMesh.parent) {
  38397. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  38398. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  38399. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  38400. }
  38401. else {
  38402. localDelta.copyFrom(event.delta);
  38403. }
  38404. // Snapping logic
  38405. if (_this.snapDistance == 0) {
  38406. _this.attachedMesh.position.addInPlace(localDelta);
  38407. }
  38408. else {
  38409. currentSnapDragDistance += event.dragDistance;
  38410. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38411. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38412. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38413. localDelta.normalizeToRef(tmpVector);
  38414. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  38415. _this.attachedMesh.position.addInPlace(tmpVector);
  38416. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  38417. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38418. }
  38419. }
  38420. }
  38421. });
  38422. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38423. if (_this._customMeshSet) {
  38424. return;
  38425. }
  38426. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38427. var material = isHovered ? hoverMaterial : coloredMaterial;
  38428. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38429. m.material = material;
  38430. if (m.color) {
  38431. m.color = material.diffuseColor;
  38432. }
  38433. });
  38434. });
  38435. var light = gizmoLayer._getSharedGizmoLight();
  38436. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes(false));
  38437. return _this;
  38438. }
  38439. /** @hidden */
  38440. AxisDragGizmo._CreateArrow = function (scene, material) {
  38441. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  38442. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 0.075, diameterBottom: 0.0375, tessellation: 96 }, scene);
  38443. var line = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0.005, height: 0.275, diameterBottom: 0.005, tessellation: 96 }, scene);
  38444. line.material = material;
  38445. cylinder.parent = arrow;
  38446. line.parent = arrow;
  38447. // Position arrow pointing in its drag axis
  38448. cylinder.material = material;
  38449. cylinder.rotation.x = Math.PI / 2;
  38450. cylinder.position.z += 0.3;
  38451. line.position.z += 0.275 / 2;
  38452. line.rotation.x = Math.PI / 2;
  38453. return arrow;
  38454. };
  38455. /** @hidden */
  38456. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  38457. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  38458. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  38459. var mesh = _a[_i];
  38460. var childInstance = mesh.createInstance(mesh.name);
  38461. childInstance.parent = instance;
  38462. }
  38463. return instance;
  38464. };
  38465. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  38466. if (this.dragBehavior) {
  38467. this.dragBehavior.enabled = value ? true : false;
  38468. }
  38469. };
  38470. /**
  38471. * Disposes of the gizmo
  38472. */
  38473. AxisDragGizmo.prototype.dispose = function () {
  38474. this.onSnapObservable.clear();
  38475. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38476. this.dragBehavior.detach();
  38477. _super.prototype.dispose.call(this);
  38478. };
  38479. return AxisDragGizmo;
  38480. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  38481. /***/ }),
  38482. /***/ "./Gizmos/axisScaleGizmo.ts":
  38483. /*!**********************************!*\
  38484. !*** ./Gizmos/axisScaleGizmo.ts ***!
  38485. \**********************************/
  38486. /*! exports provided: AxisScaleGizmo */
  38487. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38488. "use strict";
  38489. __webpack_require__.r(__webpack_exports__);
  38490. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  38491. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38492. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38493. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38494. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38495. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38496. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  38497. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38498. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38499. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38500. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38501. /**
  38502. * Single axis scale gizmo
  38503. */
  38504. var AxisScaleGizmo = /** @class */ (function (_super) {
  38505. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  38506. /**
  38507. * Creates an AxisScaleGizmo
  38508. * @param gizmoLayer The utility layer the gizmo will be added to
  38509. * @param dragAxis The axis which the gizmo will be able to scale on
  38510. * @param color The color of the gizmo
  38511. */
  38512. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  38513. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38514. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38515. var _this = _super.call(this, gizmoLayer) || this;
  38516. _this._pointerObserver = null;
  38517. /**
  38518. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38519. */
  38520. _this.snapDistance = 0;
  38521. /**
  38522. * Event that fires each time the gizmo snaps to a new location.
  38523. * * snapDistance is the the change in distance
  38524. */
  38525. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38526. /**
  38527. * If the scaling operation should be done on all axis (default: false)
  38528. */
  38529. _this.uniformScaling = false;
  38530. // Create Material
  38531. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38532. _this._coloredMaterial.diffuseColor = color;
  38533. _this._coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  38534. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38535. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38536. // Build mesh on root node
  38537. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38538. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  38539. 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);
  38540. arrowTail.material = _this._coloredMaterial;
  38541. arrow.addChild(arrowMesh);
  38542. arrow.addChild(arrowTail);
  38543. // Position arrow pointing in its drag axis
  38544. arrowMesh.scaling.scaleInPlace(0.1);
  38545. arrowMesh.material = _this._coloredMaterial;
  38546. arrowMesh.rotation.x = Math.PI / 2;
  38547. arrowMesh.position.z += 0.3;
  38548. arrowTail.position.z += 0.275 / 2;
  38549. arrowTail.rotation.x = Math.PI / 2;
  38550. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  38551. _this._rootMesh.addChild(arrow);
  38552. arrow.scaling.scaleInPlace(1 / 3);
  38553. // Add drag behavior to handle events when the gizmo is dragged
  38554. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38555. _this.dragBehavior.moveAttached = false;
  38556. _this._rootMesh.addBehavior(_this.dragBehavior);
  38557. var currentSnapDragDistance = 0;
  38558. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38559. var tmpSnapEvent = { snapDistance: 0 };
  38560. _this.dragBehavior.onDragObservable.add(function (event) {
  38561. if (_this.attachedMesh) {
  38562. // Drag strength is modified by the scale of the gizmo (eg. for small objects like boombox the strength will be increased to match the behavior of larger objects)
  38563. var dragStrength = event.dragDistance * ((_this.scaleRatio * 3) / _this._rootMesh.scaling.length());
  38564. // Snapping logic
  38565. var snapped = false;
  38566. var dragSteps = 0;
  38567. if (_this.uniformScaling) {
  38568. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  38569. if (tmpVector.y < 0) {
  38570. tmpVector.scaleInPlace(-1);
  38571. }
  38572. }
  38573. else {
  38574. tmpVector.copyFrom(dragAxis);
  38575. }
  38576. if (_this.snapDistance == 0) {
  38577. tmpVector.scaleToRef(dragStrength, tmpVector);
  38578. }
  38579. else {
  38580. currentSnapDragDistance += dragStrength;
  38581. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38582. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38583. if (currentSnapDragDistance < 0) {
  38584. dragSteps *= -1;
  38585. }
  38586. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38587. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  38588. snapped = true;
  38589. }
  38590. else {
  38591. tmpVector.scaleInPlace(0);
  38592. }
  38593. }
  38594. _this.attachedMesh.scaling.addInPlace(tmpVector);
  38595. if (snapped) {
  38596. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  38597. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38598. }
  38599. }
  38600. });
  38601. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38602. if (_this._customMeshSet) {
  38603. return;
  38604. }
  38605. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38606. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  38607. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38608. m.material = material;
  38609. if (m.color) {
  38610. m.color = material.diffuseColor;
  38611. }
  38612. });
  38613. });
  38614. var light = gizmoLayer._getSharedGizmoLight();
  38615. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes());
  38616. return _this;
  38617. }
  38618. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  38619. if (this.dragBehavior) {
  38620. this.dragBehavior.enabled = value ? true : false;
  38621. }
  38622. };
  38623. /**
  38624. * Disposes of the gizmo
  38625. */
  38626. AxisScaleGizmo.prototype.dispose = function () {
  38627. this.onSnapObservable.clear();
  38628. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38629. this.dragBehavior.detach();
  38630. _super.prototype.dispose.call(this);
  38631. };
  38632. /**
  38633. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38634. * @param mesh The mesh to replace the default mesh of the gizmo
  38635. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  38636. */
  38637. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  38638. var _this = this;
  38639. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  38640. _super.prototype.setCustomMesh.call(this, mesh);
  38641. if (useGizmoMaterial) {
  38642. this._rootMesh.getChildMeshes().forEach(function (m) {
  38643. m.material = _this._coloredMaterial;
  38644. if (m.color) {
  38645. m.color = _this._coloredMaterial.diffuseColor;
  38646. }
  38647. });
  38648. this._customMeshSet = false;
  38649. }
  38650. };
  38651. return AxisScaleGizmo;
  38652. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  38653. /***/ }),
  38654. /***/ "./Gizmos/boundingBoxGizmo.ts":
  38655. /*!************************************!*\
  38656. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  38657. \************************************/
  38658. /*! exports provided: BoundingBoxGizmo */
  38659. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38660. "use strict";
  38661. __webpack_require__.r(__webpack_exports__);
  38662. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  38663. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38664. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38665. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38666. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38667. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38668. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38669. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  38670. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38671. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38672. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38673. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38674. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38675. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38676. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  38677. /**
  38678. * Bounding box gizmo
  38679. */
  38680. var BoundingBoxGizmo = /** @class */ (function (_super) {
  38681. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  38682. /**
  38683. * Creates an BoundingBoxGizmo
  38684. * @param gizmoLayer The utility layer the gizmo will be added to
  38685. * @param color The color of the gizmo
  38686. */
  38687. function BoundingBoxGizmo(color, gizmoLayer) {
  38688. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  38689. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  38690. var _this = _super.call(this, gizmoLayer) || this;
  38691. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  38692. _this._renderObserver = null;
  38693. _this._pointerObserver = null;
  38694. _this._scaleDragSpeed = 0.2;
  38695. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38696. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  38697. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  38698. /**
  38699. * 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)
  38700. */
  38701. _this.ignoreChildren = false;
  38702. /**
  38703. * 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)
  38704. */
  38705. _this.includeChildPredicate = null;
  38706. /**
  38707. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  38708. */
  38709. _this.rotationSphereSize = 0.1;
  38710. /**
  38711. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  38712. */
  38713. _this.scaleBoxSize = 0.1;
  38714. /**
  38715. * 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)
  38716. */
  38717. _this.fixedDragMeshScreenSize = false;
  38718. /**
  38719. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  38720. */
  38721. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  38722. /**
  38723. * Fired when a rotation sphere or scale box is dragged
  38724. */
  38725. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38726. /**
  38727. * Fired when a scale box is dragged
  38728. */
  38729. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38730. /**
  38731. * Fired when a scale box drag is ended
  38732. */
  38733. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38734. /**
  38735. * Fired when a rotation sphere is dragged
  38736. */
  38737. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38738. /**
  38739. * Fired when a rotation sphere drag is ended
  38740. */
  38741. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38742. /**
  38743. * 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)
  38744. */
  38745. _this.scalePivot = null;
  38746. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  38747. // Dragging
  38748. _this._dragMesh = null;
  38749. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  38750. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  38751. _this._updateScale = false;
  38752. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  38753. // Create Materials
  38754. _this.coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38755. _this.coloredMaterial.disableLighting = true;
  38756. _this.hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38757. _this.hoverColoredMaterial.disableLighting = true;
  38758. // Build bounding box out of lines
  38759. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38760. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38761. var lines = [];
  38762. 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));
  38763. 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));
  38764. 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));
  38765. 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));
  38766. 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));
  38767. 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));
  38768. 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));
  38769. 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));
  38770. 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));
  38771. 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));
  38772. 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));
  38773. 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));
  38774. lines.forEach(function (l) {
  38775. l.color = color;
  38776. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  38777. l.isPickable = false;
  38778. _this._lineBoundingBox.addChild(l);
  38779. });
  38780. _this._rootMesh.addChild(_this._lineBoundingBox);
  38781. _this.setColor(color);
  38782. // Create rotation spheres
  38783. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38784. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38785. var _loop_1 = function (i_1) {
  38786. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  38787. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38788. sphere.material = this_1.coloredMaterial;
  38789. // Drag behavior
  38790. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  38791. _dragBehavior.moveAttached = false;
  38792. _dragBehavior.updateDragPlane = false;
  38793. sphere.addBehavior(_dragBehavior);
  38794. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  38795. var totalTurnAmountOfDrag = 0;
  38796. _dragBehavior.onDragStartObservable.add(function () {
  38797. startingTurnDirection.copyFrom(sphere.forward);
  38798. totalTurnAmountOfDrag = 0;
  38799. });
  38800. _dragBehavior.onDragObservable.add(function (event) {
  38801. _this.onRotationSphereDragObservable.notifyObservers({});
  38802. if (_this.attachedMesh) {
  38803. var originalParent = _this.attachedMesh.parent;
  38804. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38805. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38806. return;
  38807. }
  38808. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38809. var worldDragDirection = startingTurnDirection;
  38810. // Project the world right on to the drag plane
  38811. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  38812. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  38813. // project drag delta on to the resulting drag axis and rotate based on that
  38814. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  38815. // Make rotation relative to size of mesh.
  38816. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38817. // Rotate based on axis
  38818. if (!_this.attachedMesh.rotationQuaternion) {
  38819. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38820. }
  38821. if (!_this._anchorMesh.rotationQuaternion) {
  38822. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  38823. }
  38824. // Do not allow the object to turn more than a full circle
  38825. totalTurnAmountOfDrag += projectDist;
  38826. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  38827. if (i_1 >= 8) {
  38828. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  38829. }
  38830. else if (i_1 >= 4) {
  38831. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  38832. }
  38833. else {
  38834. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  38835. }
  38836. // Rotate around center of bounding box
  38837. _this._anchorMesh.addChild(_this.attachedMesh);
  38838. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  38839. _this._anchorMesh.removeChild(_this.attachedMesh);
  38840. _this.attachedMesh.setParent(originalParent);
  38841. }
  38842. _this.updateBoundingBox();
  38843. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38844. }
  38845. _this._updateDummy();
  38846. });
  38847. // Selection/deselection
  38848. _dragBehavior.onDragStartObservable.add(function () {
  38849. _this.onDragStartObservable.notifyObservers({});
  38850. _this._selectNode(sphere);
  38851. });
  38852. _dragBehavior.onDragEndObservable.add(function () {
  38853. _this.onRotationSphereDragEndObservable.notifyObservers({});
  38854. _this._selectNode(null);
  38855. _this._updateDummy();
  38856. });
  38857. this_1._rotateSpheresParent.addChild(sphere);
  38858. };
  38859. var this_1 = this, _dragBehavior;
  38860. for (var i_1 = 0; i_1 < 12; i_1++) {
  38861. _loop_1(i_1);
  38862. }
  38863. _this._rootMesh.addChild(_this._rotateSpheresParent);
  38864. // Create scale cubes
  38865. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38866. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38867. for (var i = 0; i < 2; i++) {
  38868. for (var j = 0; j < 2; j++) {
  38869. var _loop_2 = function () {
  38870. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  38871. box.material = this_2.coloredMaterial;
  38872. // Dragging logic
  38873. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  38874. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38875. _dragBehavior.moveAttached = false;
  38876. box.addBehavior(_dragBehavior);
  38877. _dragBehavior.onDragObservable.add(function (event) {
  38878. _this.onScaleBoxDragObservable.notifyObservers({});
  38879. if (_this.attachedMesh) {
  38880. var originalParent = _this.attachedMesh.parent;
  38881. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38882. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38883. return;
  38884. }
  38885. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38886. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38887. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  38888. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  38889. _this.updateBoundingBox();
  38890. if (_this.scalePivot) {
  38891. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  38892. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  38893. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  38894. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38895. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38896. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  38897. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38898. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  38899. }
  38900. else {
  38901. // Scale from the position of the opposite corner
  38902. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  38903. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38904. }
  38905. _this._anchorMesh.addChild(_this.attachedMesh);
  38906. _this._anchorMesh.scaling.addInPlace(deltaScale);
  38907. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  38908. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  38909. }
  38910. _this._anchorMesh.removeChild(_this.attachedMesh);
  38911. _this.attachedMesh.setParent(originalParent);
  38912. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38913. }
  38914. _this._updateDummy();
  38915. });
  38916. // Selection/deselection
  38917. _dragBehavior.onDragStartObservable.add(function () {
  38918. _this.onDragStartObservable.notifyObservers({});
  38919. _this._selectNode(box);
  38920. });
  38921. _dragBehavior.onDragEndObservable.add(function () {
  38922. _this.onScaleBoxDragEndObservable.notifyObservers({});
  38923. _this._selectNode(null);
  38924. _this._updateDummy();
  38925. });
  38926. this_2._scaleBoxesParent.addChild(box);
  38927. };
  38928. var this_2 = this, _dragBehavior;
  38929. for (var k = 0; k < 2; k++) {
  38930. _loop_2();
  38931. }
  38932. }
  38933. }
  38934. _this._rootMesh.addChild(_this._scaleBoxesParent);
  38935. // Hover color change
  38936. var pointerIds = new Array();
  38937. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38938. if (!pointerIds[pointerInfo.event.pointerId]) {
  38939. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  38940. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  38941. pointerIds[pointerInfo.event.pointerId] = mesh;
  38942. mesh.material = _this.hoverColoredMaterial;
  38943. }
  38944. });
  38945. }
  38946. else {
  38947. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  38948. pointerIds[pointerInfo.event.pointerId].material = _this.coloredMaterial;
  38949. delete pointerIds[pointerInfo.event.pointerId];
  38950. }
  38951. }
  38952. });
  38953. // Update bounding box positions
  38954. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  38955. // Only update the bouding box if scaling has changed
  38956. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  38957. _this.updateBoundingBox();
  38958. }
  38959. else if (_this.fixedDragMeshScreenSize) {
  38960. _this._updateRotationSpheres();
  38961. _this._updateScaleBoxes();
  38962. }
  38963. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  38964. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  38965. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  38966. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  38967. }
  38968. });
  38969. _this.updateBoundingBox();
  38970. return _this;
  38971. }
  38972. /**
  38973. * Sets the color of the bounding box gizmo
  38974. * @param color the color to set
  38975. */
  38976. BoundingBoxGizmo.prototype.setColor = function (color) {
  38977. this.coloredMaterial.emissiveColor = color;
  38978. this.hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  38979. this._lineBoundingBox.getChildren().forEach(function (l) {
  38980. if (l.color) {
  38981. l.color = color;
  38982. }
  38983. });
  38984. };
  38985. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  38986. var _this = this;
  38987. if (value) {
  38988. // Reset anchor mesh to match attached mesh's scale
  38989. // This is needed to avoid invalid box/sphere position on first drag
  38990. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  38991. var originalParent = value.parent;
  38992. this._anchorMesh.addChild(value);
  38993. this._anchorMesh.removeChild(value);
  38994. value.setParent(originalParent);
  38995. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  38996. this.updateBoundingBox();
  38997. value.getChildMeshes(false).forEach(function (m) {
  38998. m.markAsDirty("scaling");
  38999. });
  39000. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  39001. _this._updateDummy();
  39002. });
  39003. }
  39004. };
  39005. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  39006. this._rotateSpheresParent.getChildMeshes()
  39007. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  39008. m.isVisible = (!selectedMesh || m == selectedMesh);
  39009. });
  39010. };
  39011. /**
  39012. * Updates the bounding box information for the Gizmo
  39013. */
  39014. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  39015. if (this.attachedMesh) {
  39016. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  39017. // Store original parent
  39018. var originalParent = this.attachedMesh.parent;
  39019. this.attachedMesh.setParent(null);
  39020. // Store original skelton override mesh
  39021. var originalSkeletonOverrideMesh = null;
  39022. if (this.attachedMesh.skeleton) {
  39023. originalSkeletonOverrideMesh = this.attachedMesh.skeleton.overrideMesh;
  39024. this.attachedMesh.skeleton.overrideMesh = null;
  39025. }
  39026. this._update();
  39027. // Rotate based on axis
  39028. if (!this.attachedMesh.rotationQuaternion) {
  39029. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  39030. }
  39031. if (!this._anchorMesh.rotationQuaternion) {
  39032. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  39033. }
  39034. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  39035. // Store original position and reset mesh to origin before computing the bounding box
  39036. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  39037. this._tmpVector.copyFrom(this.attachedMesh.position);
  39038. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  39039. this.attachedMesh.position.set(0, 0, 0);
  39040. // Update bounding dimensions/positions
  39041. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  39042. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  39043. // Update gizmo to match bounding box scaling and rotation
  39044. // The position set here is the offset from the origin for the boundingbox when the attached mesh is at the origin
  39045. // The position of the gizmo is then set to the attachedMesh in gizmo._update
  39046. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  39047. 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);
  39048. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  39049. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  39050. this._lineBoundingBox.computeWorldMatrix();
  39051. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  39052. // Restore position/rotation values
  39053. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  39054. this.attachedMesh.position.copyFrom(this._tmpVector);
  39055. // Restore original parent
  39056. this.attachedMesh.setParent(originalParent);
  39057. // Restore original skeleton override mesh
  39058. if (this.attachedMesh.skeleton) {
  39059. this.attachedMesh.skeleton.overrideMesh = originalSkeletonOverrideMesh;
  39060. }
  39061. }
  39062. this._updateRotationSpheres();
  39063. this._updateScaleBoxes();
  39064. if (this.attachedMesh) {
  39065. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  39066. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  39067. }
  39068. };
  39069. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  39070. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  39071. for (var i = 0; i < 3; i++) {
  39072. for (var j = 0; j < 2; j++) {
  39073. for (var k = 0; k < 2; k++) {
  39074. var index = ((i * 4) + (j * 2)) + k;
  39075. if (i == 0) {
  39076. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  39077. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  39078. 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));
  39079. }
  39080. if (i == 1) {
  39081. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  39082. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  39083. 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));
  39084. }
  39085. if (i == 2) {
  39086. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  39087. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  39088. 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));
  39089. }
  39090. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  39091. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  39092. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  39093. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  39094. }
  39095. else {
  39096. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  39097. }
  39098. }
  39099. }
  39100. }
  39101. };
  39102. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  39103. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  39104. for (var i = 0; i < 2; i++) {
  39105. for (var j = 0; j < 2; j++) {
  39106. for (var k = 0; k < 2; k++) {
  39107. var index = ((i * 4) + (j * 2)) + k;
  39108. if (scaleBoxes[index]) {
  39109. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  39110. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  39111. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  39112. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  39113. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  39114. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  39115. }
  39116. else {
  39117. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  39118. }
  39119. }
  39120. }
  39121. }
  39122. }
  39123. };
  39124. /**
  39125. * Enables rotation on the specified axis and disables rotation on the others
  39126. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  39127. */
  39128. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  39129. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  39130. if (i < 4) {
  39131. m.setEnabled(axis.indexOf("x") != -1);
  39132. }
  39133. else if (i < 8) {
  39134. m.setEnabled(axis.indexOf("y") != -1);
  39135. }
  39136. else {
  39137. m.setEnabled(axis.indexOf("z") != -1);
  39138. }
  39139. });
  39140. };
  39141. /**
  39142. * Enables/disables scaling
  39143. * @param enable if scaling should be enabled
  39144. */
  39145. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  39146. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  39147. m.setEnabled(enable);
  39148. });
  39149. };
  39150. BoundingBoxGizmo.prototype._updateDummy = function () {
  39151. if (this._dragMesh) {
  39152. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  39153. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  39154. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  39155. }
  39156. };
  39157. /**
  39158. * Enables a pointer drag behavior on the bounding box of the gizmo
  39159. */
  39160. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  39161. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  39162. this._dragMesh.visibility = 0;
  39163. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  39164. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  39165. this._dragMesh.addBehavior(this.pointerDragBehavior);
  39166. };
  39167. /**
  39168. * Disposes of the gizmo
  39169. */
  39170. BoundingBoxGizmo.prototype.dispose = function () {
  39171. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  39172. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  39173. this._lineBoundingBox.dispose();
  39174. this._rotateSpheresParent.dispose();
  39175. this._scaleBoxesParent.dispose();
  39176. if (this._dragMesh) {
  39177. this._dragMesh.dispose();
  39178. }
  39179. _super.prototype.dispose.call(this);
  39180. };
  39181. /**
  39182. * 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)
  39183. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  39184. * @returns the bounding box mesh with the passed in mesh as a child
  39185. */
  39186. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  39187. var makeNotPickable = function (root) {
  39188. root.isPickable = false;
  39189. root.getChildMeshes().forEach(function (c) {
  39190. makeNotPickable(c);
  39191. });
  39192. };
  39193. makeNotPickable(mesh);
  39194. // Reset position to get boudning box from origin with no rotation
  39195. if (!mesh.rotationQuaternion) {
  39196. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  39197. }
  39198. var oldPos = mesh.position.clone();
  39199. var oldRot = mesh.rotationQuaternion.clone();
  39200. mesh.rotationQuaternion.set(0, 0, 0, 1);
  39201. mesh.position.set(0, 0, 0);
  39202. // Update bounding dimensions/positions
  39203. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  39204. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  39205. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  39206. // Adjust scale to avoid undefined behavior when adding child
  39207. if (box.scaling.y === 0) {
  39208. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  39209. }
  39210. if (box.scaling.x === 0) {
  39211. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  39212. }
  39213. if (box.scaling.z === 0) {
  39214. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  39215. }
  39216. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  39217. // Restore original positions
  39218. mesh.addChild(box);
  39219. mesh.rotationQuaternion.copyFrom(oldRot);
  39220. mesh.position.copyFrom(oldPos);
  39221. // Reverse parenting
  39222. mesh.removeChild(box);
  39223. box.addChild(mesh);
  39224. box.visibility = 0;
  39225. return box;
  39226. };
  39227. /**
  39228. * CustomMeshes are not supported by this gizmo
  39229. * @param mesh The mesh to replace the default mesh of the gizmo
  39230. */
  39231. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  39232. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  39233. };
  39234. return BoundingBoxGizmo;
  39235. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  39236. /***/ }),
  39237. /***/ "./Gizmos/gizmo.ts":
  39238. /*!*************************!*\
  39239. !*** ./Gizmos/gizmo.ts ***!
  39240. \*************************/
  39241. /*! exports provided: Gizmo */
  39242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39243. "use strict";
  39244. __webpack_require__.r(__webpack_exports__);
  39245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  39246. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39247. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39248. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39249. /**
  39250. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39251. */
  39252. var Gizmo = /** @class */ (function () {
  39253. /**
  39254. * Creates a gizmo
  39255. * @param gizmoLayer The utility layer the gizmo will be added to
  39256. */
  39257. function Gizmo(
  39258. /** The utility layer the gizmo will be added to */
  39259. gizmoLayer) {
  39260. var _this = this;
  39261. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39262. this.gizmoLayer = gizmoLayer;
  39263. this._attachedMesh = null;
  39264. /**
  39265. * Ratio for the scale of the gizmo (Default: 1)
  39266. */
  39267. this.scaleRatio = 1;
  39268. /**
  39269. * If a custom mesh has been set (Default: false)
  39270. */
  39271. this._customMeshSet = false;
  39272. /**
  39273. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39274. */
  39275. this.updateGizmoRotationToMatchAttachedMesh = true;
  39276. /**
  39277. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39278. */
  39279. this.updateGizmoPositionToMatchAttachedMesh = true;
  39280. /**
  39281. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39282. */
  39283. this._updateScale = true;
  39284. this._interactionsEnabled = true;
  39285. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  39286. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  39287. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  39288. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  39289. _this._update();
  39290. });
  39291. }
  39292. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  39293. /**
  39294. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39295. * * When set, interactions will be enabled
  39296. */
  39297. get: function () {
  39298. return this._attachedMesh;
  39299. },
  39300. set: function (value) {
  39301. this._attachedMesh = value;
  39302. this._rootMesh.setEnabled(value ? true : false);
  39303. this._attachedMeshChanged(value);
  39304. },
  39305. enumerable: true,
  39306. configurable: true
  39307. });
  39308. /**
  39309. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39310. * @param mesh The mesh to replace the default mesh of the gizmo
  39311. */
  39312. Gizmo.prototype.setCustomMesh = function (mesh) {
  39313. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  39314. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  39315. }
  39316. this._rootMesh.getChildMeshes().forEach(function (c) {
  39317. c.dispose();
  39318. });
  39319. mesh.parent = this._rootMesh;
  39320. this._customMeshSet = true;
  39321. };
  39322. Gizmo.prototype._attachedMeshChanged = function (value) {
  39323. };
  39324. /**
  39325. * Updates the gizmo to match the attached mesh's position/rotation
  39326. */
  39327. Gizmo.prototype._update = function () {
  39328. if (this.attachedMesh) {
  39329. var effectiveMesh = this.attachedMesh._effectiveMesh || this.attachedMesh;
  39330. // Position
  39331. if (this.updateGizmoPositionToMatchAttachedMesh) {
  39332. this._rootMesh.position.copyFrom(effectiveMesh.absolutePosition);
  39333. }
  39334. // Rotation
  39335. if (this.updateGizmoRotationToMatchAttachedMesh) {
  39336. effectiveMesh.getWorldMatrix().decompose(undefined, this._rootMesh.rotationQuaternion);
  39337. }
  39338. else {
  39339. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  39340. }
  39341. // Scale
  39342. if (this._updateScale) {
  39343. var activeCamera = this.gizmoLayer.utilityLayerScene.activeCamera;
  39344. var cameraPosition = activeCamera.globalPosition;
  39345. if (activeCamera.devicePosition) {
  39346. cameraPosition = activeCamera.devicePosition;
  39347. }
  39348. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  39349. var dist = this._tempVector.length() * this.scaleRatio;
  39350. this._rootMesh.scaling.set(dist, dist, dist);
  39351. // Account for handedness, similar to Matrix.decompose
  39352. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  39353. this._rootMesh.scaling.y *= -1;
  39354. }
  39355. }
  39356. }
  39357. };
  39358. /**
  39359. * Disposes of the gizmo
  39360. */
  39361. Gizmo.prototype.dispose = function () {
  39362. this._rootMesh.dispose();
  39363. if (this._beforeRenderObserver) {
  39364. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  39365. }
  39366. };
  39367. return Gizmo;
  39368. }());
  39369. /***/ }),
  39370. /***/ "./Gizmos/gizmoManager.ts":
  39371. /*!********************************!*\
  39372. !*** ./Gizmos/gizmoManager.ts ***!
  39373. \********************************/
  39374. /*! exports provided: GizmoManager */
  39375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39376. "use strict";
  39377. __webpack_require__.r(__webpack_exports__);
  39378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  39379. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39380. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  39381. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39382. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39383. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39384. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  39385. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  39386. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39387. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39388. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  39389. /**
  39390. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  39391. */
  39392. var GizmoManager = /** @class */ (function () {
  39393. /**
  39394. * Instatiates a gizmo manager
  39395. * @param scene the scene to overlay the gizmos on top of
  39396. */
  39397. function GizmoManager(scene) {
  39398. var _this = this;
  39399. this.scene = scene;
  39400. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  39401. this.clearGizmoOnEmptyPointerEvent = false;
  39402. /** Fires an event when the manager is attached to a mesh */
  39403. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  39404. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  39405. this._pointerObserver = null;
  39406. this._attachedMesh = null;
  39407. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  39408. /**
  39409. * When bounding box gizmo is enabled, this can be used to track drag/end events
  39410. */
  39411. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  39412. /**
  39413. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  39414. */
  39415. this.attachableMeshes = null;
  39416. /**
  39417. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  39418. */
  39419. this.usePointerToAttachGizmos = true;
  39420. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  39421. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  39422. this._defaultUtilityLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"].DefaultUtilityLayer;
  39423. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  39424. // Instatiate/dispose gizmos based on pointer actions
  39425. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  39426. if (!_this.usePointerToAttachGizmos) {
  39427. return;
  39428. }
  39429. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  39430. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  39431. var node = pointerInfo.pickInfo.pickedMesh;
  39432. if (_this.attachableMeshes == null) {
  39433. // Attach to the most parent node
  39434. while (node && node.parent != null) {
  39435. node = node.parent;
  39436. }
  39437. }
  39438. else {
  39439. // Attach to the parent node that is an attachableMesh
  39440. var found = false;
  39441. _this.attachableMeshes.forEach(function (mesh) {
  39442. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  39443. node = mesh;
  39444. found = true;
  39445. }
  39446. });
  39447. if (!found) {
  39448. node = null;
  39449. }
  39450. }
  39451. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  39452. if (_this._attachedMesh != node) {
  39453. _this.attachToMesh(node);
  39454. }
  39455. }
  39456. else {
  39457. if (_this.clearGizmoOnEmptyPointerEvent) {
  39458. _this.attachToMesh(null);
  39459. }
  39460. }
  39461. }
  39462. else {
  39463. if (_this.clearGizmoOnEmptyPointerEvent) {
  39464. _this.attachToMesh(null);
  39465. }
  39466. }
  39467. }
  39468. });
  39469. }
  39470. /**
  39471. * Attaches a set of gizmos to the specified mesh
  39472. * @param mesh The mesh the gizmo's should be attached to
  39473. */
  39474. GizmoManager.prototype.attachToMesh = function (mesh) {
  39475. if (this._attachedMesh) {
  39476. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39477. }
  39478. this._attachedMesh = mesh;
  39479. for (var key in this.gizmos) {
  39480. var gizmo = (this.gizmos[key]);
  39481. if (gizmo && this._gizmosEnabled[key]) {
  39482. gizmo.attachedMesh = mesh;
  39483. }
  39484. }
  39485. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  39486. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  39487. }
  39488. this.onAttachedToMeshObservable.notifyObservers(mesh);
  39489. };
  39490. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  39491. get: function () {
  39492. return this._gizmosEnabled.positionGizmo;
  39493. },
  39494. /**
  39495. * If the position gizmo is enabled
  39496. */
  39497. set: function (value) {
  39498. if (value) {
  39499. if (!this.gizmos.positionGizmo) {
  39500. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  39501. }
  39502. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  39503. }
  39504. else if (this.gizmos.positionGizmo) {
  39505. this.gizmos.positionGizmo.attachedMesh = null;
  39506. }
  39507. this._gizmosEnabled.positionGizmo = value;
  39508. },
  39509. enumerable: true,
  39510. configurable: true
  39511. });
  39512. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  39513. get: function () {
  39514. return this._gizmosEnabled.rotationGizmo;
  39515. },
  39516. /**
  39517. * If the rotation gizmo is enabled
  39518. */
  39519. set: function (value) {
  39520. if (value) {
  39521. if (!this.gizmos.rotationGizmo) {
  39522. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  39523. }
  39524. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  39525. }
  39526. else if (this.gizmos.rotationGizmo) {
  39527. this.gizmos.rotationGizmo.attachedMesh = null;
  39528. }
  39529. this._gizmosEnabled.rotationGizmo = value;
  39530. },
  39531. enumerable: true,
  39532. configurable: true
  39533. });
  39534. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  39535. get: function () {
  39536. return this._gizmosEnabled.scaleGizmo;
  39537. },
  39538. /**
  39539. * If the scale gizmo is enabled
  39540. */
  39541. set: function (value) {
  39542. if (value) {
  39543. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  39544. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  39545. }
  39546. else if (this.gizmos.scaleGizmo) {
  39547. this.gizmos.scaleGizmo.attachedMesh = null;
  39548. }
  39549. this._gizmosEnabled.scaleGizmo = value;
  39550. },
  39551. enumerable: true,
  39552. configurable: true
  39553. });
  39554. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  39555. get: function () {
  39556. return this._gizmosEnabled.boundingBoxGizmo;
  39557. },
  39558. /**
  39559. * If the boundingBox gizmo is enabled
  39560. */
  39561. set: function (value) {
  39562. if (value) {
  39563. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  39564. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  39565. if (this._attachedMesh) {
  39566. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39567. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  39568. }
  39569. }
  39570. else if (this.gizmos.boundingBoxGizmo) {
  39571. if (this._attachedMesh) {
  39572. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39573. }
  39574. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  39575. }
  39576. this._gizmosEnabled.boundingBoxGizmo = value;
  39577. },
  39578. enumerable: true,
  39579. configurable: true
  39580. });
  39581. /**
  39582. * Disposes of the gizmo manager
  39583. */
  39584. GizmoManager.prototype.dispose = function () {
  39585. this.scene.onPointerObservable.remove(this._pointerObserver);
  39586. for (var key in this.gizmos) {
  39587. var gizmo = (this.gizmos[key]);
  39588. if (gizmo) {
  39589. gizmo.dispose();
  39590. }
  39591. }
  39592. this._defaultKeepDepthUtilityLayer.dispose();
  39593. this.boundingBoxDragBehavior.detach();
  39594. this.onAttachedToMeshObservable.clear();
  39595. };
  39596. return GizmoManager;
  39597. }());
  39598. /***/ }),
  39599. /***/ "./Gizmos/index.ts":
  39600. /*!*************************!*\
  39601. !*** ./Gizmos/index.ts ***!
  39602. \*************************/
  39603. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo */
  39604. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39605. "use strict";
  39606. __webpack_require__.r(__webpack_exports__);
  39607. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  39609. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  39611. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  39612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  39613. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  39615. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  39616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  39617. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  39619. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  39621. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  39622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  39623. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  39625. /* harmony import */ var _lightGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lightGizmo */ "./Gizmos/lightGizmo.ts");
  39626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _lightGizmo__WEBPACK_IMPORTED_MODULE_9__["LightGizmo"]; });
  39627. /***/ }),
  39628. /***/ "./Gizmos/lightGizmo.ts":
  39629. /*!******************************!*\
  39630. !*** ./Gizmos/lightGizmo.ts ***!
  39631. \******************************/
  39632. /*! exports provided: LightGizmo */
  39633. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39634. "use strict";
  39635. __webpack_require__.r(__webpack_exports__);
  39636. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return LightGizmo; });
  39637. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39638. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39639. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39640. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39641. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39642. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39643. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  39644. /* harmony import */ var _Lights_directionalLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/directionalLight */ "./Lights/directionalLight.ts");
  39645. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39646. /* harmony import */ var _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/hemisphereBuilder */ "./Meshes/Builders/hemisphereBuilder.ts");
  39647. /* harmony import */ var _Lights_spotLight__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Lights/spotLight */ "./Lights/spotLight.ts");
  39648. /**
  39649. * Gizmo that enables viewing a light
  39650. */
  39651. var LightGizmo = /** @class */ (function (_super) {
  39652. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightGizmo, _super);
  39653. /**
  39654. * Creates a LightGizmo
  39655. * @param gizmoLayer The utility layer the gizmo will be added to
  39656. */
  39657. function LightGizmo(gizmoLayer) {
  39658. var _this = _super.call(this, gizmoLayer) || this;
  39659. _this.cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  39660. _this.cachedForward = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1);
  39661. _this._light = null;
  39662. _this.attachedMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", _this.gizmoLayer.utilityLayerScene);
  39663. _this._material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("light", _this.gizmoLayer.originalScene);
  39664. _this._material.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.5, 0.5, 0.5);
  39665. _this._material.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.1, 0.1, 0.1);
  39666. return _this;
  39667. }
  39668. Object.defineProperty(LightGizmo.prototype, "light", {
  39669. get: function () {
  39670. return this._light;
  39671. },
  39672. /**
  39673. * The light that the gizmo is attached to
  39674. */
  39675. set: function (light) {
  39676. var _this = this;
  39677. this._light = light;
  39678. if (light) {
  39679. // Create the mesh for the given light type
  39680. if (this._lightMesh) {
  39681. this._lightMesh.dispose();
  39682. }
  39683. if (light instanceof _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_6__["HemisphericLight"]) {
  39684. this._lightMesh = LightGizmo._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene);
  39685. }
  39686. else if (light instanceof _Lights_directionalLight__WEBPACK_IMPORTED_MODULE_7__["DirectionalLight"]) {
  39687. this._lightMesh = LightGizmo._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene);
  39688. }
  39689. else if (light instanceof _Lights_spotLight__WEBPACK_IMPORTED_MODULE_10__["SpotLight"]) {
  39690. this._lightMesh = LightGizmo._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene);
  39691. }
  39692. else {
  39693. this._lightMesh = LightGizmo._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene);
  39694. }
  39695. this._lightMesh.getChildMeshes(false).forEach(function (m) {
  39696. m.material = _this._material;
  39697. });
  39698. this._lightMesh.parent = this._rootMesh;
  39699. // Add lighting to the light gizmo
  39700. var gizmoLight = this.gizmoLayer._getSharedGizmoLight();
  39701. gizmoLight.includedOnlyMeshes = gizmoLight.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(false));
  39702. this._lightMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  39703. // Get update position and direction if the light has it
  39704. if (light.position) {
  39705. this.attachedMesh.position.copyFrom(light.position);
  39706. }
  39707. if (light.direction) {
  39708. this.attachedMesh.setDirection(light.direction);
  39709. }
  39710. this._update();
  39711. }
  39712. },
  39713. enumerable: true,
  39714. configurable: true
  39715. });
  39716. /**
  39717. * @hidden
  39718. * Updates the gizmo to match the attached mesh's position/rotation
  39719. */
  39720. LightGizmo.prototype._update = function () {
  39721. _super.prototype._update.call(this);
  39722. if (!this._light) {
  39723. return;
  39724. }
  39725. if (this._light.position) {
  39726. // If the gizmo is moved update the light otherwise update the gizmo to match the light
  39727. if (!this.attachedMesh.position.equals(this.cachedPosition)) {
  39728. // update light to match gizmo
  39729. this._light.position.copyFrom(this.attachedMesh.position);
  39730. this.cachedPosition.copyFrom(this.attachedMesh.position);
  39731. }
  39732. else {
  39733. // update gizmo to match light
  39734. this.attachedMesh.position.copyFrom(this._light.position);
  39735. }
  39736. }
  39737. if (this._light.direction) {
  39738. // If the gizmo is moved update the light otherwise update the gizmo to match the light
  39739. if (_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.attachedMesh.forward, this.cachedForward) > 0.0001) {
  39740. // update light to match gizmo
  39741. this._light.direction.copyFrom(this.attachedMesh.forward);
  39742. this.cachedForward.copyFrom(this.attachedMesh.forward);
  39743. }
  39744. else if (_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.attachedMesh.forward, this._light.direction) > 0.0001) {
  39745. // update gizmo to match light
  39746. this.attachedMesh.setDirection(this._light.direction);
  39747. this.cachedForward.copyFrom(this._lightMesh.forward);
  39748. }
  39749. }
  39750. if (!this._light.isEnabled()) {
  39751. this._material.diffuseColor.set(0, 0, 0);
  39752. }
  39753. else {
  39754. this._material.diffuseColor.set(this._light.diffuse.r / 3, this._light.diffuse.g / 3, this._light.diffuse.b / 3);
  39755. }
  39756. };
  39757. /**
  39758. * Disposes of the light gizmo
  39759. */
  39760. LightGizmo.prototype.dispose = function () {
  39761. this._material.dispose();
  39762. _super.prototype.dispose.call(this);
  39763. };
  39764. LightGizmo._CreateHemisphericLightMesh = function (scene) {
  39765. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("hemisphereLight", scene);
  39766. var hemisphere = _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__["HemisphereBuilder"].CreateHemisphere(root.name, { segments: 10, diameter: 1 }, scene);
  39767. hemisphere.position.z = -0.15;
  39768. hemisphere.rotation.x = Math.PI / 2;
  39769. hemisphere.parent = root;
  39770. var lines = this._createLightLines(3, scene);
  39771. lines.parent = root;
  39772. lines.position.z - 0.15;
  39773. root.scaling.scaleInPlace(LightGizmo._Scale);
  39774. root.rotation.x = Math.PI / 2;
  39775. return root;
  39776. };
  39777. LightGizmo._CreatePointLightMesh = function (scene) {
  39778. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("pointLight", scene);
  39779. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { segments: 10, diameter: 1 }, scene);
  39780. sphere.rotation.x = Math.PI / 2;
  39781. sphere.parent = root;
  39782. var lines = this._createLightLines(5, scene);
  39783. lines.parent = root;
  39784. root.scaling.scaleInPlace(LightGizmo._Scale);
  39785. root.rotation.x = Math.PI / 2;
  39786. return root;
  39787. };
  39788. LightGizmo._CreateSpotLightMesh = function (scene) {
  39789. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("spotLight", scene);
  39790. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { segments: 10, diameter: 1 }, scene);
  39791. sphere.parent = root;
  39792. var hemisphere = _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__["HemisphereBuilder"].CreateHemisphere(root.name, { segments: 10, diameter: 2 }, scene);
  39793. hemisphere.parent = root;
  39794. hemisphere.rotation.x = -Math.PI / 2;
  39795. var lines = this._createLightLines(2, scene);
  39796. lines.parent = root;
  39797. root.scaling.scaleInPlace(LightGizmo._Scale);
  39798. root.rotation.x = Math.PI / 2;
  39799. return root;
  39800. };
  39801. LightGizmo._CreateDirectionalLightMesh = function (scene) {
  39802. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("directionalLight", scene);
  39803. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](root.name, scene);
  39804. mesh.parent = root;
  39805. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { diameter: 1.2, segments: 10 }, scene);
  39806. sphere.parent = mesh;
  39807. var line = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder(root.name, 6, 0.3, 0.3, 6, 1, scene);
  39808. line.parent = mesh;
  39809. var left = line.clone(root.name);
  39810. left.scaling.y = 0.5;
  39811. left.position.x += 1.25;
  39812. var right = line.clone(root.name);
  39813. right.scaling.y = 0.5;
  39814. right.position.x += -1.25;
  39815. var arrowHead = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder(root.name, 1, 0, 0.6, 6, 1, scene);
  39816. arrowHead.position.y += 3;
  39817. arrowHead.parent = mesh;
  39818. var left = arrowHead.clone(root.name);
  39819. left.position.y = 1.5;
  39820. left.position.x += 1.25;
  39821. var right = arrowHead.clone(root.name);
  39822. right.position.y = 1.5;
  39823. right.position.x += -1.25;
  39824. mesh.scaling.scaleInPlace(LightGizmo._Scale);
  39825. mesh.rotation.z = Math.PI / 2;
  39826. mesh.rotation.y = Math.PI / 2;
  39827. return root;
  39828. };
  39829. // Static helper methods
  39830. LightGizmo._Scale = 0.007;
  39831. /**
  39832. * Creates the lines for a light mesh
  39833. */
  39834. LightGizmo._createLightLines = function (levels, scene) {
  39835. var distFromSphere = 1.2;
  39836. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("root", scene);
  39837. root.rotation.x = Math.PI / 2;
  39838. // Create the top line, this will be cloned for all other lines
  39839. var linePivot = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("linePivot", scene);
  39840. linePivot.parent = root;
  39841. var line = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder("line", 2, 0.2, 0.3, 6, 1, scene);
  39842. line.position.y = line.scaling.y / 2 + distFromSphere;
  39843. line.parent = linePivot;
  39844. if (levels < 2) {
  39845. return linePivot;
  39846. }
  39847. for (var i = 0; i < 4; i++) {
  39848. var l = linePivot.clone("lineParentClone");
  39849. l.rotation.z = Math.PI / 4;
  39850. l.rotation.y = (Math.PI / 2) + (Math.PI / 2 * i);
  39851. l.getChildMeshes()[0].scaling.y = 0.5;
  39852. l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = 0.8;
  39853. l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + distFromSphere;
  39854. }
  39855. if (levels < 3) {
  39856. return root;
  39857. }
  39858. for (var i = 0; i < 4; i++) {
  39859. var l = linePivot.clone("linePivotClone");
  39860. l.rotation.z = Math.PI / 2;
  39861. l.rotation.y = (Math.PI / 2 * i);
  39862. }
  39863. if (levels < 4) {
  39864. return root;
  39865. }
  39866. for (var i = 0; i < 4; i++) {
  39867. var l = linePivot.clone("linePivotClone");
  39868. l.rotation.z = Math.PI + (Math.PI / 4);
  39869. l.rotation.y = (Math.PI / 2) + (Math.PI / 2 * i);
  39870. l.getChildMeshes()[0].scaling.y = 0.5;
  39871. l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = 0.8;
  39872. l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + distFromSphere;
  39873. }
  39874. if (levels < 5) {
  39875. return root;
  39876. }
  39877. var l = linePivot.clone("linePivotClone");
  39878. l.rotation.z = Math.PI;
  39879. return root;
  39880. };
  39881. return LightGizmo;
  39882. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39883. /***/ }),
  39884. /***/ "./Gizmos/planeRotationGizmo.ts":
  39885. /*!**************************************!*\
  39886. !*** ./Gizmos/planeRotationGizmo.ts ***!
  39887. \**************************************/
  39888. /*! exports provided: PlaneRotationGizmo */
  39889. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39890. "use strict";
  39891. __webpack_require__.r(__webpack_exports__);
  39892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  39893. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39894. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39895. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39896. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39897. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39898. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  39899. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39900. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39901. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39902. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  39903. /**
  39904. * Single plane rotation gizmo
  39905. */
  39906. var PlaneRotationGizmo = /** @class */ (function (_super) {
  39907. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  39908. /**
  39909. * Creates a PlaneRotationGizmo
  39910. * @param gizmoLayer The utility layer the gizmo will be added to
  39911. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  39912. * @param color The color of the gizmo
  39913. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39914. */
  39915. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  39916. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  39917. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39918. if (tessellation === void 0) { tessellation = 32; }
  39919. var _this = _super.call(this, gizmoLayer) || this;
  39920. _this._pointerObserver = null;
  39921. /**
  39922. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  39923. */
  39924. _this.snapDistance = 0;
  39925. /**
  39926. * Event that fires each time the gizmo snaps to a new location.
  39927. * * snapDistance is the the change in distance
  39928. */
  39929. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39930. // Create Material
  39931. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39932. coloredMaterial.diffuseColor = color;
  39933. coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  39934. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39935. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  39936. // Build mesh on root node
  39937. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  39938. var drag = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateTorus("", 0.6, 0.03, tessellation, gizmoLayer.utilityLayerScene);
  39939. drag.visibility = 0;
  39940. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateTorus("", 0.6, 0.005, tessellation, gizmoLayer.utilityLayerScene);
  39941. rotationMesh.material = coloredMaterial;
  39942. // Position arrow pointing in its drag axis
  39943. rotationMesh.rotation.x = Math.PI / 2;
  39944. drag.rotation.x = Math.PI / 2;
  39945. parentMesh.addChild(rotationMesh);
  39946. parentMesh.addChild(drag);
  39947. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  39948. _this._rootMesh.addChild(parentMesh);
  39949. parentMesh.scaling.scaleInPlace(1 / 3);
  39950. // Add drag behavior to handle events when the gizmo is dragged
  39951. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  39952. _this.dragBehavior.moveAttached = false;
  39953. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  39954. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  39955. _this._rootMesh.addBehavior(_this.dragBehavior);
  39956. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39957. _this.dragBehavior.onDragStartObservable.add(function (e) {
  39958. if (_this.attachedMesh) {
  39959. lastDragPosition.copyFrom(e.dragPlanePoint);
  39960. }
  39961. });
  39962. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39963. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39964. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39965. var tmpSnapEvent = { snapDistance: 0 };
  39966. var currentSnapDragDistance = 0;
  39967. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39968. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39969. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  39970. _this.dragBehavior.onDragObservable.add(function (event) {
  39971. if (_this.attachedMesh) {
  39972. if (!_this.attachedMesh.rotationQuaternion) {
  39973. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  39974. }
  39975. // Remove parent priort to rotating
  39976. var attachedMeshParent = _this.attachedMesh.parent;
  39977. if (attachedMeshParent) {
  39978. _this.attachedMesh.setParent(null);
  39979. }
  39980. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  39981. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  39982. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  39983. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  39984. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  39985. var angle = Math.atan2(cross.length(), dot);
  39986. planeNormalTowardsCamera.copyFrom(planeNormal);
  39987. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  39988. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39989. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  39990. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  39991. }
  39992. // Flip up vector depending on which side the camera is on
  39993. if (gizmoLayer.utilityLayerScene.activeCamera) {
  39994. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  39995. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  39996. planeNormalTowardsCamera.scaleInPlace(-1);
  39997. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  39998. }
  39999. }
  40000. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  40001. if (halfCircleSide) {
  40002. angle = -angle;
  40003. }
  40004. // Snapping logic
  40005. var snapped = false;
  40006. if (_this.snapDistance != 0) {
  40007. currentSnapDragDistance += angle;
  40008. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  40009. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  40010. if (currentSnapDragDistance < 0) {
  40011. dragSteps *= -1;
  40012. }
  40013. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  40014. angle = _this.snapDistance * dragSteps;
  40015. snapped = true;
  40016. }
  40017. else {
  40018. angle = 0;
  40019. }
  40020. }
  40021. // If the mesh has a parent, convert needed world rotation to local rotation
  40022. tmpMatrix.reset();
  40023. if (_this.attachedMesh.parent) {
  40024. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  40025. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  40026. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  40027. }
  40028. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  40029. var quaternionCoefficient = Math.sin(angle / 2);
  40030. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  40031. // 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
  40032. if (tmpMatrix.determinant() > 0) {
  40033. amountToRotate.toEulerAnglesToRef(tmpVector);
  40034. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  40035. }
  40036. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  40037. // Rotate selected mesh quaternion over fixed axis
  40038. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  40039. }
  40040. else {
  40041. // Rotate selected mesh quaternion over rotated axis
  40042. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  40043. }
  40044. lastDragPosition.copyFrom(event.dragPlanePoint);
  40045. if (snapped) {
  40046. tmpSnapEvent.snapDistance = angle;
  40047. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  40048. }
  40049. // Restore parent
  40050. if (attachedMeshParent) {
  40051. _this.attachedMesh.setParent(attachedMeshParent);
  40052. }
  40053. }
  40054. });
  40055. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  40056. if (_this._customMeshSet) {
  40057. return;
  40058. }
  40059. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  40060. var material = isHovered ? hoverMaterial : coloredMaterial;
  40061. _this._rootMesh.getChildMeshes().forEach(function (m) {
  40062. m.material = material;
  40063. if (m.color) {
  40064. m.color = material.diffuseColor;
  40065. }
  40066. });
  40067. });
  40068. var light = gizmoLayer._getSharedGizmoLight();
  40069. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes(false));
  40070. return _this;
  40071. }
  40072. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  40073. if (this.dragBehavior) {
  40074. this.dragBehavior.enabled = value ? true : false;
  40075. }
  40076. };
  40077. /**
  40078. * Disposes of the gizmo
  40079. */
  40080. PlaneRotationGizmo.prototype.dispose = function () {
  40081. this.onSnapObservable.clear();
  40082. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  40083. this.dragBehavior.detach();
  40084. _super.prototype.dispose.call(this);
  40085. };
  40086. return PlaneRotationGizmo;
  40087. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  40088. /***/ }),
  40089. /***/ "./Gizmos/positionGizmo.ts":
  40090. /*!*********************************!*\
  40091. !*** ./Gizmos/positionGizmo.ts ***!
  40092. \*********************************/
  40093. /*! exports provided: PositionGizmo */
  40094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40095. "use strict";
  40096. __webpack_require__.r(__webpack_exports__);
  40097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  40098. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40099. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40100. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40101. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40102. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  40103. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  40104. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  40105. /**
  40106. * Gizmo that enables dragging a mesh along 3 axis
  40107. */
  40108. var PositionGizmo = /** @class */ (function (_super) {
  40109. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  40110. /**
  40111. * Creates a PositionGizmo
  40112. * @param gizmoLayer The utility layer the gizmo will be added to
  40113. */
  40114. function PositionGizmo(gizmoLayer) {
  40115. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  40116. var _this = _super.call(this, gizmoLayer) || this;
  40117. /** Fires an event when any of it's sub gizmos are dragged */
  40118. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40119. /** Fires an event when any of it's sub gizmos are released from dragging */
  40120. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40121. _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);
  40122. _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);
  40123. _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);
  40124. // Relay drag events
  40125. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  40126. gizmo.dragBehavior.onDragStartObservable.add(function () {
  40127. _this.onDragStartObservable.notifyObservers({});
  40128. });
  40129. gizmo.dragBehavior.onDragEndObservable.add(function () {
  40130. _this.onDragEndObservable.notifyObservers({});
  40131. });
  40132. });
  40133. _this.attachedMesh = null;
  40134. return _this;
  40135. }
  40136. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  40137. get: function () {
  40138. return this.xGizmo.attachedMesh;
  40139. },
  40140. set: function (mesh) {
  40141. if (this.xGizmo) {
  40142. this.xGizmo.attachedMesh = mesh;
  40143. this.yGizmo.attachedMesh = mesh;
  40144. this.zGizmo.attachedMesh = mesh;
  40145. }
  40146. },
  40147. enumerable: true,
  40148. configurable: true
  40149. });
  40150. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  40151. get: function () {
  40152. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  40153. },
  40154. set: function (value) {
  40155. if (this.xGizmo) {
  40156. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40157. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40158. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40159. }
  40160. },
  40161. enumerable: true,
  40162. configurable: true
  40163. });
  40164. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  40165. get: function () {
  40166. return this.xGizmo.snapDistance;
  40167. },
  40168. /**
  40169. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40170. */
  40171. set: function (value) {
  40172. if (this.xGizmo) {
  40173. this.xGizmo.snapDistance = value;
  40174. this.yGizmo.snapDistance = value;
  40175. this.zGizmo.snapDistance = value;
  40176. }
  40177. },
  40178. enumerable: true,
  40179. configurable: true
  40180. });
  40181. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  40182. get: function () {
  40183. return this.xGizmo.scaleRatio;
  40184. },
  40185. /**
  40186. * Ratio for the scale of the gizmo (Default: 1)
  40187. */
  40188. set: function (value) {
  40189. if (this.xGizmo) {
  40190. this.xGizmo.scaleRatio = value;
  40191. this.yGizmo.scaleRatio = value;
  40192. this.zGizmo.scaleRatio = value;
  40193. }
  40194. },
  40195. enumerable: true,
  40196. configurable: true
  40197. });
  40198. /**
  40199. * Disposes of the gizmo
  40200. */
  40201. PositionGizmo.prototype.dispose = function () {
  40202. this.xGizmo.dispose();
  40203. this.yGizmo.dispose();
  40204. this.zGizmo.dispose();
  40205. this.onDragStartObservable.clear();
  40206. this.onDragEndObservable.clear();
  40207. };
  40208. /**
  40209. * CustomMeshes are not supported by this gizmo
  40210. * @param mesh The mesh to replace the default mesh of the gizmo
  40211. */
  40212. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  40213. _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)");
  40214. };
  40215. return PositionGizmo;
  40216. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  40217. /***/ }),
  40218. /***/ "./Gizmos/rotationGizmo.ts":
  40219. /*!*********************************!*\
  40220. !*** ./Gizmos/rotationGizmo.ts ***!
  40221. \*********************************/
  40222. /*! exports provided: RotationGizmo */
  40223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40224. "use strict";
  40225. __webpack_require__.r(__webpack_exports__);
  40226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  40227. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40228. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40229. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40230. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40231. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  40232. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  40233. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  40234. /**
  40235. * Gizmo that enables rotating a mesh along 3 axis
  40236. */
  40237. var RotationGizmo = /** @class */ (function (_super) {
  40238. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  40239. /**
  40240. * Creates a RotationGizmo
  40241. * @param gizmoLayer The utility layer the gizmo will be added to
  40242. * @param tessellation Amount of tessellation to be used when creating rotation circles
  40243. */
  40244. function RotationGizmo(gizmoLayer, tessellation) {
  40245. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  40246. if (tessellation === void 0) { tessellation = 32; }
  40247. var _this = _super.call(this, gizmoLayer) || this;
  40248. /** Fires an event when any of it's sub gizmos are dragged */
  40249. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40250. /** Fires an event when any of it's sub gizmos are released from dragging */
  40251. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40252. _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);
  40253. _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);
  40254. _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);
  40255. // Relay drag events
  40256. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  40257. gizmo.dragBehavior.onDragStartObservable.add(function () {
  40258. _this.onDragStartObservable.notifyObservers({});
  40259. });
  40260. gizmo.dragBehavior.onDragEndObservable.add(function () {
  40261. _this.onDragEndObservable.notifyObservers({});
  40262. });
  40263. });
  40264. _this.attachedMesh = null;
  40265. return _this;
  40266. }
  40267. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  40268. get: function () {
  40269. return this.xGizmo.attachedMesh;
  40270. },
  40271. set: function (mesh) {
  40272. if (this.xGizmo) {
  40273. this.xGizmo.attachedMesh = mesh;
  40274. this.yGizmo.attachedMesh = mesh;
  40275. this.zGizmo.attachedMesh = mesh;
  40276. }
  40277. },
  40278. enumerable: true,
  40279. configurable: true
  40280. });
  40281. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  40282. get: function () {
  40283. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  40284. },
  40285. set: function (value) {
  40286. if (this.xGizmo) {
  40287. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40288. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40289. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40290. }
  40291. },
  40292. enumerable: true,
  40293. configurable: true
  40294. });
  40295. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  40296. get: function () {
  40297. return this.xGizmo.snapDistance;
  40298. },
  40299. /**
  40300. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40301. */
  40302. set: function (value) {
  40303. if (this.xGizmo) {
  40304. this.xGizmo.snapDistance = value;
  40305. this.yGizmo.snapDistance = value;
  40306. this.zGizmo.snapDistance = value;
  40307. }
  40308. },
  40309. enumerable: true,
  40310. configurable: true
  40311. });
  40312. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  40313. get: function () {
  40314. return this.xGizmo.scaleRatio;
  40315. },
  40316. /**
  40317. * Ratio for the scale of the gizmo (Default: 1)
  40318. */
  40319. set: function (value) {
  40320. if (this.xGizmo) {
  40321. this.xGizmo.scaleRatio = value;
  40322. this.yGizmo.scaleRatio = value;
  40323. this.zGizmo.scaleRatio = value;
  40324. }
  40325. },
  40326. enumerable: true,
  40327. configurable: true
  40328. });
  40329. /**
  40330. * Disposes of the gizmo
  40331. */
  40332. RotationGizmo.prototype.dispose = function () {
  40333. this.xGizmo.dispose();
  40334. this.yGizmo.dispose();
  40335. this.zGizmo.dispose();
  40336. this.onDragStartObservable.clear();
  40337. this.onDragEndObservable.clear();
  40338. };
  40339. /**
  40340. * CustomMeshes are not supported by this gizmo
  40341. * @param mesh The mesh to replace the default mesh of the gizmo
  40342. */
  40343. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  40344. _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)");
  40345. };
  40346. return RotationGizmo;
  40347. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  40348. /***/ }),
  40349. /***/ "./Gizmos/scaleGizmo.ts":
  40350. /*!******************************!*\
  40351. !*** ./Gizmos/scaleGizmo.ts ***!
  40352. \******************************/
  40353. /*! exports provided: ScaleGizmo */
  40354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40355. "use strict";
  40356. __webpack_require__.r(__webpack_exports__);
  40357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  40358. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40359. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40360. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40361. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40362. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  40363. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  40364. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  40365. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  40366. /**
  40367. * Gizmo that enables scaling a mesh along 3 axis
  40368. */
  40369. var ScaleGizmo = /** @class */ (function (_super) {
  40370. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  40371. /**
  40372. * Creates a ScaleGizmo
  40373. * @param gizmoLayer The utility layer the gizmo will be added to
  40374. */
  40375. function ScaleGizmo(gizmoLayer) {
  40376. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  40377. var _this = _super.call(this, gizmoLayer) || this;
  40378. /** Fires an event when any of it's sub gizmos are dragged */
  40379. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40380. /** Fires an event when any of it's sub gizmos are released from dragging */
  40381. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40382. _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);
  40383. _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);
  40384. _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);
  40385. // Create uniform scale gizmo
  40386. _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);
  40387. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  40388. _this.uniformScaleGizmo.uniformScaling = true;
  40389. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  40390. uniformScalingMesh.scaling.scaleInPlace(0.02);
  40391. uniformScalingMesh.visibility = 0;
  40392. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  40393. octahedron.scaling.scaleInPlace(0.007);
  40394. uniformScalingMesh.addChild(octahedron);
  40395. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  40396. var light = gizmoLayer._getSharedGizmoLight();
  40397. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(octahedron);
  40398. // Relay drag events
  40399. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  40400. gizmo.dragBehavior.onDragStartObservable.add(function () {
  40401. _this.onDragStartObservable.notifyObservers({});
  40402. });
  40403. gizmo.dragBehavior.onDragEndObservable.add(function () {
  40404. _this.onDragEndObservable.notifyObservers({});
  40405. });
  40406. });
  40407. _this.attachedMesh = null;
  40408. return _this;
  40409. }
  40410. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  40411. get: function () {
  40412. return this.xGizmo.attachedMesh;
  40413. },
  40414. set: function (mesh) {
  40415. if (this.xGizmo) {
  40416. this.xGizmo.attachedMesh = mesh;
  40417. this.yGizmo.attachedMesh = mesh;
  40418. this.zGizmo.attachedMesh = mesh;
  40419. this.uniformScaleGizmo.attachedMesh = mesh;
  40420. }
  40421. },
  40422. enumerable: true,
  40423. configurable: true
  40424. });
  40425. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  40426. get: function () {
  40427. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  40428. },
  40429. set: function (value) {
  40430. if (!value) {
  40431. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  40432. }
  40433. if (this.xGizmo) {
  40434. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40435. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40436. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40437. }
  40438. },
  40439. enumerable: true,
  40440. configurable: true
  40441. });
  40442. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  40443. get: function () {
  40444. return this.xGizmo.snapDistance;
  40445. },
  40446. /**
  40447. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40448. */
  40449. set: function (value) {
  40450. if (this.xGizmo) {
  40451. this.xGizmo.snapDistance = value;
  40452. this.yGizmo.snapDistance = value;
  40453. this.zGizmo.snapDistance = value;
  40454. this.uniformScaleGizmo.snapDistance = value;
  40455. }
  40456. },
  40457. enumerable: true,
  40458. configurable: true
  40459. });
  40460. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  40461. get: function () {
  40462. return this.xGizmo.scaleRatio;
  40463. },
  40464. /**
  40465. * Ratio for the scale of the gizmo (Default: 1)
  40466. */
  40467. set: function (value) {
  40468. if (this.xGizmo) {
  40469. this.xGizmo.scaleRatio = value;
  40470. this.yGizmo.scaleRatio = value;
  40471. this.zGizmo.scaleRatio = value;
  40472. this.uniformScaleGizmo.scaleRatio = value;
  40473. }
  40474. },
  40475. enumerable: true,
  40476. configurable: true
  40477. });
  40478. /**
  40479. * Disposes of the gizmo
  40480. */
  40481. ScaleGizmo.prototype.dispose = function () {
  40482. this.xGizmo.dispose();
  40483. this.yGizmo.dispose();
  40484. this.zGizmo.dispose();
  40485. this.uniformScaleGizmo.dispose();
  40486. this.onDragStartObservable.clear();
  40487. this.onDragEndObservable.clear();
  40488. };
  40489. return ScaleGizmo;
  40490. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  40491. /***/ }),
  40492. /***/ "./Helpers/environmentHelper.ts":
  40493. /*!**************************************!*\
  40494. !*** ./Helpers/environmentHelper.ts ***!
  40495. \**************************************/
  40496. /*! exports provided: EnvironmentHelper */
  40497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40498. "use strict";
  40499. __webpack_require__.r(__webpack_exports__);
  40500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  40501. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40502. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40503. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  40504. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40505. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40506. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  40507. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40508. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  40509. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  40510. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40511. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40512. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  40513. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40514. /**
  40515. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  40516. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  40517. * It also helps with the default setup of your imageProcessing configuration.
  40518. */
  40519. var EnvironmentHelper = /** @class */ (function () {
  40520. /**
  40521. * constructor
  40522. * @param options Defines the options we want to customize the helper
  40523. * @param scene The scene to add the material to
  40524. */
  40525. function EnvironmentHelper(options, scene) {
  40526. var _this = this;
  40527. this._errorHandler = function (message, exception) {
  40528. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  40529. };
  40530. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  40531. this._scene = scene;
  40532. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40533. this._setupBackground();
  40534. this._setupImageProcessing();
  40535. }
  40536. /**
  40537. * Creates the default options for the helper.
  40538. */
  40539. EnvironmentHelper._getDefaultOptions = function () {
  40540. return {
  40541. createGround: true,
  40542. groundSize: 15,
  40543. groundTexture: this._groundTextureCDNUrl,
  40544. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  40545. groundOpacity: 0.9,
  40546. enableGroundShadow: true,
  40547. groundShadowLevel: 0.5,
  40548. enableGroundMirror: false,
  40549. groundMirrorSizeRatio: 0.3,
  40550. groundMirrorBlurKernel: 64,
  40551. groundMirrorAmount: 1,
  40552. groundMirrorFresnelWeight: 1,
  40553. groundMirrorFallOffDistance: 0,
  40554. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  40555. groundYBias: 0.00001,
  40556. createSkybox: true,
  40557. skyboxSize: 20,
  40558. skyboxTexture: this._skyboxTextureCDNUrl,
  40559. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  40560. backgroundYRotation: 0,
  40561. sizeAuto: true,
  40562. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  40563. setupImageProcessing: true,
  40564. environmentTexture: this._environmentTextureCDNUrl,
  40565. cameraExposure: 0.8,
  40566. cameraContrast: 1.2,
  40567. toneMappingEnabled: true,
  40568. };
  40569. };
  40570. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  40571. /**
  40572. * Gets the root mesh created by the helper.
  40573. */
  40574. get: function () {
  40575. return this._rootMesh;
  40576. },
  40577. enumerable: true,
  40578. configurable: true
  40579. });
  40580. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  40581. /**
  40582. * Gets the skybox created by the helper.
  40583. */
  40584. get: function () {
  40585. return this._skybox;
  40586. },
  40587. enumerable: true,
  40588. configurable: true
  40589. });
  40590. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  40591. /**
  40592. * Gets the skybox texture created by the helper.
  40593. */
  40594. get: function () {
  40595. return this._skyboxTexture;
  40596. },
  40597. enumerable: true,
  40598. configurable: true
  40599. });
  40600. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  40601. /**
  40602. * Gets the skybox material created by the helper.
  40603. */
  40604. get: function () {
  40605. return this._skyboxMaterial;
  40606. },
  40607. enumerable: true,
  40608. configurable: true
  40609. });
  40610. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  40611. /**
  40612. * Gets the ground mesh created by the helper.
  40613. */
  40614. get: function () {
  40615. return this._ground;
  40616. },
  40617. enumerable: true,
  40618. configurable: true
  40619. });
  40620. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  40621. /**
  40622. * Gets the ground texture created by the helper.
  40623. */
  40624. get: function () {
  40625. return this._groundTexture;
  40626. },
  40627. enumerable: true,
  40628. configurable: true
  40629. });
  40630. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  40631. /**
  40632. * Gets the ground mirror created by the helper.
  40633. */
  40634. get: function () {
  40635. return this._groundMirror;
  40636. },
  40637. enumerable: true,
  40638. configurable: true
  40639. });
  40640. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  40641. /**
  40642. * Gets the ground mirror render list to helps pushing the meshes
  40643. * you wish in the ground reflection.
  40644. */
  40645. get: function () {
  40646. if (this._groundMirror) {
  40647. return this._groundMirror.renderList;
  40648. }
  40649. return null;
  40650. },
  40651. enumerable: true,
  40652. configurable: true
  40653. });
  40654. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  40655. /**
  40656. * Gets the ground material created by the helper.
  40657. */
  40658. get: function () {
  40659. return this._groundMaterial;
  40660. },
  40661. enumerable: true,
  40662. configurable: true
  40663. });
  40664. /**
  40665. * Updates the background according to the new options
  40666. * @param options
  40667. */
  40668. EnvironmentHelper.prototype.updateOptions = function (options) {
  40669. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  40670. if (this._ground && !newOptions.createGround) {
  40671. this._ground.dispose();
  40672. this._ground = null;
  40673. }
  40674. if (this._groundMaterial && !newOptions.createGround) {
  40675. this._groundMaterial.dispose();
  40676. this._groundMaterial = null;
  40677. }
  40678. if (this._groundTexture) {
  40679. if (this._options.groundTexture != newOptions.groundTexture) {
  40680. this._groundTexture.dispose();
  40681. this._groundTexture = null;
  40682. }
  40683. }
  40684. if (this._skybox && !newOptions.createSkybox) {
  40685. this._skybox.dispose();
  40686. this._skybox = null;
  40687. }
  40688. if (this._skyboxMaterial && !newOptions.createSkybox) {
  40689. this._skyboxMaterial.dispose();
  40690. this._skyboxMaterial = null;
  40691. }
  40692. if (this._skyboxTexture) {
  40693. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  40694. this._skyboxTexture.dispose();
  40695. this._skyboxTexture = null;
  40696. }
  40697. }
  40698. if (this._groundMirror && !newOptions.enableGroundMirror) {
  40699. this._groundMirror.dispose();
  40700. this._groundMirror = null;
  40701. }
  40702. if (this._scene.environmentTexture) {
  40703. if (this._options.environmentTexture != newOptions.environmentTexture) {
  40704. this._scene.environmentTexture.dispose();
  40705. }
  40706. }
  40707. this._options = newOptions;
  40708. this._setupBackground();
  40709. this._setupImageProcessing();
  40710. };
  40711. /**
  40712. * Sets the primary color of all the available elements.
  40713. * @param color the main color to affect to the ground and the background
  40714. */
  40715. EnvironmentHelper.prototype.setMainColor = function (color) {
  40716. if (this.groundMaterial) {
  40717. this.groundMaterial.primaryColor = color;
  40718. }
  40719. if (this.skyboxMaterial) {
  40720. this.skyboxMaterial.primaryColor = color;
  40721. }
  40722. if (this.groundMirror) {
  40723. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  40724. }
  40725. };
  40726. /**
  40727. * Setup the image processing according to the specified options.
  40728. */
  40729. EnvironmentHelper.prototype._setupImageProcessing = function () {
  40730. if (this._options.setupImageProcessing) {
  40731. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  40732. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  40733. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  40734. this._setupEnvironmentTexture();
  40735. }
  40736. };
  40737. /**
  40738. * Setup the environment texture according to the specified options.
  40739. */
  40740. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  40741. if (this._scene.environmentTexture) {
  40742. return;
  40743. }
  40744. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40745. this._scene.environmentTexture = this._options.environmentTexture;
  40746. return;
  40747. }
  40748. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  40749. this._scene.environmentTexture = environmentTexture;
  40750. };
  40751. /**
  40752. * Setup the background according to the specified options.
  40753. */
  40754. EnvironmentHelper.prototype._setupBackground = function () {
  40755. if (!this._rootMesh) {
  40756. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  40757. }
  40758. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  40759. var sceneSize = this._getSceneSize();
  40760. if (this._options.createGround) {
  40761. this._setupGround(sceneSize);
  40762. this._setupGroundMaterial();
  40763. this._setupGroundDiffuseTexture();
  40764. if (this._options.enableGroundMirror) {
  40765. this._setupGroundMirrorTexture(sceneSize);
  40766. }
  40767. this._setupMirrorInGroundMaterial();
  40768. }
  40769. if (this._options.createSkybox) {
  40770. this._setupSkybox(sceneSize);
  40771. this._setupSkyboxMaterial();
  40772. this._setupSkyboxReflectionTexture();
  40773. }
  40774. this._rootMesh.position.x = sceneSize.rootPosition.x;
  40775. this._rootMesh.position.z = sceneSize.rootPosition.z;
  40776. this._rootMesh.position.y = sceneSize.rootPosition.y;
  40777. };
  40778. /**
  40779. * Get the scene sizes according to the setup.
  40780. */
  40781. EnvironmentHelper.prototype._getSceneSize = function () {
  40782. var _this = this;
  40783. var groundSize = this._options.groundSize;
  40784. var skyboxSize = this._options.skyboxSize;
  40785. var rootPosition = this._options.rootPosition;
  40786. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  40787. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40788. }
  40789. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  40790. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  40791. });
  40792. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  40793. if (this._options.sizeAuto) {
  40794. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  40795. this._scene.activeCamera.upperRadiusLimit) {
  40796. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  40797. skyboxSize = groundSize;
  40798. }
  40799. var sceneDiagonalLenght = sceneDiagonal.length();
  40800. if (sceneDiagonalLenght > groundSize) {
  40801. groundSize = sceneDiagonalLenght * 2;
  40802. skyboxSize = groundSize;
  40803. }
  40804. // 10 % bigger.
  40805. groundSize *= 1.1;
  40806. skyboxSize *= 1.5;
  40807. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  40808. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  40809. }
  40810. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40811. };
  40812. /**
  40813. * Setup the ground according to the specified options.
  40814. */
  40815. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  40816. var _this = this;
  40817. if (!this._ground || this._ground.isDisposed()) {
  40818. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  40819. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  40820. this._ground.parent = this._rootMesh;
  40821. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  40822. }
  40823. this._ground.receiveShadows = this._options.enableGroundShadow;
  40824. };
  40825. /**
  40826. * Setup the ground material according to the specified options.
  40827. */
  40828. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  40829. if (!this._groundMaterial) {
  40830. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  40831. }
  40832. this._groundMaterial.alpha = this._options.groundOpacity;
  40833. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  40834. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  40835. this._groundMaterial.primaryColor = this._options.groundColor;
  40836. this._groundMaterial.useRGBColor = false;
  40837. this._groundMaterial.enableNoise = true;
  40838. if (this._ground) {
  40839. this._ground.material = this._groundMaterial;
  40840. }
  40841. };
  40842. /**
  40843. * Setup the ground diffuse texture according to the specified options.
  40844. */
  40845. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  40846. if (!this._groundMaterial) {
  40847. return;
  40848. }
  40849. if (this._groundTexture) {
  40850. return;
  40851. }
  40852. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40853. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  40854. return;
  40855. }
  40856. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40857. diffuseTexture.gammaSpace = false;
  40858. diffuseTexture.hasAlpha = true;
  40859. this._groundMaterial.diffuseTexture = diffuseTexture;
  40860. };
  40861. /**
  40862. * Setup the ground mirror texture according to the specified options.
  40863. */
  40864. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  40865. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  40866. if (!this._groundMirror) {
  40867. 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);
  40868. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  40869. this._groundMirror.anisotropicFilteringLevel = 1;
  40870. this._groundMirror.wrapU = wrapping;
  40871. this._groundMirror.wrapV = wrapping;
  40872. this._groundMirror.gammaSpace = false;
  40873. if (this._groundMirror.renderList) {
  40874. for (var i = 0; i < this._scene.meshes.length; i++) {
  40875. var mesh = this._scene.meshes[i];
  40876. if (mesh !== this._ground &&
  40877. mesh !== this._skybox &&
  40878. mesh !== this._rootMesh) {
  40879. this._groundMirror.renderList.push(mesh);
  40880. }
  40881. }
  40882. }
  40883. }
  40884. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  40885. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  40886. };
  40887. /**
  40888. * Setup the ground to receive the mirror texture.
  40889. */
  40890. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  40891. if (this._groundMaterial) {
  40892. this._groundMaterial.reflectionTexture = this._groundMirror;
  40893. this._groundMaterial.reflectionFresnel = true;
  40894. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  40895. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  40896. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  40897. }
  40898. };
  40899. /**
  40900. * Setup the skybox according to the specified options.
  40901. */
  40902. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  40903. var _this = this;
  40904. if (!this._skybox || this._skybox.isDisposed()) {
  40905. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  40906. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  40907. }
  40908. this._skybox.parent = this._rootMesh;
  40909. };
  40910. /**
  40911. * Setup the skybox material according to the specified options.
  40912. */
  40913. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  40914. if (!this._skybox) {
  40915. return;
  40916. }
  40917. if (!this._skyboxMaterial) {
  40918. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  40919. }
  40920. this._skyboxMaterial.useRGBColor = false;
  40921. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  40922. this._skyboxMaterial.enableNoise = true;
  40923. this._skybox.material = this._skyboxMaterial;
  40924. };
  40925. /**
  40926. * Setup the skybox reflection texture according to the specified options.
  40927. */
  40928. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  40929. if (!this._skyboxMaterial) {
  40930. return;
  40931. }
  40932. if (this._skyboxTexture) {
  40933. return;
  40934. }
  40935. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40936. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  40937. return;
  40938. }
  40939. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40940. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  40941. this._skyboxTexture.gammaSpace = false;
  40942. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  40943. };
  40944. /**
  40945. * Dispose all the elements created by the Helper.
  40946. */
  40947. EnvironmentHelper.prototype.dispose = function () {
  40948. if (this._groundMaterial) {
  40949. this._groundMaterial.dispose(true, true);
  40950. }
  40951. if (this._skyboxMaterial) {
  40952. this._skyboxMaterial.dispose(true, true);
  40953. }
  40954. this._rootMesh.dispose(false);
  40955. };
  40956. /**
  40957. * Default ground texture URL.
  40958. */
  40959. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  40960. /**
  40961. * Default skybox texture URL.
  40962. */
  40963. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  40964. /**
  40965. * Default environment texture URL.
  40966. */
  40967. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  40968. return EnvironmentHelper;
  40969. }());
  40970. /***/ }),
  40971. /***/ "./Helpers/index.ts":
  40972. /*!**************************!*\
  40973. !*** ./Helpers/index.ts ***!
  40974. \**************************/
  40975. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  40976. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40977. "use strict";
  40978. __webpack_require__.r(__webpack_exports__);
  40979. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  40981. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  40982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  40983. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  40984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  40985. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  40986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  40987. /***/ }),
  40988. /***/ "./Helpers/photoDome.ts":
  40989. /*!******************************!*\
  40990. !*** ./Helpers/photoDome.ts ***!
  40991. \******************************/
  40992. /*! exports provided: PhotoDome */
  40993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40994. "use strict";
  40995. __webpack_require__.r(__webpack_exports__);
  40996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  40997. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40998. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40999. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  41000. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  41001. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41002. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  41003. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  41004. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41005. /**
  41006. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  41007. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  41008. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  41009. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  41010. */
  41011. var PhotoDome = /** @class */ (function (_super) {
  41012. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  41013. /**
  41014. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  41015. * @param name Element's name, child elements will append suffixes for their own names.
  41016. * @param urlsOfPhoto defines the url of the photo to display
  41017. * @param options defines an object containing optional or exposed sub element properties
  41018. * @param onError defines a callback called when an error occured while loading the texture
  41019. */
  41020. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  41021. if (onError === void 0) { onError = null; }
  41022. var _this = _super.call(this, name, scene) || this;
  41023. _this._useDirectMapping = false;
  41024. /**
  41025. * Observable raised when an error occured while loading the 360 image
  41026. */
  41027. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  41028. // set defaults and manage values
  41029. name = name || "photoDome";
  41030. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  41031. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  41032. if (options.useDirectMapping === undefined) {
  41033. _this._useDirectMapping = true;
  41034. }
  41035. else {
  41036. _this._useDirectMapping = options.useDirectMapping;
  41037. }
  41038. if (options.faceForward === undefined) {
  41039. options.faceForward = true;
  41040. }
  41041. _this._setReady(false);
  41042. // create
  41043. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  41044. _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);
  41045. // configure material
  41046. material.opacityFresnel = false;
  41047. material.useEquirectangularFOV = true;
  41048. material.fovMultiplier = 1.0;
  41049. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  41050. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  41051. if (onError) {
  41052. onError(message, exception);
  41053. }
  41054. });
  41055. _this.photoTexture.onLoadObservable.addOnce(function () {
  41056. _this._setReady(true);
  41057. });
  41058. // configure mesh
  41059. _this._mesh.material = material;
  41060. _this._mesh.parent = _this;
  41061. // Initial rotation
  41062. if (options.faceForward && scene.activeCamera) {
  41063. var camera = scene.activeCamera;
  41064. var forward = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  41065. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  41066. direction.normalize();
  41067. _this.rotation.y = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  41068. }
  41069. return _this;
  41070. }
  41071. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  41072. /**
  41073. * Gets or sets the texture being displayed on the sphere
  41074. */
  41075. get: function () {
  41076. return this._photoTexture;
  41077. },
  41078. set: function (value) {
  41079. if (this._photoTexture === value) {
  41080. return;
  41081. }
  41082. this._photoTexture = value;
  41083. if (this._useDirectMapping) {
  41084. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  41085. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  41086. this._material.diffuseTexture = this._photoTexture;
  41087. }
  41088. else {
  41089. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  41090. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  41091. this._material.reflectionTexture = this._photoTexture;
  41092. }
  41093. },
  41094. enumerable: true,
  41095. configurable: true
  41096. });
  41097. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  41098. /**
  41099. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41100. * Also see the options.resolution property.
  41101. */
  41102. get: function () {
  41103. return this._material.fovMultiplier;
  41104. },
  41105. set: function (value) {
  41106. this._material.fovMultiplier = value;
  41107. },
  41108. enumerable: true,
  41109. configurable: true
  41110. });
  41111. /**
  41112. * Releases resources associated with this node.
  41113. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  41114. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  41115. */
  41116. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  41117. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  41118. this._photoTexture.dispose();
  41119. this._mesh.dispose();
  41120. this._material.dispose();
  41121. this.onLoadErrorObservable.clear();
  41122. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  41123. };
  41124. return PhotoDome;
  41125. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  41126. /***/ }),
  41127. /***/ "./Helpers/sceneHelpers.ts":
  41128. /*!*********************************!*\
  41129. !*** ./Helpers/sceneHelpers.ts ***!
  41130. \*********************************/
  41131. /*! exports provided: _forceSceneHelpersToBundle */
  41132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41133. "use strict";
  41134. __webpack_require__.r(__webpack_exports__);
  41135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  41136. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  41137. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  41138. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41139. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  41140. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41141. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  41142. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  41143. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  41144. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  41145. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  41146. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  41147. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  41148. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  41149. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  41150. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  41151. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  41152. /* harmony import */ var _Materials_Textures_Loaders_ddsTextureLoader__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  41153. /* harmony import */ var _Materials_Textures_Loaders_envTextureLoader__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/Loaders/envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  41154. /* harmony import */ var _Materials_Textures_Loaders_ktxTextureLoader__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  41155. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  41156. /** @hidden */
  41157. var _forceSceneHelpersToBundle = true;
  41158. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  41159. if (replace === void 0) { replace = false; }
  41160. // Dispose existing light in replace mode.
  41161. if (replace) {
  41162. if (this.lights) {
  41163. for (var i = 0; i < this.lights.length; i++) {
  41164. this.lights[i].dispose();
  41165. }
  41166. }
  41167. }
  41168. // Light
  41169. if (this.lights.length === 0) {
  41170. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  41171. }
  41172. };
  41173. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  41174. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  41175. if (replace === void 0) { replace = false; }
  41176. if (attachCameraControls === void 0) { attachCameraControls = false; }
  41177. // Dispose existing camera in replace mode.
  41178. if (replace) {
  41179. if (this.activeCamera) {
  41180. this.activeCamera.dispose();
  41181. this.activeCamera = null;
  41182. }
  41183. }
  41184. // Camera
  41185. if (!this.activeCamera) {
  41186. var worldExtends = this.getWorldExtends();
  41187. var worldSize = worldExtends.max.subtract(worldExtends.min);
  41188. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  41189. var camera;
  41190. var radius = worldSize.length() * 1.5;
  41191. // empty scene scenario!
  41192. if (!isFinite(radius)) {
  41193. radius = 1;
  41194. worldCenter.copyFromFloats(0, 0, 0);
  41195. }
  41196. if (createArcRotateCamera) {
  41197. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  41198. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  41199. arcRotateCamera.wheelPrecision = 100 / radius;
  41200. camera = arcRotateCamera;
  41201. }
  41202. else {
  41203. 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);
  41204. freeCamera.setTarget(worldCenter);
  41205. camera = freeCamera;
  41206. }
  41207. camera.minZ = radius * 0.01;
  41208. camera.maxZ = radius * 1000;
  41209. camera.speed = radius * 0.2;
  41210. this.activeCamera = camera;
  41211. var canvas = this.getEngine().getRenderingCanvas();
  41212. if (attachCameraControls && canvas) {
  41213. camera.attachControl(canvas);
  41214. }
  41215. }
  41216. };
  41217. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  41218. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  41219. if (replace === void 0) { replace = false; }
  41220. if (attachCameraControls === void 0) { attachCameraControls = false; }
  41221. this.createDefaultLight(replace);
  41222. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  41223. };
  41224. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  41225. if (pbr === void 0) { pbr = false; }
  41226. if (scale === void 0) { scale = 1000; }
  41227. if (blur === void 0) { blur = 0; }
  41228. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  41229. if (!environmentTexture) {
  41230. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  41231. return null;
  41232. }
  41233. if (setGlobalEnvTexture) {
  41234. if (environmentTexture) {
  41235. this.environmentTexture = environmentTexture;
  41236. }
  41237. }
  41238. // Skybox
  41239. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  41240. if (pbr) {
  41241. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  41242. hdrSkyboxMaterial.backFaceCulling = false;
  41243. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  41244. if (hdrSkyboxMaterial.reflectionTexture) {
  41245. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  41246. }
  41247. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  41248. hdrSkyboxMaterial.disableLighting = true;
  41249. hdrSkyboxMaterial.twoSidedLighting = true;
  41250. hdrSkybox.infiniteDistance = true;
  41251. hdrSkybox.material = hdrSkyboxMaterial;
  41252. }
  41253. else {
  41254. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  41255. skyboxMaterial.backFaceCulling = false;
  41256. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  41257. if (skyboxMaterial.reflectionTexture) {
  41258. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  41259. }
  41260. skyboxMaterial.disableLighting = true;
  41261. hdrSkybox.infiniteDistance = true;
  41262. hdrSkybox.material = skyboxMaterial;
  41263. }
  41264. hdrSkybox.isPickable = false;
  41265. return hdrSkybox;
  41266. };
  41267. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  41268. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  41269. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  41270. }
  41271. return null;
  41272. };
  41273. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  41274. if (webVROptions === void 0) { webVROptions = {}; }
  41275. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  41276. };
  41277. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  41278. var _this = this;
  41279. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  41280. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  41281. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  41282. .then(function (ui) {
  41283. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  41284. return helper;
  41285. });
  41286. });
  41287. };
  41288. /***/ }),
  41289. /***/ "./Helpers/videoDome.ts":
  41290. /*!******************************!*\
  41291. !*** ./Helpers/videoDome.ts ***!
  41292. \******************************/
  41293. /*! exports provided: VideoDome */
  41294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41295. "use strict";
  41296. __webpack_require__.r(__webpack_exports__);
  41297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  41298. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41299. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  41300. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  41301. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41302. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  41303. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  41304. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  41305. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41306. /**
  41307. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  41308. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  41309. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  41310. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  41311. */
  41312. var VideoDome = /** @class */ (function (_super) {
  41313. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  41314. /**
  41315. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  41316. * @param name Element's name, child elements will append suffixes for their own names.
  41317. * @param urlsOrVideo defines the url(s) or the video element to use
  41318. * @param options An object containing optional or exposed sub element properties
  41319. */
  41320. function VideoDome(name, urlsOrVideo, options, scene) {
  41321. var _this = _super.call(this, name, scene) || this;
  41322. _this._useDirectMapping = false;
  41323. _this._videoMode = VideoDome.MODE_MONOSCOPIC;
  41324. /**
  41325. * Oberserver used in Stereoscopic VR Mode.
  41326. */
  41327. _this._onBeforeCameraRenderObserver = null;
  41328. scene = _this.getScene();
  41329. // set defaults and manage values
  41330. name = name || "videoDome";
  41331. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  41332. options.clickToPlay = Boolean(options.clickToPlay);
  41333. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  41334. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  41335. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  41336. if (options.useDirectMapping === undefined) {
  41337. _this._useDirectMapping = true;
  41338. }
  41339. else {
  41340. _this._useDirectMapping = options.useDirectMapping;
  41341. }
  41342. if (options.faceForward === undefined) {
  41343. options.faceForward = true;
  41344. }
  41345. _this._setReady(false);
  41346. // create
  41347. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  41348. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  41349. 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);
  41350. _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);
  41351. texture.onLoadObservable.addOnce(function () {
  41352. _this._setReady(true);
  41353. });
  41354. // configure material
  41355. material.useEquirectangularFOV = true;
  41356. material.fovMultiplier = 1.0;
  41357. material.opacityFresnel = false;
  41358. if (_this._useDirectMapping) {
  41359. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41360. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41361. material.diffuseTexture = texture;
  41362. }
  41363. else {
  41364. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  41365. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41366. material.reflectionTexture = texture;
  41367. }
  41368. // configure mesh
  41369. _this._mesh.material = material;
  41370. _this._mesh.parent = _this;
  41371. // optional configuration
  41372. if (options.clickToPlay) {
  41373. scene.onPointerUp = function () {
  41374. _this._videoTexture.video.play();
  41375. };
  41376. }
  41377. // Initial rotation
  41378. if (options.faceForward && scene.activeCamera) {
  41379. var camera = scene.activeCamera;
  41380. var forward = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  41381. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  41382. direction.normalize();
  41383. _this.rotation.y = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  41384. }
  41385. return _this;
  41386. }
  41387. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  41388. /**
  41389. * Gets the video texture being displayed on the sphere
  41390. */
  41391. get: function () {
  41392. return this._videoTexture;
  41393. },
  41394. enumerable: true,
  41395. configurable: true
  41396. });
  41397. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  41398. /**
  41399. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41400. * Also see the options.resolution property.
  41401. */
  41402. get: function () {
  41403. return this._material.fovMultiplier;
  41404. },
  41405. set: function (value) {
  41406. this._material.fovMultiplier = value;
  41407. },
  41408. enumerable: true,
  41409. configurable: true
  41410. });
  41411. Object.defineProperty(VideoDome.prototype, "videoMode", {
  41412. /**
  41413. * Gets or set the current video mode for the video. It can be:
  41414. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  41415. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  41416. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  41417. */
  41418. get: function () {
  41419. return this._videoMode;
  41420. },
  41421. set: function (value) {
  41422. if (this._videoMode === value) {
  41423. return;
  41424. }
  41425. this._changeVideoMode(value);
  41426. },
  41427. enumerable: true,
  41428. configurable: true
  41429. });
  41430. VideoDome.prototype._changeVideoMode = function (value) {
  41431. var _this = this;
  41432. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41433. this._videoMode = value;
  41434. // Default Setup and Reset.
  41435. this._videoTexture.uScale = 1;
  41436. this._videoTexture.vScale = 1;
  41437. this._videoTexture.uOffset = 0;
  41438. this._videoTexture.vOffset = 0;
  41439. switch (value) {
  41440. case VideoDome.MODE_SIDEBYSIDE:
  41441. this._videoTexture.uScale = 0.5;
  41442. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  41443. _this._videoTexture.uOffset = camera.isRightCamera ? 0.5 : 0.0;
  41444. });
  41445. break;
  41446. case VideoDome.MODE_TOPBOTTOM:
  41447. this._videoTexture.vScale = 0.5;
  41448. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  41449. _this._videoTexture.vOffset = camera.isRightCamera ? 0.5 : 0.0;
  41450. });
  41451. break;
  41452. }
  41453. };
  41454. /**
  41455. * Releases resources associated with this node.
  41456. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  41457. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  41458. */
  41459. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  41460. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  41461. this._videoTexture.dispose();
  41462. this._mesh.dispose();
  41463. this._material.dispose();
  41464. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41465. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  41466. };
  41467. /**
  41468. * Define the video source as a Monoscopic panoramic 360 video.
  41469. */
  41470. VideoDome.MODE_MONOSCOPIC = 0;
  41471. /**
  41472. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  41473. */
  41474. VideoDome.MODE_TOPBOTTOM = 1;
  41475. /**
  41476. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  41477. */
  41478. VideoDome.MODE_SIDEBYSIDE = 2;
  41479. return VideoDome;
  41480. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  41481. /***/ }),
  41482. /***/ "./Inputs/scene.inputManager.ts":
  41483. /*!**************************************!*\
  41484. !*** ./Inputs/scene.inputManager.ts ***!
  41485. \**************************************/
  41486. /*! exports provided: InputManager */
  41487. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41488. "use strict";
  41489. __webpack_require__.r(__webpack_exports__);
  41490. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputManager", function() { return InputManager; });
  41491. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  41492. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  41493. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41494. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41495. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  41496. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41497. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  41498. /** @hidden */
  41499. var _ClickInfo = /** @class */ (function () {
  41500. function _ClickInfo() {
  41501. this._singleClick = false;
  41502. this._doubleClick = false;
  41503. this._hasSwiped = false;
  41504. this._ignore = false;
  41505. }
  41506. Object.defineProperty(_ClickInfo.prototype, "singleClick", {
  41507. get: function () {
  41508. return this._singleClick;
  41509. },
  41510. set: function (b) {
  41511. this._singleClick = b;
  41512. },
  41513. enumerable: true,
  41514. configurable: true
  41515. });
  41516. Object.defineProperty(_ClickInfo.prototype, "doubleClick", {
  41517. get: function () {
  41518. return this._doubleClick;
  41519. },
  41520. set: function (b) {
  41521. this._doubleClick = b;
  41522. },
  41523. enumerable: true,
  41524. configurable: true
  41525. });
  41526. Object.defineProperty(_ClickInfo.prototype, "hasSwiped", {
  41527. get: function () {
  41528. return this._hasSwiped;
  41529. },
  41530. set: function (b) {
  41531. this._hasSwiped = b;
  41532. },
  41533. enumerable: true,
  41534. configurable: true
  41535. });
  41536. Object.defineProperty(_ClickInfo.prototype, "ignore", {
  41537. get: function () {
  41538. return this._ignore;
  41539. },
  41540. set: function (b) {
  41541. this._ignore = b;
  41542. },
  41543. enumerable: true,
  41544. configurable: true
  41545. });
  41546. return _ClickInfo;
  41547. }());
  41548. /**
  41549. * Class used to manage all inputs for the scene.
  41550. */
  41551. var InputManager = /** @class */ (function () {
  41552. /**
  41553. * Creates a new InputManager
  41554. * @param scene defines the hosting scene
  41555. */
  41556. function InputManager(scene) {
  41557. // Pointers
  41558. this._wheelEventName = "";
  41559. this._meshPickProceed = false;
  41560. this._currentPickResult = null;
  41561. this._previousPickResult = null;
  41562. this._totalPointersPressed = 0;
  41563. this._doubleClickOccured = false;
  41564. this._pointerX = 0;
  41565. this._pointerY = 0;
  41566. this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  41567. this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  41568. this._startingPointerTime = 0;
  41569. this._previousStartingPointerTime = 0;
  41570. this._pointerCaptures = {};
  41571. this._scene = scene;
  41572. }
  41573. Object.defineProperty(InputManager.prototype, "meshUnderPointer", {
  41574. /**
  41575. * Gets the mesh that is currently under the pointer
  41576. */
  41577. get: function () {
  41578. return this._pointerOverMesh;
  41579. },
  41580. enumerable: true,
  41581. configurable: true
  41582. });
  41583. Object.defineProperty(InputManager.prototype, "unTranslatedPointer", {
  41584. /**
  41585. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  41586. */
  41587. get: function () {
  41588. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  41589. },
  41590. enumerable: true,
  41591. configurable: true
  41592. });
  41593. Object.defineProperty(InputManager.prototype, "pointerX", {
  41594. /**
  41595. * Gets or sets the current on-screen X position of the pointer
  41596. */
  41597. get: function () {
  41598. return this._pointerX;
  41599. },
  41600. set: function (value) {
  41601. this._pointerX = value;
  41602. },
  41603. enumerable: true,
  41604. configurable: true
  41605. });
  41606. Object.defineProperty(InputManager.prototype, "pointerY", {
  41607. /**
  41608. * Gets or sets the current on-screen Y position of the pointer
  41609. */
  41610. get: function () {
  41611. return this._pointerY;
  41612. },
  41613. set: function (value) {
  41614. this._pointerY = value;
  41615. },
  41616. enumerable: true,
  41617. configurable: true
  41618. });
  41619. InputManager.prototype._updatePointerPosition = function (evt) {
  41620. var canvasRect = this._scene.getEngine().getRenderingCanvasClientRect();
  41621. if (!canvasRect) {
  41622. return;
  41623. }
  41624. this._pointerX = evt.clientX - canvasRect.left;
  41625. this._pointerY = evt.clientY - canvasRect.top;
  41626. this._unTranslatedPointerX = this._pointerX;
  41627. this._unTranslatedPointerY = this._pointerY;
  41628. };
  41629. InputManager.prototype._processPointerMove = function (pickResult, evt) {
  41630. var scene = this._scene;
  41631. var canvas = scene.getEngine().getRenderingCanvas();
  41632. if (!canvas) {
  41633. return;
  41634. }
  41635. canvas.tabIndex = 1;
  41636. // Restore pointer
  41637. canvas.style.cursor = scene.defaultCursor;
  41638. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  41639. if (isMeshPicked) {
  41640. scene.setPointerOverMesh(pickResult.pickedMesh);
  41641. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  41642. if (this._pointerOverMesh.actionManager.hoverCursor) {
  41643. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  41644. }
  41645. else {
  41646. canvas.style.cursor = scene.hoverCursor;
  41647. }
  41648. }
  41649. }
  41650. else {
  41651. scene.setPointerOverMesh(null);
  41652. }
  41653. for (var _i = 0, _a = scene._pointerMoveStage; _i < _a.length; _i++) {
  41654. var step = _a[_i];
  41655. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  41656. }
  41657. if (pickResult) {
  41658. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE;
  41659. if (scene.onPointerMove) {
  41660. scene.onPointerMove(evt, pickResult, type);
  41661. }
  41662. if (scene.onPointerObservable.hasObservers()) {
  41663. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"](type, evt, pickResult);
  41664. this._setRayOnPointerInfo(pi);
  41665. scene.onPointerObservable.notifyObservers(pi, type);
  41666. }
  41667. }
  41668. };
  41669. // Pointers handling
  41670. InputManager.prototype._setRayOnPointerInfo = function (pointerInfo) {
  41671. var scene = this._scene;
  41672. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  41673. if (!pointerInfo.pickInfo.ray) {
  41674. pointerInfo.pickInfo.ray = scene.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity(), scene.activeCamera);
  41675. }
  41676. }
  41677. };
  41678. InputManager.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  41679. var scene = this._scene;
  41680. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  41681. if (pickResult) {
  41682. pi.ray = pickResult.ray;
  41683. }
  41684. scene.onPrePointerObservable.notifyObservers(pi, type);
  41685. if (pi.skipOnPointerObservable) {
  41686. return true;
  41687. }
  41688. else {
  41689. return false;
  41690. }
  41691. };
  41692. /**
  41693. * Use this method to simulate a pointer move on a mesh
  41694. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41695. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41696. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41697. */
  41698. InputManager.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  41699. var evt = new PointerEvent("pointermove", pointerEventInit);
  41700. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE)) {
  41701. return;
  41702. }
  41703. this._processPointerMove(pickResult, evt);
  41704. };
  41705. /**
  41706. * Use this method to simulate a pointer down on a mesh
  41707. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41708. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41709. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41710. */
  41711. InputManager.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  41712. var evt = new PointerEvent("pointerdown", pointerEventInit);
  41713. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN)) {
  41714. return;
  41715. }
  41716. this._processPointerDown(pickResult, evt);
  41717. };
  41718. InputManager.prototype._processPointerDown = function (pickResult, evt) {
  41719. var _this = this;
  41720. var scene = this._scene;
  41721. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  41722. this._pickedDownMesh = pickResult.pickedMesh;
  41723. var actionManager = pickResult.pickedMesh.actionManager;
  41724. if (actionManager) {
  41725. if (actionManager.hasPickTriggers) {
  41726. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  41727. switch (evt.button) {
  41728. case 0:
  41729. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  41730. break;
  41731. case 1:
  41732. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  41733. break;
  41734. case 2:
  41735. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  41736. break;
  41737. }
  41738. }
  41739. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnLongPressTrigger)) {
  41740. window.setTimeout(function () {
  41741. var pickResult = scene.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnLongPressTrigger) && mesh == _this._pickedDownMesh); }, false, scene.cameraToUseForPointers);
  41742. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  41743. if (_this._totalPointersPressed !== 0 &&
  41744. ((Date.now() - _this._startingPointerTime) > InputManager.LongPressDelay) &&
  41745. !_this._isPointerSwiping()) {
  41746. _this._startingPointerTime = 0;
  41747. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  41748. }
  41749. }
  41750. }, InputManager.LongPressDelay);
  41751. }
  41752. }
  41753. }
  41754. else {
  41755. for (var _i = 0, _a = scene._pointerDownStage; _i < _a.length; _i++) {
  41756. var step = _a[_i];
  41757. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  41758. }
  41759. }
  41760. if (pickResult) {
  41761. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN;
  41762. if (scene.onPointerDown) {
  41763. scene.onPointerDown(evt, pickResult, type);
  41764. }
  41765. if (scene.onPointerObservable.hasObservers()) {
  41766. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"](type, evt, pickResult);
  41767. this._setRayOnPointerInfo(pi);
  41768. scene.onPointerObservable.notifyObservers(pi, type);
  41769. }
  41770. }
  41771. };
  41772. /** @hidden */
  41773. InputManager.prototype._isPointerSwiping = function () {
  41774. return Math.abs(this._startingPointerPosition.x - this._pointerX) > InputManager.DragMovementThreshold ||
  41775. Math.abs(this._startingPointerPosition.y - this._pointerY) > InputManager.DragMovementThreshold;
  41776. };
  41777. /**
  41778. * Use this method to simulate a pointer up on a mesh
  41779. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41780. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41781. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41782. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41783. */
  41784. InputManager.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  41785. var evt = new PointerEvent("pointerup", pointerEventInit);
  41786. var clickInfo = new _ClickInfo();
  41787. if (doubleTap) {
  41788. clickInfo.doubleClick = true;
  41789. }
  41790. else {
  41791. clickInfo.singleClick = true;
  41792. }
  41793. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP)) {
  41794. return;
  41795. }
  41796. this._processPointerUp(pickResult, evt, clickInfo);
  41797. };
  41798. InputManager.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  41799. var scene = this._scene;
  41800. if (pickResult && pickResult && pickResult.pickedMesh) {
  41801. this._pickedUpMesh = pickResult.pickedMesh;
  41802. if (this._pickedDownMesh === this._pickedUpMesh) {
  41803. if (scene.onPointerPick) {
  41804. scene.onPointerPick(evt, pickResult);
  41805. }
  41806. if (clickInfo.singleClick && !clickInfo.ignore && scene.onPointerObservable.hasObservers()) {
  41807. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERPICK;
  41808. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"](type_1, evt, pickResult);
  41809. this._setRayOnPointerInfo(pi);
  41810. scene.onPointerObservable.notifyObservers(pi, type_1);
  41811. }
  41812. }
  41813. var actionManager = pickResult.pickedMesh._getActionManagerForTrigger();
  41814. if (actionManager && !clickInfo.ignore) {
  41815. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  41816. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  41817. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  41818. }
  41819. var doubleClickActionManager = pickResult.pickedMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnDoublePickTrigger);
  41820. if (clickInfo.doubleClick && doubleClickActionManager) {
  41821. doubleClickActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  41822. }
  41823. }
  41824. }
  41825. else {
  41826. if (!clickInfo.ignore) {
  41827. for (var _i = 0, _a = scene._pointerUpStage; _i < _a.length; _i++) {
  41828. var step = _a[_i];
  41829. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  41830. }
  41831. }
  41832. }
  41833. if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
  41834. var pickedDownActionManager = this._pickedDownMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPickOutTrigger);
  41835. if (pickedDownActionManager) {
  41836. pickedDownActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  41837. }
  41838. }
  41839. var type = 0;
  41840. if (scene.onPointerObservable.hasObservers()) {
  41841. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  41842. if (clickInfo.singleClick && scene.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERTAP)) {
  41843. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERTAP;
  41844. }
  41845. else if (clickInfo.doubleClick && scene.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP)) {
  41846. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP;
  41847. }
  41848. if (type) {
  41849. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"](type, evt, pickResult);
  41850. this._setRayOnPointerInfo(pi);
  41851. scene.onPointerObservable.notifyObservers(pi, type);
  41852. }
  41853. }
  41854. if (!clickInfo.ignore) {
  41855. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP;
  41856. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"](type, evt, pickResult);
  41857. this._setRayOnPointerInfo(pi);
  41858. scene.onPointerObservable.notifyObservers(pi, type);
  41859. }
  41860. }
  41861. if (scene.onPointerUp && !clickInfo.ignore) {
  41862. scene.onPointerUp(evt, pickResult, type);
  41863. }
  41864. };
  41865. /**
  41866. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41867. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41868. * @returns true if the pointer was captured
  41869. */
  41870. InputManager.prototype.isPointerCaptured = function (pointerId) {
  41871. if (pointerId === void 0) { pointerId = 0; }
  41872. return this._pointerCaptures[pointerId];
  41873. };
  41874. /**
  41875. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41876. * @param attachUp defines if you want to attach events to pointerup
  41877. * @param attachDown defines if you want to attach events to pointerdown
  41878. * @param attachMove defines if you want to attach events to pointermove
  41879. */
  41880. InputManager.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  41881. var _this = this;
  41882. if (attachUp === void 0) { attachUp = true; }
  41883. if (attachDown === void 0) { attachDown = true; }
  41884. if (attachMove === void 0) { attachMove = true; }
  41885. var scene = this._scene;
  41886. var canvas = scene.getEngine().getRenderingCanvas();
  41887. if (!canvas) {
  41888. return;
  41889. }
  41890. var engine = scene.getEngine();
  41891. this._initActionManager = function (act, clickInfo) {
  41892. if (!_this._meshPickProceed) {
  41893. var pickResult = scene.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, scene.pointerDownPredicate, false, scene.cameraToUseForPointers);
  41894. _this._currentPickResult = pickResult;
  41895. if (pickResult) {
  41896. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh._getActionManagerForTrigger() : null;
  41897. }
  41898. _this._meshPickProceed = true;
  41899. }
  41900. return act;
  41901. };
  41902. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  41903. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  41904. if ((Date.now() - _this._previousStartingPointerTime > InputManager.DoubleClickDelay && !_this._doubleClickOccured) ||
  41905. btn !== _this._previousButtonPressed) {
  41906. _this._doubleClickOccured = false;
  41907. clickInfo.singleClick = true;
  41908. clickInfo.ignore = false;
  41909. cb(clickInfo, _this._currentPickResult);
  41910. }
  41911. };
  41912. this._initClickEvent = function (obs1, obs2, evt, cb) {
  41913. var clickInfo = new _ClickInfo();
  41914. _this._currentPickResult = null;
  41915. var act = null;
  41916. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERPICK)
  41917. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERTAP)
  41918. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP);
  41919. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_1__["AbstractActionManager"]) {
  41920. act = _this._initActionManager(act, clickInfo);
  41921. if (act) {
  41922. checkPicking = act.hasPickTriggers;
  41923. }
  41924. }
  41925. var needToIgnoreNext = false;
  41926. if (checkPicking) {
  41927. var btn = evt.button;
  41928. clickInfo.hasSwiped = _this._isPointerSwiping();
  41929. if (!clickInfo.hasSwiped) {
  41930. var checkSingleClickImmediately = !InputManager.ExclusiveDoubleClickMode;
  41931. if (!checkSingleClickImmediately) {
  41932. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) &&
  41933. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP);
  41934. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_1__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnDoublePickTrigger)) {
  41935. act = _this._initActionManager(act, clickInfo);
  41936. if (act) {
  41937. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnDoublePickTrigger);
  41938. }
  41939. }
  41940. }
  41941. if (checkSingleClickImmediately) {
  41942. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  41943. if (Date.now() - _this._previousStartingPointerTime > InputManager.DoubleClickDelay ||
  41944. btn !== _this._previousButtonPressed) {
  41945. clickInfo.singleClick = true;
  41946. cb(clickInfo, _this._currentPickResult);
  41947. needToIgnoreNext = true;
  41948. }
  41949. }
  41950. // at least one double click is required to be check and exclusive double click is enabled
  41951. else {
  41952. // wait that no double click has been raised during the double click delay
  41953. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  41954. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), InputManager.DoubleClickDelay);
  41955. }
  41956. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) ||
  41957. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP);
  41958. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_1__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnDoublePickTrigger)) {
  41959. act = _this._initActionManager(act, clickInfo);
  41960. if (act) {
  41961. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnDoublePickTrigger);
  41962. }
  41963. }
  41964. if (checkDoubleClick) {
  41965. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  41966. if (btn === _this._previousButtonPressed &&
  41967. Date.now() - _this._previousStartingPointerTime < InputManager.DoubleClickDelay &&
  41968. !_this._doubleClickOccured) {
  41969. // pointer has not moved for 2 clicks, it's a double click
  41970. if (!clickInfo.hasSwiped &&
  41971. !_this._isPointerSwiping()) {
  41972. _this._previousStartingPointerTime = 0;
  41973. _this._doubleClickOccured = true;
  41974. clickInfo.doubleClick = true;
  41975. clickInfo.ignore = false;
  41976. if (InputManager.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  41977. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  41978. }
  41979. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  41980. cb(clickInfo, _this._currentPickResult);
  41981. }
  41982. // if the two successive clicks are too far, it's just two simple clicks
  41983. else {
  41984. _this._doubleClickOccured = false;
  41985. _this._previousStartingPointerTime = _this._startingPointerTime;
  41986. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  41987. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  41988. _this._previousButtonPressed = btn;
  41989. if (InputManager.ExclusiveDoubleClickMode) {
  41990. if (_this._previousDelayedSimpleClickTimeout) {
  41991. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  41992. }
  41993. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  41994. cb(clickInfo, _this._previousPickResult);
  41995. }
  41996. else {
  41997. cb(clickInfo, _this._currentPickResult);
  41998. }
  41999. }
  42000. needToIgnoreNext = true;
  42001. }
  42002. // just the first click of the double has been raised
  42003. else {
  42004. _this._doubleClickOccured = false;
  42005. _this._previousStartingPointerTime = _this._startingPointerTime;
  42006. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  42007. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  42008. _this._previousButtonPressed = btn;
  42009. }
  42010. }
  42011. }
  42012. }
  42013. if (!needToIgnoreNext) {
  42014. cb(clickInfo, _this._currentPickResult);
  42015. }
  42016. };
  42017. this._onPointerMove = function (evt) {
  42018. _this._updatePointerPosition(evt);
  42019. // PreObservable support
  42020. if (_this._checkPrePointerObservable(null, evt, evt.type === _this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE)) {
  42021. return;
  42022. }
  42023. if (!scene.cameraToUseForPointers && !scene.activeCamera) {
  42024. return;
  42025. }
  42026. if (!scene.pointerMovePredicate) {
  42027. scene.pointerMovePredicate = function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || scene.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)) && (!scene.cameraToUseForPointers || (scene.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0)); };
  42028. }
  42029. // Meshes
  42030. var pickResult = scene.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, scene.pointerMovePredicate, false, scene.cameraToUseForPointers);
  42031. _this._processPointerMove(pickResult, evt);
  42032. };
  42033. this._onPointerDown = function (evt) {
  42034. _this._totalPointersPressed++;
  42035. _this._pickedDownMesh = null;
  42036. _this._meshPickProceed = false;
  42037. _this._updatePointerPosition(evt);
  42038. if (scene.preventDefaultOnPointerDown && canvas) {
  42039. evt.preventDefault();
  42040. canvas.focus();
  42041. }
  42042. _this._startingPointerPosition.x = _this._pointerX;
  42043. _this._startingPointerPosition.y = _this._pointerY;
  42044. _this._startingPointerTime = Date.now();
  42045. // PreObservable support
  42046. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN)) {
  42047. return;
  42048. }
  42049. if (!scene.cameraToUseForPointers && !scene.activeCamera) {
  42050. return;
  42051. }
  42052. _this._pointerCaptures[evt.pointerId] = true;
  42053. if (!scene.pointerDownPredicate) {
  42054. scene.pointerDownPredicate = function (mesh) {
  42055. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!scene.cameraToUseForPointers || (scene.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  42056. };
  42057. }
  42058. // Meshes
  42059. _this._pickedDownMesh = null;
  42060. var pickResult = scene.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, scene.pointerDownPredicate, false, scene.cameraToUseForPointers);
  42061. _this._processPointerDown(pickResult, evt);
  42062. };
  42063. this._onPointerUp = function (evt) {
  42064. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  42065. return; // So we need to test it the pointer down was pressed before.
  42066. }
  42067. _this._totalPointersPressed--;
  42068. _this._pickedUpMesh = null;
  42069. _this._meshPickProceed = false;
  42070. _this._updatePointerPosition(evt);
  42071. if (scene.preventDefaultOnPointerUp && canvas) {
  42072. evt.preventDefault();
  42073. canvas.focus();
  42074. }
  42075. _this._initClickEvent(scene.onPrePointerObservable, scene.onPointerObservable, evt, function (clickInfo, pickResult) {
  42076. // PreObservable support
  42077. if (scene.onPrePointerObservable.hasObservers()) {
  42078. if (!clickInfo.ignore) {
  42079. if (!clickInfo.hasSwiped) {
  42080. if (clickInfo.singleClick && scene.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERTAP)) {
  42081. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERTAP)) {
  42082. return;
  42083. }
  42084. }
  42085. if (clickInfo.doubleClick && scene.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP)) {
  42086. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP)) {
  42087. return;
  42088. }
  42089. }
  42090. }
  42091. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP)) {
  42092. return;
  42093. }
  42094. }
  42095. }
  42096. if (!_this._pointerCaptures[evt.pointerId]) {
  42097. return;
  42098. }
  42099. _this._pointerCaptures[evt.pointerId] = false;
  42100. if (!scene.cameraToUseForPointers && !scene.activeCamera) {
  42101. return;
  42102. }
  42103. if (!scene.pointerUpPredicate) {
  42104. scene.pointerUpPredicate = function (mesh) {
  42105. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!scene.cameraToUseForPointers || (scene.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  42106. };
  42107. }
  42108. // Meshes
  42109. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_1__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_1__["AbstractActionManager"].HasTriggers || scene.onPointerObservable.hasObservers())) {
  42110. _this._initActionManager(null, clickInfo);
  42111. }
  42112. if (!pickResult) {
  42113. pickResult = _this._currentPickResult;
  42114. }
  42115. _this._processPointerUp(pickResult, evt, clickInfo);
  42116. _this._previousPickResult = _this._currentPickResult;
  42117. });
  42118. };
  42119. this._onKeyDown = function (evt) {
  42120. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_6__["KeyboardEventTypes"].KEYDOWN;
  42121. if (scene.onPreKeyboardObservable.hasObservers()) {
  42122. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_6__["KeyboardInfoPre"](type, evt);
  42123. scene.onPreKeyboardObservable.notifyObservers(pi, type);
  42124. if (pi.skipOnPointerObservable) {
  42125. return;
  42126. }
  42127. }
  42128. if (scene.onKeyboardObservable.hasObservers()) {
  42129. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_6__["KeyboardInfo"](type, evt);
  42130. scene.onKeyboardObservable.notifyObservers(pi, type);
  42131. }
  42132. if (scene.actionManager) {
  42133. scene.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNewFromScene(scene, evt));
  42134. }
  42135. };
  42136. this._onKeyUp = function (evt) {
  42137. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_6__["KeyboardEventTypes"].KEYUP;
  42138. if (scene.onPreKeyboardObservable.hasObservers()) {
  42139. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_6__["KeyboardInfoPre"](type, evt);
  42140. scene.onPreKeyboardObservable.notifyObservers(pi, type);
  42141. if (pi.skipOnPointerObservable) {
  42142. return;
  42143. }
  42144. }
  42145. if (scene.onKeyboardObservable.hasObservers()) {
  42146. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_6__["KeyboardInfo"](type, evt);
  42147. scene.onKeyboardObservable.notifyObservers(pi, type);
  42148. }
  42149. if (scene.actionManager) {
  42150. scene.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNewFromScene(scene, evt));
  42151. }
  42152. };
  42153. // Keyboard events
  42154. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  42155. if (!canvas) {
  42156. return;
  42157. }
  42158. canvas.addEventListener("keydown", _this._onKeyDown, false);
  42159. canvas.addEventListener("keyup", _this._onKeyUp, false);
  42160. });
  42161. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  42162. if (!canvas) {
  42163. return;
  42164. }
  42165. canvas.removeEventListener("keydown", _this._onKeyDown);
  42166. canvas.removeEventListener("keyup", _this._onKeyUp);
  42167. });
  42168. // Pointer events
  42169. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetPointerPrefix();
  42170. if (attachMove) {
  42171. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  42172. // Wheel
  42173. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  42174. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  42175. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  42176. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  42177. }
  42178. if (attachDown) {
  42179. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  42180. }
  42181. if (attachUp) {
  42182. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  42183. }
  42184. };
  42185. /**
  42186. * Detaches all event handlers
  42187. */
  42188. InputManager.prototype.detachControl = function () {
  42189. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetPointerPrefix();
  42190. var canvas = this._scene.getEngine().getRenderingCanvas();
  42191. var engine = this._scene.getEngine();
  42192. if (!canvas) {
  42193. return;
  42194. }
  42195. // Pointer
  42196. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  42197. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  42198. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  42199. // Blur / Focus
  42200. if (this._onCanvasBlurObserver) {
  42201. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  42202. }
  42203. if (this._onCanvasFocusObserver) {
  42204. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  42205. }
  42206. // Keyboard
  42207. canvas.removeEventListener("keydown", this._onKeyDown);
  42208. canvas.removeEventListener("keyup", this._onKeyUp);
  42209. // Cursor
  42210. canvas.style.cursor = this._scene.defaultCursor;
  42211. };
  42212. /**
  42213. * Force the value of meshUnderPointer
  42214. * @param mesh defines the mesh to use
  42215. */
  42216. InputManager.prototype.setPointerOverMesh = function (mesh) {
  42217. if (this._pointerOverMesh === mesh) {
  42218. return;
  42219. }
  42220. var actionManager;
  42221. if (this._pointerOverMesh) {
  42222. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPointerOutTrigger);
  42223. if (actionManager) {
  42224. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(this._pointerOverMesh));
  42225. }
  42226. }
  42227. this._pointerOverMesh = mesh;
  42228. if (this._pointerOverMesh) {
  42229. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPointerOverTrigger);
  42230. if (actionManager) {
  42231. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_4__["ActionEvent"].CreateNew(this._pointerOverMesh));
  42232. }
  42233. }
  42234. };
  42235. /**
  42236. * Gets the mesh under the pointer
  42237. * @returns a Mesh or null if no mesh is under the pointer
  42238. */
  42239. InputManager.prototype.getPointerOverMesh = function () {
  42240. return this._pointerOverMesh;
  42241. };
  42242. /** The distance in pixel that you have to move to prevent some events */
  42243. InputManager.DragMovementThreshold = 10; // in pixels
  42244. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42245. InputManager.LongPressDelay = 500; // in milliseconds
  42246. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42247. InputManager.DoubleClickDelay = 300; // in milliseconds
  42248. /** If you need to check double click without raising a single click at first click, enable this flag */
  42249. InputManager.ExclusiveDoubleClickMode = false;
  42250. return InputManager;
  42251. }());
  42252. /***/ }),
  42253. /***/ "./Instrumentation/engineInstrumentation.ts":
  42254. /*!**************************************************!*\
  42255. !*** ./Instrumentation/engineInstrumentation.ts ***!
  42256. \**************************************************/
  42257. /*! exports provided: EngineInstrumentation */
  42258. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42259. "use strict";
  42260. __webpack_require__.r(__webpack_exports__);
  42261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  42262. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42263. /**
  42264. * This class can be used to get instrumentation data from a Babylon engine
  42265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42266. */
  42267. var EngineInstrumentation = /** @class */ (function () {
  42268. /**
  42269. * Instantiates a new engine instrumentation.
  42270. * This class can be used to get instrumentation data from a Babylon engine
  42271. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42272. * @param engine Defines the engine to instrument
  42273. */
  42274. function EngineInstrumentation(
  42275. /**
  42276. * Define the instrumented engine.
  42277. */
  42278. engine) {
  42279. this.engine = engine;
  42280. this._captureGPUFrameTime = false;
  42281. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  42282. this._captureShaderCompilationTime = false;
  42283. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  42284. // Observers
  42285. this._onBeginFrameObserver = null;
  42286. this._onEndFrameObserver = null;
  42287. this._onBeforeShaderCompilationObserver = null;
  42288. this._onAfterShaderCompilationObserver = null;
  42289. }
  42290. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  42291. // Properties
  42292. /**
  42293. * Gets the perf counter used for GPU frame time
  42294. */
  42295. get: function () {
  42296. return this._gpuFrameTime;
  42297. },
  42298. enumerable: true,
  42299. configurable: true
  42300. });
  42301. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  42302. /**
  42303. * Gets the GPU frame time capture status
  42304. */
  42305. get: function () {
  42306. return this._captureGPUFrameTime;
  42307. },
  42308. /**
  42309. * Enable or disable the GPU frame time capture
  42310. */
  42311. set: function (value) {
  42312. var _this = this;
  42313. if (value === this._captureGPUFrameTime) {
  42314. return;
  42315. }
  42316. this._captureGPUFrameTime = value;
  42317. if (value) {
  42318. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  42319. if (!_this._gpuFrameTimeToken) {
  42320. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  42321. }
  42322. });
  42323. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  42324. if (!_this._gpuFrameTimeToken) {
  42325. return;
  42326. }
  42327. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  42328. if (time > -1) {
  42329. _this._gpuFrameTimeToken = null;
  42330. _this._gpuFrameTime.fetchNewFrame();
  42331. _this._gpuFrameTime.addCount(time, true);
  42332. }
  42333. });
  42334. }
  42335. else {
  42336. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  42337. this._onBeginFrameObserver = null;
  42338. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  42339. this._onEndFrameObserver = null;
  42340. }
  42341. },
  42342. enumerable: true,
  42343. configurable: true
  42344. });
  42345. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  42346. /**
  42347. * Gets the perf counter used for shader compilation time
  42348. */
  42349. get: function () {
  42350. return this._shaderCompilationTime;
  42351. },
  42352. enumerable: true,
  42353. configurable: true
  42354. });
  42355. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  42356. /**
  42357. * Gets the shader compilation time capture status
  42358. */
  42359. get: function () {
  42360. return this._captureShaderCompilationTime;
  42361. },
  42362. /**
  42363. * Enable or disable the shader compilation time capture
  42364. */
  42365. set: function (value) {
  42366. var _this = this;
  42367. if (value === this._captureShaderCompilationTime) {
  42368. return;
  42369. }
  42370. this._captureShaderCompilationTime = value;
  42371. if (value) {
  42372. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  42373. _this._shaderCompilationTime.fetchNewFrame();
  42374. _this._shaderCompilationTime.beginMonitoring();
  42375. });
  42376. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  42377. _this._shaderCompilationTime.endMonitoring();
  42378. });
  42379. }
  42380. else {
  42381. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  42382. this._onBeforeShaderCompilationObserver = null;
  42383. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  42384. this._onAfterShaderCompilationObserver = null;
  42385. }
  42386. },
  42387. enumerable: true,
  42388. configurable: true
  42389. });
  42390. /**
  42391. * Dispose and release associated resources.
  42392. */
  42393. EngineInstrumentation.prototype.dispose = function () {
  42394. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  42395. this._onBeginFrameObserver = null;
  42396. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  42397. this._onEndFrameObserver = null;
  42398. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  42399. this._onBeforeShaderCompilationObserver = null;
  42400. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  42401. this._onAfterShaderCompilationObserver = null;
  42402. this.engine = null;
  42403. };
  42404. return EngineInstrumentation;
  42405. }());
  42406. /***/ }),
  42407. /***/ "./Instrumentation/index.ts":
  42408. /*!**********************************!*\
  42409. !*** ./Instrumentation/index.ts ***!
  42410. \**********************************/
  42411. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  42412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42413. "use strict";
  42414. __webpack_require__.r(__webpack_exports__);
  42415. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  42416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  42417. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  42418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  42419. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  42420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  42421. /***/ }),
  42422. /***/ "./Instrumentation/sceneInstrumentation.ts":
  42423. /*!*************************************************!*\
  42424. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  42425. \*************************************************/
  42426. /*! exports provided: SceneInstrumentation */
  42427. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42428. "use strict";
  42429. __webpack_require__.r(__webpack_exports__);
  42430. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  42431. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42432. /**
  42433. * This class can be used to get instrumentation data from a Babylon engine
  42434. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  42435. */
  42436. var SceneInstrumentation = /** @class */ (function () {
  42437. /**
  42438. * Instantiates a new scene instrumentation.
  42439. * This class can be used to get instrumentation data from a Babylon engine
  42440. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  42441. * @param scene Defines the scene to instrument
  42442. */
  42443. function SceneInstrumentation(
  42444. /**
  42445. * Defines the scene to instrument
  42446. */
  42447. scene) {
  42448. var _this = this;
  42449. this.scene = scene;
  42450. this._captureActiveMeshesEvaluationTime = false;
  42451. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  42452. this._captureRenderTargetsRenderTime = false;
  42453. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  42454. this._captureFrameTime = false;
  42455. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  42456. this._captureRenderTime = false;
  42457. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  42458. this._captureInterFrameTime = false;
  42459. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  42460. this._captureParticlesRenderTime = false;
  42461. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  42462. this._captureSpritesRenderTime = false;
  42463. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  42464. this._capturePhysicsTime = false;
  42465. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  42466. this._captureAnimationsTime = false;
  42467. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  42468. this._captureCameraRenderTime = false;
  42469. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  42470. // Observers
  42471. this._onBeforeActiveMeshesEvaluationObserver = null;
  42472. this._onAfterActiveMeshesEvaluationObserver = null;
  42473. this._onBeforeRenderTargetsRenderObserver = null;
  42474. this._onAfterRenderTargetsRenderObserver = null;
  42475. this._onAfterRenderObserver = null;
  42476. this._onBeforeDrawPhaseObserver = null;
  42477. this._onAfterDrawPhaseObserver = null;
  42478. this._onBeforeAnimationsObserver = null;
  42479. this._onBeforeParticlesRenderingObserver = null;
  42480. this._onAfterParticlesRenderingObserver = null;
  42481. this._onBeforeSpritesRenderingObserver = null;
  42482. this._onAfterSpritesRenderingObserver = null;
  42483. this._onBeforePhysicsObserver = null;
  42484. this._onAfterPhysicsObserver = null;
  42485. this._onAfterAnimationsObserver = null;
  42486. this._onBeforeCameraRenderObserver = null;
  42487. this._onAfterCameraRenderObserver = null;
  42488. // Before render
  42489. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  42490. if (_this._captureActiveMeshesEvaluationTime) {
  42491. _this._activeMeshesEvaluationTime.fetchNewFrame();
  42492. }
  42493. if (_this._captureRenderTargetsRenderTime) {
  42494. _this._renderTargetsRenderTime.fetchNewFrame();
  42495. }
  42496. if (_this._captureFrameTime) {
  42497. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  42498. _this._frameTime.beginMonitoring();
  42499. }
  42500. if (_this._captureInterFrameTime) {
  42501. _this._interFrameTime.endMonitoring();
  42502. }
  42503. if (_this._captureParticlesRenderTime) {
  42504. _this._particlesRenderTime.fetchNewFrame();
  42505. }
  42506. if (_this._captureSpritesRenderTime) {
  42507. _this._spritesRenderTime.fetchNewFrame();
  42508. }
  42509. if (_this._captureAnimationsTime) {
  42510. _this._animationsTime.beginMonitoring();
  42511. }
  42512. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  42513. });
  42514. // After render
  42515. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  42516. if (_this._captureFrameTime) {
  42517. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  42518. _this._frameTime.endMonitoring();
  42519. }
  42520. if (_this._captureRenderTime) {
  42521. _this._renderTime.endMonitoring(false);
  42522. }
  42523. if (_this._captureInterFrameTime) {
  42524. _this._interFrameTime.beginMonitoring();
  42525. }
  42526. });
  42527. }
  42528. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  42529. // Properties
  42530. /**
  42531. * Gets the perf counter used for active meshes evaluation time
  42532. */
  42533. get: function () {
  42534. return this._activeMeshesEvaluationTime;
  42535. },
  42536. enumerable: true,
  42537. configurable: true
  42538. });
  42539. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  42540. /**
  42541. * Gets the active meshes evaluation time capture status
  42542. */
  42543. get: function () {
  42544. return this._captureActiveMeshesEvaluationTime;
  42545. },
  42546. /**
  42547. * Enable or disable the active meshes evaluation time capture
  42548. */
  42549. set: function (value) {
  42550. var _this = this;
  42551. if (value === this._captureActiveMeshesEvaluationTime) {
  42552. return;
  42553. }
  42554. this._captureActiveMeshesEvaluationTime = value;
  42555. if (value) {
  42556. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  42557. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  42558. _this._activeMeshesEvaluationTime.beginMonitoring();
  42559. });
  42560. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  42561. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  42562. _this._activeMeshesEvaluationTime.endMonitoring();
  42563. });
  42564. }
  42565. else {
  42566. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  42567. this._onBeforeActiveMeshesEvaluationObserver = null;
  42568. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  42569. this._onAfterActiveMeshesEvaluationObserver = null;
  42570. }
  42571. },
  42572. enumerable: true,
  42573. configurable: true
  42574. });
  42575. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  42576. /**
  42577. * Gets the perf counter used for render targets render time
  42578. */
  42579. get: function () {
  42580. return this._renderTargetsRenderTime;
  42581. },
  42582. enumerable: true,
  42583. configurable: true
  42584. });
  42585. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  42586. /**
  42587. * Gets the render targets render time capture status
  42588. */
  42589. get: function () {
  42590. return this._captureRenderTargetsRenderTime;
  42591. },
  42592. /**
  42593. * Enable or disable the render targets render time capture
  42594. */
  42595. set: function (value) {
  42596. var _this = this;
  42597. if (value === this._captureRenderTargetsRenderTime) {
  42598. return;
  42599. }
  42600. this._captureRenderTargetsRenderTime = value;
  42601. if (value) {
  42602. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  42603. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  42604. _this._renderTargetsRenderTime.beginMonitoring();
  42605. });
  42606. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  42607. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  42608. _this._renderTargetsRenderTime.endMonitoring(false);
  42609. });
  42610. }
  42611. else {
  42612. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  42613. this._onBeforeRenderTargetsRenderObserver = null;
  42614. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  42615. this._onAfterRenderTargetsRenderObserver = null;
  42616. }
  42617. },
  42618. enumerable: true,
  42619. configurable: true
  42620. });
  42621. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  42622. /**
  42623. * Gets the perf counter used for particles render time
  42624. */
  42625. get: function () {
  42626. return this._particlesRenderTime;
  42627. },
  42628. enumerable: true,
  42629. configurable: true
  42630. });
  42631. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  42632. /**
  42633. * Gets the particles render time capture status
  42634. */
  42635. get: function () {
  42636. return this._captureParticlesRenderTime;
  42637. },
  42638. /**
  42639. * Enable or disable the particles render time capture
  42640. */
  42641. set: function (value) {
  42642. var _this = this;
  42643. if (value === this._captureParticlesRenderTime) {
  42644. return;
  42645. }
  42646. this._captureParticlesRenderTime = value;
  42647. if (value) {
  42648. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  42649. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  42650. _this._particlesRenderTime.beginMonitoring();
  42651. });
  42652. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  42653. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  42654. _this._particlesRenderTime.endMonitoring(false);
  42655. });
  42656. }
  42657. else {
  42658. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  42659. this._onBeforeParticlesRenderingObserver = null;
  42660. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  42661. this._onAfterParticlesRenderingObserver = null;
  42662. }
  42663. },
  42664. enumerable: true,
  42665. configurable: true
  42666. });
  42667. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  42668. /**
  42669. * Gets the perf counter used for sprites render time
  42670. */
  42671. get: function () {
  42672. return this._spritesRenderTime;
  42673. },
  42674. enumerable: true,
  42675. configurable: true
  42676. });
  42677. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  42678. /**
  42679. * Gets the sprites render time capture status
  42680. */
  42681. get: function () {
  42682. return this._captureSpritesRenderTime;
  42683. },
  42684. /**
  42685. * Enable or disable the sprites render time capture
  42686. */
  42687. set: function (value) {
  42688. var _this = this;
  42689. if (value === this._captureSpritesRenderTime) {
  42690. return;
  42691. }
  42692. this._captureSpritesRenderTime = value;
  42693. if (!this.scene.spriteManagers) {
  42694. return;
  42695. }
  42696. if (value) {
  42697. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  42698. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  42699. _this._spritesRenderTime.beginMonitoring();
  42700. });
  42701. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  42702. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  42703. _this._spritesRenderTime.endMonitoring(false);
  42704. });
  42705. }
  42706. else {
  42707. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  42708. this._onBeforeSpritesRenderingObserver = null;
  42709. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  42710. this._onAfterSpritesRenderingObserver = null;
  42711. }
  42712. },
  42713. enumerable: true,
  42714. configurable: true
  42715. });
  42716. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  42717. /**
  42718. * Gets the perf counter used for physics time
  42719. */
  42720. get: function () {
  42721. return this._physicsTime;
  42722. },
  42723. enumerable: true,
  42724. configurable: true
  42725. });
  42726. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  42727. /**
  42728. * Gets the physics time capture status
  42729. */
  42730. get: function () {
  42731. return this._capturePhysicsTime;
  42732. },
  42733. /**
  42734. * Enable or disable the physics time capture
  42735. */
  42736. set: function (value) {
  42737. var _this = this;
  42738. if (value === this._capturePhysicsTime) {
  42739. return;
  42740. }
  42741. if (!this.scene.onBeforePhysicsObservable) {
  42742. return;
  42743. }
  42744. this._capturePhysicsTime = value;
  42745. if (value) {
  42746. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  42747. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  42748. _this._physicsTime.beginMonitoring();
  42749. });
  42750. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  42751. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  42752. _this._physicsTime.endMonitoring();
  42753. });
  42754. }
  42755. else {
  42756. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  42757. this._onBeforePhysicsObserver = null;
  42758. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  42759. this._onAfterPhysicsObserver = null;
  42760. }
  42761. },
  42762. enumerable: true,
  42763. configurable: true
  42764. });
  42765. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  42766. /**
  42767. * Gets the perf counter used for animations time
  42768. */
  42769. get: function () {
  42770. return this._animationsTime;
  42771. },
  42772. enumerable: true,
  42773. configurable: true
  42774. });
  42775. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  42776. /**
  42777. * Gets the animations time capture status
  42778. */
  42779. get: function () {
  42780. return this._captureAnimationsTime;
  42781. },
  42782. /**
  42783. * Enable or disable the animations time capture
  42784. */
  42785. set: function (value) {
  42786. var _this = this;
  42787. if (value === this._captureAnimationsTime) {
  42788. return;
  42789. }
  42790. this._captureAnimationsTime = value;
  42791. if (value) {
  42792. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  42793. _this._animationsTime.endMonitoring();
  42794. });
  42795. }
  42796. else {
  42797. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  42798. this._onAfterAnimationsObserver = null;
  42799. }
  42800. },
  42801. enumerable: true,
  42802. configurable: true
  42803. });
  42804. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  42805. /**
  42806. * Gets the perf counter used for frame time capture
  42807. */
  42808. get: function () {
  42809. return this._frameTime;
  42810. },
  42811. enumerable: true,
  42812. configurable: true
  42813. });
  42814. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  42815. /**
  42816. * Gets the frame time capture status
  42817. */
  42818. get: function () {
  42819. return this._captureFrameTime;
  42820. },
  42821. /**
  42822. * Enable or disable the frame time capture
  42823. */
  42824. set: function (value) {
  42825. this._captureFrameTime = value;
  42826. },
  42827. enumerable: true,
  42828. configurable: true
  42829. });
  42830. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  42831. /**
  42832. * Gets the perf counter used for inter-frames time capture
  42833. */
  42834. get: function () {
  42835. return this._interFrameTime;
  42836. },
  42837. enumerable: true,
  42838. configurable: true
  42839. });
  42840. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  42841. /**
  42842. * Gets the inter-frames time capture status
  42843. */
  42844. get: function () {
  42845. return this._captureInterFrameTime;
  42846. },
  42847. /**
  42848. * Enable or disable the inter-frames time capture
  42849. */
  42850. set: function (value) {
  42851. this._captureInterFrameTime = value;
  42852. },
  42853. enumerable: true,
  42854. configurable: true
  42855. });
  42856. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  42857. /**
  42858. * Gets the perf counter used for render time capture
  42859. */
  42860. get: function () {
  42861. return this._renderTime;
  42862. },
  42863. enumerable: true,
  42864. configurable: true
  42865. });
  42866. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  42867. /**
  42868. * Gets the render time capture status
  42869. */
  42870. get: function () {
  42871. return this._captureRenderTime;
  42872. },
  42873. /**
  42874. * Enable or disable the render time capture
  42875. */
  42876. set: function (value) {
  42877. var _this = this;
  42878. if (value === this._captureRenderTime) {
  42879. return;
  42880. }
  42881. this._captureRenderTime = value;
  42882. if (value) {
  42883. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  42884. _this._renderTime.beginMonitoring();
  42885. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  42886. });
  42887. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  42888. _this._renderTime.endMonitoring(false);
  42889. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  42890. });
  42891. }
  42892. else {
  42893. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  42894. this._onBeforeDrawPhaseObserver = null;
  42895. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  42896. this._onAfterDrawPhaseObserver = null;
  42897. }
  42898. },
  42899. enumerable: true,
  42900. configurable: true
  42901. });
  42902. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  42903. /**
  42904. * Gets the perf counter used for camera render time capture
  42905. */
  42906. get: function () {
  42907. return this._cameraRenderTime;
  42908. },
  42909. enumerable: true,
  42910. configurable: true
  42911. });
  42912. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  42913. /**
  42914. * Gets the camera render time capture status
  42915. */
  42916. get: function () {
  42917. return this._captureCameraRenderTime;
  42918. },
  42919. /**
  42920. * Enable or disable the camera render time capture
  42921. */
  42922. set: function (value) {
  42923. var _this = this;
  42924. if (value === this._captureCameraRenderTime) {
  42925. return;
  42926. }
  42927. this._captureCameraRenderTime = value;
  42928. if (value) {
  42929. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  42930. _this._cameraRenderTime.beginMonitoring();
  42931. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  42932. });
  42933. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  42934. _this._cameraRenderTime.endMonitoring(false);
  42935. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  42936. });
  42937. }
  42938. else {
  42939. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  42940. this._onBeforeCameraRenderObserver = null;
  42941. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  42942. this._onAfterCameraRenderObserver = null;
  42943. }
  42944. },
  42945. enumerable: true,
  42946. configurable: true
  42947. });
  42948. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  42949. /**
  42950. * Gets the perf counter used for draw calls
  42951. */
  42952. get: function () {
  42953. return this.scene.getEngine()._drawCalls;
  42954. },
  42955. enumerable: true,
  42956. configurable: true
  42957. });
  42958. /**
  42959. * Dispose and release associated resources.
  42960. */
  42961. SceneInstrumentation.prototype.dispose = function () {
  42962. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  42963. this._onAfterRenderObserver = null;
  42964. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  42965. this._onBeforeActiveMeshesEvaluationObserver = null;
  42966. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  42967. this._onAfterActiveMeshesEvaluationObserver = null;
  42968. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  42969. this._onBeforeRenderTargetsRenderObserver = null;
  42970. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  42971. this._onAfterRenderTargetsRenderObserver = null;
  42972. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  42973. this._onBeforeAnimationsObserver = null;
  42974. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  42975. this._onBeforeParticlesRenderingObserver = null;
  42976. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  42977. this._onAfterParticlesRenderingObserver = null;
  42978. if (this._onBeforeSpritesRenderingObserver) {
  42979. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  42980. this._onBeforeSpritesRenderingObserver = null;
  42981. }
  42982. if (this._onAfterSpritesRenderingObserver) {
  42983. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  42984. this._onAfterSpritesRenderingObserver = null;
  42985. }
  42986. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  42987. this._onBeforeDrawPhaseObserver = null;
  42988. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  42989. this._onAfterDrawPhaseObserver = null;
  42990. if (this._onBeforePhysicsObserver) {
  42991. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  42992. this._onBeforePhysicsObserver = null;
  42993. }
  42994. if (this._onAfterPhysicsObserver) {
  42995. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  42996. this._onAfterPhysicsObserver = null;
  42997. }
  42998. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  42999. this._onAfterAnimationsObserver = null;
  43000. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  43001. this._onBeforeCameraRenderObserver = null;
  43002. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  43003. this._onAfterCameraRenderObserver = null;
  43004. this.scene = null;
  43005. };
  43006. return SceneInstrumentation;
  43007. }());
  43008. /***/ }),
  43009. /***/ "./Instrumentation/timeToken.ts":
  43010. /*!**************************************!*\
  43011. !*** ./Instrumentation/timeToken.ts ***!
  43012. \**************************************/
  43013. /*! exports provided: _TimeToken */
  43014. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43015. "use strict";
  43016. __webpack_require__.r(__webpack_exports__);
  43017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  43018. /**
  43019. * @hidden
  43020. **/
  43021. var _TimeToken = /** @class */ (function () {
  43022. function _TimeToken() {
  43023. this._timeElapsedQueryEnded = false;
  43024. }
  43025. return _TimeToken;
  43026. }());
  43027. /***/ }),
  43028. /***/ "./Layers/effectLayer.ts":
  43029. /*!*******************************!*\
  43030. !*** ./Layers/effectLayer.ts ***!
  43031. \*******************************/
  43032. /*! exports provided: EffectLayer */
  43033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43034. "use strict";
  43035. __webpack_require__.r(__webpack_exports__);
  43036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  43037. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  43038. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  43039. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43040. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  43041. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43042. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43043. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43044. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43045. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  43046. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43047. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  43048. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43049. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  43050. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  43051. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  43052. /**
  43053. * The effect layer Helps adding post process effect blended with the main pass.
  43054. *
  43055. * This can be for instance use to generate glow or higlight effects on the scene.
  43056. *
  43057. * The effect layer class can not be used directly and is intented to inherited from to be
  43058. * customized per effects.
  43059. */
  43060. var EffectLayer = /** @class */ (function () {
  43061. /**
  43062. * Instantiates a new effect Layer and references it in the scene.
  43063. * @param name The name of the layer
  43064. * @param scene The scene to use the layer in
  43065. */
  43066. function EffectLayer(
  43067. /** The Friendly of the effect in the scene */
  43068. name, scene) {
  43069. this._vertexBuffers = {};
  43070. this._maxSize = 0;
  43071. this._mainTextureDesiredSize = { width: 0, height: 0 };
  43072. this._shouldRender = true;
  43073. this._postProcesses = [];
  43074. this._textures = [];
  43075. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  43076. /**
  43077. * The clear color of the texture used to generate the glow map.
  43078. */
  43079. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  43080. /**
  43081. * Specifies wether the highlight layer is enabled or not.
  43082. */
  43083. this.isEnabled = true;
  43084. /**
  43085. * An event triggered when the effect layer has been disposed.
  43086. */
  43087. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  43088. /**
  43089. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  43090. */
  43091. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  43092. /**
  43093. * An event triggered when the generated texture is being merged in the scene.
  43094. */
  43095. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  43096. /**
  43097. * An event triggered when the generated texture has been merged in the scene.
  43098. */
  43099. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  43100. /**
  43101. * An event triggered when the efffect layer changes its size.
  43102. */
  43103. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  43104. this.name = name;
  43105. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  43106. EffectLayer._SceneComponentInitialization(this._scene);
  43107. this._engine = this._scene.getEngine();
  43108. this._maxSize = this._engine.getCaps().maxTextureSize;
  43109. this._scene.effectLayers.push(this);
  43110. // Generate Buffers
  43111. this._generateIndexBuffer();
  43112. this._generateVertexBuffer();
  43113. }
  43114. Object.defineProperty(EffectLayer.prototype, "camera", {
  43115. /**
  43116. * Gets the camera attached to the layer.
  43117. */
  43118. get: function () {
  43119. return this._effectLayerOptions.camera;
  43120. },
  43121. enumerable: true,
  43122. configurable: true
  43123. });
  43124. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  43125. /**
  43126. * Gets the rendering group id the layer should render in.
  43127. */
  43128. get: function () {
  43129. return this._effectLayerOptions.renderingGroupId;
  43130. },
  43131. enumerable: true,
  43132. configurable: true
  43133. });
  43134. /**
  43135. * Initializes the effect layer with the required options.
  43136. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  43137. */
  43138. EffectLayer.prototype._init = function (options) {
  43139. // Adapt options
  43140. 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);
  43141. this._setMainTextureSize();
  43142. this._createMainTexture();
  43143. this._createTextureAndPostProcesses();
  43144. this._mergeEffect = this._createMergeEffect();
  43145. };
  43146. /**
  43147. * Generates the index buffer of the full screen quad blending to the main canvas.
  43148. */
  43149. EffectLayer.prototype._generateIndexBuffer = function () {
  43150. // Indices
  43151. var indices = [];
  43152. indices.push(0);
  43153. indices.push(1);
  43154. indices.push(2);
  43155. indices.push(0);
  43156. indices.push(2);
  43157. indices.push(3);
  43158. this._indexBuffer = this._engine.createIndexBuffer(indices);
  43159. };
  43160. /**
  43161. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  43162. */
  43163. EffectLayer.prototype._generateVertexBuffer = function () {
  43164. // VBO
  43165. var vertices = [];
  43166. vertices.push(1, 1);
  43167. vertices.push(-1, 1);
  43168. vertices.push(-1, -1);
  43169. vertices.push(1, -1);
  43170. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  43171. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  43172. };
  43173. /**
  43174. * Sets the main texture desired size which is the closest power of two
  43175. * of the engine canvas size.
  43176. */
  43177. EffectLayer.prototype._setMainTextureSize = function () {
  43178. if (this._effectLayerOptions.mainTextureFixedSize) {
  43179. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  43180. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  43181. }
  43182. else {
  43183. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  43184. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  43185. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  43186. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  43187. }
  43188. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  43189. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  43190. };
  43191. /**
  43192. * Creates the main texture for the effect layer.
  43193. */
  43194. EffectLayer.prototype._createMainTexture = function () {
  43195. var _this = this;
  43196. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  43197. width: this._mainTextureDesiredSize.width,
  43198. height: this._mainTextureDesiredSize.height
  43199. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  43200. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  43201. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  43202. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  43203. this._mainTexture.anisotropicFilteringLevel = 1;
  43204. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  43205. this._mainTexture.renderParticles = false;
  43206. this._mainTexture.renderList = null;
  43207. this._mainTexture.ignoreCameraViewport = true;
  43208. // Custom render function
  43209. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  43210. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  43211. var index;
  43212. var engine = _this._scene.getEngine();
  43213. if (depthOnlySubMeshes.length) {
  43214. engine.setColorWrite(false);
  43215. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  43216. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  43217. }
  43218. engine.setColorWrite(true);
  43219. }
  43220. for (index = 0; index < opaqueSubMeshes.length; index++) {
  43221. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  43222. }
  43223. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  43224. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  43225. }
  43226. var previousAlphaMode = engine.getAlphaMode();
  43227. for (index = 0; index < transparentSubMeshes.length; index++) {
  43228. _this._renderSubMesh(transparentSubMeshes.data[index], true);
  43229. }
  43230. engine.setAlphaMode(previousAlphaMode);
  43231. };
  43232. this._mainTexture.onClearObservable.add(function (engine) {
  43233. engine.clear(_this.neutralColor, true, true, true);
  43234. });
  43235. };
  43236. /**
  43237. * Adds specific effects defines.
  43238. * @param defines The defines to add specifics to.
  43239. */
  43240. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  43241. // Nothing to add by default.
  43242. };
  43243. /**
  43244. * Checks for the readiness of the element composing the layer.
  43245. * @param subMesh the mesh to check for
  43246. * @param useInstances specify wether or not to use instances to render the mesh
  43247. * @param emissiveTexture the associated emissive texture used to generate the glow
  43248. * @return true if ready otherwise, false
  43249. */
  43250. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  43251. var material = subMesh.getMaterial();
  43252. if (!material) {
  43253. return false;
  43254. }
  43255. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  43256. return false;
  43257. }
  43258. var defines = [];
  43259. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  43260. var mesh = subMesh.getMesh();
  43261. var uv1 = false;
  43262. var uv2 = false;
  43263. // Diffuse
  43264. if (material) {
  43265. var needAlphaTest = material.needAlphaTesting();
  43266. var diffuseTexture = material.getAlphaTestTexture();
  43267. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  43268. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  43269. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  43270. defines.push("#define DIFFUSE");
  43271. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  43272. diffuseTexture.coordinatesIndex === 1) {
  43273. defines.push("#define DIFFUSEUV2");
  43274. uv2 = true;
  43275. }
  43276. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  43277. defines.push("#define DIFFUSEUV1");
  43278. uv1 = true;
  43279. }
  43280. if (needAlphaTest) {
  43281. defines.push("#define ALPHATEST");
  43282. defines.push("#define ALPHATESTVALUE 0.4");
  43283. }
  43284. }
  43285. var opacityTexture = material.opacityTexture;
  43286. if (opacityTexture) {
  43287. defines.push("#define OPACITY");
  43288. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  43289. opacityTexture.coordinatesIndex === 1) {
  43290. defines.push("#define OPACITYUV2");
  43291. uv2 = true;
  43292. }
  43293. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  43294. defines.push("#define OPACITYUV1");
  43295. uv1 = true;
  43296. }
  43297. }
  43298. }
  43299. // Emissive
  43300. if (emissiveTexture) {
  43301. defines.push("#define EMISSIVE");
  43302. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  43303. emissiveTexture.coordinatesIndex === 1) {
  43304. defines.push("#define EMISSIVEUV2");
  43305. uv2 = true;
  43306. }
  43307. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  43308. defines.push("#define EMISSIVEUV1");
  43309. uv1 = true;
  43310. }
  43311. }
  43312. // Vertex
  43313. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  43314. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  43315. defines.push("#define VERTEXALPHA");
  43316. }
  43317. if (uv1) {
  43318. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  43319. defines.push("#define UV1");
  43320. }
  43321. if (uv2) {
  43322. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  43323. defines.push("#define UV2");
  43324. }
  43325. // Bones
  43326. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  43327. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  43328. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  43329. if (mesh.numBoneInfluencers > 4) {
  43330. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  43331. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  43332. }
  43333. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  43334. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  43335. }
  43336. else {
  43337. defines.push("#define NUM_BONE_INFLUENCERS 0");
  43338. }
  43339. // Morph targets
  43340. var manager = mesh.morphTargetManager;
  43341. var morphInfluencers = 0;
  43342. if (manager) {
  43343. if (manager.numInfluencers > 0) {
  43344. defines.push("#define MORPHTARGETS");
  43345. morphInfluencers = manager.numInfluencers;
  43346. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  43347. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  43348. }
  43349. }
  43350. // Instances
  43351. if (useInstances) {
  43352. defines.push("#define INSTANCES");
  43353. attribs.push("world0");
  43354. attribs.push("world1");
  43355. attribs.push("world2");
  43356. attribs.push("world3");
  43357. }
  43358. this._addCustomEffectDefines(defines);
  43359. // Get correct effect
  43360. var join = defines.join("\n");
  43361. if (this._cachedDefines !== join) {
  43362. this._cachedDefines = join;
  43363. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  43364. "glowColor", "morphTargetInfluences",
  43365. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  43366. }
  43367. return this._effectLayerMapGenerationEffect.isReady();
  43368. };
  43369. /**
  43370. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  43371. */
  43372. EffectLayer.prototype.render = function () {
  43373. var currentEffect = this._mergeEffect;
  43374. // Check
  43375. if (!currentEffect.isReady()) {
  43376. return;
  43377. }
  43378. for (var i = 0; i < this._postProcesses.length; i++) {
  43379. if (!this._postProcesses[i].isReady()) {
  43380. return;
  43381. }
  43382. }
  43383. var engine = this._scene.getEngine();
  43384. this.onBeforeComposeObservable.notifyObservers(this);
  43385. // Render
  43386. engine.enableEffect(currentEffect);
  43387. engine.setState(false);
  43388. // VBOs
  43389. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  43390. // Cache
  43391. var previousAlphaMode = engine.getAlphaMode();
  43392. // Go Blend.
  43393. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  43394. // Blends the map on the main canvas.
  43395. this._internalRender(currentEffect);
  43396. // Restore Alpha
  43397. engine.setAlphaMode(previousAlphaMode);
  43398. this.onAfterComposeObservable.notifyObservers(this);
  43399. // Handle size changes.
  43400. var size = this._mainTexture.getSize();
  43401. this._setMainTextureSize();
  43402. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  43403. // Recreate RTT and post processes on size change.
  43404. this.onSizeChangedObservable.notifyObservers(this);
  43405. this._disposeTextureAndPostProcesses();
  43406. this._createMainTexture();
  43407. this._createTextureAndPostProcesses();
  43408. }
  43409. };
  43410. /**
  43411. * Determine if a given mesh will be used in the current effect.
  43412. * @param mesh mesh to test
  43413. * @returns true if the mesh will be used
  43414. */
  43415. EffectLayer.prototype.hasMesh = function (mesh) {
  43416. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  43417. return true;
  43418. }
  43419. return false;
  43420. };
  43421. /**
  43422. * Returns true if the layer contains information to display, otherwise false.
  43423. * @returns true if the glow layer should be rendered
  43424. */
  43425. EffectLayer.prototype.shouldRender = function () {
  43426. return this.isEnabled && this._shouldRender;
  43427. };
  43428. /**
  43429. * Returns true if the mesh should render, otherwise false.
  43430. * @param mesh The mesh to render
  43431. * @returns true if it should render otherwise false
  43432. */
  43433. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  43434. return true;
  43435. };
  43436. /**
  43437. * Returns true if the mesh can be rendered, otherwise false.
  43438. * @param mesh The mesh to render
  43439. * @param material The material used on the mesh
  43440. * @returns true if it can be rendered otherwise false
  43441. */
  43442. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  43443. return !material.needAlphaBlendingForMesh(mesh);
  43444. };
  43445. /**
  43446. * Returns true if the mesh should render, otherwise false.
  43447. * @param mesh The mesh to render
  43448. * @returns true if it should render otherwise false
  43449. */
  43450. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  43451. return true;
  43452. };
  43453. /**
  43454. * Renders the submesh passed in parameter to the generation map.
  43455. */
  43456. EffectLayer.prototype._renderSubMesh = function (subMesh, enableAlphaMode) {
  43457. var _this = this;
  43458. if (enableAlphaMode === void 0) { enableAlphaMode = false; }
  43459. if (!this.shouldRender()) {
  43460. return;
  43461. }
  43462. var material = subMesh.getMaterial();
  43463. var mesh = subMesh.getRenderingMesh();
  43464. var scene = this._scene;
  43465. var engine = scene.getEngine();
  43466. mesh._internalAbstractMeshDataInfo._isActiveIntermediate = false;
  43467. if (!material) {
  43468. return;
  43469. }
  43470. // Do not block in blend mode.
  43471. if (!this._canRenderMesh(mesh, material)) {
  43472. return;
  43473. }
  43474. // Culling
  43475. engine.setState(material.backFaceCulling);
  43476. // Managing instances
  43477. var batch = mesh._getInstancesRenderList(subMesh._id);
  43478. if (batch.mustReturn) {
  43479. return;
  43480. }
  43481. // Early Exit per mesh
  43482. if (!this._shouldRenderMesh(mesh)) {
  43483. return;
  43484. }
  43485. var hardwareInstancedRendering = batch.hardwareInstancedRendering[subMesh._id];
  43486. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  43487. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  43488. engine.enableEffect(this._effectLayerMapGenerationEffect);
  43489. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  43490. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  43491. this._effectLayerMapGenerationEffect.setFloat4("glowColor", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  43492. var needAlphaTest = material.needAlphaTesting();
  43493. var diffuseTexture = material.getAlphaTestTexture();
  43494. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  43495. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  43496. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  43497. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  43498. var textureMatrix = diffuseTexture.getTextureMatrix();
  43499. if (textureMatrix) {
  43500. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  43501. }
  43502. }
  43503. var opacityTexture = material.opacityTexture;
  43504. if (opacityTexture) {
  43505. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  43506. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  43507. var textureMatrix = opacityTexture.getTextureMatrix();
  43508. if (textureMatrix) {
  43509. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  43510. }
  43511. }
  43512. // Glow emissive only
  43513. if (this._emissiveTextureAndColor.texture) {
  43514. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  43515. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  43516. }
  43517. // Bones
  43518. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  43519. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  43520. }
  43521. // Morph targets
  43522. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  43523. // Alpha mode
  43524. if (enableAlphaMode) {
  43525. engine.setAlphaMode(material.alphaMode);
  43526. }
  43527. // Draw
  43528. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  43529. }
  43530. else {
  43531. // Need to reset refresh rate of the main map
  43532. this._mainTexture.resetRefreshCounter();
  43533. }
  43534. };
  43535. /**
  43536. * Rebuild the required buffers.
  43537. * @hidden Internal use only.
  43538. */
  43539. EffectLayer.prototype._rebuild = function () {
  43540. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  43541. if (vb) {
  43542. vb._rebuild();
  43543. }
  43544. this._generateIndexBuffer();
  43545. };
  43546. /**
  43547. * Dispose only the render target textures and post process.
  43548. */
  43549. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  43550. this._mainTexture.dispose();
  43551. for (var i = 0; i < this._postProcesses.length; i++) {
  43552. if (this._postProcesses[i]) {
  43553. this._postProcesses[i].dispose();
  43554. }
  43555. }
  43556. this._postProcesses = [];
  43557. for (var i = 0; i < this._textures.length; i++) {
  43558. if (this._textures[i]) {
  43559. this._textures[i].dispose();
  43560. }
  43561. }
  43562. this._textures = [];
  43563. };
  43564. /**
  43565. * Dispose the highlight layer and free resources.
  43566. */
  43567. EffectLayer.prototype.dispose = function () {
  43568. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  43569. if (vertexBuffer) {
  43570. vertexBuffer.dispose();
  43571. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  43572. }
  43573. if (this._indexBuffer) {
  43574. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  43575. this._indexBuffer = null;
  43576. }
  43577. // Clean textures and post processes
  43578. this._disposeTextureAndPostProcesses();
  43579. // Remove from scene
  43580. var index = this._scene.effectLayers.indexOf(this, 0);
  43581. if (index > -1) {
  43582. this._scene.effectLayers.splice(index, 1);
  43583. }
  43584. // Callback
  43585. this.onDisposeObservable.notifyObservers(this);
  43586. this.onDisposeObservable.clear();
  43587. this.onBeforeRenderMainTextureObservable.clear();
  43588. this.onBeforeComposeObservable.clear();
  43589. this.onAfterComposeObservable.clear();
  43590. this.onSizeChangedObservable.clear();
  43591. };
  43592. /**
  43593. * Gets the class name of the effect layer
  43594. * @returns the string with the class name of the effect layer
  43595. */
  43596. EffectLayer.prototype.getClassName = function () {
  43597. return "EffectLayer";
  43598. };
  43599. /**
  43600. * Creates an effect layer from parsed effect layer data
  43601. * @param parsedEffectLayer defines effect layer data
  43602. * @param scene defines the current scene
  43603. * @param rootUrl defines the root URL containing the effect layer information
  43604. * @returns a parsed effect Layer
  43605. */
  43606. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  43607. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  43608. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  43609. };
  43610. /** @hidden */
  43611. EffectLayer._SceneComponentInitialization = function (_) {
  43612. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  43613. };
  43614. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43615. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43616. ], EffectLayer.prototype, "name", void 0);
  43617. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43618. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  43619. ], EffectLayer.prototype, "neutralColor", void 0);
  43620. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43621. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43622. ], EffectLayer.prototype, "isEnabled", void 0);
  43623. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43624. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  43625. ], EffectLayer.prototype, "camera", null);
  43626. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43627. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43628. ], EffectLayer.prototype, "renderingGroupId", null);
  43629. return EffectLayer;
  43630. }());
  43631. /***/ }),
  43632. /***/ "./Layers/effectLayerSceneComponent.ts":
  43633. /*!*********************************************!*\
  43634. !*** ./Layers/effectLayerSceneComponent.ts ***!
  43635. \*********************************************/
  43636. /*! exports provided: EffectLayerSceneComponent */
  43637. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43638. "use strict";
  43639. __webpack_require__.r(__webpack_exports__);
  43640. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  43641. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  43642. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43643. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  43644. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  43645. // Adds the parser to the scene parsers.
  43646. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  43647. if (parsedData.effectLayers) {
  43648. if (!container.effectLayers) {
  43649. container.effectLayers = new Array();
  43650. }
  43651. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  43652. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  43653. container.effectLayers.push(effectLayer);
  43654. }
  43655. }
  43656. });
  43657. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  43658. var index = this.effectLayers.indexOf(toRemove);
  43659. if (index !== -1) {
  43660. this.effectLayers.splice(index, 1);
  43661. }
  43662. return index;
  43663. };
  43664. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  43665. this.effectLayers.push(newEffectLayer);
  43666. };
  43667. /**
  43668. * Defines the layer scene component responsible to manage any effect layers
  43669. * in a given scene.
  43670. */
  43671. var EffectLayerSceneComponent = /** @class */ (function () {
  43672. /**
  43673. * Creates a new instance of the component for the given scene
  43674. * @param scene Defines the scene to register the component in
  43675. */
  43676. function EffectLayerSceneComponent(scene) {
  43677. /**
  43678. * The component name helpfull to identify the component in the list of scene components.
  43679. */
  43680. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  43681. this._renderEffects = false;
  43682. this._needStencil = false;
  43683. this._previousStencilState = false;
  43684. this.scene = scene;
  43685. this._engine = scene.getEngine();
  43686. scene.effectLayers = new Array();
  43687. }
  43688. /**
  43689. * Registers the component in a given scene
  43690. */
  43691. EffectLayerSceneComponent.prototype.register = function () {
  43692. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  43693. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  43694. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  43695. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  43696. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  43697. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  43698. };
  43699. /**
  43700. * Rebuilds the elements related to this component in case of
  43701. * context lost for instance.
  43702. */
  43703. EffectLayerSceneComponent.prototype.rebuild = function () {
  43704. var layers = this.scene.effectLayers;
  43705. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  43706. var effectLayer = layers_1[_i];
  43707. effectLayer._rebuild();
  43708. }
  43709. };
  43710. /**
  43711. * Serializes the component data to the specified json object
  43712. * @param serializationObject The object to serialize to
  43713. */
  43714. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  43715. // Effect layers
  43716. serializationObject.effectLayers = [];
  43717. var layers = this.scene.effectLayers;
  43718. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  43719. var effectLayer = layers_2[_i];
  43720. if (effectLayer.serialize) {
  43721. serializationObject.effectLayers.push(effectLayer.serialize());
  43722. }
  43723. }
  43724. };
  43725. /**
  43726. * Adds all the element from the container to the scene
  43727. * @param container the container holding the elements
  43728. */
  43729. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  43730. var _this = this;
  43731. if (!container.effectLayers) {
  43732. return;
  43733. }
  43734. container.effectLayers.forEach(function (o) {
  43735. _this.scene.addEffectLayer(o);
  43736. });
  43737. };
  43738. /**
  43739. * Removes all the elements in the container from the scene
  43740. * @param container contains the elements to remove
  43741. * @param dispose if the removed element should be disposed (default: false)
  43742. */
  43743. EffectLayerSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  43744. var _this = this;
  43745. if (!container.effectLayers) {
  43746. return;
  43747. }
  43748. container.effectLayers.forEach(function (o) {
  43749. _this.scene.removeEffectLayer(o);
  43750. if (dispose) {
  43751. o.dispose();
  43752. }
  43753. });
  43754. };
  43755. /**
  43756. * Disposes the component and the associated ressources.
  43757. */
  43758. EffectLayerSceneComponent.prototype.dispose = function () {
  43759. var layers = this.scene.effectLayers;
  43760. while (layers.length) {
  43761. layers[0].dispose();
  43762. }
  43763. };
  43764. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  43765. var layers = this.scene.effectLayers;
  43766. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  43767. var layer = layers_3[_i];
  43768. if (!layer.hasMesh(mesh)) {
  43769. continue;
  43770. }
  43771. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  43772. var subMesh = _b[_a];
  43773. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  43774. return false;
  43775. }
  43776. }
  43777. }
  43778. return true;
  43779. };
  43780. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  43781. this._renderEffects = false;
  43782. this._needStencil = false;
  43783. var needRebind = false;
  43784. var layers = this.scene.effectLayers;
  43785. if (layers && layers.length > 0) {
  43786. this._previousStencilState = this._engine.getStencilBuffer();
  43787. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  43788. var effectLayer = layers_4[_i];
  43789. if (effectLayer.shouldRender() &&
  43790. (!effectLayer.camera ||
  43791. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  43792. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  43793. this._renderEffects = true;
  43794. this._needStencil = this._needStencil || effectLayer.needStencil();
  43795. var renderTarget = effectLayer._mainTexture;
  43796. if (renderTarget._shouldRender()) {
  43797. this.scene.incrementRenderId();
  43798. renderTarget.render(false, false);
  43799. needRebind = true;
  43800. }
  43801. }
  43802. }
  43803. this.scene.incrementRenderId();
  43804. }
  43805. return needRebind;
  43806. };
  43807. EffectLayerSceneComponent.prototype._setStencil = function () {
  43808. // Activate effect Layer stencil
  43809. if (this._needStencil) {
  43810. this._engine.setStencilBuffer(true);
  43811. }
  43812. };
  43813. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  43814. // Restore effect Layer stencil
  43815. if (this._needStencil) {
  43816. this._engine.setStencilBuffer(this._previousStencilState);
  43817. }
  43818. };
  43819. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  43820. if (this._renderEffects) {
  43821. this._engine.setDepthBuffer(false);
  43822. var layers = this.scene.effectLayers;
  43823. for (var i = 0; i < layers.length; i++) {
  43824. var effectLayer = layers[i];
  43825. if (effectLayer.renderingGroupId === renderingGroupId) {
  43826. if (effectLayer.shouldRender()) {
  43827. effectLayer.render();
  43828. }
  43829. }
  43830. }
  43831. this._engine.setDepthBuffer(true);
  43832. }
  43833. };
  43834. EffectLayerSceneComponent.prototype._drawCamera = function () {
  43835. if (this._renderEffects) {
  43836. this._draw(-1);
  43837. }
  43838. };
  43839. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  43840. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  43841. this._draw(index);
  43842. }
  43843. };
  43844. return EffectLayerSceneComponent;
  43845. }());
  43846. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  43847. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  43848. if (!component) {
  43849. component = new EffectLayerSceneComponent(scene);
  43850. scene._addComponent(component);
  43851. }
  43852. };
  43853. /***/ }),
  43854. /***/ "./Layers/glowLayer.ts":
  43855. /*!*****************************!*\
  43856. !*** ./Layers/glowLayer.ts ***!
  43857. \*****************************/
  43858. /*! exports provided: GlowLayer */
  43859. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43860. "use strict";
  43861. __webpack_require__.r(__webpack_exports__);
  43862. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  43863. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  43864. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  43865. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43866. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43867. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43868. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43869. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  43870. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43871. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  43872. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  43873. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  43874. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43875. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  43876. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  43877. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  43878. /* harmony import */ var _Layers_effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Layers/effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  43879. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  43880. for (var index = 0; index < this.effectLayers.length; index++) {
  43881. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  43882. return this.effectLayers[index];
  43883. }
  43884. }
  43885. return null;
  43886. };
  43887. /**
  43888. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  43889. *
  43890. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43891. * glowy meshes to your scene.
  43892. *
  43893. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  43894. */
  43895. var GlowLayer = /** @class */ (function (_super) {
  43896. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  43897. /**
  43898. * Instantiates a new glow Layer and references it to the scene.
  43899. * @param name The name of the layer
  43900. * @param scene The scene to use the layer in
  43901. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  43902. */
  43903. function GlowLayer(name, scene, options) {
  43904. var _this = _super.call(this, name, scene) || this;
  43905. _this._intensity = 1.0;
  43906. _this._includedOnlyMeshes = [];
  43907. _this._excludedMeshes = [];
  43908. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  43909. // Adapt options
  43910. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  43911. // Initialize the layer
  43912. _this._init({
  43913. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  43914. camera: _this._options.camera,
  43915. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  43916. mainTextureRatio: _this._options.mainTextureRatio,
  43917. renderingGroupId: _this._options.renderingGroupId
  43918. });
  43919. return _this;
  43920. }
  43921. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  43922. /**
  43923. * Gets the kernel size of the blur.
  43924. */
  43925. get: function () {
  43926. return this._horizontalBlurPostprocess1.kernel;
  43927. },
  43928. /**
  43929. * Sets the kernel size of the blur.
  43930. */
  43931. set: function (value) {
  43932. this._horizontalBlurPostprocess1.kernel = value;
  43933. this._verticalBlurPostprocess1.kernel = value;
  43934. this._horizontalBlurPostprocess2.kernel = value;
  43935. this._verticalBlurPostprocess2.kernel = value;
  43936. },
  43937. enumerable: true,
  43938. configurable: true
  43939. });
  43940. Object.defineProperty(GlowLayer.prototype, "intensity", {
  43941. /**
  43942. * Gets the glow intensity.
  43943. */
  43944. get: function () {
  43945. return this._intensity;
  43946. },
  43947. /**
  43948. * Sets the glow intensity.
  43949. */
  43950. set: function (value) {
  43951. this._intensity = value;
  43952. },
  43953. enumerable: true,
  43954. configurable: true
  43955. });
  43956. /**
  43957. * Get the effect name of the layer.
  43958. * @return The effect name
  43959. */
  43960. GlowLayer.prototype.getEffectName = function () {
  43961. return GlowLayer.EffectName;
  43962. };
  43963. /**
  43964. * Create the merge effect. This is the shader use to blit the information back
  43965. * to the main canvas at the end of the scene rendering.
  43966. */
  43967. GlowLayer.prototype._createMergeEffect = function () {
  43968. // Effect
  43969. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  43970. };
  43971. /**
  43972. * Creates the render target textures and post processes used in the glow layer.
  43973. */
  43974. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  43975. var _this = this;
  43976. var blurTextureWidth = this._mainTextureDesiredSize.width;
  43977. var blurTextureHeight = this._mainTextureDesiredSize.height;
  43978. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  43979. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  43980. var textureType = 0;
  43981. if (this._engine.getCaps().textureHalfFloatRender) {
  43982. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  43983. }
  43984. else {
  43985. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  43986. }
  43987. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  43988. width: blurTextureWidth,
  43989. height: blurTextureHeight
  43990. }, this._scene, false, true, textureType);
  43991. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  43992. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  43993. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  43994. this._blurTexture1.renderParticles = false;
  43995. this._blurTexture1.ignoreCameraViewport = true;
  43996. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  43997. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  43998. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  43999. width: blurTextureWidth2,
  44000. height: blurTextureHeight2
  44001. }, this._scene, false, true, textureType);
  44002. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  44003. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  44004. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  44005. this._blurTexture2.renderParticles = false;
  44006. this._blurTexture2.ignoreCameraViewport = true;
  44007. this._textures = [this._blurTexture1, this._blurTexture2];
  44008. 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, {
  44009. width: blurTextureWidth,
  44010. height: blurTextureHeight
  44011. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  44012. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  44013. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  44014. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  44015. effect.setTexture("textureSampler", _this._mainTexture);
  44016. });
  44017. 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, {
  44018. width: blurTextureWidth,
  44019. height: blurTextureHeight
  44020. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  44021. 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, {
  44022. width: blurTextureWidth2,
  44023. height: blurTextureHeight2
  44024. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  44025. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  44026. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  44027. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  44028. effect.setTexture("textureSampler", _this._blurTexture1);
  44029. });
  44030. 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, {
  44031. width: blurTextureWidth2,
  44032. height: blurTextureHeight2
  44033. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  44034. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  44035. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  44036. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  44037. this._mainTexture.samples = this._options.mainTextureSamples;
  44038. this._mainTexture.onAfterUnbindObservable.add(function () {
  44039. var internalTexture = _this._blurTexture1.getInternalTexture();
  44040. if (internalTexture) {
  44041. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  44042. internalTexture = _this._blurTexture2.getInternalTexture();
  44043. if (internalTexture) {
  44044. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  44045. }
  44046. }
  44047. });
  44048. // Prevent autoClear.
  44049. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  44050. };
  44051. /**
  44052. * Checks for the readiness of the element composing the layer.
  44053. * @param subMesh the mesh to check for
  44054. * @param useInstances specify wether or not to use instances to render the mesh
  44055. * @param emissiveTexture the associated emissive texture used to generate the glow
  44056. * @return true if ready otherwise, false
  44057. */
  44058. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  44059. var material = subMesh.getMaterial();
  44060. var mesh = subMesh.getRenderingMesh();
  44061. if (!material || !mesh) {
  44062. return false;
  44063. }
  44064. var emissiveTexture = material.emissiveTexture;
  44065. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  44066. };
  44067. /**
  44068. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44069. */
  44070. GlowLayer.prototype.needStencil = function () {
  44071. return false;
  44072. };
  44073. /**
  44074. * Returns true if the mesh can be rendered, otherwise false.
  44075. * @param mesh The mesh to render
  44076. * @param material The material used on the mesh
  44077. * @returns true if it can be rendered otherwise false
  44078. */
  44079. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  44080. return true;
  44081. };
  44082. /**
  44083. * Implementation specific of rendering the generating effect on the main canvas.
  44084. * @param effect The effect used to render through
  44085. */
  44086. GlowLayer.prototype._internalRender = function (effect) {
  44087. // Texture
  44088. effect.setTexture("textureSampler", this._blurTexture1);
  44089. effect.setTexture("textureSampler2", this._blurTexture2);
  44090. effect.setFloat("offset", this._intensity);
  44091. // Cache
  44092. var engine = this._engine;
  44093. var previousStencilBuffer = engine.getStencilBuffer();
  44094. // Draw order
  44095. engine.setStencilBuffer(false);
  44096. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  44097. // Draw order
  44098. engine.setStencilBuffer(previousStencilBuffer);
  44099. };
  44100. /**
  44101. * Sets the required values for both the emissive texture and and the main color.
  44102. */
  44103. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  44104. var textureLevel = 1.0;
  44105. if (this.customEmissiveTextureSelector) {
  44106. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  44107. }
  44108. else {
  44109. if (material) {
  44110. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  44111. if (this._emissiveTextureAndColor.texture) {
  44112. textureLevel = this._emissiveTextureAndColor.texture.level;
  44113. }
  44114. }
  44115. else {
  44116. this._emissiveTextureAndColor.texture = null;
  44117. }
  44118. }
  44119. if (this.customEmissiveColorSelector) {
  44120. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  44121. }
  44122. else {
  44123. if (material.emissiveColor) {
  44124. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  44125. }
  44126. else {
  44127. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  44128. }
  44129. }
  44130. };
  44131. /**
  44132. * Returns true if the mesh should render, otherwise false.
  44133. * @param mesh The mesh to render
  44134. * @returns true if it should render otherwise false
  44135. */
  44136. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  44137. return this.hasMesh(mesh);
  44138. };
  44139. /**
  44140. * Adds specific effects defines.
  44141. * @param defines The defines to add specifics to.
  44142. */
  44143. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  44144. defines.push("#define GLOW");
  44145. };
  44146. /**
  44147. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  44148. * @param mesh The mesh to exclude from the glow layer
  44149. */
  44150. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  44151. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  44152. this._excludedMeshes.push(mesh.uniqueId);
  44153. }
  44154. };
  44155. /**
  44156. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  44157. * @param mesh The mesh to remove
  44158. */
  44159. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  44160. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  44161. if (index !== -1) {
  44162. this._excludedMeshes.splice(index, 1);
  44163. }
  44164. };
  44165. /**
  44166. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  44167. * @param mesh The mesh to include in the glow layer
  44168. */
  44169. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  44170. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  44171. this._includedOnlyMeshes.push(mesh.uniqueId);
  44172. }
  44173. };
  44174. /**
  44175. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  44176. * @param mesh The mesh to remove
  44177. */
  44178. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  44179. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  44180. if (index !== -1) {
  44181. this._includedOnlyMeshes.splice(index, 1);
  44182. }
  44183. };
  44184. /**
  44185. * Determine if a given mesh will be used in the glow layer
  44186. * @param mesh The mesh to test
  44187. * @returns true if the mesh will be highlighted by the current glow layer
  44188. */
  44189. GlowLayer.prototype.hasMesh = function (mesh) {
  44190. if (!_super.prototype.hasMesh.call(this, mesh)) {
  44191. return false;
  44192. }
  44193. // Included Mesh
  44194. if (this._includedOnlyMeshes.length) {
  44195. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  44196. }
  44197. // Excluded Mesh
  44198. if (this._excludedMeshes.length) {
  44199. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  44200. }
  44201. return true;
  44202. };
  44203. /**
  44204. * Free any resources and references associated to a mesh.
  44205. * Internal use
  44206. * @param mesh The mesh to free.
  44207. * @hidden
  44208. */
  44209. GlowLayer.prototype._disposeMesh = function (mesh) {
  44210. this.removeIncludedOnlyMesh(mesh);
  44211. this.removeExcludedMesh(mesh);
  44212. };
  44213. /**
  44214. * Gets the class name of the effect layer
  44215. * @returns the string with the class name of the effect layer
  44216. */
  44217. GlowLayer.prototype.getClassName = function () {
  44218. return "GlowLayer";
  44219. };
  44220. /**
  44221. * Serializes this glow layer
  44222. * @returns a serialized glow layer object
  44223. */
  44224. GlowLayer.prototype.serialize = function () {
  44225. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  44226. serializationObject.customType = "BABYLON.GlowLayer";
  44227. var index;
  44228. // Included meshes
  44229. serializationObject.includedMeshes = [];
  44230. if (this._includedOnlyMeshes.length) {
  44231. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  44232. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  44233. if (mesh) {
  44234. serializationObject.includedMeshes.push(mesh.id);
  44235. }
  44236. }
  44237. }
  44238. // Excluded meshes
  44239. serializationObject.excludedMeshes = [];
  44240. if (this._excludedMeshes.length) {
  44241. for (index = 0; index < this._excludedMeshes.length; index++) {
  44242. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  44243. if (mesh) {
  44244. serializationObject.excludedMeshes.push(mesh.id);
  44245. }
  44246. }
  44247. }
  44248. return serializationObject;
  44249. };
  44250. /**
  44251. * Creates a Glow Layer from parsed glow layer data
  44252. * @param parsedGlowLayer defines glow layer data
  44253. * @param scene defines the current scene
  44254. * @param rootUrl defines the root URL containing the glow layer information
  44255. * @returns a parsed Glow Layer
  44256. */
  44257. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  44258. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  44259. var index;
  44260. // Excluded meshes
  44261. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  44262. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  44263. if (mesh) {
  44264. gl.addExcludedMesh(mesh);
  44265. }
  44266. }
  44267. // Included meshes
  44268. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  44269. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  44270. if (mesh) {
  44271. gl.addIncludedOnlyMesh(mesh);
  44272. }
  44273. }
  44274. return gl;
  44275. };
  44276. /**
  44277. * Effect Name of the layer.
  44278. */
  44279. GlowLayer.EffectName = "GlowLayer";
  44280. /**
  44281. * The default blur kernel size used for the glow.
  44282. */
  44283. GlowLayer.DefaultBlurKernelSize = 32;
  44284. /**
  44285. * The default texture size ratio used for the glow.
  44286. */
  44287. GlowLayer.DefaultTextureRatio = 0.5;
  44288. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  44289. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  44290. ], GlowLayer.prototype, "blurKernelSize", null);
  44291. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  44292. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  44293. ], GlowLayer.prototype, "intensity", null);
  44294. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  44295. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  44296. ], GlowLayer.prototype, "_options", void 0);
  44297. return GlowLayer;
  44298. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  44299. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  44300. /***/ }),
  44301. /***/ "./Layers/highlightLayer.ts":
  44302. /*!**********************************!*\
  44303. !*** ./Layers/highlightLayer.ts ***!
  44304. \**********************************/
  44305. /*! exports provided: HighlightLayer */
  44306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44307. "use strict";
  44308. __webpack_require__.r(__webpack_exports__);
  44309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  44310. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  44311. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  44312. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  44313. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44314. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44315. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  44316. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  44317. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44318. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  44319. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  44320. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  44321. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  44322. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  44323. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  44324. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44325. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  44326. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  44327. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  44328. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  44329. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  44330. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  44331. for (var index = 0; index < this.effectLayers.length; index++) {
  44332. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  44333. return this.effectLayers[index];
  44334. }
  44335. }
  44336. return null;
  44337. };
  44338. /**
  44339. * Special Glow Blur post process only blurring the alpha channel
  44340. * It enforces keeping the most luminous color in the color channel.
  44341. */
  44342. var GlowBlurPostProcess = /** @class */ (function (_super) {
  44343. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  44344. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  44345. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  44346. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  44347. _this.direction = direction;
  44348. _this.kernel = kernel;
  44349. _this.onApplyObservable.add(function (effect) {
  44350. effect.setFloat2("screenSize", _this.width, _this.height);
  44351. effect.setVector2("direction", _this.direction);
  44352. effect.setFloat("blurWidth", _this.kernel);
  44353. });
  44354. return _this;
  44355. }
  44356. return GlowBlurPostProcess;
  44357. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  44358. /**
  44359. * The highlight layer Helps adding a glow effect around a mesh.
  44360. *
  44361. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  44362. * glowy meshes to your scene.
  44363. *
  44364. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  44365. */
  44366. var HighlightLayer = /** @class */ (function (_super) {
  44367. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  44368. /**
  44369. * Instantiates a new highlight Layer and references it to the scene..
  44370. * @param name The name of the layer
  44371. * @param scene The scene to use the layer in
  44372. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  44373. */
  44374. function HighlightLayer(name, scene, options) {
  44375. var _this = _super.call(this, name, scene) || this;
  44376. _this.name = name;
  44377. /**
  44378. * Specifies whether or not the inner glow is ACTIVE in the layer.
  44379. */
  44380. _this.innerGlow = true;
  44381. /**
  44382. * Specifies whether or not the outer glow is ACTIVE in the layer.
  44383. */
  44384. _this.outerGlow = true;
  44385. /**
  44386. * An event triggered when the highlight layer is being blurred.
  44387. */
  44388. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  44389. /**
  44390. * An event triggered when the highlight layer has been blurred.
  44391. */
  44392. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  44393. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  44394. _this._meshes = {};
  44395. _this._excludedMeshes = {};
  44396. _this.neutralColor = HighlightLayer.NeutralColor;
  44397. // Warn on stencil
  44398. if (!_this._engine.isStencilEnable) {
  44399. _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 }");
  44400. }
  44401. // Adapt options
  44402. _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);
  44403. // Initialize the layer
  44404. _this._init({
  44405. alphaBlendingMode: _this._options.alphaBlendingMode,
  44406. camera: _this._options.camera,
  44407. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  44408. mainTextureRatio: _this._options.mainTextureRatio,
  44409. renderingGroupId: _this._options.renderingGroupId
  44410. });
  44411. // Do not render as long as no meshes have been added
  44412. _this._shouldRender = false;
  44413. return _this;
  44414. }
  44415. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  44416. /**
  44417. * Gets the horizontal size of the blur.
  44418. */
  44419. get: function () {
  44420. return this._horizontalBlurPostprocess.kernel;
  44421. },
  44422. /**
  44423. * Specifies the horizontal size of the blur.
  44424. */
  44425. set: function (value) {
  44426. this._horizontalBlurPostprocess.kernel = value;
  44427. },
  44428. enumerable: true,
  44429. configurable: true
  44430. });
  44431. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  44432. /**
  44433. * Gets the vertical size of the blur.
  44434. */
  44435. get: function () {
  44436. return this._verticalBlurPostprocess.kernel;
  44437. },
  44438. /**
  44439. * Specifies the vertical size of the blur.
  44440. */
  44441. set: function (value) {
  44442. this._verticalBlurPostprocess.kernel = value;
  44443. },
  44444. enumerable: true,
  44445. configurable: true
  44446. });
  44447. /**
  44448. * Get the effect name of the layer.
  44449. * @return The effect name
  44450. */
  44451. HighlightLayer.prototype.getEffectName = function () {
  44452. return HighlightLayer.EffectName;
  44453. };
  44454. /**
  44455. * Create the merge effect. This is the shader use to blit the information back
  44456. * to the main canvas at the end of the scene rendering.
  44457. */
  44458. HighlightLayer.prototype._createMergeEffect = function () {
  44459. // Effect
  44460. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  44461. };
  44462. /**
  44463. * Creates the render target textures and post processes used in the highlight layer.
  44464. */
  44465. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  44466. var _this = this;
  44467. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  44468. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  44469. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  44470. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  44471. var textureType = 0;
  44472. if (this._engine.getCaps().textureHalfFloatRender) {
  44473. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44474. }
  44475. else {
  44476. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44477. }
  44478. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  44479. width: blurTextureWidth,
  44480. height: blurTextureHeight
  44481. }, this._scene, false, true, textureType);
  44482. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  44483. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  44484. this._blurTexture.anisotropicFilteringLevel = 16;
  44485. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  44486. this._blurTexture.renderParticles = false;
  44487. this._blurTexture.ignoreCameraViewport = true;
  44488. this._textures = [this._blurTexture];
  44489. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  44490. 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());
  44491. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  44492. effect.setTexture("textureSampler", _this._mainTexture);
  44493. });
  44494. 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());
  44495. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  44496. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  44497. });
  44498. 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());
  44499. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  44500. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  44501. });
  44502. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  44503. }
  44504. else {
  44505. 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, {
  44506. width: blurTextureWidth,
  44507. height: blurTextureHeight
  44508. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  44509. this._horizontalBlurPostprocess.width = blurTextureWidth;
  44510. this._horizontalBlurPostprocess.height = blurTextureHeight;
  44511. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  44512. effect.setTexture("textureSampler", _this._mainTexture);
  44513. });
  44514. 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, {
  44515. width: blurTextureWidth,
  44516. height: blurTextureHeight
  44517. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  44518. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  44519. }
  44520. this._mainTexture.onAfterUnbindObservable.add(function () {
  44521. _this.onBeforeBlurObservable.notifyObservers(_this);
  44522. var internalTexture = _this._blurTexture.getInternalTexture();
  44523. if (internalTexture) {
  44524. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  44525. }
  44526. _this.onAfterBlurObservable.notifyObservers(_this);
  44527. });
  44528. // Prevent autoClear.
  44529. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  44530. };
  44531. /**
  44532. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44533. */
  44534. HighlightLayer.prototype.needStencil = function () {
  44535. return true;
  44536. };
  44537. /**
  44538. * Checks for the readiness of the element composing the layer.
  44539. * @param subMesh the mesh to check for
  44540. * @param useInstances specify wether or not to use instances to render the mesh
  44541. * @param emissiveTexture the associated emissive texture used to generate the glow
  44542. * @return true if ready otherwise, false
  44543. */
  44544. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  44545. var material = subMesh.getMaterial();
  44546. var mesh = subMesh.getRenderingMesh();
  44547. if (!material || !mesh || !this._meshes) {
  44548. return false;
  44549. }
  44550. var emissiveTexture = null;
  44551. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  44552. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  44553. emissiveTexture = material.emissiveTexture;
  44554. }
  44555. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  44556. };
  44557. /**
  44558. * Implementation specific of rendering the generating effect on the main canvas.
  44559. * @param effect The effect used to render through
  44560. */
  44561. HighlightLayer.prototype._internalRender = function (effect) {
  44562. // Texture
  44563. effect.setTexture("textureSampler", this._blurTexture);
  44564. // Cache
  44565. var engine = this._engine;
  44566. engine.cacheStencilState();
  44567. // Stencil operations
  44568. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  44569. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  44570. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  44571. // Draw order
  44572. engine.setStencilMask(0x00);
  44573. engine.setStencilBuffer(true);
  44574. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  44575. // 2 passes inner outer
  44576. if (this.outerGlow) {
  44577. effect.setFloat("offset", 0);
  44578. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  44579. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  44580. }
  44581. if (this.innerGlow) {
  44582. effect.setFloat("offset", 1);
  44583. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  44584. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  44585. }
  44586. // Restore Cache
  44587. engine.restoreStencilState();
  44588. };
  44589. /**
  44590. * Returns true if the layer contains information to display, otherwise false.
  44591. */
  44592. HighlightLayer.prototype.shouldRender = function () {
  44593. if (_super.prototype.shouldRender.call(this)) {
  44594. return this._meshes ? true : false;
  44595. }
  44596. return false;
  44597. };
  44598. /**
  44599. * Returns true if the mesh should render, otherwise false.
  44600. * @param mesh The mesh to render
  44601. * @returns true if it should render otherwise false
  44602. */
  44603. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  44604. // Excluded Mesh
  44605. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  44606. return false;
  44607. }
  44608. if (!_super.prototype.hasMesh.call(this, mesh)) {
  44609. return false;
  44610. }
  44611. return true;
  44612. };
  44613. /**
  44614. * Sets the required values for both the emissive texture and and the main color.
  44615. */
  44616. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  44617. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  44618. if (highlightLayerMesh) {
  44619. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  44620. }
  44621. else {
  44622. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  44623. }
  44624. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  44625. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  44626. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  44627. }
  44628. else {
  44629. this._emissiveTextureAndColor.texture = null;
  44630. }
  44631. };
  44632. /**
  44633. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  44634. * @param mesh The mesh to exclude from the highlight layer
  44635. */
  44636. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  44637. if (!this._excludedMeshes) {
  44638. return;
  44639. }
  44640. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  44641. if (!meshExcluded) {
  44642. this._excludedMeshes[mesh.uniqueId] = {
  44643. mesh: mesh,
  44644. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  44645. mesh.getEngine().setStencilBuffer(false);
  44646. }),
  44647. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  44648. mesh.getEngine().setStencilBuffer(true);
  44649. }),
  44650. };
  44651. }
  44652. };
  44653. /**
  44654. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  44655. * @param mesh The mesh to highlight
  44656. */
  44657. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  44658. if (!this._excludedMeshes) {
  44659. return;
  44660. }
  44661. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  44662. if (meshExcluded) {
  44663. if (meshExcluded.beforeBind) {
  44664. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  44665. }
  44666. if (meshExcluded.afterRender) {
  44667. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  44668. }
  44669. }
  44670. this._excludedMeshes[mesh.uniqueId] = null;
  44671. };
  44672. /**
  44673. * Determine if a given mesh will be highlighted by the current HighlightLayer
  44674. * @param mesh mesh to test
  44675. * @returns true if the mesh will be highlighted by the current HighlightLayer
  44676. */
  44677. HighlightLayer.prototype.hasMesh = function (mesh) {
  44678. if (!this._meshes) {
  44679. return false;
  44680. }
  44681. if (!_super.prototype.hasMesh.call(this, mesh)) {
  44682. return false;
  44683. }
  44684. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  44685. };
  44686. /**
  44687. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  44688. * @param mesh The mesh to highlight
  44689. * @param color The color of the highlight
  44690. * @param glowEmissiveOnly Extract the glow from the emissive texture
  44691. */
  44692. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  44693. var _this = this;
  44694. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  44695. if (!this._meshes) {
  44696. return;
  44697. }
  44698. var meshHighlight = this._meshes[mesh.uniqueId];
  44699. if (meshHighlight) {
  44700. meshHighlight.color = color;
  44701. }
  44702. else {
  44703. this._meshes[mesh.uniqueId] = {
  44704. mesh: mesh,
  44705. color: color,
  44706. // Lambda required for capture due to Observable this context
  44707. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  44708. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  44709. _this._defaultStencilReference(mesh);
  44710. }
  44711. else {
  44712. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  44713. }
  44714. }),
  44715. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  44716. glowEmissiveOnly: glowEmissiveOnly
  44717. };
  44718. mesh.onDisposeObservable.add(function () {
  44719. _this._disposeMesh(mesh);
  44720. });
  44721. }
  44722. this._shouldRender = true;
  44723. };
  44724. /**
  44725. * Remove a mesh from the highlight layer in order to make it stop glowing.
  44726. * @param mesh The mesh to highlight
  44727. */
  44728. HighlightLayer.prototype.removeMesh = function (mesh) {
  44729. if (!this._meshes) {
  44730. return;
  44731. }
  44732. var meshHighlight = this._meshes[mesh.uniqueId];
  44733. if (meshHighlight) {
  44734. if (meshHighlight.observerHighlight) {
  44735. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  44736. }
  44737. if (meshHighlight.observerDefault) {
  44738. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  44739. }
  44740. delete this._meshes[mesh.uniqueId];
  44741. }
  44742. this._shouldRender = false;
  44743. for (var meshHighlightToCheck in this._meshes) {
  44744. if (this._meshes[meshHighlightToCheck]) {
  44745. this._shouldRender = true;
  44746. break;
  44747. }
  44748. }
  44749. };
  44750. /**
  44751. * Force the stencil to the normal expected value for none glowing parts
  44752. */
  44753. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  44754. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  44755. };
  44756. /**
  44757. * Free any resources and references associated to a mesh.
  44758. * Internal use
  44759. * @param mesh The mesh to free.
  44760. * @hidden
  44761. */
  44762. HighlightLayer.prototype._disposeMesh = function (mesh) {
  44763. this.removeMesh(mesh);
  44764. this.removeExcludedMesh(mesh);
  44765. };
  44766. /**
  44767. * Dispose the highlight layer and free resources.
  44768. */
  44769. HighlightLayer.prototype.dispose = function () {
  44770. if (this._meshes) {
  44771. // Clean mesh references
  44772. for (var id in this._meshes) {
  44773. var meshHighlight = this._meshes[id];
  44774. if (meshHighlight && meshHighlight.mesh) {
  44775. if (meshHighlight.observerHighlight) {
  44776. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  44777. }
  44778. if (meshHighlight.observerDefault) {
  44779. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  44780. }
  44781. }
  44782. }
  44783. this._meshes = null;
  44784. }
  44785. if (this._excludedMeshes) {
  44786. for (var id in this._excludedMeshes) {
  44787. var meshHighlight = this._excludedMeshes[id];
  44788. if (meshHighlight) {
  44789. if (meshHighlight.beforeBind) {
  44790. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  44791. }
  44792. if (meshHighlight.afterRender) {
  44793. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  44794. }
  44795. }
  44796. }
  44797. this._excludedMeshes = null;
  44798. }
  44799. _super.prototype.dispose.call(this);
  44800. };
  44801. /**
  44802. * Gets the class name of the effect layer
  44803. * @returns the string with the class name of the effect layer
  44804. */
  44805. HighlightLayer.prototype.getClassName = function () {
  44806. return "HighlightLayer";
  44807. };
  44808. /**
  44809. * Serializes this Highlight layer
  44810. * @returns a serialized Highlight layer object
  44811. */
  44812. HighlightLayer.prototype.serialize = function () {
  44813. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  44814. serializationObject.customType = "BABYLON.HighlightLayer";
  44815. // Highlighted meshes
  44816. serializationObject.meshes = [];
  44817. if (this._meshes) {
  44818. for (var m in this._meshes) {
  44819. var mesh = this._meshes[m];
  44820. if (mesh) {
  44821. serializationObject.meshes.push({
  44822. glowEmissiveOnly: mesh.glowEmissiveOnly,
  44823. color: mesh.color.asArray(),
  44824. meshId: mesh.mesh.id
  44825. });
  44826. }
  44827. }
  44828. }
  44829. // Excluded meshes
  44830. serializationObject.excludedMeshes = [];
  44831. if (this._excludedMeshes) {
  44832. for (var e in this._excludedMeshes) {
  44833. var excludedMesh = this._excludedMeshes[e];
  44834. if (excludedMesh) {
  44835. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  44836. }
  44837. }
  44838. }
  44839. return serializationObject;
  44840. };
  44841. /**
  44842. * Creates a Highlight layer from parsed Highlight layer data
  44843. * @param parsedHightlightLayer defines the Highlight layer data
  44844. * @param scene defines the current scene
  44845. * @param rootUrl defines the root URL containing the Highlight layer information
  44846. * @returns a parsed Highlight layer
  44847. */
  44848. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  44849. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  44850. var index;
  44851. // Excluded meshes
  44852. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  44853. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  44854. if (mesh) {
  44855. hl.addExcludedMesh(mesh);
  44856. }
  44857. }
  44858. // Included meshes
  44859. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  44860. var highlightedMesh = parsedHightlightLayer.meshes[index];
  44861. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  44862. if (mesh) {
  44863. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  44864. }
  44865. }
  44866. return hl;
  44867. };
  44868. /**
  44869. * Effect Name of the highlight layer.
  44870. */
  44871. HighlightLayer.EffectName = "HighlightLayer";
  44872. /**
  44873. * The neutral color used during the preparation of the glow effect.
  44874. * This is black by default as the blend operation is a blend operation.
  44875. */
  44876. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  44877. /**
  44878. * Stencil value used for glowing meshes.
  44879. */
  44880. HighlightLayer.GlowingMeshStencilReference = 0x02;
  44881. /**
  44882. * Stencil value used for the other meshes in the scene.
  44883. */
  44884. HighlightLayer.NormalMeshStencilReference = 0x01;
  44885. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  44886. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  44887. ], HighlightLayer.prototype, "innerGlow", void 0);
  44888. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  44889. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  44890. ], HighlightLayer.prototype, "outerGlow", void 0);
  44891. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  44892. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  44893. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  44894. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  44895. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  44896. ], HighlightLayer.prototype, "blurVerticalSize", null);
  44897. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  44898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  44899. ], HighlightLayer.prototype, "_options", void 0);
  44900. return HighlightLayer;
  44901. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  44902. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  44903. /***/ }),
  44904. /***/ "./Layers/index.ts":
  44905. /*!*************************!*\
  44906. !*** ./Layers/index.ts ***!
  44907. \*************************/
  44908. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  44909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44910. "use strict";
  44911. __webpack_require__.r(__webpack_exports__);
  44912. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  44913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  44914. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  44915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  44916. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  44917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  44918. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  44919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  44920. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  44921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  44922. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  44923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  44924. /***/ }),
  44925. /***/ "./Layers/layer.ts":
  44926. /*!*************************!*\
  44927. !*** ./Layers/layer.ts ***!
  44928. \*************************/
  44929. /*! exports provided: Layer */
  44930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44931. "use strict";
  44932. __webpack_require__.r(__webpack_exports__);
  44933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  44934. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  44935. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44936. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  44937. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  44938. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  44939. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44940. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  44941. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  44942. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44943. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  44944. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  44945. /**
  44946. * This represents a full screen 2d layer.
  44947. * This can be useful to display a picture in the background of your scene for instance.
  44948. * @see https://www.babylonjs-playground.com/#08A2BS#1
  44949. */
  44950. var Layer = /** @class */ (function () {
  44951. /**
  44952. * Instantiates a new layer.
  44953. * This represents a full screen 2d layer.
  44954. * This can be useful to display a picture in the background of your scene for instance.
  44955. * @see https://www.babylonjs-playground.com/#08A2BS#1
  44956. * @param name Define the name of the layer in the scene
  44957. * @param imgUrl Define the url of the texture to display in the layer
  44958. * @param scene Define the scene the layer belongs to
  44959. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  44960. * @param color Defines a color for the layer
  44961. */
  44962. function Layer(
  44963. /**
  44964. * Define the name of the layer.
  44965. */
  44966. name, imgUrl, scene, isBackground, color) {
  44967. this.name = name;
  44968. /**
  44969. * Define the scale of the layer in order to zoom in out of the texture.
  44970. */
  44971. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  44972. /**
  44973. * Define an offset for the layer in order to shift the texture.
  44974. */
  44975. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  44976. /**
  44977. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  44978. */
  44979. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  44980. /**
  44981. * Define a mask to restrict the layer to only some of the scene cameras.
  44982. */
  44983. this.layerMask = 0x0FFFFFFF;
  44984. /**
  44985. * Define the list of render target the layer is visible into.
  44986. */
  44987. this.renderTargetTextures = [];
  44988. /**
  44989. * Define if the layer is only used in renderTarget or if it also
  44990. * renders in the main frame buffer of the canvas.
  44991. */
  44992. this.renderOnlyInRenderTargetTextures = false;
  44993. this._vertexBuffers = {};
  44994. /**
  44995. * An event triggered when the layer is disposed.
  44996. */
  44997. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  44998. /**
  44999. * An event triggered before rendering the scene
  45000. */
  45001. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  45002. /**
  45003. * An event triggered after rendering the scene
  45004. */
  45005. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  45006. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  45007. this.isBackground = isBackground === undefined ? true : isBackground;
  45008. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  45009. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  45010. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  45011. if (!layerComponent) {
  45012. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  45013. this._scene._addComponent(layerComponent);
  45014. }
  45015. this._scene.layers.push(this);
  45016. var engine = this._scene.getEngine();
  45017. // VBO
  45018. var vertices = [];
  45019. vertices.push(1, 1);
  45020. vertices.push(-1, 1);
  45021. vertices.push(-1, -1);
  45022. vertices.push(1, -1);
  45023. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  45024. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  45025. this._createIndexBuffer();
  45026. // Effects
  45027. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  45028. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  45029. }
  45030. Object.defineProperty(Layer.prototype, "onDispose", {
  45031. /**
  45032. * Back compatibility with callback before the onDisposeObservable existed.
  45033. * The set callback will be triggered when the layer has been disposed.
  45034. */
  45035. set: function (callback) {
  45036. if (this._onDisposeObserver) {
  45037. this.onDisposeObservable.remove(this._onDisposeObserver);
  45038. }
  45039. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  45040. },
  45041. enumerable: true,
  45042. configurable: true
  45043. });
  45044. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  45045. /**
  45046. * Back compatibility with callback before the onBeforeRenderObservable existed.
  45047. * The set callback will be triggered just before rendering the layer.
  45048. */
  45049. set: function (callback) {
  45050. if (this._onBeforeRenderObserver) {
  45051. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  45052. }
  45053. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  45054. },
  45055. enumerable: true,
  45056. configurable: true
  45057. });
  45058. Object.defineProperty(Layer.prototype, "onAfterRender", {
  45059. /**
  45060. * Back compatibility with callback before the onAfterRenderObservable existed.
  45061. * The set callback will be triggered just after rendering the layer.
  45062. */
  45063. set: function (callback) {
  45064. if (this._onAfterRenderObserver) {
  45065. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  45066. }
  45067. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  45068. },
  45069. enumerable: true,
  45070. configurable: true
  45071. });
  45072. Layer.prototype._createIndexBuffer = function () {
  45073. var engine = this._scene.getEngine();
  45074. // Indices
  45075. var indices = [];
  45076. indices.push(0);
  45077. indices.push(1);
  45078. indices.push(2);
  45079. indices.push(0);
  45080. indices.push(2);
  45081. indices.push(3);
  45082. this._indexBuffer = engine.createIndexBuffer(indices);
  45083. };
  45084. /** @hidden */
  45085. Layer.prototype._rebuild = function () {
  45086. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  45087. if (vb) {
  45088. vb._rebuild();
  45089. }
  45090. this._createIndexBuffer();
  45091. };
  45092. /**
  45093. * Renders the layer in the scene.
  45094. */
  45095. Layer.prototype.render = function () {
  45096. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  45097. // Check
  45098. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  45099. return;
  45100. }
  45101. var engine = this._scene.getEngine();
  45102. this.onBeforeRenderObservable.notifyObservers(this);
  45103. // Render
  45104. engine.enableEffect(currentEffect);
  45105. engine.setState(false);
  45106. // Texture
  45107. currentEffect.setTexture("textureSampler", this.texture);
  45108. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  45109. // Color
  45110. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  45111. // Scale / offset
  45112. currentEffect.setVector2("offset", this.offset);
  45113. currentEffect.setVector2("scale", this.scale);
  45114. // VBOs
  45115. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  45116. // Draw order
  45117. if (!this.alphaTest) {
  45118. engine.setAlphaMode(this.alphaBlendingMode);
  45119. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  45120. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  45121. }
  45122. else {
  45123. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  45124. }
  45125. this.onAfterRenderObservable.notifyObservers(this);
  45126. };
  45127. /**
  45128. * Disposes and releases the associated ressources.
  45129. */
  45130. Layer.prototype.dispose = function () {
  45131. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  45132. if (vertexBuffer) {
  45133. vertexBuffer.dispose();
  45134. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  45135. }
  45136. if (this._indexBuffer) {
  45137. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  45138. this._indexBuffer = null;
  45139. }
  45140. if (this.texture) {
  45141. this.texture.dispose();
  45142. this.texture = null;
  45143. }
  45144. // Clean RTT list
  45145. this.renderTargetTextures = [];
  45146. // Remove from scene
  45147. var index = this._scene.layers.indexOf(this);
  45148. this._scene.layers.splice(index, 1);
  45149. // Callback
  45150. this.onDisposeObservable.notifyObservers(this);
  45151. this.onDisposeObservable.clear();
  45152. this.onAfterRenderObservable.clear();
  45153. this.onBeforeRenderObservable.clear();
  45154. };
  45155. return Layer;
  45156. }());
  45157. /***/ }),
  45158. /***/ "./Layers/layerSceneComponent.ts":
  45159. /*!***************************************!*\
  45160. !*** ./Layers/layerSceneComponent.ts ***!
  45161. \***************************************/
  45162. /*! exports provided: LayerSceneComponent */
  45163. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45164. "use strict";
  45165. __webpack_require__.r(__webpack_exports__);
  45166. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  45167. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  45168. /**
  45169. * Defines the layer scene component responsible to manage any layers
  45170. * in a given scene.
  45171. */
  45172. var LayerSceneComponent = /** @class */ (function () {
  45173. /**
  45174. * Creates a new instance of the component for the given scene
  45175. * @param scene Defines the scene to register the component in
  45176. */
  45177. function LayerSceneComponent(scene) {
  45178. /**
  45179. * The component name helpfull to identify the component in the list of scene components.
  45180. */
  45181. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  45182. this.scene = scene;
  45183. this._engine = scene.getEngine();
  45184. scene.layers = new Array();
  45185. }
  45186. /**
  45187. * Registers the component in a given scene
  45188. */
  45189. LayerSceneComponent.prototype.register = function () {
  45190. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  45191. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  45192. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  45193. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  45194. };
  45195. /**
  45196. * Rebuilds the elements related to this component in case of
  45197. * context lost for instance.
  45198. */
  45199. LayerSceneComponent.prototype.rebuild = function () {
  45200. var layers = this.scene.layers;
  45201. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  45202. var layer = layers_1[_i];
  45203. layer._rebuild();
  45204. }
  45205. };
  45206. /**
  45207. * Disposes the component and the associated ressources.
  45208. */
  45209. LayerSceneComponent.prototype.dispose = function () {
  45210. var layers = this.scene.layers;
  45211. while (layers.length) {
  45212. layers[0].dispose();
  45213. }
  45214. };
  45215. LayerSceneComponent.prototype._draw = function (predicate) {
  45216. var layers = this.scene.layers;
  45217. if (layers.length) {
  45218. this._engine.setDepthBuffer(false);
  45219. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  45220. var layer = layers_2[_i];
  45221. if (predicate(layer)) {
  45222. layer.render();
  45223. }
  45224. }
  45225. this._engine.setDepthBuffer(true);
  45226. }
  45227. };
  45228. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  45229. return !layer.renderOnlyInRenderTargetTextures &&
  45230. layer.isBackground === isBackground &&
  45231. ((layer.layerMask & cameraLayerMask) !== 0);
  45232. };
  45233. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  45234. var _this = this;
  45235. this._draw(function (layer) {
  45236. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  45237. });
  45238. };
  45239. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  45240. var _this = this;
  45241. this._draw(function (layer) {
  45242. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  45243. });
  45244. };
  45245. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  45246. return (layer.renderTargetTextures.length > 0) &&
  45247. layer.isBackground === isBackground &&
  45248. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  45249. ((layer.layerMask & cameraLayerMask) !== 0);
  45250. };
  45251. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  45252. var _this = this;
  45253. this._draw(function (layer) {
  45254. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  45255. });
  45256. };
  45257. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  45258. var _this = this;
  45259. this._draw(function (layer) {
  45260. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  45261. });
  45262. };
  45263. return LayerSceneComponent;
  45264. }());
  45265. /***/ }),
  45266. /***/ "./Legacy/legacy.ts":
  45267. /*!**************************!*\
  45268. !*** ./Legacy/legacy.ts ***!
  45269. \**************************/
  45270. /*! 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, AutoRotationBehavior, BouncingBehavior, FramingBehavior, PointerDragBehavior, 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, _MeshCollisionData, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, WebGLPipelineContext, 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, 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, SphericalHarmonics, SphericalPolynomial, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, MeshLODLevel, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DataBuffer, WebGLDataBuffer, 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, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, 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, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, HtmlElementTexture, 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 */
  45271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45272. "use strict";
  45273. __webpack_require__.r(__webpack_exports__);
  45274. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return Debug; });
  45275. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  45276. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  45277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  45278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  45279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  45280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  45281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  45282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  45283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  45284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  45285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  45286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  45287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  45288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  45289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  45290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  45291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  45292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  45293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  45294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  45295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  45296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  45297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  45298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  45299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  45300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  45301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  45302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  45303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  45304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  45305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IAnimationState"]; });
  45306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  45307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  45308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  45309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  45310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  45311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  45312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  45313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  45314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  45315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  45316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  45317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  45318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  45319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  45320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  45321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  45322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  45323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  45324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  45325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  45326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  45327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  45328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  45329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  45330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  45331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  45332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  45333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  45334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  45335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  45336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  45337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  45338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  45339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  45340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  45341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  45342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  45343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  45344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  45345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  45346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  45347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  45348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  45349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  45350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  45351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  45352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  45353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  45354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  45355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  45356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  45357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  45358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  45359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  45360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  45361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  45362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_MeshCollisionData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_MeshCollisionData"]; });
  45363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  45364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  45365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  45366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  45367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  45368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  45369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  45370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  45371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  45372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  45373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  45374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  45375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  45376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  45377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  45378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  45379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  45380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  45381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGLPipelineContext", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebGLPipelineContext"]; });
  45382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  45383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  45384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  45385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  45386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  45387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  45388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  45389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  45390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  45391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  45392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  45393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  45394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  45395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  45396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  45397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  45398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  45399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  45400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  45401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  45402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  45403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  45404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  45405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  45406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  45407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  45408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  45409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  45410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  45411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  45412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  45413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  45414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  45415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  45416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  45417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  45418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightGizmo"]; });
  45419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  45420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  45421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  45422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  45423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  45424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  45425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  45426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  45427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  45428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  45429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  45430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  45431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  45432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  45433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  45434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  45435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  45436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  45437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  45438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  45439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  45440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  45441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  45442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  45443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  45444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  45445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  45446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  45447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  45448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  45449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  45450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  45451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  45452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  45453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  45454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  45455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  45456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  45457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  45458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  45459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  45460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  45461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  45462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EquiRectangularCubeTexture"]; });
  45463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  45464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  45465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  45466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  45467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  45468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  45469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  45470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  45471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  45472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  45473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  45474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  45475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  45476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  45477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  45478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  45479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  45480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  45481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  45482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  45483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  45484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  45485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  45486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  45487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  45488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  45489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  45490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  45491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  45492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  45493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  45494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  45495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  45496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  45497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  45498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  45499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  45500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  45501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  45502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  45503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  45504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  45505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  45506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TrailMesh"]; });
  45507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  45508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  45509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  45510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  45511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  45512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  45513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  45514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  45515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  45516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  45517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  45518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  45519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  45520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  45521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  45522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  45523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  45524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  45525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  45526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  45527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  45528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  45529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  45530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DataBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DataBuffer"]; });
  45531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGLDataBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebGLDataBuffer"]; });
  45532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  45533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  45534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  45535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  45536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  45537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  45538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  45539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  45540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  45541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  45542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  45543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  45544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  45545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  45546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  45547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  45548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  45549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  45550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  45551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEventOptions"]; });
  45552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEventOptions"]; });
  45553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEventOptions"]; });
  45554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  45555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  45556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  45557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  45558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  45559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  45560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  45561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  45562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  45563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  45564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  45565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  45566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  45567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  45568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  45569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  45570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  45571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  45572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  45573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  45574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  45575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  45576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  45577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  45578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  45579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  45580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  45581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  45582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  45583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  45584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  45585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  45586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  45587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  45588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  45589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  45590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  45591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  45592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  45593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  45594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  45595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRMultiviewToSingleviewPostProcess"]; });
  45596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  45597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  45598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  45599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  45600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  45601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  45602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  45603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  45604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  45605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  45606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  45607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  45608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  45609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  45610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  45611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  45612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  45613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  45614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  45615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  45616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  45617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  45618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  45619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  45620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  45621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  45622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  45623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  45624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  45625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  45626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EquiRectangularCubeTextureAssetTask"]; });
  45627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  45628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  45629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  45630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  45631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  45632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  45633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  45634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  45635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  45636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  45637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  45638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  45639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  45640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  45641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMatrix"]; });
  45642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  45643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  45644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  45645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  45646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshExploder"]; });
  45647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  45648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  45649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  45650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  45651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  45652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  45653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  45654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  45655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  45656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  45657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  45658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  45659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  45660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  45661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  45662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  45663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  45664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  45665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  45666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  45667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  45668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  45669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  45670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  45671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  45672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  45673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  45674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  45675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  45676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  45677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  45678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  45679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  45680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  45681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  45682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  45683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  45684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  45685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  45686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  45687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  45688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  45689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  45690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  45691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  45692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  45693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  45694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  45695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebRequest"]; });
  45696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InspectableType"]; });
  45697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  45698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  45699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  45700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  45701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  45702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  45703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  45704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  45705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  45706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  45707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  45708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  45709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  45710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  45711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  45712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  45713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  45714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  45715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  45716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  45717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  45718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  45719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  45720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  45721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  45722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  45723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  45724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  45725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  45726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  45727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  45728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  45729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OnAfterEnteringVRObservableEvent"]; });
  45730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  45731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  45732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  45733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  45734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  45735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  45736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  45737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  45738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  45739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  45740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  45741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  45742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  45743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  45744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  45745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  45746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  45747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  45748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  45749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  45750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  45751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterialDefines"]; });
  45752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  45753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  45754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  45755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  45756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  45757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  45758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  45759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  45760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  45761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  45762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  45763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  45764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  45765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HtmlElementTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HtmlElementTexture"]; });
  45766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  45767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  45768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  45769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphereBuilder"]; });
  45770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  45771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  45772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  45773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  45774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  45775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  45776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  45777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  45778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  45779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  45780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  45781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  45782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  45783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  45784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  45785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  45786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  45787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  45788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  45789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  45790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  45791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  45792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  45793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  45794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  45795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  45796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  45797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  45798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  45799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  45800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  45801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  45802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  45803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  45804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  45805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  45806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  45807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  45808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  45809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  45810. /**
  45811. * Legacy support, defining window.BABYLON (global variable).
  45812. *
  45813. * This is the entry point for the UMD module.
  45814. * The entry point for a future ESM package should be index.ts
  45815. */
  45816. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  45817. if (typeof globalObject !== "undefined") {
  45818. globalObject.BABYLON = BABYLON;
  45819. globalObject.BABYLON = globalObject.BABYLON || {};
  45820. var BABYLON = globalObject.BABYLON;
  45821. BABYLON.Debug = BABYLON.Debug || {};
  45822. var keys = [];
  45823. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  45824. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  45825. keys.push(key);
  45826. }
  45827. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  45828. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  45829. }
  45830. }
  45831. var Debug = {
  45832. AxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"],
  45833. BoneAxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"],
  45834. PhysicsViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["PhysicsViewer"],
  45835. SkeletonViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["SkeletonViewer"],
  45836. };
  45837. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  45838. /***/ }),
  45839. /***/ "./LensFlares/index.ts":
  45840. /*!*****************************!*\
  45841. !*** ./LensFlares/index.ts ***!
  45842. \*****************************/
  45843. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  45844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45845. "use strict";
  45846. __webpack_require__.r(__webpack_exports__);
  45847. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  45848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  45849. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  45850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  45851. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  45852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  45853. /***/ }),
  45854. /***/ "./LensFlares/lensFlare.ts":
  45855. /*!*********************************!*\
  45856. !*** ./LensFlares/lensFlare.ts ***!
  45857. \*********************************/
  45858. /*! exports provided: LensFlare */
  45859. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45860. "use strict";
  45861. __webpack_require__.r(__webpack_exports__);
  45862. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  45863. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45864. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  45865. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  45866. /**
  45867. * This represents one of the lens effect in a `lensFlareSystem`.
  45868. * It controls one of the indiviual texture used in the effect.
  45869. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45870. */
  45871. var LensFlare = /** @class */ (function () {
  45872. /**
  45873. * Instantiates a new Lens Flare.
  45874. * This represents one of the lens effect in a `lensFlareSystem`.
  45875. * It controls one of the indiviual texture used in the effect.
  45876. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45877. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  45878. * @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.
  45879. * @param color Define the lens color
  45880. * @param imgUrl Define the lens texture url
  45881. * @param system Define the `lensFlareSystem` this flare is part of
  45882. */
  45883. function LensFlare(
  45884. /**
  45885. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  45886. */
  45887. size,
  45888. /**
  45889. * 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.
  45890. */
  45891. position, color, imgUrl, system) {
  45892. this.size = size;
  45893. this.position = position;
  45894. /**
  45895. * Define the alpha mode to render this particular lens.
  45896. */
  45897. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  45898. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  45899. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  45900. this._system = system;
  45901. system.lensFlares.push(this);
  45902. }
  45903. /**
  45904. * Creates a new Lens Flare.
  45905. * This represents one of the lens effect in a `lensFlareSystem`.
  45906. * It controls one of the indiviual texture used in the effect.
  45907. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45908. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  45909. * @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.
  45910. * @param color Define the lens color
  45911. * @param imgUrl Define the lens texture url
  45912. * @param system Define the `lensFlareSystem` this flare is part of
  45913. * @returns The newly created Lens Flare
  45914. */
  45915. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  45916. return new LensFlare(size, position, color, imgUrl, system);
  45917. };
  45918. /**
  45919. * Dispose and release the lens flare with its associated resources.
  45920. */
  45921. LensFlare.prototype.dispose = function () {
  45922. if (this.texture) {
  45923. this.texture.dispose();
  45924. }
  45925. // Remove from scene
  45926. var index = this._system.lensFlares.indexOf(this);
  45927. this._system.lensFlares.splice(index, 1);
  45928. };
  45929. return LensFlare;
  45930. }());
  45931. /***/ }),
  45932. /***/ "./LensFlares/lensFlareSystem.ts":
  45933. /*!***************************************!*\
  45934. !*** ./LensFlares/lensFlareSystem.ts ***!
  45935. \***************************************/
  45936. /*! exports provided: LensFlareSystem */
  45937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45938. "use strict";
  45939. __webpack_require__.r(__webpack_exports__);
  45940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  45941. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  45942. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45943. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  45944. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  45945. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  45946. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  45947. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  45948. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  45949. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  45950. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  45951. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  45952. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  45953. /**
  45954. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  45955. * It is usually composed of several `lensFlare`.
  45956. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45957. */
  45958. var LensFlareSystem = /** @class */ (function () {
  45959. /**
  45960. * Instantiates a lens flare system.
  45961. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  45962. * It is usually composed of several `lensFlare`.
  45963. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45964. * @param name Define the name of the lens flare system in the scene
  45965. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  45966. * @param scene Define the scene the lens flare system belongs to
  45967. */
  45968. function LensFlareSystem(
  45969. /**
  45970. * Define the name of the lens flare system
  45971. */
  45972. name, emitter, scene) {
  45973. this.name = name;
  45974. /**
  45975. * List of lens flares used in this system.
  45976. */
  45977. this.lensFlares = new Array();
  45978. /**
  45979. * Define a limit from the border the lens flare can be visible.
  45980. */
  45981. this.borderLimit = 300;
  45982. /**
  45983. * Define a viewport border we do not want to see the lens flare in.
  45984. */
  45985. this.viewportBorder = 0;
  45986. /**
  45987. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  45988. */
  45989. this.layerMask = 0x0FFFFFFF;
  45990. this._vertexBuffers = {};
  45991. this._isEnabled = true;
  45992. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  45993. LensFlareSystem._SceneComponentInitialization(this._scene);
  45994. this._emitter = emitter;
  45995. this.id = name;
  45996. scene.lensFlareSystems.push(this);
  45997. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  45998. var engine = scene.getEngine();
  45999. // VBO
  46000. var vertices = [];
  46001. vertices.push(1, 1);
  46002. vertices.push(-1, 1);
  46003. vertices.push(-1, -1);
  46004. vertices.push(1, -1);
  46005. 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);
  46006. // Indices
  46007. var indices = [];
  46008. indices.push(0);
  46009. indices.push(1);
  46010. indices.push(2);
  46011. indices.push(0);
  46012. indices.push(2);
  46013. indices.push(3);
  46014. this._indexBuffer = engine.createIndexBuffer(indices);
  46015. // Effects
  46016. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  46017. }
  46018. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  46019. /**
  46020. * Define if the lens flare system is enabled.
  46021. */
  46022. get: function () {
  46023. return this._isEnabled;
  46024. },
  46025. set: function (value) {
  46026. this._isEnabled = value;
  46027. },
  46028. enumerable: true,
  46029. configurable: true
  46030. });
  46031. /**
  46032. * Get the scene the effects belongs to.
  46033. * @returns the scene holding the lens flare system
  46034. */
  46035. LensFlareSystem.prototype.getScene = function () {
  46036. return this._scene;
  46037. };
  46038. /**
  46039. * Get the emitter of the lens flare system.
  46040. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46041. * @returns the emitter of the lens flare system
  46042. */
  46043. LensFlareSystem.prototype.getEmitter = function () {
  46044. return this._emitter;
  46045. };
  46046. /**
  46047. * Set the emitter of the lens flare system.
  46048. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46049. * @param newEmitter Define the new emitter of the system
  46050. */
  46051. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  46052. this._emitter = newEmitter;
  46053. };
  46054. /**
  46055. * Get the lens flare system emitter position.
  46056. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46057. * @returns the position
  46058. */
  46059. LensFlareSystem.prototype.getEmitterPosition = function () {
  46060. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  46061. };
  46062. /**
  46063. * @hidden
  46064. */
  46065. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  46066. var position = this.getEmitterPosition();
  46067. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  46068. this._positionX = position.x;
  46069. this._positionY = position.y;
  46070. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  46071. if (this.viewportBorder > 0) {
  46072. globalViewport.x -= this.viewportBorder;
  46073. globalViewport.y -= this.viewportBorder;
  46074. globalViewport.width += this.viewportBorder * 2;
  46075. globalViewport.height += this.viewportBorder * 2;
  46076. position.x += this.viewportBorder;
  46077. position.y += this.viewportBorder;
  46078. this._positionX += this.viewportBorder;
  46079. this._positionY += this.viewportBorder;
  46080. }
  46081. if (position.z > 0) {
  46082. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  46083. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  46084. return true;
  46085. }
  46086. }
  46087. return true;
  46088. }
  46089. return false;
  46090. };
  46091. /** @hidden */
  46092. LensFlareSystem.prototype._isVisible = function () {
  46093. if (!this._isEnabled || !this._scene.activeCamera) {
  46094. return false;
  46095. }
  46096. var emitterPosition = this.getEmitterPosition();
  46097. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  46098. var distance = direction.length();
  46099. direction.normalize();
  46100. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  46101. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  46102. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  46103. };
  46104. /**
  46105. * @hidden
  46106. */
  46107. LensFlareSystem.prototype.render = function () {
  46108. if (!this._effect.isReady() || !this._scene.activeCamera) {
  46109. return false;
  46110. }
  46111. var engine = this._scene.getEngine();
  46112. var viewport = this._scene.activeCamera.viewport;
  46113. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  46114. // Position
  46115. if (!this.computeEffectivePosition(globalViewport)) {
  46116. return false;
  46117. }
  46118. // Visibility
  46119. if (!this._isVisible()) {
  46120. return false;
  46121. }
  46122. // Intensity
  46123. var awayX;
  46124. var awayY;
  46125. if (this._positionX < this.borderLimit + globalViewport.x) {
  46126. awayX = this.borderLimit + globalViewport.x - this._positionX;
  46127. }
  46128. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  46129. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  46130. }
  46131. else {
  46132. awayX = 0;
  46133. }
  46134. if (this._positionY < this.borderLimit + globalViewport.y) {
  46135. awayY = this.borderLimit + globalViewport.y - this._positionY;
  46136. }
  46137. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  46138. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  46139. }
  46140. else {
  46141. awayY = 0;
  46142. }
  46143. var away = (awayX > awayY) ? awayX : awayY;
  46144. away -= this.viewportBorder;
  46145. if (away > this.borderLimit) {
  46146. away = this.borderLimit;
  46147. }
  46148. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  46149. if (intensity < 0) {
  46150. return false;
  46151. }
  46152. if (intensity > 1.0) {
  46153. intensity = 1.0;
  46154. }
  46155. if (this.viewportBorder > 0) {
  46156. globalViewport.x += this.viewportBorder;
  46157. globalViewport.y += this.viewportBorder;
  46158. globalViewport.width -= this.viewportBorder * 2;
  46159. globalViewport.height -= this.viewportBorder * 2;
  46160. this._positionX -= this.viewportBorder;
  46161. this._positionY -= this.viewportBorder;
  46162. }
  46163. // Position
  46164. var centerX = globalViewport.x + globalViewport.width / 2;
  46165. var centerY = globalViewport.y + globalViewport.height / 2;
  46166. var distX = centerX - this._positionX;
  46167. var distY = centerY - this._positionY;
  46168. // Effects
  46169. engine.enableEffect(this._effect);
  46170. engine.setState(false);
  46171. engine.setDepthBuffer(false);
  46172. // VBOs
  46173. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  46174. // Flares
  46175. for (var index = 0; index < this.lensFlares.length; index++) {
  46176. var flare = this.lensFlares[index];
  46177. engine.setAlphaMode(flare.alphaMode);
  46178. var x = centerX - (distX * flare.position);
  46179. var y = centerY - (distY * flare.position);
  46180. var cw = flare.size;
  46181. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  46182. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  46183. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  46184. 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);
  46185. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  46186. // Texture
  46187. this._effect.setTexture("textureSampler", flare.texture);
  46188. // Color
  46189. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  46190. // Draw order
  46191. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  46192. }
  46193. engine.setDepthBuffer(true);
  46194. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  46195. return true;
  46196. };
  46197. /**
  46198. * Dispose and release the lens flare with its associated resources.
  46199. */
  46200. LensFlareSystem.prototype.dispose = function () {
  46201. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  46202. if (vertexBuffer) {
  46203. vertexBuffer.dispose();
  46204. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  46205. }
  46206. if (this._indexBuffer) {
  46207. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  46208. this._indexBuffer = null;
  46209. }
  46210. while (this.lensFlares.length) {
  46211. this.lensFlares[0].dispose();
  46212. }
  46213. // Remove from scene
  46214. var index = this._scene.lensFlareSystems.indexOf(this);
  46215. this._scene.lensFlareSystems.splice(index, 1);
  46216. };
  46217. /**
  46218. * Parse a lens flare system from a JSON repressentation
  46219. * @param parsedLensFlareSystem Define the JSON to parse
  46220. * @param scene Define the scene the parsed system should be instantiated in
  46221. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46222. * @returns the parsed system
  46223. */
  46224. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  46225. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  46226. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  46227. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  46228. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  46229. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  46230. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  46231. var parsedFlare = parsedLensFlareSystem.flares[index];
  46232. _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);
  46233. }
  46234. return lensFlareSystem;
  46235. };
  46236. /**
  46237. * Serialize the current Lens Flare System into a JSON representation.
  46238. * @returns the serialized JSON
  46239. */
  46240. LensFlareSystem.prototype.serialize = function () {
  46241. var serializationObject = {};
  46242. serializationObject.id = this.id;
  46243. serializationObject.name = this.name;
  46244. serializationObject.emitterId = this.getEmitter().id;
  46245. serializationObject.borderLimit = this.borderLimit;
  46246. serializationObject.flares = [];
  46247. for (var index = 0; index < this.lensFlares.length; index++) {
  46248. var flare = this.lensFlares[index];
  46249. serializationObject.flares.push({
  46250. size: flare.size,
  46251. position: flare.position,
  46252. color: flare.color.asArray(),
  46253. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  46254. });
  46255. }
  46256. return serializationObject;
  46257. };
  46258. /** @hidden */
  46259. LensFlareSystem._SceneComponentInitialization = function (_) {
  46260. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  46261. };
  46262. return LensFlareSystem;
  46263. }());
  46264. /***/ }),
  46265. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  46266. /*!*****************************************************!*\
  46267. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  46268. \*****************************************************/
  46269. /*! exports provided: LensFlareSystemSceneComponent */
  46270. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46271. "use strict";
  46272. __webpack_require__.r(__webpack_exports__);
  46273. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  46274. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  46275. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  46276. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  46277. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  46278. // Adds the parser to the scene parsers.
  46279. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  46280. // Lens flares
  46281. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  46282. if (!container.lensFlareSystems) {
  46283. container.lensFlareSystems = new Array();
  46284. }
  46285. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  46286. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  46287. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  46288. container.lensFlareSystems.push(lf);
  46289. }
  46290. }
  46291. });
  46292. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  46293. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  46294. if (this.lensFlareSystems[index].name === name) {
  46295. return this.lensFlareSystems[index];
  46296. }
  46297. }
  46298. return null;
  46299. };
  46300. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  46301. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  46302. if (this.lensFlareSystems[index].id === id) {
  46303. return this.lensFlareSystems[index];
  46304. }
  46305. }
  46306. return null;
  46307. };
  46308. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  46309. var index = this.lensFlareSystems.indexOf(toRemove);
  46310. if (index !== -1) {
  46311. this.lensFlareSystems.splice(index, 1);
  46312. }
  46313. return index;
  46314. };
  46315. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  46316. this.lensFlareSystems.push(newLensFlareSystem);
  46317. };
  46318. /**
  46319. * Defines the lens flare scene component responsible to manage any lens flares
  46320. * in a given scene.
  46321. */
  46322. var LensFlareSystemSceneComponent = /** @class */ (function () {
  46323. /**
  46324. * Creates a new instance of the component for the given scene
  46325. * @param scene Defines the scene to register the component in
  46326. */
  46327. function LensFlareSystemSceneComponent(scene) {
  46328. /**
  46329. * The component name helpfull to identify the component in the list of scene components.
  46330. */
  46331. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  46332. this.scene = scene;
  46333. scene.lensFlareSystems = new Array();
  46334. }
  46335. /**
  46336. * Registers the component in a given scene
  46337. */
  46338. LensFlareSystemSceneComponent.prototype.register = function () {
  46339. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  46340. };
  46341. /**
  46342. * Rebuilds the elements related to this component in case of
  46343. * context lost for instance.
  46344. */
  46345. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  46346. // Nothing to do for lens flare
  46347. };
  46348. /**
  46349. * Adds all the element from the container to the scene
  46350. * @param container the container holding the elements
  46351. */
  46352. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  46353. var _this = this;
  46354. if (!container.lensFlareSystems) {
  46355. return;
  46356. }
  46357. container.lensFlareSystems.forEach(function (o) {
  46358. _this.scene.addLensFlareSystem(o);
  46359. });
  46360. };
  46361. /**
  46362. * Removes all the elements in the container from the scene
  46363. * @param container contains the elements to remove
  46364. * @param dispose if the removed element should be disposed (default: false)
  46365. */
  46366. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  46367. var _this = this;
  46368. if (!container.lensFlareSystems) {
  46369. return;
  46370. }
  46371. container.lensFlareSystems.forEach(function (o) {
  46372. _this.scene.removeLensFlareSystem(o);
  46373. if (dispose) {
  46374. o.dispose();
  46375. }
  46376. });
  46377. };
  46378. /**
  46379. * Serializes the component data to the specified json object
  46380. * @param serializationObject The object to serialize to
  46381. */
  46382. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  46383. // Lens flares
  46384. serializationObject.lensFlareSystems = [];
  46385. var lensFlareSystems = this.scene.lensFlareSystems;
  46386. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  46387. var lensFlareSystem = lensFlareSystems_1[_i];
  46388. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  46389. }
  46390. };
  46391. /**
  46392. * Disposes the component and the associated ressources.
  46393. */
  46394. LensFlareSystemSceneComponent.prototype.dispose = function () {
  46395. var lensFlareSystems = this.scene.lensFlareSystems;
  46396. while (lensFlareSystems.length) {
  46397. lensFlareSystems[0].dispose();
  46398. }
  46399. };
  46400. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  46401. // Lens flares
  46402. if (this.scene.lensFlaresEnabled) {
  46403. var lensFlareSystems = this.scene.lensFlareSystems;
  46404. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  46405. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  46406. var lensFlareSystem = lensFlareSystems_2[_i];
  46407. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  46408. lensFlareSystem.render();
  46409. }
  46410. }
  46411. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  46412. }
  46413. };
  46414. return LensFlareSystemSceneComponent;
  46415. }());
  46416. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  46417. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  46418. if (!component) {
  46419. component = new LensFlareSystemSceneComponent(scene);
  46420. scene._addComponent(component);
  46421. }
  46422. };
  46423. /***/ }),
  46424. /***/ "./Lights/Shadows/index.ts":
  46425. /*!*********************************!*\
  46426. !*** ./Lights/Shadows/index.ts ***!
  46427. \*********************************/
  46428. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  46429. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46430. "use strict";
  46431. __webpack_require__.r(__webpack_exports__);
  46432. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  46433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  46434. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  46435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  46436. /***/ }),
  46437. /***/ "./Lights/Shadows/shadowGenerator.ts":
  46438. /*!*******************************************!*\
  46439. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  46440. \*******************************************/
  46441. /*! exports provided: ShadowGenerator */
  46442. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46443. "use strict";
  46444. __webpack_require__.r(__webpack_exports__);
  46445. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  46446. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46447. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  46448. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  46449. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  46450. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  46451. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  46452. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  46453. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  46454. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  46455. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  46456. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  46457. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  46458. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  46459. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  46460. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  46461. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  46462. /**
  46463. * Default implementation IShadowGenerator.
  46464. * This is the main object responsible of generating shadows in the framework.
  46465. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  46466. */
  46467. var ShadowGenerator = /** @class */ (function () {
  46468. /**
  46469. * Creates a ShadowGenerator object.
  46470. * A ShadowGenerator is the required tool to use the shadows.
  46471. * Each light casting shadows needs to use its own ShadowGenerator.
  46472. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  46473. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  46474. * @param light The light object generating the shadows.
  46475. * @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.
  46476. */
  46477. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  46478. /**
  46479. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  46480. */
  46481. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  46482. /**
  46483. * Observable triggered before a mesh is rendered in the shadow map.
  46484. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  46485. */
  46486. this.onBeforeShadowMapRenderMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  46487. this._bias = 0.00005;
  46488. this._normalBias = 0;
  46489. this._blurBoxOffset = 1;
  46490. this._blurScale = 2;
  46491. this._blurKernel = 1;
  46492. this._useKernelBlur = false;
  46493. this._filter = ShadowGenerator.FILTER_NONE;
  46494. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  46495. this._contactHardeningLightSizeUVRatio = 0.1;
  46496. this._darkness = 0;
  46497. this._transparencyShadow = false;
  46498. /**
  46499. * Controls the extent to which the shadows fade out at the edge of the frustum
  46500. * Used only by directionals and spots
  46501. */
  46502. this.frustumEdgeFalloff = 0;
  46503. /**
  46504. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  46505. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  46506. * It might on the other hand introduce peter panning.
  46507. */
  46508. this.forceBackFacesOnly = false;
  46509. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  46510. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  46511. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  46512. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  46513. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  46514. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  46515. this._currentFaceIndex = 0;
  46516. this._currentFaceIndexCache = 0;
  46517. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  46518. this._mapSize = mapSize;
  46519. this._light = light;
  46520. this._scene = light.getScene();
  46521. light._shadowGenerator = this;
  46522. ShadowGenerator._SceneComponentInitialization(this._scene);
  46523. // Texture type fallback from float to int if not supported.
  46524. var caps = this._scene.getEngine().getCaps();
  46525. if (!usefulFloatFirst) {
  46526. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  46527. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  46528. }
  46529. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  46530. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  46531. }
  46532. else {
  46533. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  46534. }
  46535. }
  46536. else {
  46537. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  46538. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  46539. }
  46540. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  46541. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  46542. }
  46543. else {
  46544. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  46545. }
  46546. }
  46547. this._initializeGenerator();
  46548. this._applyFilterValues();
  46549. }
  46550. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  46551. /**
  46552. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  46553. */
  46554. get: function () {
  46555. return this._bias;
  46556. },
  46557. /**
  46558. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  46559. */
  46560. set: function (bias) {
  46561. this._bias = bias;
  46562. },
  46563. enumerable: true,
  46564. configurable: true
  46565. });
  46566. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  46567. /**
  46568. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  46569. */
  46570. get: function () {
  46571. return this._normalBias;
  46572. },
  46573. /**
  46574. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  46575. */
  46576. set: function (normalBias) {
  46577. this._normalBias = normalBias;
  46578. },
  46579. enumerable: true,
  46580. configurable: true
  46581. });
  46582. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  46583. /**
  46584. * Gets the blur box offset: offset applied during the blur pass.
  46585. * Only useful if useKernelBlur = false
  46586. */
  46587. get: function () {
  46588. return this._blurBoxOffset;
  46589. },
  46590. /**
  46591. * Sets the blur box offset: offset applied during the blur pass.
  46592. * Only useful if useKernelBlur = false
  46593. */
  46594. set: function (value) {
  46595. if (this._blurBoxOffset === value) {
  46596. return;
  46597. }
  46598. this._blurBoxOffset = value;
  46599. this._disposeBlurPostProcesses();
  46600. },
  46601. enumerable: true,
  46602. configurable: true
  46603. });
  46604. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  46605. /**
  46606. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  46607. * 2 means half of the size.
  46608. */
  46609. get: function () {
  46610. return this._blurScale;
  46611. },
  46612. /**
  46613. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  46614. * 2 means half of the size.
  46615. */
  46616. set: function (value) {
  46617. if (this._blurScale === value) {
  46618. return;
  46619. }
  46620. this._blurScale = value;
  46621. this._disposeBlurPostProcesses();
  46622. },
  46623. enumerable: true,
  46624. configurable: true
  46625. });
  46626. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  46627. /**
  46628. * Gets the blur kernel: kernel size of the blur pass.
  46629. * Only useful if useKernelBlur = true
  46630. */
  46631. get: function () {
  46632. return this._blurKernel;
  46633. },
  46634. /**
  46635. * Sets the blur kernel: kernel size of the blur pass.
  46636. * Only useful if useKernelBlur = true
  46637. */
  46638. set: function (value) {
  46639. if (this._blurKernel === value) {
  46640. return;
  46641. }
  46642. this._blurKernel = value;
  46643. this._disposeBlurPostProcesses();
  46644. },
  46645. enumerable: true,
  46646. configurable: true
  46647. });
  46648. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  46649. /**
  46650. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  46651. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  46652. */
  46653. get: function () {
  46654. return this._useKernelBlur;
  46655. },
  46656. /**
  46657. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  46658. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  46659. */
  46660. set: function (value) {
  46661. if (this._useKernelBlur === value) {
  46662. return;
  46663. }
  46664. this._useKernelBlur = value;
  46665. this._disposeBlurPostProcesses();
  46666. },
  46667. enumerable: true,
  46668. configurable: true
  46669. });
  46670. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  46671. /**
  46672. * Gets the depth scale used in ESM mode.
  46673. */
  46674. get: function () {
  46675. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  46676. },
  46677. /**
  46678. * Sets the depth scale used in ESM mode.
  46679. * This can override the scale stored on the light.
  46680. */
  46681. set: function (value) {
  46682. this._depthScale = value;
  46683. },
  46684. enumerable: true,
  46685. configurable: true
  46686. });
  46687. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  46688. /**
  46689. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  46690. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  46691. */
  46692. get: function () {
  46693. return this._filter;
  46694. },
  46695. /**
  46696. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  46697. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  46698. */
  46699. set: function (value) {
  46700. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  46701. if (this._light.needCube()) {
  46702. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  46703. this.useExponentialShadowMap = true;
  46704. return;
  46705. }
  46706. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  46707. this.useCloseExponentialShadowMap = true;
  46708. return;
  46709. }
  46710. // PCF on cubemap would also be expensive
  46711. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  46712. this.usePoissonSampling = true;
  46713. return;
  46714. }
  46715. }
  46716. // Weblg1 fallback for PCF.
  46717. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  46718. if (this._scene.getEngine().webGLVersion === 1) {
  46719. this.usePoissonSampling = true;
  46720. return;
  46721. }
  46722. }
  46723. if (this._filter === value) {
  46724. return;
  46725. }
  46726. this._filter = value;
  46727. this._disposeBlurPostProcesses();
  46728. this._applyFilterValues();
  46729. this._light._markMeshesAsLightDirty();
  46730. },
  46731. enumerable: true,
  46732. configurable: true
  46733. });
  46734. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  46735. /**
  46736. * Gets if the current filter is set to Poisson Sampling.
  46737. */
  46738. get: function () {
  46739. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  46740. },
  46741. /**
  46742. * Sets the current filter to Poisson Sampling.
  46743. */
  46744. set: function (value) {
  46745. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  46746. return;
  46747. }
  46748. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  46749. },
  46750. enumerable: true,
  46751. configurable: true
  46752. });
  46753. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  46754. /**
  46755. * Gets if the current filter is set to ESM.
  46756. */
  46757. get: function () {
  46758. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  46759. },
  46760. /**
  46761. * Sets the current filter is to ESM.
  46762. */
  46763. set: function (value) {
  46764. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  46765. return;
  46766. }
  46767. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  46768. },
  46769. enumerable: true,
  46770. configurable: true
  46771. });
  46772. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  46773. /**
  46774. * Gets if the current filter is set to filtered ESM.
  46775. */
  46776. get: function () {
  46777. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  46778. },
  46779. /**
  46780. * Gets if the current filter is set to filtered ESM.
  46781. */
  46782. set: function (value) {
  46783. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  46784. return;
  46785. }
  46786. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  46787. },
  46788. enumerable: true,
  46789. configurable: true
  46790. });
  46791. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  46792. /**
  46793. * Gets if the current filter is set to "close ESM" (using the inverse of the
  46794. * exponential to prevent steep falloff artifacts).
  46795. */
  46796. get: function () {
  46797. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  46798. },
  46799. /**
  46800. * Sets the current filter to "close ESM" (using the inverse of the
  46801. * exponential to prevent steep falloff artifacts).
  46802. */
  46803. set: function (value) {
  46804. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  46805. return;
  46806. }
  46807. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  46808. },
  46809. enumerable: true,
  46810. configurable: true
  46811. });
  46812. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  46813. /**
  46814. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  46815. * exponential to prevent steep falloff artifacts).
  46816. */
  46817. get: function () {
  46818. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  46819. },
  46820. /**
  46821. * Sets the current filter to filtered "close ESM" (using the inverse of the
  46822. * exponential to prevent steep falloff artifacts).
  46823. */
  46824. set: function (value) {
  46825. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  46826. return;
  46827. }
  46828. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  46829. },
  46830. enumerable: true,
  46831. configurable: true
  46832. });
  46833. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  46834. /**
  46835. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  46836. */
  46837. get: function () {
  46838. return this.filter === ShadowGenerator.FILTER_PCF;
  46839. },
  46840. /**
  46841. * Sets the current filter to "PCF" (percentage closer filtering).
  46842. */
  46843. set: function (value) {
  46844. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  46845. return;
  46846. }
  46847. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  46848. },
  46849. enumerable: true,
  46850. configurable: true
  46851. });
  46852. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  46853. /**
  46854. * Gets the PCF or PCSS Quality.
  46855. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  46856. */
  46857. get: function () {
  46858. return this._filteringQuality;
  46859. },
  46860. /**
  46861. * Sets the PCF or PCSS Quality.
  46862. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  46863. */
  46864. set: function (filteringQuality) {
  46865. this._filteringQuality = filteringQuality;
  46866. },
  46867. enumerable: true,
  46868. configurable: true
  46869. });
  46870. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  46871. /**
  46872. * Gets if the current filter is set to "PCSS" (contact hardening).
  46873. */
  46874. get: function () {
  46875. return this.filter === ShadowGenerator.FILTER_PCSS;
  46876. },
  46877. /**
  46878. * Sets the current filter to "PCSS" (contact hardening).
  46879. */
  46880. set: function (value) {
  46881. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  46882. return;
  46883. }
  46884. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  46885. },
  46886. enumerable: true,
  46887. configurable: true
  46888. });
  46889. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  46890. /**
  46891. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  46892. * Using a ratio helps keeping shape stability independently of the map size.
  46893. *
  46894. * It does not account for the light projection as it was having too much
  46895. * instability during the light setup or during light position changes.
  46896. *
  46897. * Only valid if useContactHardeningShadow is true.
  46898. */
  46899. get: function () {
  46900. return this._contactHardeningLightSizeUVRatio;
  46901. },
  46902. /**
  46903. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  46904. * Using a ratio helps keeping shape stability independently of the map size.
  46905. *
  46906. * It does not account for the light projection as it was having too much
  46907. * instability during the light setup or during light position changes.
  46908. *
  46909. * Only valid if useContactHardeningShadow is true.
  46910. */
  46911. set: function (contactHardeningLightSizeUVRatio) {
  46912. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  46913. },
  46914. enumerable: true,
  46915. configurable: true
  46916. });
  46917. /**
  46918. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  46919. * 0 means strongest and 1 would means no shadow.
  46920. * @returns the darkness.
  46921. */
  46922. ShadowGenerator.prototype.getDarkness = function () {
  46923. return this._darkness;
  46924. };
  46925. /**
  46926. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  46927. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  46928. * @returns the shadow generator allowing fluent coding.
  46929. */
  46930. ShadowGenerator.prototype.setDarkness = function (darkness) {
  46931. if (darkness >= 1.0) {
  46932. this._darkness = 1.0;
  46933. }
  46934. else if (darkness <= 0.0) {
  46935. this._darkness = 0.0;
  46936. }
  46937. else {
  46938. this._darkness = darkness;
  46939. }
  46940. return this;
  46941. };
  46942. /**
  46943. * Sets the ability to have transparent shadow (boolean).
  46944. * @param transparent True if transparent else False
  46945. * @returns the shadow generator allowing fluent coding
  46946. */
  46947. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  46948. this._transparencyShadow = transparent;
  46949. return this;
  46950. };
  46951. /**
  46952. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  46953. * @returns The render target texture if present otherwise, null
  46954. */
  46955. ShadowGenerator.prototype.getShadowMap = function () {
  46956. return this._shadowMap;
  46957. };
  46958. /**
  46959. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  46960. * @returns The render target texture if the shadow map is present otherwise, null
  46961. */
  46962. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  46963. if (this._shadowMap2) {
  46964. return this._shadowMap2;
  46965. }
  46966. return this._shadowMap;
  46967. };
  46968. /**
  46969. * Helper function to add a mesh and its descendants to the list of shadow casters.
  46970. * @param mesh Mesh to add
  46971. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  46972. * @returns the Shadow Generator itself
  46973. */
  46974. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  46975. var _a;
  46976. if (includeDescendants === void 0) { includeDescendants = true; }
  46977. if (!this._shadowMap) {
  46978. return this;
  46979. }
  46980. if (!this._shadowMap.renderList) {
  46981. this._shadowMap.renderList = [];
  46982. }
  46983. this._shadowMap.renderList.push(mesh);
  46984. if (includeDescendants) {
  46985. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  46986. }
  46987. return this;
  46988. };
  46989. /**
  46990. * Helper function to remove a mesh and its descendants from the list of shadow casters
  46991. * @param mesh Mesh to remove
  46992. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  46993. * @returns the Shadow Generator itself
  46994. */
  46995. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  46996. if (includeDescendants === void 0) { includeDescendants = true; }
  46997. if (!this._shadowMap || !this._shadowMap.renderList) {
  46998. return this;
  46999. }
  47000. var index = this._shadowMap.renderList.indexOf(mesh);
  47001. if (index !== -1) {
  47002. this._shadowMap.renderList.splice(index, 1);
  47003. }
  47004. if (includeDescendants) {
  47005. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  47006. var child = _a[_i];
  47007. this.removeShadowCaster(child);
  47008. }
  47009. }
  47010. return this;
  47011. };
  47012. /**
  47013. * Returns the associated light object.
  47014. * @returns the light generating the shadow
  47015. */
  47016. ShadowGenerator.prototype.getLight = function () {
  47017. return this._light;
  47018. };
  47019. ShadowGenerator.prototype._initializeGenerator = function () {
  47020. this._light._markMeshesAsLightDirty();
  47021. this._initializeShadowMap();
  47022. };
  47023. ShadowGenerator.prototype._initializeShadowMap = function () {
  47024. var _this = this;
  47025. // Render target
  47026. var engine = this._scene.getEngine();
  47027. if (engine.webGLVersion > 1) {
  47028. 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);
  47029. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  47030. }
  47031. else {
  47032. 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());
  47033. }
  47034. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  47035. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  47036. this._shadowMap.anisotropicFilteringLevel = 1;
  47037. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  47038. this._shadowMap.renderParticles = false;
  47039. this._shadowMap.ignoreCameraViewport = true;
  47040. // Record Face Index before render.
  47041. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  47042. _this._currentFaceIndex = faceIndex;
  47043. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  47044. engine.setColorWrite(false);
  47045. }
  47046. });
  47047. // Custom render function.
  47048. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  47049. // Blur if required afer render.
  47050. this._shadowMap.onAfterUnbindObservable.add(function () {
  47051. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  47052. engine.setColorWrite(true);
  47053. }
  47054. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  47055. return;
  47056. }
  47057. var shadowMap = _this.getShadowMapForRendering();
  47058. if (shadowMap) {
  47059. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  47060. }
  47061. });
  47062. // Clear according to the chosen filter.
  47063. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  47064. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  47065. this._shadowMap.onClearObservable.add(function (engine) {
  47066. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  47067. engine.clear(clearOne, false, true, false);
  47068. }
  47069. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  47070. engine.clear(clearZero, true, true, false);
  47071. }
  47072. else {
  47073. engine.clear(clearOne, true, true, false);
  47074. }
  47075. });
  47076. };
  47077. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  47078. var _this = this;
  47079. var engine = this._scene.getEngine();
  47080. var targetSize = this._mapSize / this.blurScale;
  47081. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  47082. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  47083. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  47084. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  47085. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  47086. }
  47087. if (this.useKernelBlur) {
  47088. 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);
  47089. this._kernelBlurXPostprocess.width = targetSize;
  47090. this._kernelBlurXPostprocess.height = targetSize;
  47091. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  47092. effect.setTexture("textureSampler", _this._shadowMap);
  47093. });
  47094. 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);
  47095. this._kernelBlurXPostprocess.autoClear = false;
  47096. this._kernelBlurYPostprocess.autoClear = false;
  47097. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  47098. this._kernelBlurXPostprocess.packedFloat = true;
  47099. this._kernelBlurYPostprocess.packedFloat = true;
  47100. }
  47101. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  47102. }
  47103. else {
  47104. 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);
  47105. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  47106. effect.setFloat2("screenSize", targetSize, targetSize);
  47107. effect.setTexture("textureSampler", _this._shadowMap);
  47108. });
  47109. this._boxBlurPostprocess.autoClear = false;
  47110. this._blurPostProcesses = [this._boxBlurPostprocess];
  47111. }
  47112. };
  47113. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  47114. var index;
  47115. var engine = this._scene.getEngine();
  47116. if (depthOnlySubMeshes.length) {
  47117. engine.setColorWrite(false);
  47118. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  47119. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  47120. }
  47121. engine.setColorWrite(true);
  47122. }
  47123. for (index = 0; index < opaqueSubMeshes.length; index++) {
  47124. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  47125. }
  47126. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  47127. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  47128. }
  47129. if (this._transparencyShadow) {
  47130. for (index = 0; index < transparentSubMeshes.length; index++) {
  47131. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  47132. }
  47133. }
  47134. };
  47135. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  47136. var _this = this;
  47137. var mesh = subMesh.getRenderingMesh();
  47138. var scene = this._scene;
  47139. var engine = scene.getEngine();
  47140. var material = subMesh.getMaterial();
  47141. mesh._internalAbstractMeshDataInfo._isActiveIntermediate = false;
  47142. if (!material || subMesh.verticesCount === 0) {
  47143. return;
  47144. }
  47145. // Culling
  47146. engine.setState(material.backFaceCulling);
  47147. // Managing instances
  47148. var batch = mesh._getInstancesRenderList(subMesh._id);
  47149. if (batch.mustReturn) {
  47150. return;
  47151. }
  47152. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  47153. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  47154. engine.enableEffect(this._effect);
  47155. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  47156. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  47157. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  47158. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  47159. this._effect.setVector3("lightData", this._cachedDirection);
  47160. }
  47161. else {
  47162. this._effect.setVector3("lightData", this._cachedPosition);
  47163. }
  47164. if (scene.activeCamera) {
  47165. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  47166. }
  47167. // Alpha test
  47168. if (material && material.needAlphaTesting()) {
  47169. var alphaTexture = material.getAlphaTestTexture();
  47170. if (alphaTexture) {
  47171. this._effect.setTexture("diffuseSampler", alphaTexture);
  47172. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  47173. }
  47174. }
  47175. // Bones
  47176. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  47177. var skeleton = mesh.skeleton;
  47178. if (skeleton.isUsingTextureForMatrices) {
  47179. var boneTexture = skeleton.getTransformMatrixTexture();
  47180. if (!boneTexture) {
  47181. return;
  47182. }
  47183. this._effect.setTexture("boneSampler", boneTexture);
  47184. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  47185. }
  47186. else {
  47187. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  47188. }
  47189. }
  47190. // Morph targets
  47191. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  47192. if (this.forceBackFacesOnly) {
  47193. engine.setState(true, 0, false, true);
  47194. }
  47195. // Observables
  47196. this.onBeforeShadowMapRenderMeshObservable.notifyObservers(mesh);
  47197. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  47198. // Draw
  47199. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  47200. if (this.forceBackFacesOnly) {
  47201. engine.setState(true, 0, false, false);
  47202. }
  47203. }
  47204. else {
  47205. // Need to reset refresh rate of the shadowMap
  47206. if (this._shadowMap) {
  47207. this._shadowMap.resetRefreshCounter();
  47208. }
  47209. }
  47210. };
  47211. ShadowGenerator.prototype._applyFilterValues = function () {
  47212. if (!this._shadowMap) {
  47213. return;
  47214. }
  47215. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  47216. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  47217. }
  47218. else {
  47219. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  47220. }
  47221. };
  47222. /**
  47223. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  47224. * @param onCompiled Callback triggered at the and of the effects compilation
  47225. * @param options Sets of optional options forcing the compilation with different modes
  47226. */
  47227. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  47228. var _this = this;
  47229. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  47230. var shadowMap = this.getShadowMap();
  47231. if (!shadowMap) {
  47232. if (onCompiled) {
  47233. onCompiled(this);
  47234. }
  47235. return;
  47236. }
  47237. var renderList = shadowMap.renderList;
  47238. if (!renderList) {
  47239. if (onCompiled) {
  47240. onCompiled(this);
  47241. }
  47242. return;
  47243. }
  47244. var subMeshes = new Array();
  47245. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  47246. var mesh = renderList_1[_i];
  47247. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  47248. }
  47249. if (subMeshes.length === 0) {
  47250. if (onCompiled) {
  47251. onCompiled(this);
  47252. }
  47253. return;
  47254. }
  47255. var currentIndex = 0;
  47256. var checkReady = function () {
  47257. if (!_this._scene || !_this._scene.getEngine()) {
  47258. return;
  47259. }
  47260. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  47261. currentIndex++;
  47262. if (currentIndex >= subMeshes.length) {
  47263. if (onCompiled) {
  47264. onCompiled(_this);
  47265. }
  47266. return;
  47267. }
  47268. }
  47269. setTimeout(checkReady, 16);
  47270. };
  47271. checkReady();
  47272. };
  47273. /**
  47274. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  47275. * @param options Sets of optional options forcing the compilation with different modes
  47276. * @returns A promise that resolves when the compilation completes
  47277. */
  47278. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  47279. var _this = this;
  47280. return new Promise(function (resolve) {
  47281. _this.forceCompilation(function () {
  47282. resolve();
  47283. }, options);
  47284. });
  47285. };
  47286. /**
  47287. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  47288. * @param subMesh The submesh we want to render in the shadow map
  47289. * @param useInstances Defines wether will draw in the map using instances
  47290. * @returns true if ready otherwise, false
  47291. */
  47292. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  47293. var defines = [];
  47294. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  47295. defines.push("#define FLOAT");
  47296. }
  47297. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  47298. defines.push("#define ESM");
  47299. }
  47300. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  47301. defines.push("#define DEPTHTEXTURE");
  47302. }
  47303. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  47304. var mesh = subMesh.getMesh();
  47305. var material = subMesh.getMaterial();
  47306. // Normal bias.
  47307. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  47308. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  47309. defines.push("#define NORMAL");
  47310. if (mesh.nonUniformScaling) {
  47311. defines.push("#define NONUNIFORMSCALING");
  47312. }
  47313. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  47314. defines.push("#define DIRECTIONINLIGHTDATA");
  47315. }
  47316. }
  47317. // Alpha test
  47318. if (material && material.needAlphaTesting()) {
  47319. var alphaTexture = material.getAlphaTestTexture();
  47320. if (alphaTexture) {
  47321. defines.push("#define ALPHATEST");
  47322. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  47323. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  47324. defines.push("#define UV1");
  47325. }
  47326. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  47327. if (alphaTexture.coordinatesIndex === 1) {
  47328. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  47329. defines.push("#define UV2");
  47330. }
  47331. }
  47332. }
  47333. }
  47334. // Bones
  47335. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  47336. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  47337. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  47338. if (mesh.numBoneInfluencers > 4) {
  47339. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  47340. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  47341. }
  47342. var skeleton = mesh.skeleton;
  47343. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  47344. if (skeleton.isUsingTextureForMatrices) {
  47345. defines.push("#define BONETEXTURE");
  47346. }
  47347. else {
  47348. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  47349. }
  47350. }
  47351. else {
  47352. defines.push("#define NUM_BONE_INFLUENCERS 0");
  47353. }
  47354. // Morph targets
  47355. var manager = mesh.morphTargetManager;
  47356. var morphInfluencers = 0;
  47357. if (manager) {
  47358. if (manager.numInfluencers > 0) {
  47359. defines.push("#define MORPHTARGETS");
  47360. morphInfluencers = manager.numInfluencers;
  47361. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  47362. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  47363. }
  47364. }
  47365. // Instances
  47366. if (useInstances) {
  47367. defines.push("#define INSTANCES");
  47368. attribs.push("world0");
  47369. attribs.push("world1");
  47370. attribs.push("world2");
  47371. attribs.push("world3");
  47372. }
  47373. if (this.customShaderOptions) {
  47374. if (this.customShaderOptions.defines) {
  47375. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  47376. var define = _a[_i];
  47377. if (defines.indexOf(define) === -1) {
  47378. defines.push(define);
  47379. }
  47380. }
  47381. }
  47382. }
  47383. // Get correct effect
  47384. var join = defines.join("\n");
  47385. if (this._cachedDefines !== join) {
  47386. this._cachedDefines = join;
  47387. var shaderName = "shadowMap";
  47388. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  47389. var samplers = ["diffuseSampler", "boneSampler"];
  47390. // Custom shader?
  47391. if (this.customShaderOptions) {
  47392. shaderName = this.customShaderOptions.shaderName;
  47393. if (this.customShaderOptions.attributes) {
  47394. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  47395. var attrib = _c[_b];
  47396. if (attribs.indexOf(attrib) === -1) {
  47397. attribs.push(attrib);
  47398. }
  47399. }
  47400. }
  47401. if (this.customShaderOptions.uniforms) {
  47402. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  47403. var uniform = _e[_d];
  47404. if (uniforms.indexOf(uniform) === -1) {
  47405. uniforms.push(uniform);
  47406. }
  47407. }
  47408. }
  47409. if (this.customShaderOptions.samplers) {
  47410. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  47411. var sampler = _g[_f];
  47412. if (samplers.indexOf(sampler) === -1) {
  47413. samplers.push(sampler);
  47414. }
  47415. }
  47416. }
  47417. }
  47418. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  47419. }
  47420. if (!this._effect.isReady()) {
  47421. return false;
  47422. }
  47423. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  47424. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  47425. this._initializeBlurRTTAndPostProcesses();
  47426. }
  47427. }
  47428. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  47429. return false;
  47430. }
  47431. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  47432. return false;
  47433. }
  47434. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  47435. return false;
  47436. }
  47437. return true;
  47438. };
  47439. /**
  47440. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  47441. * @param defines Defines of the material we want to update
  47442. * @param lightIndex Index of the light in the enabled light list of the material
  47443. */
  47444. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  47445. var scene = this._scene;
  47446. var light = this._light;
  47447. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  47448. return;
  47449. }
  47450. defines["SHADOW" + lightIndex] = true;
  47451. if (this.useContactHardeningShadow) {
  47452. defines["SHADOWPCSS" + lightIndex] = true;
  47453. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  47454. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  47455. }
  47456. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  47457. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  47458. }
  47459. // else default to high.
  47460. }
  47461. if (this.usePercentageCloserFiltering) {
  47462. defines["SHADOWPCF" + lightIndex] = true;
  47463. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  47464. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  47465. }
  47466. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  47467. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  47468. }
  47469. // else default to high.
  47470. }
  47471. else if (this.usePoissonSampling) {
  47472. defines["SHADOWPOISSON" + lightIndex] = true;
  47473. }
  47474. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  47475. defines["SHADOWESM" + lightIndex] = true;
  47476. }
  47477. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  47478. defines["SHADOWCLOSEESM" + lightIndex] = true;
  47479. }
  47480. if (light.needCube()) {
  47481. defines["SHADOWCUBE" + lightIndex] = true;
  47482. }
  47483. };
  47484. /**
  47485. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  47486. * defined in the generator but impacting the effect).
  47487. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  47488. * @param effect The effect we are binfing the information for
  47489. */
  47490. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  47491. var light = this._light;
  47492. var scene = this._scene;
  47493. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  47494. return;
  47495. }
  47496. var camera = scene.activeCamera;
  47497. if (!camera) {
  47498. return;
  47499. }
  47500. var shadowMap = this.getShadowMap();
  47501. if (!shadowMap) {
  47502. return;
  47503. }
  47504. if (!light.needCube()) {
  47505. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  47506. }
  47507. // Only PCF uses depth stencil texture.
  47508. if (this._filter === ShadowGenerator.FILTER_PCF) {
  47509. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  47510. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  47511. }
  47512. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  47513. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  47514. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  47515. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  47516. }
  47517. else {
  47518. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  47519. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  47520. }
  47521. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  47522. };
  47523. /**
  47524. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  47525. * (eq to shadow prjection matrix * light transform matrix)
  47526. * @returns The transform matrix used to create the shadow map
  47527. */
  47528. ShadowGenerator.prototype.getTransformMatrix = function () {
  47529. var scene = this._scene;
  47530. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  47531. return this._transformMatrix;
  47532. }
  47533. this._currentRenderID = scene.getRenderId();
  47534. this._currentFaceIndexCache = this._currentFaceIndex;
  47535. var lightPosition = this._light.position;
  47536. if (this._light.computeTransformedInformation()) {
  47537. lightPosition = this._light.transformedPosition;
  47538. }
  47539. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  47540. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  47541. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  47542. }
  47543. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  47544. this._cachedPosition.copyFrom(lightPosition);
  47545. this._cachedDirection.copyFrom(this._lightDirection);
  47546. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  47547. var shadowMap = this.getShadowMap();
  47548. if (shadowMap) {
  47549. var renderList = shadowMap.renderList;
  47550. if (renderList) {
  47551. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  47552. }
  47553. }
  47554. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  47555. }
  47556. return this._transformMatrix;
  47557. };
  47558. /**
  47559. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  47560. * Cube and 2D textures for instance.
  47561. */
  47562. ShadowGenerator.prototype.recreateShadowMap = function () {
  47563. var shadowMap = this._shadowMap;
  47564. if (!shadowMap) {
  47565. return;
  47566. }
  47567. // Track render list.
  47568. var renderList = shadowMap.renderList;
  47569. // Clean up existing data.
  47570. this._disposeRTTandPostProcesses();
  47571. // Reinitializes.
  47572. this._initializeGenerator();
  47573. // Reaffect the filter to ensure a correct fallback if necessary.
  47574. this.filter = this.filter;
  47575. // Reaffect the filter.
  47576. this._applyFilterValues();
  47577. // Reaffect Render List.
  47578. this._shadowMap.renderList = renderList;
  47579. };
  47580. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  47581. if (this._shadowMap2) {
  47582. this._shadowMap2.dispose();
  47583. this._shadowMap2 = null;
  47584. }
  47585. if (this._boxBlurPostprocess) {
  47586. this._boxBlurPostprocess.dispose();
  47587. this._boxBlurPostprocess = null;
  47588. }
  47589. if (this._kernelBlurXPostprocess) {
  47590. this._kernelBlurXPostprocess.dispose();
  47591. this._kernelBlurXPostprocess = null;
  47592. }
  47593. if (this._kernelBlurYPostprocess) {
  47594. this._kernelBlurYPostprocess.dispose();
  47595. this._kernelBlurYPostprocess = null;
  47596. }
  47597. this._blurPostProcesses = [];
  47598. };
  47599. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  47600. if (this._shadowMap) {
  47601. this._shadowMap.dispose();
  47602. this._shadowMap = null;
  47603. }
  47604. this._disposeBlurPostProcesses();
  47605. };
  47606. /**
  47607. * Disposes the ShadowGenerator.
  47608. * Returns nothing.
  47609. */
  47610. ShadowGenerator.prototype.dispose = function () {
  47611. this._disposeRTTandPostProcesses();
  47612. if (this._light) {
  47613. this._light._shadowGenerator = null;
  47614. this._light._markMeshesAsLightDirty();
  47615. }
  47616. };
  47617. /**
  47618. * Serializes the shadow generator setup to a json object.
  47619. * @returns The serialized JSON object
  47620. */
  47621. ShadowGenerator.prototype.serialize = function () {
  47622. var serializationObject = {};
  47623. var shadowMap = this.getShadowMap();
  47624. if (!shadowMap) {
  47625. return serializationObject;
  47626. }
  47627. serializationObject.lightId = this._light.id;
  47628. serializationObject.mapSize = shadowMap.getRenderSize();
  47629. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  47630. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  47631. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  47632. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  47633. serializationObject.usePoissonSampling = this.usePoissonSampling;
  47634. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  47635. serializationObject.depthScale = this.depthScale;
  47636. serializationObject.darkness = this.getDarkness();
  47637. serializationObject.blurBoxOffset = this.blurBoxOffset;
  47638. serializationObject.blurKernel = this.blurKernel;
  47639. serializationObject.blurScale = this.blurScale;
  47640. serializationObject.useKernelBlur = this.useKernelBlur;
  47641. serializationObject.transparencyShadow = this._transparencyShadow;
  47642. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  47643. serializationObject.bias = this.bias;
  47644. serializationObject.normalBias = this.normalBias;
  47645. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  47646. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  47647. serializationObject.filteringQuality = this.filteringQuality;
  47648. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  47649. serializationObject.renderList = [];
  47650. if (shadowMap.renderList) {
  47651. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  47652. var mesh = shadowMap.renderList[meshIndex];
  47653. serializationObject.renderList.push(mesh.id);
  47654. }
  47655. }
  47656. return serializationObject;
  47657. };
  47658. /**
  47659. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  47660. * @param parsedShadowGenerator The JSON object to parse
  47661. * @param scene The scene to create the shadow map for
  47662. * @returns The parsed shadow generator
  47663. */
  47664. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  47665. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  47666. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  47667. var shadowMap = shadowGenerator.getShadowMap();
  47668. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  47669. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  47670. meshes.forEach(function (mesh) {
  47671. if (!shadowMap) {
  47672. return;
  47673. }
  47674. if (!shadowMap.renderList) {
  47675. shadowMap.renderList = [];
  47676. }
  47677. shadowMap.renderList.push(mesh);
  47678. });
  47679. }
  47680. if (parsedShadowGenerator.usePoissonSampling) {
  47681. shadowGenerator.usePoissonSampling = true;
  47682. }
  47683. else if (parsedShadowGenerator.useExponentialShadowMap) {
  47684. shadowGenerator.useExponentialShadowMap = true;
  47685. }
  47686. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  47687. shadowGenerator.useBlurExponentialShadowMap = true;
  47688. }
  47689. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  47690. shadowGenerator.useCloseExponentialShadowMap = true;
  47691. }
  47692. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  47693. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  47694. }
  47695. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  47696. shadowGenerator.usePercentageCloserFiltering = true;
  47697. }
  47698. else if (parsedShadowGenerator.useContactHardeningShadow) {
  47699. shadowGenerator.useContactHardeningShadow = true;
  47700. }
  47701. if (parsedShadowGenerator.filteringQuality) {
  47702. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  47703. }
  47704. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  47705. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  47706. }
  47707. // Backward compat
  47708. else if (parsedShadowGenerator.useVarianceShadowMap) {
  47709. shadowGenerator.useExponentialShadowMap = true;
  47710. }
  47711. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  47712. shadowGenerator.useBlurExponentialShadowMap = true;
  47713. }
  47714. if (parsedShadowGenerator.depthScale) {
  47715. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  47716. }
  47717. if (parsedShadowGenerator.blurScale) {
  47718. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  47719. }
  47720. if (parsedShadowGenerator.blurBoxOffset) {
  47721. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  47722. }
  47723. if (parsedShadowGenerator.useKernelBlur) {
  47724. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  47725. }
  47726. if (parsedShadowGenerator.blurKernel) {
  47727. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  47728. }
  47729. if (parsedShadowGenerator.bias !== undefined) {
  47730. shadowGenerator.bias = parsedShadowGenerator.bias;
  47731. }
  47732. if (parsedShadowGenerator.normalBias !== undefined) {
  47733. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  47734. }
  47735. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  47736. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  47737. }
  47738. if (parsedShadowGenerator.darkness) {
  47739. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  47740. }
  47741. if (parsedShadowGenerator.transparencyShadow) {
  47742. shadowGenerator.setTransparencyShadow(true);
  47743. }
  47744. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  47745. return shadowGenerator;
  47746. };
  47747. /**
  47748. * Shadow generator mode None: no filtering applied.
  47749. */
  47750. ShadowGenerator.FILTER_NONE = 0;
  47751. /**
  47752. * Shadow generator mode ESM: Exponential Shadow Mapping.
  47753. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  47754. */
  47755. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  47756. /**
  47757. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  47758. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  47759. */
  47760. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  47761. /**
  47762. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  47763. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  47764. */
  47765. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  47766. /**
  47767. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  47768. * edge artifacts on steep falloff.
  47769. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  47770. */
  47771. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  47772. /**
  47773. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  47774. * edge artifacts on steep falloff.
  47775. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  47776. */
  47777. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  47778. /**
  47779. * Shadow generator mode PCF: Percentage Closer Filtering
  47780. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  47781. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  47782. */
  47783. ShadowGenerator.FILTER_PCF = 6;
  47784. /**
  47785. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  47786. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  47787. * Contact Hardening
  47788. */
  47789. ShadowGenerator.FILTER_PCSS = 7;
  47790. /**
  47791. * Reserved for PCF and PCSS
  47792. * Highest Quality.
  47793. *
  47794. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  47795. *
  47796. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  47797. */
  47798. ShadowGenerator.QUALITY_HIGH = 0;
  47799. /**
  47800. * Reserved for PCF and PCSS
  47801. * Good tradeoff for quality/perf cross devices
  47802. *
  47803. * Execute PCF on a 3*3 kernel.
  47804. *
  47805. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  47806. */
  47807. ShadowGenerator.QUALITY_MEDIUM = 1;
  47808. /**
  47809. * Reserved for PCF and PCSS
  47810. * The lowest quality but the fastest.
  47811. *
  47812. * Execute PCF on a 1*1 kernel.
  47813. *
  47814. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  47815. */
  47816. ShadowGenerator.QUALITY_LOW = 2;
  47817. /** @hidden */
  47818. ShadowGenerator._SceneComponentInitialization = function (_) {
  47819. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  47820. };
  47821. return ShadowGenerator;
  47822. }());
  47823. /***/ }),
  47824. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  47825. /*!*********************************************************!*\
  47826. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  47827. \*********************************************************/
  47828. /*! exports provided: ShadowGeneratorSceneComponent */
  47829. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47830. "use strict";
  47831. __webpack_require__.r(__webpack_exports__);
  47832. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  47833. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  47834. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  47835. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  47836. // Adds the parser to the scene parsers.
  47837. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  47838. // Shadows
  47839. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  47840. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  47841. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  47842. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  47843. // SG would be available on their associated lights
  47844. }
  47845. }
  47846. });
  47847. /**
  47848. * Defines the shadow generator component responsible to manage any shadow generators
  47849. * in a given scene.
  47850. */
  47851. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  47852. /**
  47853. * Creates a new instance of the component for the given scene
  47854. * @param scene Defines the scene to register the component in
  47855. */
  47856. function ShadowGeneratorSceneComponent(scene) {
  47857. /**
  47858. * The component name helpfull to identify the component in the list of scene components.
  47859. */
  47860. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  47861. this.scene = scene;
  47862. }
  47863. /**
  47864. * Registers the component in a given scene
  47865. */
  47866. ShadowGeneratorSceneComponent.prototype.register = function () {
  47867. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  47868. };
  47869. /**
  47870. * Rebuilds the elements related to this component in case of
  47871. * context lost for instance.
  47872. */
  47873. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  47874. // Nothing To Do Here.
  47875. };
  47876. /**
  47877. * Serializes the component data to the specified json object
  47878. * @param serializationObject The object to serialize to
  47879. */
  47880. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  47881. // Shadows
  47882. serializationObject.shadowGenerators = [];
  47883. var lights = this.scene.lights;
  47884. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  47885. var light = lights_1[_i];
  47886. var shadowGenerator = light.getShadowGenerator();
  47887. if (shadowGenerator) {
  47888. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  47889. }
  47890. }
  47891. };
  47892. /**
  47893. * Adds all the element from the container to the scene
  47894. * @param container the container holding the elements
  47895. */
  47896. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  47897. // Nothing To Do Here. (directly attached to a light)
  47898. };
  47899. /**
  47900. * Removes all the elements in the container from the scene
  47901. * @param container contains the elements to remove
  47902. * @param dispose if the removed element should be disposed (default: false)
  47903. */
  47904. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  47905. // Nothing To Do Here. (directly attached to a light)
  47906. };
  47907. /**
  47908. * Rebuilds the elements related to this component in case of
  47909. * context lost for instance.
  47910. */
  47911. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  47912. // Nothing To Do Here.
  47913. };
  47914. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  47915. // Shadows
  47916. var scene = this.scene;
  47917. if (this.scene.shadowsEnabled) {
  47918. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  47919. var light = scene.lights[lightIndex];
  47920. var shadowGenerator = light.getShadowGenerator();
  47921. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  47922. var shadowMap = (shadowGenerator.getShadowMap());
  47923. if (scene.textures.indexOf(shadowMap) !== -1) {
  47924. renderTargets.push(shadowMap);
  47925. }
  47926. }
  47927. }
  47928. }
  47929. };
  47930. return ShadowGeneratorSceneComponent;
  47931. }());
  47932. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  47933. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  47934. if (!component) {
  47935. component = new ShadowGeneratorSceneComponent(scene);
  47936. scene._addComponent(component);
  47937. }
  47938. };
  47939. /***/ }),
  47940. /***/ "./Lights/directionalLight.ts":
  47941. /*!************************************!*\
  47942. !*** ./Lights/directionalLight.ts ***!
  47943. \************************************/
  47944. /*! exports provided: DirectionalLight */
  47945. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47946. "use strict";
  47947. __webpack_require__.r(__webpack_exports__);
  47948. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  47949. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47950. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47951. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47952. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47953. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47954. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47955. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  47956. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  47957. });
  47958. /**
  47959. * A directional light is defined by a direction (what a surprise!).
  47960. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47961. * 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.
  47962. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47963. */
  47964. var DirectionalLight = /** @class */ (function (_super) {
  47965. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  47966. /**
  47967. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47968. * The directional light is emitted from everywhere in the given direction.
  47969. * It can cast shadows.
  47970. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47971. * @param name The friendly name of the light
  47972. * @param direction The direction of the light
  47973. * @param scene The scene the light belongs to
  47974. */
  47975. function DirectionalLight(name, direction, scene) {
  47976. var _this = _super.call(this, name, scene) || this;
  47977. _this._shadowFrustumSize = 0;
  47978. _this._shadowOrthoScale = 0.1;
  47979. /**
  47980. * Automatically compute the projection matrix to best fit (including all the casters)
  47981. * on each frame.
  47982. */
  47983. _this.autoUpdateExtends = true;
  47984. // Cache
  47985. _this._orthoLeft = Number.MAX_VALUE;
  47986. _this._orthoRight = Number.MIN_VALUE;
  47987. _this._orthoTop = Number.MIN_VALUE;
  47988. _this._orthoBottom = Number.MAX_VALUE;
  47989. _this.position = direction.scale(-1.0);
  47990. _this.direction = direction;
  47991. return _this;
  47992. }
  47993. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  47994. /**
  47995. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47996. */
  47997. get: function () {
  47998. return this._shadowFrustumSize;
  47999. },
  48000. /**
  48001. * Specifies a fix frustum size for the shadow generation.
  48002. */
  48003. set: function (value) {
  48004. this._shadowFrustumSize = value;
  48005. this.forceProjectionMatrixCompute();
  48006. },
  48007. enumerable: true,
  48008. configurable: true
  48009. });
  48010. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  48011. /**
  48012. * Gets the shadow projection scale against the optimal computed one.
  48013. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48014. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48015. */
  48016. get: function () {
  48017. return this._shadowOrthoScale;
  48018. },
  48019. /**
  48020. * Sets the shadow projection scale against the optimal computed one.
  48021. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48022. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48023. */
  48024. set: function (value) {
  48025. this._shadowOrthoScale = value;
  48026. this.forceProjectionMatrixCompute();
  48027. },
  48028. enumerable: true,
  48029. configurable: true
  48030. });
  48031. /**
  48032. * Returns the string "DirectionalLight".
  48033. * @return The class name
  48034. */
  48035. DirectionalLight.prototype.getClassName = function () {
  48036. return "DirectionalLight";
  48037. };
  48038. /**
  48039. * Returns the integer 1.
  48040. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48041. */
  48042. DirectionalLight.prototype.getTypeID = function () {
  48043. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  48044. };
  48045. /**
  48046. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48047. * Returns the DirectionalLight Shadow projection matrix.
  48048. */
  48049. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48050. if (this.shadowFrustumSize > 0) {
  48051. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  48052. }
  48053. else {
  48054. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  48055. }
  48056. };
  48057. /**
  48058. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48059. * Returns the DirectionalLight Shadow projection matrix.
  48060. */
  48061. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  48062. var activeCamera = this.getScene().activeCamera;
  48063. if (!activeCamera) {
  48064. return;
  48065. }
  48066. _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);
  48067. };
  48068. /**
  48069. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48070. * Returns the DirectionalLight Shadow projection matrix.
  48071. */
  48072. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48073. var activeCamera = this.getScene().activeCamera;
  48074. if (!activeCamera) {
  48075. return;
  48076. }
  48077. // Check extends
  48078. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  48079. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48080. this._orthoLeft = Number.MAX_VALUE;
  48081. this._orthoRight = Number.MIN_VALUE;
  48082. this._orthoTop = Number.MIN_VALUE;
  48083. this._orthoBottom = Number.MAX_VALUE;
  48084. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  48085. var mesh = renderList[meshIndex];
  48086. if (!mesh) {
  48087. continue;
  48088. }
  48089. var boundingInfo = mesh.getBoundingInfo();
  48090. var boundingBox = boundingInfo.boundingBox;
  48091. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  48092. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  48093. if (tempVector3.x < this._orthoLeft) {
  48094. this._orthoLeft = tempVector3.x;
  48095. }
  48096. if (tempVector3.y < this._orthoBottom) {
  48097. this._orthoBottom = tempVector3.y;
  48098. }
  48099. if (tempVector3.x > this._orthoRight) {
  48100. this._orthoRight = tempVector3.x;
  48101. }
  48102. if (tempVector3.y > this._orthoTop) {
  48103. this._orthoTop = tempVector3.y;
  48104. }
  48105. }
  48106. }
  48107. }
  48108. var xOffset = this._orthoRight - this._orthoLeft;
  48109. var yOffset = this._orthoTop - this._orthoBottom;
  48110. _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);
  48111. };
  48112. DirectionalLight.prototype._buildUniformLayout = function () {
  48113. this._uniformBuffer.addUniform("vLightData", 4);
  48114. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  48115. this._uniformBuffer.addUniform("vLightSpecular", 3);
  48116. this._uniformBuffer.addUniform("shadowsInfo", 3);
  48117. this._uniformBuffer.addUniform("depthValues", 2);
  48118. this._uniformBuffer.create();
  48119. };
  48120. /**
  48121. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48122. * @param effect The effect to update
  48123. * @param lightIndex The index of the light in the effect to update
  48124. * @returns The directional light
  48125. */
  48126. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  48127. if (this.computeTransformedInformation()) {
  48128. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  48129. return this;
  48130. }
  48131. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  48132. return this;
  48133. };
  48134. /**
  48135. * Gets the minZ used for shadow according to both the scene and the light.
  48136. *
  48137. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48138. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48139. * @param activeCamera The camera we are returning the min for
  48140. * @returns the depth min z
  48141. */
  48142. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  48143. return 1;
  48144. };
  48145. /**
  48146. * Gets the maxZ used for shadow according to both the scene and the light.
  48147. *
  48148. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48149. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48150. * @param activeCamera The camera we are returning the max for
  48151. * @returns the depth max z
  48152. */
  48153. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  48154. return 1;
  48155. };
  48156. /**
  48157. * Prepares the list of defines specific to the light type.
  48158. * @param defines the list of defines
  48159. * @param lightIndex defines the index of the light for the effect
  48160. */
  48161. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  48162. defines["DIRLIGHT" + lightIndex] = true;
  48163. };
  48164. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48165. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48166. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  48167. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48168. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48169. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  48170. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48171. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48172. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  48173. return DirectionalLight;
  48174. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  48175. /***/ }),
  48176. /***/ "./Lights/hemisphericLight.ts":
  48177. /*!************************************!*\
  48178. !*** ./Lights/hemisphericLight.ts ***!
  48179. \************************************/
  48180. /*! exports provided: HemisphericLight */
  48181. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48182. "use strict";
  48183. __webpack_require__.r(__webpack_exports__);
  48184. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  48185. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48186. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48187. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48188. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  48189. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48190. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  48191. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  48192. });
  48193. /**
  48194. * The HemisphericLight simulates the ambient environment light,
  48195. * so the passed direction is the light reflection direction, not the incoming direction.
  48196. */
  48197. var HemisphericLight = /** @class */ (function (_super) {
  48198. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  48199. /**
  48200. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  48201. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  48202. * The HemisphericLight can't cast shadows.
  48203. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48204. * @param name The friendly name of the light
  48205. * @param direction The direction of the light reflection
  48206. * @param scene The scene the light belongs to
  48207. */
  48208. function HemisphericLight(name, direction, scene) {
  48209. var _this = _super.call(this, name, scene) || this;
  48210. /**
  48211. * The groundColor is the light in the opposite direction to the one specified during creation.
  48212. * 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.
  48213. */
  48214. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  48215. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  48216. return _this;
  48217. }
  48218. HemisphericLight.prototype._buildUniformLayout = function () {
  48219. this._uniformBuffer.addUniform("vLightData", 4);
  48220. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  48221. this._uniformBuffer.addUniform("vLightSpecular", 3);
  48222. this._uniformBuffer.addUniform("vLightGround", 3);
  48223. this._uniformBuffer.addUniform("shadowsInfo", 3);
  48224. this._uniformBuffer.addUniform("depthValues", 2);
  48225. this._uniformBuffer.create();
  48226. };
  48227. /**
  48228. * Returns the string "HemisphericLight".
  48229. * @return The class name
  48230. */
  48231. HemisphericLight.prototype.getClassName = function () {
  48232. return "HemisphericLight";
  48233. };
  48234. /**
  48235. * Sets the HemisphericLight direction towards the passed target (Vector3).
  48236. * Returns the updated direction.
  48237. * @param target The target the direction should point to
  48238. * @return The computed direction
  48239. */
  48240. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  48241. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  48242. return this.direction;
  48243. };
  48244. /**
  48245. * Returns the shadow generator associated to the light.
  48246. * @returns Always null for hemispheric lights because it does not support shadows.
  48247. */
  48248. HemisphericLight.prototype.getShadowGenerator = function () {
  48249. return null;
  48250. };
  48251. /**
  48252. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  48253. * @param effect The effect to update
  48254. * @param lightIndex The index of the light in the effect to update
  48255. * @returns The hemispheric light
  48256. */
  48257. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  48258. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  48259. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  48260. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  48261. return this;
  48262. };
  48263. /**
  48264. * Computes the world matrix of the node
  48265. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  48266. * @param useWasUpdatedFlag defines a reserved property
  48267. * @returns the world matrix
  48268. */
  48269. HemisphericLight.prototype.computeWorldMatrix = function () {
  48270. if (!this._worldMatrix) {
  48271. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  48272. }
  48273. return this._worldMatrix;
  48274. };
  48275. /**
  48276. * Returns the integer 3.
  48277. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48278. */
  48279. HemisphericLight.prototype.getTypeID = function () {
  48280. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  48281. };
  48282. /**
  48283. * Prepares the list of defines specific to the light type.
  48284. * @param defines the list of defines
  48285. * @param lightIndex defines the index of the light for the effect
  48286. */
  48287. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  48288. defines["HEMILIGHT" + lightIndex] = true;
  48289. };
  48290. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  48292. ], HemisphericLight.prototype, "groundColor", void 0);
  48293. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  48295. ], HemisphericLight.prototype, "direction", void 0);
  48296. return HemisphericLight;
  48297. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  48298. /***/ }),
  48299. /***/ "./Lights/index.ts":
  48300. /*!*************************!*\
  48301. !*** ./Lights/index.ts ***!
  48302. \*************************/
  48303. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  48304. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48305. "use strict";
  48306. __webpack_require__.r(__webpack_exports__);
  48307. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  48309. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  48310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  48311. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  48312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  48313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  48314. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  48315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  48316. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  48317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  48318. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  48319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  48320. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  48321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  48322. /***/ }),
  48323. /***/ "./Lights/light.ts":
  48324. /*!*************************!*\
  48325. !*** ./Lights/light.ts ***!
  48326. \*************************/
  48327. /*! exports provided: Light */
  48328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48329. "use strict";
  48330. __webpack_require__.r(__webpack_exports__);
  48331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  48332. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48333. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48334. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48335. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  48336. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  48337. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  48338. /**
  48339. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  48340. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  48341. * 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.
  48342. */
  48343. var Light = /** @class */ (function (_super) {
  48344. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  48345. /**
  48346. * Creates a Light object in the scene.
  48347. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48348. * @param name The firendly name of the light
  48349. * @param scene The scene the light belongs too
  48350. */
  48351. function Light(name, scene) {
  48352. var _this = _super.call(this, name, scene) || this;
  48353. /**
  48354. * Diffuse gives the basic color to an object.
  48355. */
  48356. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  48357. /**
  48358. * Specular produces a highlight color on an object.
  48359. * Note: This is note affecting PBR materials.
  48360. */
  48361. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  48362. /**
  48363. * Defines the falloff type for this light. This lets overrriding how punctual light are
  48364. * falling off base on range or angle.
  48365. * This can be set to any values in Light.FALLOFF_x.
  48366. *
  48367. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  48368. * other types of materials.
  48369. */
  48370. _this.falloffType = Light.FALLOFF_DEFAULT;
  48371. /**
  48372. * Strength of the light.
  48373. * Note: By default it is define in the framework own unit.
  48374. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  48375. */
  48376. _this.intensity = 1.0;
  48377. _this._range = Number.MAX_VALUE;
  48378. _this._inverseSquaredRange = 0;
  48379. /**
  48380. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  48381. * of light.
  48382. */
  48383. _this._photometricScale = 1.0;
  48384. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  48385. _this._radius = 0.00001;
  48386. /**
  48387. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  48388. * exceeding the number allowed of the materials.
  48389. */
  48390. _this.renderPriority = 0;
  48391. _this._shadowEnabled = true;
  48392. _this._excludeWithLayerMask = 0;
  48393. _this._includeOnlyWithLayerMask = 0;
  48394. _this._lightmapMode = 0;
  48395. /**
  48396. * @hidden Internal use only.
  48397. */
  48398. _this._excludedMeshesIds = new Array();
  48399. /**
  48400. * @hidden Internal use only.
  48401. */
  48402. _this._includedOnlyMeshesIds = new Array();
  48403. /** @hidden */
  48404. _this._isLight = true;
  48405. _this.getScene().addLight(_this);
  48406. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  48407. _this._buildUniformLayout();
  48408. _this.includedOnlyMeshes = new Array();
  48409. _this.excludedMeshes = new Array();
  48410. _this._resyncMeshes();
  48411. return _this;
  48412. }
  48413. Object.defineProperty(Light.prototype, "range", {
  48414. /**
  48415. * Defines how far from the source the light is impacting in scene units.
  48416. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  48417. */
  48418. get: function () {
  48419. return this._range;
  48420. },
  48421. /**
  48422. * Defines how far from the source the light is impacting in scene units.
  48423. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  48424. */
  48425. set: function (value) {
  48426. this._range = value;
  48427. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  48428. },
  48429. enumerable: true,
  48430. configurable: true
  48431. });
  48432. Object.defineProperty(Light.prototype, "intensityMode", {
  48433. /**
  48434. * Gets the photometric scale used to interpret the intensity.
  48435. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  48436. */
  48437. get: function () {
  48438. return this._intensityMode;
  48439. },
  48440. /**
  48441. * Sets the photometric scale used to interpret the intensity.
  48442. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  48443. */
  48444. set: function (value) {
  48445. this._intensityMode = value;
  48446. this._computePhotometricScale();
  48447. },
  48448. enumerable: true,
  48449. configurable: true
  48450. });
  48451. Object.defineProperty(Light.prototype, "radius", {
  48452. /**
  48453. * Gets the light radius used by PBR Materials to simulate soft area lights.
  48454. */
  48455. get: function () {
  48456. return this._radius;
  48457. },
  48458. /**
  48459. * sets the light radius used by PBR Materials to simulate soft area lights.
  48460. */
  48461. set: function (value) {
  48462. this._radius = value;
  48463. this._computePhotometricScale();
  48464. },
  48465. enumerable: true,
  48466. configurable: true
  48467. });
  48468. Object.defineProperty(Light.prototype, "shadowEnabled", {
  48469. /**
  48470. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  48471. * the current shadow generator.
  48472. */
  48473. get: function () {
  48474. return this._shadowEnabled;
  48475. },
  48476. /**
  48477. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  48478. * the current shadow generator.
  48479. */
  48480. set: function (value) {
  48481. if (this._shadowEnabled === value) {
  48482. return;
  48483. }
  48484. this._shadowEnabled = value;
  48485. this._markMeshesAsLightDirty();
  48486. },
  48487. enumerable: true,
  48488. configurable: true
  48489. });
  48490. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  48491. /**
  48492. * Gets the only meshes impacted by this light.
  48493. */
  48494. get: function () {
  48495. return this._includedOnlyMeshes;
  48496. },
  48497. /**
  48498. * Sets the only meshes impacted by this light.
  48499. */
  48500. set: function (value) {
  48501. this._includedOnlyMeshes = value;
  48502. this._hookArrayForIncludedOnly(value);
  48503. },
  48504. enumerable: true,
  48505. configurable: true
  48506. });
  48507. Object.defineProperty(Light.prototype, "excludedMeshes", {
  48508. /**
  48509. * Gets the meshes not impacted by this light.
  48510. */
  48511. get: function () {
  48512. return this._excludedMeshes;
  48513. },
  48514. /**
  48515. * Sets the meshes not impacted by this light.
  48516. */
  48517. set: function (value) {
  48518. this._excludedMeshes = value;
  48519. this._hookArrayForExcluded(value);
  48520. },
  48521. enumerable: true,
  48522. configurable: true
  48523. });
  48524. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  48525. /**
  48526. * Gets the layer id use to find what meshes are not impacted by the light.
  48527. * Inactive if 0
  48528. */
  48529. get: function () {
  48530. return this._excludeWithLayerMask;
  48531. },
  48532. /**
  48533. * Sets the layer id use to find what meshes are not impacted by the light.
  48534. * Inactive if 0
  48535. */
  48536. set: function (value) {
  48537. this._excludeWithLayerMask = value;
  48538. this._resyncMeshes();
  48539. },
  48540. enumerable: true,
  48541. configurable: true
  48542. });
  48543. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  48544. /**
  48545. * Gets the layer id use to find what meshes are impacted by the light.
  48546. * Inactive if 0
  48547. */
  48548. get: function () {
  48549. return this._includeOnlyWithLayerMask;
  48550. },
  48551. /**
  48552. * Sets the layer id use to find what meshes are impacted by the light.
  48553. * Inactive if 0
  48554. */
  48555. set: function (value) {
  48556. this._includeOnlyWithLayerMask = value;
  48557. this._resyncMeshes();
  48558. },
  48559. enumerable: true,
  48560. configurable: true
  48561. });
  48562. Object.defineProperty(Light.prototype, "lightmapMode", {
  48563. /**
  48564. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  48565. */
  48566. get: function () {
  48567. return this._lightmapMode;
  48568. },
  48569. /**
  48570. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  48571. */
  48572. set: function (value) {
  48573. if (this._lightmapMode === value) {
  48574. return;
  48575. }
  48576. this._lightmapMode = value;
  48577. this._markMeshesAsLightDirty();
  48578. },
  48579. enumerable: true,
  48580. configurable: true
  48581. });
  48582. /**
  48583. * Returns the string "Light".
  48584. * @returns the class name
  48585. */
  48586. Light.prototype.getClassName = function () {
  48587. return "Light";
  48588. };
  48589. /**
  48590. * Converts the light information to a readable string for debug purpose.
  48591. * @param fullDetails Supports for multiple levels of logging within scene loading
  48592. * @returns the human readable light info
  48593. */
  48594. Light.prototype.toString = function (fullDetails) {
  48595. var ret = "Name: " + this.name;
  48596. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  48597. if (this.animations) {
  48598. for (var i = 0; i < this.animations.length; i++) {
  48599. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  48600. }
  48601. }
  48602. if (fullDetails) {
  48603. }
  48604. return ret;
  48605. };
  48606. /** @hidden */
  48607. Light.prototype._syncParentEnabledState = function () {
  48608. _super.prototype._syncParentEnabledState.call(this);
  48609. this._resyncMeshes();
  48610. };
  48611. /**
  48612. * Set the enabled state of this node.
  48613. * @param value - the new enabled state
  48614. */
  48615. Light.prototype.setEnabled = function (value) {
  48616. _super.prototype.setEnabled.call(this, value);
  48617. this._resyncMeshes();
  48618. };
  48619. /**
  48620. * Returns the Light associated shadow generator if any.
  48621. * @return the associated shadow generator.
  48622. */
  48623. Light.prototype.getShadowGenerator = function () {
  48624. return this._shadowGenerator;
  48625. };
  48626. /**
  48627. * Returns a Vector3, the absolute light position in the World.
  48628. * @returns the world space position of the light
  48629. */
  48630. Light.prototype.getAbsolutePosition = function () {
  48631. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48632. };
  48633. /**
  48634. * Specifies if the light will affect the passed mesh.
  48635. * @param mesh The mesh to test against the light
  48636. * @return true the mesh is affected otherwise, false.
  48637. */
  48638. Light.prototype.canAffectMesh = function (mesh) {
  48639. if (!mesh) {
  48640. return true;
  48641. }
  48642. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  48643. return false;
  48644. }
  48645. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  48646. return false;
  48647. }
  48648. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  48649. return false;
  48650. }
  48651. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  48652. return false;
  48653. }
  48654. return true;
  48655. };
  48656. /**
  48657. * Sort function to order lights for rendering.
  48658. * @param a First Light object to compare to second.
  48659. * @param b Second Light object to compare first.
  48660. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  48661. */
  48662. Light.CompareLightsPriority = function (a, b) {
  48663. //shadow-casting lights have priority over non-shadow-casting lights
  48664. //the renderPrioirty is a secondary sort criterion
  48665. if (a.shadowEnabled !== b.shadowEnabled) {
  48666. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  48667. }
  48668. return b.renderPriority - a.renderPriority;
  48669. };
  48670. /**
  48671. * Releases resources associated with this node.
  48672. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48673. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48674. */
  48675. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  48676. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  48677. if (this._shadowGenerator) {
  48678. this._shadowGenerator.dispose();
  48679. this._shadowGenerator = null;
  48680. }
  48681. // Animations
  48682. this.getScene().stopAnimation(this);
  48683. // Remove from meshes
  48684. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  48685. var mesh = _a[_i];
  48686. mesh._removeLightSource(this);
  48687. }
  48688. this._uniformBuffer.dispose();
  48689. // Remove from scene
  48690. this.getScene().removeLight(this);
  48691. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  48692. };
  48693. /**
  48694. * Returns the light type ID (integer).
  48695. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48696. */
  48697. Light.prototype.getTypeID = function () {
  48698. return 0;
  48699. };
  48700. /**
  48701. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  48702. * @returns the scaled intensity in intensity mode unit
  48703. */
  48704. Light.prototype.getScaledIntensity = function () {
  48705. return this._photometricScale * this.intensity;
  48706. };
  48707. /**
  48708. * Returns a new Light object, named "name", from the current one.
  48709. * @param name The name of the cloned light
  48710. * @returns the new created light
  48711. */
  48712. Light.prototype.clone = function (name) {
  48713. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  48714. if (!constructor) {
  48715. return null;
  48716. }
  48717. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  48718. };
  48719. /**
  48720. * Serializes the current light into a Serialization object.
  48721. * @returns the serialized object.
  48722. */
  48723. Light.prototype.serialize = function () {
  48724. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  48725. // Type
  48726. serializationObject.type = this.getTypeID();
  48727. // Parent
  48728. if (this.parent) {
  48729. serializationObject.parentId = this.parent.id;
  48730. }
  48731. // Inclusion / exclusions
  48732. if (this.excludedMeshes.length > 0) {
  48733. serializationObject.excludedMeshesIds = [];
  48734. this.excludedMeshes.forEach(function (mesh) {
  48735. serializationObject.excludedMeshesIds.push(mesh.id);
  48736. });
  48737. }
  48738. if (this.includedOnlyMeshes.length > 0) {
  48739. serializationObject.includedOnlyMeshesIds = [];
  48740. this.includedOnlyMeshes.forEach(function (mesh) {
  48741. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  48742. });
  48743. }
  48744. // Animations
  48745. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  48746. serializationObject.ranges = this.serializeAnimationRanges();
  48747. return serializationObject;
  48748. };
  48749. /**
  48750. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  48751. * This new light is named "name" and added to the passed scene.
  48752. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  48753. * @param name The friendly name of the light
  48754. * @param scene The scene the new light will belong to
  48755. * @returns the constructor function
  48756. */
  48757. Light.GetConstructorFromName = function (type, name, scene) {
  48758. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  48759. if (constructorFunc) {
  48760. return constructorFunc;
  48761. }
  48762. // Default to no light for none present once.
  48763. return null;
  48764. };
  48765. /**
  48766. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  48767. * @param parsedLight The JSON representation of the light
  48768. * @param scene The scene to create the parsed light in
  48769. * @returns the created light after parsing
  48770. */
  48771. Light.Parse = function (parsedLight, scene) {
  48772. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  48773. if (!constructor) {
  48774. return null;
  48775. }
  48776. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  48777. // Inclusion / exclusions
  48778. if (parsedLight.excludedMeshesIds) {
  48779. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  48780. }
  48781. if (parsedLight.includedOnlyMeshesIds) {
  48782. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  48783. }
  48784. // Parent
  48785. if (parsedLight.parentId) {
  48786. light._waitingParentId = parsedLight.parentId;
  48787. }
  48788. // Falloff
  48789. if (parsedLight.falloffType !== undefined) {
  48790. light.falloffType = parsedLight.falloffType;
  48791. }
  48792. // Lightmaps
  48793. if (parsedLight.lightmapMode !== undefined) {
  48794. light.lightmapMode = parsedLight.lightmapMode;
  48795. }
  48796. // Animations
  48797. if (parsedLight.animations) {
  48798. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  48799. var parsedAnimation = parsedLight.animations[animationIndex];
  48800. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  48801. if (internalClass) {
  48802. light.animations.push(internalClass.Parse(parsedAnimation));
  48803. }
  48804. }
  48805. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  48806. }
  48807. if (parsedLight.autoAnimate) {
  48808. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  48809. }
  48810. return light;
  48811. };
  48812. Light.prototype._hookArrayForExcluded = function (array) {
  48813. var _this = this;
  48814. var oldPush = array.push;
  48815. array.push = function () {
  48816. var items = [];
  48817. for (var _i = 0; _i < arguments.length; _i++) {
  48818. items[_i] = arguments[_i];
  48819. }
  48820. var result = oldPush.apply(array, items);
  48821. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  48822. var item = items_1[_a];
  48823. item._resyncLighSource(_this);
  48824. }
  48825. return result;
  48826. };
  48827. var oldSplice = array.splice;
  48828. array.splice = function (index, deleteCount) {
  48829. var deleted = oldSplice.apply(array, [index, deleteCount]);
  48830. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  48831. var item = deleted_1[_i];
  48832. item._resyncLighSource(_this);
  48833. }
  48834. return deleted;
  48835. };
  48836. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  48837. var item = array_1[_i];
  48838. item._resyncLighSource(this);
  48839. }
  48840. };
  48841. Light.prototype._hookArrayForIncludedOnly = function (array) {
  48842. var _this = this;
  48843. var oldPush = array.push;
  48844. array.push = function () {
  48845. var items = [];
  48846. for (var _i = 0; _i < arguments.length; _i++) {
  48847. items[_i] = arguments[_i];
  48848. }
  48849. var result = oldPush.apply(array, items);
  48850. _this._resyncMeshes();
  48851. return result;
  48852. };
  48853. var oldSplice = array.splice;
  48854. array.splice = function (index, deleteCount) {
  48855. var deleted = oldSplice.apply(array, [index, deleteCount]);
  48856. _this._resyncMeshes();
  48857. return deleted;
  48858. };
  48859. this._resyncMeshes();
  48860. };
  48861. Light.prototype._resyncMeshes = function () {
  48862. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  48863. var mesh = _a[_i];
  48864. mesh._resyncLighSource(this);
  48865. }
  48866. };
  48867. /**
  48868. * Forces the meshes to update their light related information in their rendering used effects
  48869. * @hidden Internal Use Only
  48870. */
  48871. Light.prototype._markMeshesAsLightDirty = function () {
  48872. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  48873. var mesh = _a[_i];
  48874. if (mesh.lightSources.indexOf(this) !== -1) {
  48875. mesh._markSubMeshesAsLightDirty();
  48876. }
  48877. }
  48878. };
  48879. /**
  48880. * Recomputes the cached photometric scale if needed.
  48881. */
  48882. Light.prototype._computePhotometricScale = function () {
  48883. this._photometricScale = this._getPhotometricScale();
  48884. this.getScene().resetCachedMaterial();
  48885. };
  48886. /**
  48887. * Returns the Photometric Scale according to the light type and intensity mode.
  48888. */
  48889. Light.prototype._getPhotometricScale = function () {
  48890. var photometricScale = 0.0;
  48891. var lightTypeID = this.getTypeID();
  48892. //get photometric mode
  48893. var photometricMode = this.intensityMode;
  48894. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  48895. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  48896. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  48897. }
  48898. else {
  48899. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  48900. }
  48901. }
  48902. //compute photometric scale
  48903. switch (lightTypeID) {
  48904. case Light.LIGHTTYPEID_POINTLIGHT:
  48905. case Light.LIGHTTYPEID_SPOTLIGHT:
  48906. switch (photometricMode) {
  48907. case Light.INTENSITYMODE_LUMINOUSPOWER:
  48908. photometricScale = 1.0 / (4.0 * Math.PI);
  48909. break;
  48910. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  48911. photometricScale = 1.0;
  48912. break;
  48913. case Light.INTENSITYMODE_LUMINANCE:
  48914. photometricScale = this.radius * this.radius;
  48915. break;
  48916. }
  48917. break;
  48918. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  48919. switch (photometricMode) {
  48920. case Light.INTENSITYMODE_ILLUMINANCE:
  48921. photometricScale = 1.0;
  48922. break;
  48923. case Light.INTENSITYMODE_LUMINANCE:
  48924. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  48925. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  48926. var apexAngleRadians = this.radius;
  48927. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  48928. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  48929. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  48930. photometricScale = solidAngle;
  48931. break;
  48932. }
  48933. break;
  48934. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  48935. // No fall off in hemisperic light.
  48936. photometricScale = 1.0;
  48937. break;
  48938. }
  48939. return photometricScale;
  48940. };
  48941. /**
  48942. * Reorder the light in the scene according to their defined priority.
  48943. * @hidden Internal Use Only
  48944. */
  48945. Light.prototype._reorderLightsInScene = function () {
  48946. var scene = this.getScene();
  48947. if (this._renderPriority != 0) {
  48948. scene.requireLightSorting = true;
  48949. }
  48950. this.getScene().sortLightsByPriority();
  48951. };
  48952. /**
  48953. * Falloff Default: light is falling off following the material specification:
  48954. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  48955. */
  48956. Light.FALLOFF_DEFAULT = 0;
  48957. /**
  48958. * Falloff Physical: light is falling off following the inverse squared distance law.
  48959. */
  48960. Light.FALLOFF_PHYSICAL = 1;
  48961. /**
  48962. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  48963. * to enhance interoperability with other engines.
  48964. */
  48965. Light.FALLOFF_GLTF = 2;
  48966. /**
  48967. * Falloff Standard: light is falling off like in the standard material
  48968. * to enhance interoperability with other materials.
  48969. */
  48970. Light.FALLOFF_STANDARD = 3;
  48971. //lightmapMode Consts
  48972. /**
  48973. * If every light affecting the material is in this lightmapMode,
  48974. * material.lightmapTexture adds or multiplies
  48975. * (depends on material.useLightmapAsShadowmap)
  48976. * after every other light calculations.
  48977. */
  48978. Light.LIGHTMAP_DEFAULT = 0;
  48979. /**
  48980. * material.lightmapTexture as only diffuse lighting from this light
  48981. * adds only specular lighting from this light
  48982. * adds dynamic shadows
  48983. */
  48984. Light.LIGHTMAP_SPECULAR = 1;
  48985. /**
  48986. * material.lightmapTexture as only lighting
  48987. * no light calculation from this light
  48988. * only adds dynamic shadows from this light
  48989. */
  48990. Light.LIGHTMAP_SHADOWSONLY = 2;
  48991. // Intensity Mode Consts
  48992. /**
  48993. * Each light type uses the default quantity according to its type:
  48994. * point/spot lights use luminous intensity
  48995. * directional lights use illuminance
  48996. */
  48997. Light.INTENSITYMODE_AUTOMATIC = 0;
  48998. /**
  48999. * lumen (lm)
  49000. */
  49001. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  49002. /**
  49003. * candela (lm/sr)
  49004. */
  49005. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  49006. /**
  49007. * lux (lm/m^2)
  49008. */
  49009. Light.INTENSITYMODE_ILLUMINANCE = 3;
  49010. /**
  49011. * nit (cd/m^2)
  49012. */
  49013. Light.INTENSITYMODE_LUMINANCE = 4;
  49014. // Light types ids const.
  49015. /**
  49016. * Light type const id of the point light.
  49017. */
  49018. Light.LIGHTTYPEID_POINTLIGHT = 0;
  49019. /**
  49020. * Light type const id of the directional light.
  49021. */
  49022. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  49023. /**
  49024. * Light type const id of the spot light.
  49025. */
  49026. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  49027. /**
  49028. * Light type const id of the hemispheric light.
  49029. */
  49030. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  49031. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49032. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  49033. ], Light.prototype, "diffuse", void 0);
  49034. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49035. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  49036. ], Light.prototype, "specular", void 0);
  49037. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49038. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49039. ], Light.prototype, "falloffType", void 0);
  49040. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49041. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49042. ], Light.prototype, "intensity", void 0);
  49043. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49044. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49045. ], Light.prototype, "range", null);
  49046. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49047. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49048. ], Light.prototype, "intensityMode", null);
  49049. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49050. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49051. ], Light.prototype, "radius", null);
  49052. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49053. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49054. ], Light.prototype, "_renderPriority", void 0);
  49055. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49056. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  49057. ], Light.prototype, "renderPriority", void 0);
  49058. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49059. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  49060. ], Light.prototype, "_shadowEnabled", void 0);
  49061. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49062. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  49063. ], Light.prototype, "_excludeWithLayerMask", void 0);
  49064. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49065. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  49066. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  49067. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49068. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  49069. ], Light.prototype, "_lightmapMode", void 0);
  49070. return Light;
  49071. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  49072. /***/ }),
  49073. /***/ "./Lights/pointLight.ts":
  49074. /*!******************************!*\
  49075. !*** ./Lights/pointLight.ts ***!
  49076. \******************************/
  49077. /*! exports provided: PointLight */
  49078. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49079. "use strict";
  49080. __webpack_require__.r(__webpack_exports__);
  49081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  49082. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  49083. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  49084. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  49085. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  49086. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  49087. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  49088. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  49089. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  49090. });
  49091. /**
  49092. * A point light is a light defined by an unique point in world space.
  49093. * The light is emitted in every direction from this point.
  49094. * A good example of a point light is a standard light bulb.
  49095. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49096. */
  49097. var PointLight = /** @class */ (function (_super) {
  49098. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  49099. /**
  49100. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49101. * A PointLight emits the light in every direction.
  49102. * It can cast shadows.
  49103. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49104. * ```javascript
  49105. * var pointLight = new PointLight("pl", camera.position, scene);
  49106. * ```
  49107. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49108. * @param name The light friendly name
  49109. * @param position The position of the point light in the scene
  49110. * @param scene The scene the lights belongs to
  49111. */
  49112. function PointLight(name, position, scene) {
  49113. var _this = _super.call(this, name, scene) || this;
  49114. _this._shadowAngle = Math.PI / 2;
  49115. _this.position = position;
  49116. return _this;
  49117. }
  49118. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  49119. /**
  49120. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49121. * This specifies what angle the shadow will use to be created.
  49122. *
  49123. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49124. */
  49125. get: function () {
  49126. return this._shadowAngle;
  49127. },
  49128. /**
  49129. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49130. * This specifies what angle the shadow will use to be created.
  49131. *
  49132. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49133. */
  49134. set: function (value) {
  49135. this._shadowAngle = value;
  49136. this.forceProjectionMatrixCompute();
  49137. },
  49138. enumerable: true,
  49139. configurable: true
  49140. });
  49141. Object.defineProperty(PointLight.prototype, "direction", {
  49142. /**
  49143. * Gets the direction if it has been set.
  49144. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49145. */
  49146. get: function () {
  49147. return this._direction;
  49148. },
  49149. /**
  49150. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49151. */
  49152. set: function (value) {
  49153. var previousNeedCube = this.needCube();
  49154. this._direction = value;
  49155. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  49156. this._shadowGenerator.recreateShadowMap();
  49157. }
  49158. },
  49159. enumerable: true,
  49160. configurable: true
  49161. });
  49162. /**
  49163. * Returns the string "PointLight"
  49164. * @returns the class name
  49165. */
  49166. PointLight.prototype.getClassName = function () {
  49167. return "PointLight";
  49168. };
  49169. /**
  49170. * Returns the integer 0.
  49171. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49172. */
  49173. PointLight.prototype.getTypeID = function () {
  49174. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  49175. };
  49176. /**
  49177. * Specifies wether or not the shadowmap should be a cube texture.
  49178. * @returns true if the shadowmap needs to be a cube texture.
  49179. */
  49180. PointLight.prototype.needCube = function () {
  49181. return !this.direction;
  49182. };
  49183. /**
  49184. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49185. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49186. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49187. */
  49188. PointLight.prototype.getShadowDirection = function (faceIndex) {
  49189. if (this.direction) {
  49190. return _super.prototype.getShadowDirection.call(this, faceIndex);
  49191. }
  49192. else {
  49193. switch (faceIndex) {
  49194. case 0:
  49195. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  49196. case 1:
  49197. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  49198. case 2:
  49199. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  49200. case 3:
  49201. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  49202. case 4:
  49203. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  49204. case 5:
  49205. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  49206. }
  49207. }
  49208. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  49209. };
  49210. /**
  49211. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49212. * - fov = PI / 2
  49213. * - aspect ratio : 1.0
  49214. * - z-near and far equal to the active camera minZ and maxZ.
  49215. * Returns the PointLight.
  49216. */
  49217. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  49218. var activeCamera = this.getScene().activeCamera;
  49219. if (!activeCamera) {
  49220. return;
  49221. }
  49222. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  49223. };
  49224. PointLight.prototype._buildUniformLayout = function () {
  49225. this._uniformBuffer.addUniform("vLightData", 4);
  49226. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  49227. this._uniformBuffer.addUniform("vLightSpecular", 3);
  49228. this._uniformBuffer.addUniform("vLightFalloff", 4);
  49229. this._uniformBuffer.addUniform("shadowsInfo", 3);
  49230. this._uniformBuffer.addUniform("depthValues", 2);
  49231. this._uniformBuffer.create();
  49232. };
  49233. /**
  49234. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49235. * @param effect The effect to update
  49236. * @param lightIndex The index of the light in the effect to update
  49237. * @returns The point light
  49238. */
  49239. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  49240. if (this.computeTransformedInformation()) {
  49241. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  49242. }
  49243. else {
  49244. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  49245. }
  49246. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  49247. return this;
  49248. };
  49249. /**
  49250. * Prepares the list of defines specific to the light type.
  49251. * @param defines the list of defines
  49252. * @param lightIndex defines the index of the light for the effect
  49253. */
  49254. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  49255. defines["POINTLIGHT" + lightIndex] = true;
  49256. };
  49257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49259. ], PointLight.prototype, "shadowAngle", null);
  49260. return PointLight;
  49261. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  49262. /***/ }),
  49263. /***/ "./Lights/shadowLight.ts":
  49264. /*!*******************************!*\
  49265. !*** ./Lights/shadowLight.ts ***!
  49266. \*******************************/
  49267. /*! exports provided: ShadowLight */
  49268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49269. "use strict";
  49270. __webpack_require__.r(__webpack_exports__);
  49271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  49272. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  49273. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  49274. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  49275. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  49276. /**
  49277. * Base implementation IShadowLight
  49278. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  49279. */
  49280. var ShadowLight = /** @class */ (function (_super) {
  49281. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  49282. function ShadowLight() {
  49283. var _this = _super !== null && _super.apply(this, arguments) || this;
  49284. _this._needProjectionMatrixCompute = true;
  49285. return _this;
  49286. }
  49287. ShadowLight.prototype._setPosition = function (value) {
  49288. this._position = value;
  49289. };
  49290. Object.defineProperty(ShadowLight.prototype, "position", {
  49291. /**
  49292. * Sets the position the shadow will be casted from. Also use as the light position for both
  49293. * point and spot lights.
  49294. */
  49295. get: function () {
  49296. return this._position;
  49297. },
  49298. /**
  49299. * Sets the position the shadow will be casted from. Also use as the light position for both
  49300. * point and spot lights.
  49301. */
  49302. set: function (value) {
  49303. this._setPosition(value);
  49304. },
  49305. enumerable: true,
  49306. configurable: true
  49307. });
  49308. ShadowLight.prototype._setDirection = function (value) {
  49309. this._direction = value;
  49310. };
  49311. Object.defineProperty(ShadowLight.prototype, "direction", {
  49312. /**
  49313. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  49314. * Also use as the light direction on spot and directional lights.
  49315. */
  49316. get: function () {
  49317. return this._direction;
  49318. },
  49319. /**
  49320. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  49321. * Also use as the light direction on spot and directional lights.
  49322. */
  49323. set: function (value) {
  49324. this._setDirection(value);
  49325. },
  49326. enumerable: true,
  49327. configurable: true
  49328. });
  49329. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  49330. /**
  49331. * Gets the shadow projection clipping minimum z value.
  49332. */
  49333. get: function () {
  49334. return this._shadowMinZ;
  49335. },
  49336. /**
  49337. * Sets the shadow projection clipping minimum z value.
  49338. */
  49339. set: function (value) {
  49340. this._shadowMinZ = value;
  49341. this.forceProjectionMatrixCompute();
  49342. },
  49343. enumerable: true,
  49344. configurable: true
  49345. });
  49346. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  49347. /**
  49348. * Sets the shadow projection clipping maximum z value.
  49349. */
  49350. get: function () {
  49351. return this._shadowMaxZ;
  49352. },
  49353. /**
  49354. * Gets the shadow projection clipping maximum z value.
  49355. */
  49356. set: function (value) {
  49357. this._shadowMaxZ = value;
  49358. this.forceProjectionMatrixCompute();
  49359. },
  49360. enumerable: true,
  49361. configurable: true
  49362. });
  49363. /**
  49364. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  49365. * @returns true if the information has been computed, false if it does not need to (no parenting)
  49366. */
  49367. ShadowLight.prototype.computeTransformedInformation = function () {
  49368. if (this.parent && this.parent.getWorldMatrix) {
  49369. if (!this.transformedPosition) {
  49370. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  49371. }
  49372. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  49373. // In case the direction is present.
  49374. if (this.direction) {
  49375. if (!this.transformedDirection) {
  49376. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  49377. }
  49378. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  49379. }
  49380. return true;
  49381. }
  49382. return false;
  49383. };
  49384. /**
  49385. * Return the depth scale used for the shadow map.
  49386. * @returns the depth scale.
  49387. */
  49388. ShadowLight.prototype.getDepthScale = function () {
  49389. return 50.0;
  49390. };
  49391. /**
  49392. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  49393. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49394. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49395. */
  49396. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  49397. return this.transformedDirection ? this.transformedDirection : this.direction;
  49398. };
  49399. /**
  49400. * Returns the ShadowLight absolute position in the World.
  49401. * @returns the position vector in world space
  49402. */
  49403. ShadowLight.prototype.getAbsolutePosition = function () {
  49404. return this.transformedPosition ? this.transformedPosition : this.position;
  49405. };
  49406. /**
  49407. * Sets the ShadowLight direction toward the passed target.
  49408. * @param target The point to target in local space
  49409. * @returns the updated ShadowLight direction
  49410. */
  49411. ShadowLight.prototype.setDirectionToTarget = function (target) {
  49412. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  49413. return this.direction;
  49414. };
  49415. /**
  49416. * Returns the light rotation in euler definition.
  49417. * @returns the x y z rotation in local space.
  49418. */
  49419. ShadowLight.prototype.getRotation = function () {
  49420. this.direction.normalize();
  49421. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  49422. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  49423. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  49424. };
  49425. /**
  49426. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  49427. * @returns true if a cube texture needs to be use
  49428. */
  49429. ShadowLight.prototype.needCube = function () {
  49430. return false;
  49431. };
  49432. /**
  49433. * Detects if the projection matrix requires to be recomputed this frame.
  49434. * @returns true if it requires to be recomputed otherwise, false.
  49435. */
  49436. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  49437. return this._needProjectionMatrixCompute;
  49438. };
  49439. /**
  49440. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  49441. */
  49442. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  49443. this._needProjectionMatrixCompute = true;
  49444. };
  49445. /** @hidden */
  49446. ShadowLight.prototype._initCache = function () {
  49447. _super.prototype._initCache.call(this);
  49448. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  49449. };
  49450. /** @hidden */
  49451. ShadowLight.prototype._isSynchronized = function () {
  49452. if (!this._cache.position.equals(this.position)) {
  49453. return false;
  49454. }
  49455. return true;
  49456. };
  49457. /**
  49458. * Computes the world matrix of the node
  49459. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  49460. * @returns the world matrix
  49461. */
  49462. ShadowLight.prototype.computeWorldMatrix = function (force) {
  49463. if (!force && this.isSynchronized()) {
  49464. this._currentRenderId = this.getScene().getRenderId();
  49465. return this._worldMatrix;
  49466. }
  49467. this._updateCache();
  49468. this._cache.position.copyFrom(this.position);
  49469. if (!this._worldMatrix) {
  49470. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  49471. }
  49472. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  49473. if (this.parent && this.parent.getWorldMatrix) {
  49474. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  49475. this._markSyncedWithParent();
  49476. }
  49477. // Cache the determinant
  49478. this._worldMatrixDeterminantIsDirty = true;
  49479. return this._worldMatrix;
  49480. };
  49481. /**
  49482. * Gets the minZ used for shadow according to both the scene and the light.
  49483. * @param activeCamera The camera we are returning the min for
  49484. * @returns the depth min z
  49485. */
  49486. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  49487. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  49488. };
  49489. /**
  49490. * Gets the maxZ used for shadow according to both the scene and the light.
  49491. * @param activeCamera The camera we are returning the max for
  49492. * @returns the depth max z
  49493. */
  49494. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  49495. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  49496. };
  49497. /**
  49498. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  49499. * @param matrix The materix to updated with the projection information
  49500. * @param viewMatrix The transform matrix of the light
  49501. * @param renderList The list of mesh to render in the map
  49502. * @returns The current light
  49503. */
  49504. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  49505. if (this.customProjectionMatrixBuilder) {
  49506. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  49507. }
  49508. else {
  49509. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  49510. }
  49511. return this;
  49512. };
  49513. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49514. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  49515. ], ShadowLight.prototype, "position", null);
  49516. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49517. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  49518. ], ShadowLight.prototype, "direction", null);
  49519. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49520. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49521. ], ShadowLight.prototype, "shadowMinZ", null);
  49522. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49523. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49524. ], ShadowLight.prototype, "shadowMaxZ", null);
  49525. return ShadowLight;
  49526. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  49527. /***/ }),
  49528. /***/ "./Lights/spotLight.ts":
  49529. /*!*****************************!*\
  49530. !*** ./Lights/spotLight.ts ***!
  49531. \*****************************/
  49532. /*! exports provided: SpotLight */
  49533. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49534. "use strict";
  49535. __webpack_require__.r(__webpack_exports__);
  49536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  49537. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  49538. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  49539. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  49540. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  49541. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  49542. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  49543. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  49544. 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); };
  49545. });
  49546. /**
  49547. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49548. * These values define a cone of light starting from the position, emitting toward the direction.
  49549. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49550. * and the exponent defines the speed of the decay of the light with distance (reach).
  49551. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49552. */
  49553. var SpotLight = /** @class */ (function (_super) {
  49554. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  49555. /**
  49556. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49557. * It can cast shadows.
  49558. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49559. * @param name The light friendly name
  49560. * @param position The position of the spot light in the scene
  49561. * @param direction The direction of the light in the scene
  49562. * @param angle The cone angle of the light in Radians
  49563. * @param exponent The light decay speed with the distance from the emission spot
  49564. * @param scene The scene the lights belongs to
  49565. */
  49566. function SpotLight(name, position, direction, angle, exponent, scene) {
  49567. var _this = _super.call(this, name, scene) || this;
  49568. _this._innerAngle = 0;
  49569. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  49570. _this._projectionTextureLightNear = 1e-6;
  49571. _this._projectionTextureLightFar = 1000.0;
  49572. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  49573. _this._projectionTextureViewLightDirty = true;
  49574. _this._projectionTextureProjectionLightDirty = true;
  49575. _this._projectionTextureDirty = true;
  49576. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  49577. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  49578. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  49579. _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);
  49580. _this.position = position;
  49581. _this.direction = direction;
  49582. _this.angle = angle;
  49583. _this.exponent = exponent;
  49584. return _this;
  49585. }
  49586. Object.defineProperty(SpotLight.prototype, "angle", {
  49587. /**
  49588. * Gets the cone angle of the spot light in Radians.
  49589. */
  49590. get: function () {
  49591. return this._angle;
  49592. },
  49593. /**
  49594. * Sets the cone angle of the spot light in Radians.
  49595. */
  49596. set: function (value) {
  49597. this._angle = value;
  49598. this._cosHalfAngle = Math.cos(value * 0.5);
  49599. this._projectionTextureProjectionLightDirty = true;
  49600. this.forceProjectionMatrixCompute();
  49601. this._computeAngleValues();
  49602. },
  49603. enumerable: true,
  49604. configurable: true
  49605. });
  49606. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  49607. /**
  49608. * Only used in gltf falloff mode, this defines the angle where
  49609. * the directional falloff will start before cutting at angle which could be seen
  49610. * as outer angle.
  49611. */
  49612. get: function () {
  49613. return this._innerAngle;
  49614. },
  49615. /**
  49616. * Only used in gltf falloff mode, this defines the angle where
  49617. * the directional falloff will start before cutting at angle which could be seen
  49618. * as outer angle.
  49619. */
  49620. set: function (value) {
  49621. this._innerAngle = value;
  49622. this._computeAngleValues();
  49623. },
  49624. enumerable: true,
  49625. configurable: true
  49626. });
  49627. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  49628. /**
  49629. * Allows scaling the angle of the light for shadow generation only.
  49630. */
  49631. get: function () {
  49632. return this._shadowAngleScale;
  49633. },
  49634. /**
  49635. * Allows scaling the angle of the light for shadow generation only.
  49636. */
  49637. set: function (value) {
  49638. this._shadowAngleScale = value;
  49639. this.forceProjectionMatrixCompute();
  49640. },
  49641. enumerable: true,
  49642. configurable: true
  49643. });
  49644. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  49645. /**
  49646. * Allows reading the projecton texture
  49647. */
  49648. get: function () {
  49649. return this._projectionTextureMatrix;
  49650. },
  49651. enumerable: true,
  49652. configurable: true
  49653. });
  49654. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  49655. /**
  49656. * Gets the near clip of the Spotlight for texture projection.
  49657. */
  49658. get: function () {
  49659. return this._projectionTextureLightNear;
  49660. },
  49661. /**
  49662. * Sets the near clip of the Spotlight for texture projection.
  49663. */
  49664. set: function (value) {
  49665. this._projectionTextureLightNear = value;
  49666. this._projectionTextureProjectionLightDirty = true;
  49667. },
  49668. enumerable: true,
  49669. configurable: true
  49670. });
  49671. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  49672. /**
  49673. * Gets the far clip of the Spotlight for texture projection.
  49674. */
  49675. get: function () {
  49676. return this._projectionTextureLightFar;
  49677. },
  49678. /**
  49679. * Sets the far clip of the Spotlight for texture projection.
  49680. */
  49681. set: function (value) {
  49682. this._projectionTextureLightFar = value;
  49683. this._projectionTextureProjectionLightDirty = true;
  49684. },
  49685. enumerable: true,
  49686. configurable: true
  49687. });
  49688. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  49689. /**
  49690. * Gets the Up vector of the Spotlight for texture projection.
  49691. */
  49692. get: function () {
  49693. return this._projectionTextureUpDirection;
  49694. },
  49695. /**
  49696. * Sets the Up vector of the Spotlight for texture projection.
  49697. */
  49698. set: function (value) {
  49699. this._projectionTextureUpDirection = value;
  49700. this._projectionTextureProjectionLightDirty = true;
  49701. },
  49702. enumerable: true,
  49703. configurable: true
  49704. });
  49705. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  49706. /**
  49707. * Gets the projection texture of the light.
  49708. */
  49709. get: function () {
  49710. return this._projectionTexture;
  49711. },
  49712. /**
  49713. * Sets the projection texture of the light.
  49714. */
  49715. set: function (value) {
  49716. var _this = this;
  49717. if (this._projectionTexture === value) {
  49718. return;
  49719. }
  49720. this._projectionTexture = value;
  49721. this._projectionTextureDirty = true;
  49722. if (this._projectionTexture && !this._projectionTexture.isReady()) {
  49723. var texture = this._projectionTexture;
  49724. if (texture.onLoadObservable) {
  49725. texture.onLoadObservable.addOnce(function () {
  49726. _this._markMeshesAsLightDirty();
  49727. });
  49728. }
  49729. }
  49730. },
  49731. enumerable: true,
  49732. configurable: true
  49733. });
  49734. /**
  49735. * Returns the string "SpotLight".
  49736. * @returns the class name
  49737. */
  49738. SpotLight.prototype.getClassName = function () {
  49739. return "SpotLight";
  49740. };
  49741. /**
  49742. * Returns the integer 2.
  49743. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49744. */
  49745. SpotLight.prototype.getTypeID = function () {
  49746. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  49747. };
  49748. /**
  49749. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49750. */
  49751. SpotLight.prototype._setDirection = function (value) {
  49752. _super.prototype._setDirection.call(this, value);
  49753. this._projectionTextureViewLightDirty = true;
  49754. };
  49755. /**
  49756. * Overrides the position setter to recompute the projection texture view light Matrix.
  49757. */
  49758. SpotLight.prototype._setPosition = function (value) {
  49759. _super.prototype._setPosition.call(this, value);
  49760. this._projectionTextureViewLightDirty = true;
  49761. };
  49762. /**
  49763. * 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.
  49764. * Returns the SpotLight.
  49765. */
  49766. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  49767. var activeCamera = this.getScene().activeCamera;
  49768. if (!activeCamera) {
  49769. return;
  49770. }
  49771. this._shadowAngleScale = this._shadowAngleScale || 1;
  49772. var angle = this._shadowAngleScale * this._angle;
  49773. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  49774. };
  49775. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  49776. this._projectionTextureViewLightDirty = false;
  49777. this._projectionTextureDirty = true;
  49778. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  49779. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  49780. };
  49781. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  49782. this._projectionTextureProjectionLightDirty = false;
  49783. this._projectionTextureDirty = true;
  49784. var light_far = this.projectionTextureLightFar;
  49785. var light_near = this.projectionTextureLightNear;
  49786. var P = light_far / (light_far - light_near);
  49787. var Q = -P * light_near;
  49788. var S = 1.0 / Math.tan(this._angle / 2.0);
  49789. var A = 1.0;
  49790. _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);
  49791. };
  49792. /**
  49793. * Main function for light texture projection matrix computing.
  49794. */
  49795. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  49796. this._projectionTextureDirty = false;
  49797. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  49798. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  49799. };
  49800. SpotLight.prototype._buildUniformLayout = function () {
  49801. this._uniformBuffer.addUniform("vLightData", 4);
  49802. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  49803. this._uniformBuffer.addUniform("vLightSpecular", 3);
  49804. this._uniformBuffer.addUniform("vLightDirection", 3);
  49805. this._uniformBuffer.addUniform("vLightFalloff", 4);
  49806. this._uniformBuffer.addUniform("shadowsInfo", 3);
  49807. this._uniformBuffer.addUniform("depthValues", 2);
  49808. this._uniformBuffer.create();
  49809. };
  49810. SpotLight.prototype._computeAngleValues = function () {
  49811. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  49812. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  49813. };
  49814. /**
  49815. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49816. * @param effect The effect to update
  49817. * @param lightIndex The index of the light in the effect to update
  49818. * @returns The spot light
  49819. */
  49820. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  49821. var normalizeDirection;
  49822. if (this.computeTransformedInformation()) {
  49823. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  49824. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  49825. }
  49826. else {
  49827. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  49828. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  49829. }
  49830. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  49831. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  49832. if (this.projectionTexture && this.projectionTexture.isReady()) {
  49833. if (this._projectionTextureViewLightDirty) {
  49834. this._computeProjectionTextureViewLightMatrix();
  49835. }
  49836. if (this._projectionTextureProjectionLightDirty) {
  49837. this._computeProjectionTextureProjectionLightMatrix();
  49838. }
  49839. if (this._projectionTextureDirty) {
  49840. this._computeProjectionTextureMatrix();
  49841. }
  49842. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  49843. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  49844. }
  49845. return this;
  49846. };
  49847. /**
  49848. * Disposes the light and the associated resources.
  49849. */
  49850. SpotLight.prototype.dispose = function () {
  49851. _super.prototype.dispose.call(this);
  49852. if (this._projectionTexture) {
  49853. this._projectionTexture.dispose();
  49854. }
  49855. };
  49856. /**
  49857. * Prepares the list of defines specific to the light type.
  49858. * @param defines the list of defines
  49859. * @param lightIndex defines the index of the light for the effect
  49860. */
  49861. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  49862. defines["SPOTLIGHT" + lightIndex] = true;
  49863. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture && this.projectionTexture.isReady() ? true : false;
  49864. };
  49865. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49867. ], SpotLight.prototype, "angle", null);
  49868. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49870. ], SpotLight.prototype, "innerAngle", null);
  49871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49873. ], SpotLight.prototype, "shadowAngleScale", null);
  49874. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49875. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49876. ], SpotLight.prototype, "exponent", void 0);
  49877. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49878. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49879. ], SpotLight.prototype, "projectionTextureLightNear", null);
  49880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49882. ], SpotLight.prototype, "projectionTextureLightFar", null);
  49883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49885. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  49886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  49888. ], SpotLight.prototype, "_projectionTexture", void 0);
  49889. return SpotLight;
  49890. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  49891. /***/ }),
  49892. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  49893. /*!**********************************************!*\
  49894. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  49895. \**********************************************/
  49896. /*! exports provided: _BabylonLoaderRegistered */
  49897. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49898. "use strict";
  49899. __webpack_require__.r(__webpack_exports__);
  49900. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  49901. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  49902. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  49903. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  49904. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  49905. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  49906. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  49907. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  49908. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  49909. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  49910. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  49911. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  49912. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  49913. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  49914. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  49915. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  49916. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  49917. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  49918. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  49919. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  49920. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  49921. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  49922. /* harmony import */ var _Physics_Plugins_ammoJSPlugin__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Physics/Plugins/ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  49923. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  49924. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  49925. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  49926. /** @hidden */
  49927. var _BabylonLoaderRegistered = true;
  49928. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  49929. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  49930. var parsedMaterial = parsedData.materials[index];
  49931. if (parsedMaterial.id === id) {
  49932. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  49933. }
  49934. }
  49935. return null;
  49936. };
  49937. var isDescendantOf = function (mesh, names, hierarchyIds) {
  49938. for (var i in names) {
  49939. if (mesh.name === names[i]) {
  49940. hierarchyIds.push(mesh.id);
  49941. return true;
  49942. }
  49943. }
  49944. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  49945. hierarchyIds.push(mesh.id);
  49946. return true;
  49947. }
  49948. return false;
  49949. };
  49950. var logOperation = function (operation, producer) {
  49951. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  49952. };
  49953. var loadDetailLevels = function (scene, mesh) {
  49954. var mastermesh = mesh;
  49955. // Every value specified in the ids array of the lod data points to another mesh which should be used as the lower LOD level.
  49956. // The distances (or coverages) array values specified are used along with the lod mesh ids as a hint to determine the switching threshold for the various LODs.
  49957. if (mesh._waitingData.lods) {
  49958. if (mesh._waitingData.lods.ids && mesh._waitingData.lods.ids.length > 0) {
  49959. var lodmeshes = mesh._waitingData.lods.ids;
  49960. var wasenabled = mastermesh.isEnabled(false);
  49961. if (mesh._waitingData.lods.distances) {
  49962. var distances = mesh._waitingData.lods.distances;
  49963. if (distances.length >= lodmeshes.length) {
  49964. var culling = (distances.length > lodmeshes.length) ? distances[distances.length - 1] : 0;
  49965. mastermesh.setEnabled(false);
  49966. for (var index = 0; index < lodmeshes.length; index++) {
  49967. var lodid = lodmeshes[index];
  49968. var lodmesh = scene.getMeshByID(lodid);
  49969. if (lodmesh != null) {
  49970. mastermesh.addLODLevel(distances[index], lodmesh);
  49971. }
  49972. }
  49973. if (culling > 0) {
  49974. mastermesh.addLODLevel(culling, null);
  49975. }
  49976. if (wasenabled === true) {
  49977. mastermesh.setEnabled(true);
  49978. }
  49979. }
  49980. else {
  49981. _Misc_tools__WEBPACK_IMPORTED_MODULE_24__["Tools"].Warn("Invalid level of detail distances for " + mesh.name);
  49982. }
  49983. }
  49984. }
  49985. mesh._waitingData.lods = null;
  49986. }
  49987. };
  49988. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  49989. if (addToScene === void 0) { addToScene = false; }
  49990. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  49991. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  49992. // when SceneLoader.debugLogging = true (default), or exception encountered.
  49993. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  49994. // and avoid problems with multiple concurrent .babylon loads.
  49995. var log = "importScene has failed JSON parse";
  49996. try {
  49997. var parsedData = JSON.parse(data);
  49998. log = "";
  49999. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  50000. var index;
  50001. var cache;
  50002. // Environment texture
  50003. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  50004. // PBR needed for both HDR texture (gamma space) & a sky box
  50005. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  50006. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  50007. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  50008. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"]((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  50009. if (parsedData.environmentTextureRotationY) {
  50010. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  50011. }
  50012. scene.environmentTexture = hdrTexture;
  50013. }
  50014. else {
  50015. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_24__["Tools"].EndsWith(parsedData.environmentTexture, ".env")) {
  50016. var compressedTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"]((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene);
  50017. if (parsedData.environmentTextureRotationY) {
  50018. compressedTexture.rotationY = parsedData.environmentTextureRotationY;
  50019. }
  50020. scene.environmentTexture = compressedTexture;
  50021. }
  50022. else {
  50023. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene);
  50024. if (parsedData.environmentTextureRotationY) {
  50025. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  50026. }
  50027. scene.environmentTexture = cubeTexture;
  50028. }
  50029. }
  50030. if (parsedData.createDefaultSkybox === true) {
  50031. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  50032. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  50033. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  50034. }
  50035. container.environmentTexture = scene.environmentTexture;
  50036. }
  50037. // Lights
  50038. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  50039. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  50040. var parsedLight = parsedData.lights[index];
  50041. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  50042. if (light) {
  50043. container.lights.push(light);
  50044. log += (index === 0 ? "\n\tLights:" : "");
  50045. log += "\n\t\t" + light.toString(fullDetails);
  50046. }
  50047. }
  50048. }
  50049. // Reflection probes
  50050. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  50051. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  50052. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  50053. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  50054. if (reflectionProbe) {
  50055. container.reflectionProbes.push(reflectionProbe);
  50056. log += (index === 0 ? "\n\tReflection Probes:" : "");
  50057. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  50058. }
  50059. }
  50060. }
  50061. // Animations
  50062. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  50063. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  50064. var parsedAnimation = parsedData.animations[index];
  50065. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_23__["_TypeStore"].GetClass("BABYLON.Animation");
  50066. if (internalClass) {
  50067. var animation = internalClass.Parse(parsedAnimation);
  50068. scene.animations.push(animation);
  50069. container.animations.push(animation);
  50070. log += (index === 0 ? "\n\tAnimations:" : "");
  50071. log += "\n\t\t" + animation.toString(fullDetails);
  50072. }
  50073. }
  50074. }
  50075. // Materials
  50076. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  50077. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  50078. var parsedMaterial = parsedData.materials[index];
  50079. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  50080. if (mat) {
  50081. container.materials.push(mat);
  50082. log += (index === 0 ? "\n\tMaterials:" : "");
  50083. log += "\n\t\t" + mat.toString(fullDetails);
  50084. // Textures
  50085. var textures = mat.getActiveTextures();
  50086. textures.forEach(function (t) {
  50087. if (container.textures.indexOf(t) == -1) {
  50088. container.textures.push(t);
  50089. }
  50090. });
  50091. }
  50092. }
  50093. }
  50094. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  50095. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  50096. var parsedMultiMaterial = parsedData.multiMaterials[index];
  50097. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  50098. container.multiMaterials.push(mmat);
  50099. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  50100. log += "\n\t\t" + mmat.toString(fullDetails);
  50101. // Textures
  50102. var textures = mmat.getActiveTextures();
  50103. textures.forEach(function (t) {
  50104. if (container.textures.indexOf(t) == -1) {
  50105. container.textures.push(t);
  50106. }
  50107. });
  50108. }
  50109. }
  50110. // Morph targets
  50111. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  50112. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  50113. var managerData = _a[_i];
  50114. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  50115. }
  50116. }
  50117. // Skeletons
  50118. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  50119. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  50120. var parsedSkeleton = parsedData.skeletons[index];
  50121. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  50122. container.skeletons.push(skeleton);
  50123. log += (index === 0 ? "\n\tSkeletons:" : "");
  50124. log += "\n\t\t" + skeleton.toString(fullDetails);
  50125. }
  50126. }
  50127. // Geometries
  50128. var geometries = parsedData.geometries;
  50129. if (geometries !== undefined && geometries !== null) {
  50130. var addedGeometry = new Array();
  50131. // VertexData
  50132. var vertexData = geometries.vertexData;
  50133. if (vertexData !== undefined && vertexData !== null) {
  50134. for (index = 0, cache = vertexData.length; index < cache; index++) {
  50135. var parsedVertexData = vertexData[index];
  50136. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  50137. }
  50138. }
  50139. addedGeometry.forEach(function (g) {
  50140. if (g) {
  50141. container.geometries.push(g);
  50142. }
  50143. });
  50144. }
  50145. // Transform nodes
  50146. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  50147. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  50148. var parsedTransformNode = parsedData.transformNodes[index];
  50149. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  50150. container.transformNodes.push(node);
  50151. }
  50152. }
  50153. // Meshes
  50154. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  50155. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  50156. var parsedMesh = parsedData.meshes[index];
  50157. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  50158. container.meshes.push(mesh);
  50159. log += (index === 0 ? "\n\tMeshes:" : "");
  50160. log += "\n\t\t" + mesh.toString(fullDetails);
  50161. }
  50162. }
  50163. // Cameras
  50164. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  50165. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  50166. var parsedCamera = parsedData.cameras[index];
  50167. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  50168. container.cameras.push(camera);
  50169. log += (index === 0 ? "\n\tCameras:" : "");
  50170. log += "\n\t\t" + camera.toString(fullDetails);
  50171. }
  50172. }
  50173. // Animation Groups
  50174. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  50175. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  50176. var parsedAnimationGroup = parsedData.animationGroups[index];
  50177. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  50178. container.animationGroups.push(animationGroup);
  50179. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  50180. log += "\n\t\t" + animationGroup.toString(fullDetails);
  50181. }
  50182. }
  50183. // Browsing all the graph to connect the dots
  50184. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  50185. var camera = scene.cameras[index];
  50186. if (camera._waitingParentId) {
  50187. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  50188. camera._waitingParentId = null;
  50189. }
  50190. }
  50191. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  50192. var light_1 = scene.lights[index];
  50193. if (light_1 && light_1._waitingParentId) {
  50194. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  50195. light_1._waitingParentId = null;
  50196. }
  50197. }
  50198. // Connect parents & children and parse actions and lods
  50199. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  50200. var transformNode = scene.transformNodes[index];
  50201. if (transformNode._waitingParentId) {
  50202. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  50203. transformNode._waitingParentId = null;
  50204. }
  50205. }
  50206. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  50207. var mesh = scene.meshes[index];
  50208. if (mesh._waitingParentId) {
  50209. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  50210. mesh._waitingParentId = null;
  50211. }
  50212. if (mesh._waitingData.lods) {
  50213. loadDetailLevels(scene, mesh);
  50214. }
  50215. }
  50216. // link skeleton transform nodes
  50217. for (index = 0, cache = scene.skeletons.length; index < cache; index++) {
  50218. var skeleton = scene.skeletons[index];
  50219. if (skeleton._hasWaitingData) {
  50220. if (skeleton.bones != null) {
  50221. skeleton.bones.forEach(function (bone) {
  50222. if (bone._waitingTransformNodeId) {
  50223. var linkTransformNode = scene.getLastEntryByID(bone._waitingTransformNodeId);
  50224. if (linkTransformNode) {
  50225. bone.linkTransformNode(linkTransformNode);
  50226. }
  50227. bone._waitingTransformNodeId = null;
  50228. }
  50229. });
  50230. }
  50231. skeleton._hasWaitingData = null;
  50232. }
  50233. }
  50234. // freeze world matrix application
  50235. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  50236. var currentMesh = scene.meshes[index];
  50237. if (currentMesh._waitingData.freezeWorldMatrix) {
  50238. currentMesh.freezeWorldMatrix();
  50239. currentMesh._waitingData.freezeWorldMatrix = null;
  50240. }
  50241. else {
  50242. currentMesh.computeWorldMatrix(true);
  50243. }
  50244. }
  50245. // Lights exclusions / inclusions
  50246. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  50247. var light_2 = scene.lights[index];
  50248. // Excluded check
  50249. if (light_2._excludedMeshesIds.length > 0) {
  50250. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  50251. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  50252. if (excludedMesh) {
  50253. light_2.excludedMeshes.push(excludedMesh);
  50254. }
  50255. }
  50256. light_2._excludedMeshesIds = [];
  50257. }
  50258. // Included check
  50259. if (light_2._includedOnlyMeshesIds.length > 0) {
  50260. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  50261. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  50262. if (includedOnlyMesh) {
  50263. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  50264. }
  50265. }
  50266. light_2._includedOnlyMeshesIds = [];
  50267. }
  50268. }
  50269. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  50270. // Actions (scene) Done last as it can access other objects.
  50271. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  50272. var mesh = scene.meshes[index];
  50273. if (mesh._waitingData.actions) {
  50274. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingData.actions, mesh, scene);
  50275. mesh._waitingData.actions = null;
  50276. }
  50277. }
  50278. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  50279. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  50280. }
  50281. if (!addToScene) {
  50282. container.removeAllFromScene();
  50283. }
  50284. }
  50285. catch (err) {
  50286. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  50287. if (onError) {
  50288. onError(msg, err);
  50289. }
  50290. else {
  50291. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  50292. throw err;
  50293. }
  50294. }
  50295. finally {
  50296. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  50297. _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 : ""));
  50298. }
  50299. }
  50300. return container;
  50301. };
  50302. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  50303. name: "babylon.js",
  50304. extensions: ".babylon",
  50305. canDirectLoad: function (data) {
  50306. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  50307. return true;
  50308. }
  50309. return false;
  50310. },
  50311. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  50312. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  50313. // when SceneLoader.debugLogging = true (default), or exception encountered.
  50314. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  50315. // and avoid problems with multiple concurrent .babylon loads.
  50316. var log = "importMesh has failed JSON parse";
  50317. try {
  50318. var parsedData = JSON.parse(data);
  50319. log = "";
  50320. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  50321. if (!meshesNames) {
  50322. meshesNames = null;
  50323. }
  50324. else if (!Array.isArray(meshesNames)) {
  50325. meshesNames = [meshesNames];
  50326. }
  50327. var hierarchyIds = new Array();
  50328. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  50329. var loadedSkeletonsIds = [];
  50330. var loadedMaterialsIds = [];
  50331. var index;
  50332. var cache;
  50333. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  50334. var parsedMesh = parsedData.meshes[index];
  50335. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  50336. if (meshesNames !== null) {
  50337. // Remove found mesh name from list.
  50338. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  50339. }
  50340. //Geometry?
  50341. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  50342. //does the file contain geometries?
  50343. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  50344. //find the correct geometry and add it to the scene
  50345. var found = false;
  50346. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  50347. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  50348. return;
  50349. }
  50350. else {
  50351. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  50352. if (parsedGeometryData.id === parsedMesh.geometryId) {
  50353. switch (geometryType) {
  50354. case "vertexData":
  50355. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  50356. break;
  50357. }
  50358. found = true;
  50359. }
  50360. });
  50361. }
  50362. });
  50363. if (found === false) {
  50364. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  50365. }
  50366. }
  50367. }
  50368. // Material ?
  50369. if (parsedMesh.materialId) {
  50370. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  50371. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  50372. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  50373. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  50374. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  50375. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  50376. var subMatId = parsedMultiMaterial.materials[matIndex];
  50377. loadedMaterialsIds.push(subMatId);
  50378. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  50379. if (mat) {
  50380. log += "\n\tMaterial " + mat.toString(fullDetails);
  50381. }
  50382. }
  50383. loadedMaterialsIds.push(parsedMultiMaterial.id);
  50384. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  50385. if (mmat) {
  50386. materialFound = true;
  50387. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  50388. }
  50389. break;
  50390. }
  50391. }
  50392. }
  50393. if (materialFound === false) {
  50394. loadedMaterialsIds.push(parsedMesh.materialId);
  50395. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  50396. if (!mat) {
  50397. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  50398. }
  50399. else {
  50400. log += "\n\tMaterial " + mat.toString(fullDetails);
  50401. }
  50402. }
  50403. }
  50404. // Skeleton ?
  50405. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  50406. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  50407. if (skeletonAlreadyLoaded === false) {
  50408. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  50409. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  50410. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  50411. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  50412. skeletons.push(skeleton);
  50413. loadedSkeletonsIds.push(parsedSkeleton.id);
  50414. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  50415. }
  50416. }
  50417. }
  50418. }
  50419. // Morph targets ?
  50420. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  50421. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  50422. var managerData = _a[_i];
  50423. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  50424. }
  50425. }
  50426. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  50427. meshes.push(mesh);
  50428. log += "\n\tMesh " + mesh.toString(fullDetails);
  50429. }
  50430. }
  50431. // Connecting parents and lods
  50432. var currentMesh;
  50433. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  50434. currentMesh = scene.meshes[index];
  50435. if (currentMesh._waitingParentId) {
  50436. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  50437. currentMesh._waitingParentId = null;
  50438. }
  50439. if (currentMesh._waitingData.lods) {
  50440. loadDetailLevels(scene, currentMesh);
  50441. }
  50442. }
  50443. // link skeleton transform nodes
  50444. for (index = 0, cache = scene.skeletons.length; index < cache; index++) {
  50445. var skeleton = scene.skeletons[index];
  50446. if (skeleton._hasWaitingData) {
  50447. if (skeleton.bones != null) {
  50448. skeleton.bones.forEach(function (bone) {
  50449. if (bone._waitingTransformNodeId) {
  50450. var linkTransformNode = scene.getLastEntryByID(bone._waitingTransformNodeId);
  50451. if (linkTransformNode) {
  50452. bone.linkTransformNode(linkTransformNode);
  50453. }
  50454. bone._waitingTransformNodeId = null;
  50455. }
  50456. });
  50457. }
  50458. skeleton._hasWaitingData = null;
  50459. }
  50460. }
  50461. // freeze and compute world matrix application
  50462. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  50463. currentMesh = scene.meshes[index];
  50464. if (currentMesh._waitingData.freezeWorldMatrix) {
  50465. currentMesh.freezeWorldMatrix();
  50466. currentMesh._waitingData.freezeWorldMatrix = null;
  50467. }
  50468. else {
  50469. currentMesh.computeWorldMatrix(true);
  50470. }
  50471. }
  50472. }
  50473. // Particles
  50474. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  50475. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  50476. if (parser) {
  50477. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  50478. var parsedParticleSystem = parsedData.particleSystems[index];
  50479. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  50480. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  50481. }
  50482. }
  50483. }
  50484. }
  50485. return true;
  50486. }
  50487. catch (err) {
  50488. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  50489. if (onError) {
  50490. onError(msg, err);
  50491. }
  50492. else {
  50493. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  50494. throw err;
  50495. }
  50496. }
  50497. finally {
  50498. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  50499. _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 : ""));
  50500. }
  50501. }
  50502. return false;
  50503. },
  50504. load: function (scene, data, rootUrl, onError) {
  50505. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  50506. // when SceneLoader.debugLogging = true (default), or exception encountered.
  50507. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  50508. // and avoid problems with multiple concurrent .babylon loads.
  50509. var log = "importScene has failed JSON parse";
  50510. try {
  50511. var parsedData = JSON.parse(data);
  50512. log = "";
  50513. // Scene
  50514. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  50515. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  50516. }
  50517. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  50518. scene.autoClear = parsedData.autoClear;
  50519. }
  50520. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  50521. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  50522. }
  50523. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  50524. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  50525. }
  50526. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  50527. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  50528. }
  50529. // Fog
  50530. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  50531. scene.fogMode = parsedData.fogMode;
  50532. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  50533. scene.fogStart = parsedData.fogStart;
  50534. scene.fogEnd = parsedData.fogEnd;
  50535. scene.fogDensity = parsedData.fogDensity;
  50536. log += "\tFog mode for scene: ";
  50537. switch (scene.fogMode) {
  50538. // getters not compiling, so using hardcoded
  50539. case 1:
  50540. log += "exp\n";
  50541. break;
  50542. case 2:
  50543. log += "exp2\n";
  50544. break;
  50545. case 3:
  50546. log += "linear\n";
  50547. break;
  50548. }
  50549. }
  50550. //Physics
  50551. if (parsedData.physicsEnabled) {
  50552. var physicsPlugin;
  50553. if (parsedData.physicsEngine === "cannon") {
  50554. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  50555. }
  50556. else if (parsedData.physicsEngine === "oimo") {
  50557. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  50558. }
  50559. else if (parsedData.physicsEngine === "ammo") {
  50560. physicsPlugin = new _Physics_Plugins_ammoJSPlugin__WEBPACK_IMPORTED_MODULE_21__["AmmoJSPlugin"]();
  50561. }
  50562. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  50563. //else - default engine, which is currently oimo
  50564. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  50565. scene.enablePhysics(physicsGravity, physicsPlugin);
  50566. }
  50567. // Metadata
  50568. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  50569. scene.metadata = parsedData.metadata;
  50570. }
  50571. //collisions, if defined. otherwise, default is true
  50572. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  50573. scene.collisionsEnabled = parsedData.collisionsEnabled;
  50574. }
  50575. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  50576. if (!container) {
  50577. return false;
  50578. }
  50579. if (parsedData.autoAnimate) {
  50580. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  50581. }
  50582. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  50583. scene.setActiveCameraByID(parsedData.activeCameraID);
  50584. }
  50585. // Environment texture
  50586. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  50587. // PBR needed for both HDR texture (gamma space) & a sky box
  50588. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  50589. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  50590. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  50591. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  50592. if (parsedData.environmentTextureRotationY) {
  50593. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  50594. }
  50595. scene.environmentTexture = hdrTexture;
  50596. }
  50597. else {
  50598. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_24__["Tools"].EndsWith(parsedData.environmentTexture, ".env")) {
  50599. var compressedTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](rootUrl + parsedData.environmentTexture, scene);
  50600. if (parsedData.environmentTextureRotationY) {
  50601. compressedTexture.rotationY = parsedData.environmentTextureRotationY;
  50602. }
  50603. scene.environmentTexture = compressedTexture;
  50604. }
  50605. else {
  50606. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  50607. if (parsedData.environmentTextureRotationY) {
  50608. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  50609. }
  50610. scene.environmentTexture = cubeTexture;
  50611. }
  50612. }
  50613. if (parsedData.createDefaultSkybox === true) {
  50614. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  50615. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  50616. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  50617. }
  50618. }
  50619. // Finish
  50620. return true;
  50621. }
  50622. catch (err) {
  50623. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  50624. if (onError) {
  50625. onError(msg, err);
  50626. }
  50627. else {
  50628. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  50629. throw err;
  50630. }
  50631. }
  50632. finally {
  50633. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  50634. _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 : ""));
  50635. }
  50636. }
  50637. return false;
  50638. },
  50639. loadAssetContainer: function (scene, data, rootUrl, onError) {
  50640. var container = loadAssetContainer(scene, data, rootUrl, onError);
  50641. return container;
  50642. }
  50643. });
  50644. /***/ }),
  50645. /***/ "./Loading/Plugins/index.ts":
  50646. /*!**********************************!*\
  50647. !*** ./Loading/Plugins/index.ts ***!
  50648. \**********************************/
  50649. /*! exports provided: _BabylonLoaderRegistered */
  50650. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50651. "use strict";
  50652. __webpack_require__.r(__webpack_exports__);
  50653. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  50654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  50655. /***/ }),
  50656. /***/ "./Loading/index.ts":
  50657. /*!**************************!*\
  50658. !*** ./Loading/index.ts ***!
  50659. \**************************/
  50660. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  50661. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50662. "use strict";
  50663. __webpack_require__.r(__webpack_exports__);
  50664. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  50665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  50666. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  50667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  50668. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  50669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  50670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  50671. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  50672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  50673. /***/ }),
  50674. /***/ "./Loading/loadingScreen.ts":
  50675. /*!**********************************!*\
  50676. !*** ./Loading/loadingScreen.ts ***!
  50677. \**********************************/
  50678. /*! exports provided: DefaultLoadingScreen */
  50679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50680. "use strict";
  50681. __webpack_require__.r(__webpack_exports__);
  50682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  50683. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  50684. /**
  50685. * Class used for the default loading screen
  50686. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  50687. */
  50688. var DefaultLoadingScreen = /** @class */ (function () {
  50689. /**
  50690. * Creates a new default loading screen
  50691. * @param _renderingCanvas defines the canvas used to render the scene
  50692. * @param _loadingText defines the default text to display
  50693. * @param _loadingDivBackgroundColor defines the default background color
  50694. */
  50695. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  50696. var _this = this;
  50697. if (_loadingText === void 0) { _loadingText = ""; }
  50698. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  50699. this._renderingCanvas = _renderingCanvas;
  50700. this._loadingText = _loadingText;
  50701. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  50702. // Resize
  50703. this._resizeLoadingUI = function () {
  50704. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  50705. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  50706. if (!_this._loadingDiv) {
  50707. return;
  50708. }
  50709. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  50710. _this._loadingDiv.style.left = canvasRect.left + "px";
  50711. _this._loadingDiv.style.top = canvasRect.top + "px";
  50712. _this._loadingDiv.style.width = canvasRect.width + "px";
  50713. _this._loadingDiv.style.height = canvasRect.height + "px";
  50714. };
  50715. }
  50716. /**
  50717. * Function called to display the loading screen
  50718. */
  50719. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  50720. if (this._loadingDiv) {
  50721. // Do not add a loading screen if there is already one
  50722. return;
  50723. }
  50724. this._loadingDiv = document.createElement("div");
  50725. this._loadingDiv.id = "babylonjsLoadingDiv";
  50726. this._loadingDiv.style.opacity = "0";
  50727. this._loadingDiv.style.transition = "opacity 1.5s ease";
  50728. this._loadingDiv.style.pointerEvents = "none";
  50729. // Loading text
  50730. this._loadingTextDiv = document.createElement("div");
  50731. this._loadingTextDiv.style.position = "absolute";
  50732. this._loadingTextDiv.style.left = "0";
  50733. this._loadingTextDiv.style.top = "50%";
  50734. this._loadingTextDiv.style.marginTop = "80px";
  50735. this._loadingTextDiv.style.width = "100%";
  50736. this._loadingTextDiv.style.height = "20px";
  50737. this._loadingTextDiv.style.fontFamily = "Arial";
  50738. this._loadingTextDiv.style.fontSize = "14px";
  50739. this._loadingTextDiv.style.color = "white";
  50740. this._loadingTextDiv.style.textAlign = "center";
  50741. this._loadingTextDiv.innerHTML = "Loading";
  50742. this._loadingDiv.appendChild(this._loadingTextDiv);
  50743. //set the predefined text
  50744. this._loadingTextDiv.innerHTML = this._loadingText;
  50745. // Generating keyframes
  50746. var style = document.createElement('style');
  50747. style.type = 'text/css';
  50748. 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 }";
  50749. style.innerHTML = keyFrames;
  50750. document.getElementsByTagName('head')[0].appendChild(style);
  50751. // Loading img
  50752. var imgBack = new Image();
  50753. if (!DefaultLoadingScreen.DefaultLogoUrl) {
  50754. imgBack.src = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODAuMTcgMjA4LjA0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6I2UwNjg0Yjt9LmNscy0ze2ZpbGw6I2JiNDY0Yjt9LmNscy00e2ZpbGw6I2UwZGVkODt9LmNscy01e2ZpbGw6I2Q1ZDJjYTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkJhYnlsb25Mb2dvPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iUGFnZV9FbGVtZW50cyIgZGF0YS1uYW1lPSJQYWdlIEVsZW1lbnRzIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05MC4wOSwwLDAsNTJWMTU2bDkwLjA5LDUyLDkwLjA4LTUyVjUyWiIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxODAuMTcgNTIuMDEgMTUxLjk3IDM1LjczIDEyNC44NSA1MS4zOSAxNTMuMDUgNjcuNjcgMTgwLjE3IDUyLjAxIi8+PHBvbHlnb24gY2xhc3M9ImNscy0yIiBwb2ludHM9IjI3LjEyIDY3LjY3IDExNy4yMSAxNS42NiA5MC4wOCAwIDAgNTIuMDEgMjcuMTIgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iNjEuODkgMTIwLjMgOTAuMDggMTM2LjU4IDExOC4yOCAxMjAuMyA5MC4wOCAxMDQuMDIgNjEuODkgMTIwLjMiLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDE1My4wNSAxNDAuMzcgOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyAwIDUyLjAxIDAgMTU2LjAzIDkwLjA4IDIwOC4wNCAxODAuMTcgMTU2LjAzIDE4MC4xNyA1Mi4wMSAxNTMuMDUgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iOTAuMDggNzEuNDYgNjEuODkgODcuNzQgNjEuODkgMTIwLjMgOTAuMDggMTA0LjAyIDExOC4yOCAxMjAuMyAxMTguMjggODcuNzQgOTAuMDggNzEuNDYiLz48cG9seWdvbiBjbGFzcz0iY2xzLTQiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDExOC4yOCA4Ny43NCAxMTguMjggMTIwLjMgOTAuMDggMTM2LjU4IDkwLjA4IDE3Ni43MiAxNTMuMDUgMTQwLjM3IDE1My4wNSA2Ny42NyIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtNSIgcG9pbnRzPSIyNy4xMiA2Ny42NyA2MS44OSA4Ny43NCA2MS44OSAxMjAuMyA5MC4wOCAxMzYuNTggOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyIvPjwvZz48L2c+PC9zdmc+";
  50755. }
  50756. else {
  50757. imgBack.src = DefaultLoadingScreen.DefaultLogoUrl;
  50758. }
  50759. imgBack.style.position = "absolute";
  50760. imgBack.style.left = "50%";
  50761. imgBack.style.top = "50%";
  50762. imgBack.style.width = "10vw";
  50763. imgBack.style.height = "10vw";
  50764. imgBack.style.marginLeft = "-5vw";
  50765. imgBack.style.marginTop = "-5vw";
  50766. // Loading spinner
  50767. var imgSpinner = new Image();
  50768. if (!DefaultLoadingScreen.DefaultSpinnerUrl) {
  50769. imgSpinner.src = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOTIgMzkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UwNjg0Yjt9LmNscy0ye2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlNwaW5uZXJJY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iU3Bpbm5lciI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDAuMjEsMTI2LjQzYzMuNy03LjMxLDcuNjctMTQuNDQsMTItMjEuMzJsMy4zNi01LjEsMy41Mi01YzEuMjMtMS42MywyLjQxLTMuMjksMy42NS00LjkxczIuNTMtMy4yMSwzLjgyLTQuNzlBMTg1LjIsMTg1LjIsMCwwLDEsODMuNCw2Ny40M2EyMDgsMjA4LDAsMCwxLDE5LTE1LjY2YzMuMzUtMi40MSw2Ljc0LTQuNzgsMTAuMjUtN3M3LjExLTQuMjgsMTAuNzUtNi4zMmM3LjI5LTQsMTQuNzMtOCwyMi41My0xMS40OSwzLjktMS43Miw3Ljg4LTMuMywxMi00LjY0YTEwNC4yMiwxMDQuMjIsMCwwLDEsMTIuNDQtMy4yMyw2Mi40NCw2Mi40NCwwLDAsMSwxMi43OC0xLjM5QTI1LjkyLDI1LjkyLDAsMCwxLDE5NiwyMS40NGE2LjU1LDYuNTUsMCwwLDEsMi4wNSw5LDYuNjYsNi42NiwwLDAsMS0xLjY0LDEuNzhsLS40MS4yOWEyMi4wNywyMi4wNywwLDAsMS01Ljc4LDMsMzAuNDIsMzAuNDIsMCwwLDEtNS42NywxLjYyLDM3LjgyLDM3LjgyLDAsMCwxLTUuNjkuNzFjLTEsMC0xLjkuMTgtMi44NS4yNmwtMi44NS4yNHEtNS43Mi41MS0xMS40OCwxLjFjLTMuODQuNC03LjcxLjgyLTExLjU4LDEuNGExMTIuMzQsMTEyLjM0LDAsMCwwLTIyLjk0LDUuNjFjLTMuNzIsMS4zNS03LjM0LDMtMTAuOTQsNC42NHMtNy4xNCwzLjUxLTEwLjYsNS41MUExNTEuNiwxNTEuNiwwLDAsMCw2OC41Niw4N0M2Ny4yMyw4OC40OCw2Niw5MCw2NC42NCw5MS41NnMtMi41MSwzLjE1LTMuNzUsNC43M2wtMy41NCw0LjljLTEuMTMsMS42Ni0yLjIzLDMuMzUtMy4zMyw1YTEyNywxMjcsMCwwLDAtMTAuOTMsMjEuNDksMS41OCwxLjU4LDAsMSwxLTMtMS4xNVM0MC4xOSwxMjYuNDcsNDAuMjEsMTI2LjQzWiIvPjxyZWN0IGNsYXNzPSJjbHMtMiIgd2lkdGg9IjM5MiIgaGVpZ2h0PSIzOTIiLz48L2c+PC9nPjwvc3ZnPg==";
  50770. }
  50771. else {
  50772. imgSpinner.src = DefaultLoadingScreen.DefaultSpinnerUrl;
  50773. }
  50774. imgSpinner.style.position = "absolute";
  50775. imgSpinner.style.left = "50%";
  50776. imgSpinner.style.top = "50%";
  50777. imgSpinner.style.width = "18vw";
  50778. imgSpinner.style.height = "18vw";
  50779. imgSpinner.style.marginLeft = "-9vw";
  50780. imgSpinner.style.marginTop = "-9vw";
  50781. imgSpinner.style.animation = "spin1 0.75s infinite linear";
  50782. imgSpinner.style.webkitAnimation = "spin1 0.75s infinite linear";
  50783. imgSpinner.style.transformOrigin = "50% 50%";
  50784. imgSpinner.style.webkitTransformOrigin = "50% 50%";
  50785. this._loadingDiv.appendChild(imgBack);
  50786. this._loadingDiv.appendChild(imgSpinner);
  50787. this._resizeLoadingUI();
  50788. window.addEventListener("resize", this._resizeLoadingUI);
  50789. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  50790. document.body.appendChild(this._loadingDiv);
  50791. this._loadingDiv.style.opacity = "1";
  50792. };
  50793. /**
  50794. * Function called to hide the loading screen
  50795. */
  50796. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  50797. var _this = this;
  50798. if (!this._loadingDiv) {
  50799. return;
  50800. }
  50801. var onTransitionEnd = function () {
  50802. if (!_this._loadingDiv) {
  50803. return;
  50804. }
  50805. if (_this._loadingDiv.parentElement) {
  50806. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  50807. }
  50808. window.removeEventListener("resize", _this._resizeLoadingUI);
  50809. _this._loadingDiv = null;
  50810. };
  50811. this._loadingDiv.style.opacity = "0";
  50812. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  50813. };
  50814. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  50815. get: function () {
  50816. return this._loadingText;
  50817. },
  50818. /**
  50819. * Gets or sets the text to display while loading
  50820. */
  50821. set: function (text) {
  50822. this._loadingText = text;
  50823. if (this._loadingTextDiv) {
  50824. this._loadingTextDiv.innerHTML = this._loadingText;
  50825. }
  50826. },
  50827. enumerable: true,
  50828. configurable: true
  50829. });
  50830. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  50831. /**
  50832. * Gets or sets the color to use for the background
  50833. */
  50834. get: function () {
  50835. return this._loadingDivBackgroundColor;
  50836. },
  50837. set: function (color) {
  50838. this._loadingDivBackgroundColor = color;
  50839. if (!this._loadingDiv) {
  50840. return;
  50841. }
  50842. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  50843. },
  50844. enumerable: true,
  50845. configurable: true
  50846. });
  50847. /** Gets or sets the logo url to use for the default loading screen */
  50848. DefaultLoadingScreen.DefaultLogoUrl = "";
  50849. /** Gets or sets the spinner url to use for the default loading screen */
  50850. DefaultLoadingScreen.DefaultSpinnerUrl = "";
  50851. return DefaultLoadingScreen;
  50852. }());
  50853. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  50854. /***/ }),
  50855. /***/ "./Loading/sceneLoader.ts":
  50856. /*!********************************!*\
  50857. !*** ./Loading/sceneLoader.ts ***!
  50858. \********************************/
  50859. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  50860. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50861. "use strict";
  50862. __webpack_require__.r(__webpack_exports__);
  50863. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  50864. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  50865. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  50866. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  50867. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  50868. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  50869. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  50870. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  50871. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  50872. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  50873. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  50874. /**
  50875. * Class used to represent data loading progression
  50876. */
  50877. var SceneLoaderProgressEvent = /** @class */ (function () {
  50878. /**
  50879. * Create a new progress event
  50880. * @param lengthComputable defines if data length to load can be evaluated
  50881. * @param loaded defines the loaded data length
  50882. * @param total defines the data length to load
  50883. */
  50884. function SceneLoaderProgressEvent(
  50885. /** defines if data length to load can be evaluated */
  50886. lengthComputable,
  50887. /** defines the loaded data length */
  50888. loaded,
  50889. /** defines the data length to load */
  50890. total) {
  50891. this.lengthComputable = lengthComputable;
  50892. this.loaded = loaded;
  50893. this.total = total;
  50894. }
  50895. /**
  50896. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  50897. * @param event defines the source event
  50898. * @returns a new SceneLoaderProgressEvent
  50899. */
  50900. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  50901. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  50902. };
  50903. return SceneLoaderProgressEvent;
  50904. }());
  50905. /**
  50906. * Class used to load scene from various file formats using registered plugins
  50907. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  50908. */
  50909. var SceneLoader = /** @class */ (function () {
  50910. function SceneLoader() {
  50911. }
  50912. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  50913. /**
  50914. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  50915. */
  50916. get: function () {
  50917. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  50918. },
  50919. set: function (value) {
  50920. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  50921. },
  50922. enumerable: true,
  50923. configurable: true
  50924. });
  50925. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  50926. /**
  50927. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  50928. */
  50929. get: function () {
  50930. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  50931. },
  50932. set: function (value) {
  50933. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  50934. },
  50935. enumerable: true,
  50936. configurable: true
  50937. });
  50938. Object.defineProperty(SceneLoader, "loggingLevel", {
  50939. /**
  50940. * Defines the current logging level (while loading the scene)
  50941. * @ignorenaming
  50942. */
  50943. get: function () {
  50944. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  50945. },
  50946. set: function (value) {
  50947. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  50948. },
  50949. enumerable: true,
  50950. configurable: true
  50951. });
  50952. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  50953. /**
  50954. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  50955. */
  50956. get: function () {
  50957. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  50958. },
  50959. set: function (value) {
  50960. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  50961. },
  50962. enumerable: true,
  50963. configurable: true
  50964. });
  50965. SceneLoader._getDefaultPlugin = function () {
  50966. return SceneLoader._registeredPlugins[".babylon"];
  50967. };
  50968. SceneLoader._getPluginForExtension = function (extension) {
  50969. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  50970. if (registeredPlugin) {
  50971. return registeredPlugin;
  50972. }
  50973. _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");
  50974. return SceneLoader._getDefaultPlugin();
  50975. };
  50976. SceneLoader._getPluginForDirectLoad = function (data) {
  50977. for (var extension in SceneLoader._registeredPlugins) {
  50978. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  50979. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  50980. return SceneLoader._registeredPlugins[extension];
  50981. }
  50982. }
  50983. return SceneLoader._getDefaultPlugin();
  50984. };
  50985. SceneLoader._getPluginForFilename = function (sceneFilename) {
  50986. var queryStringPosition = sceneFilename.indexOf("?");
  50987. if (queryStringPosition !== -1) {
  50988. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  50989. }
  50990. var dotPosition = sceneFilename.lastIndexOf(".");
  50991. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  50992. return SceneLoader._getPluginForExtension(extension);
  50993. };
  50994. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  50995. SceneLoader._getDirectLoad = function (sceneFilename) {
  50996. if (sceneFilename.substr(0, 5) === "data:") {
  50997. return sceneFilename.substr(5);
  50998. }
  50999. return null;
  51000. };
  51001. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  51002. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  51003. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  51004. var plugin;
  51005. if (registeredPlugin.plugin.createPlugin) {
  51006. plugin = registeredPlugin.plugin.createPlugin();
  51007. }
  51008. else {
  51009. plugin = registeredPlugin.plugin;
  51010. }
  51011. if (!plugin) {
  51012. 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.";
  51013. }
  51014. var useArrayBuffer = registeredPlugin.isBinary;
  51015. var offlineProvider;
  51016. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  51017. var dataCallback = function (data, responseURL) {
  51018. if (scene.isDisposed) {
  51019. onError("Scene has been disposed");
  51020. return;
  51021. }
  51022. scene.offlineProvider = offlineProvider;
  51023. onSuccess(plugin, data, responseURL);
  51024. };
  51025. var request = null;
  51026. var pluginDisposed = false;
  51027. var onDisposeObservable = plugin.onDisposeObservable;
  51028. if (onDisposeObservable) {
  51029. onDisposeObservable.add(function () {
  51030. pluginDisposed = true;
  51031. if (request) {
  51032. request.abort();
  51033. request = null;
  51034. }
  51035. onDispose();
  51036. });
  51037. }
  51038. var manifestChecked = function () {
  51039. if (pluginDisposed) {
  51040. return;
  51041. }
  51042. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  51043. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  51044. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  51045. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  51046. });
  51047. };
  51048. if (directLoad) {
  51049. dataCallback(directLoad);
  51050. return plugin;
  51051. }
  51052. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  51053. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  51054. var engine = scene.getEngine();
  51055. var canUseOfflineSupport = engine.enableOfflineSupport;
  51056. if (canUseOfflineSupport) {
  51057. // Also check for exceptions
  51058. var exceptionFound = false;
  51059. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  51060. var regex = _a[_i];
  51061. if (regex.test(fileInfo.url)) {
  51062. exceptionFound = true;
  51063. break;
  51064. }
  51065. }
  51066. canUseOfflineSupport = !exceptionFound;
  51067. }
  51068. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  51069. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  51070. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  51071. }
  51072. else {
  51073. manifestChecked();
  51074. }
  51075. }
  51076. // Loading file from disk via input file or drag'n'drop
  51077. else {
  51078. if (file) {
  51079. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  51080. }
  51081. else {
  51082. onError("Unable to find file named " + fileInfo.name);
  51083. }
  51084. }
  51085. return plugin;
  51086. };
  51087. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  51088. var url;
  51089. var name;
  51090. var file = null;
  51091. if (!sceneFilename) {
  51092. url = rootUrl;
  51093. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  51094. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  51095. }
  51096. else if (sceneFilename.name) {
  51097. var sceneFile = sceneFilename;
  51098. url = rootUrl + sceneFile.name;
  51099. name = sceneFile.name;
  51100. file = sceneFile;
  51101. }
  51102. else {
  51103. var filename = sceneFilename;
  51104. if (filename.substr(0, 1) === "/") {
  51105. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  51106. return null;
  51107. }
  51108. url = rootUrl + filename;
  51109. name = filename;
  51110. }
  51111. return {
  51112. url: url,
  51113. rootUrl: rootUrl,
  51114. name: name,
  51115. file: file
  51116. };
  51117. };
  51118. // Public functions
  51119. /**
  51120. * Gets a plugin that can load the given extension
  51121. * @param extension defines the extension to load
  51122. * @returns a plugin or null if none works
  51123. */
  51124. SceneLoader.GetPluginForExtension = function (extension) {
  51125. return SceneLoader._getPluginForExtension(extension).plugin;
  51126. };
  51127. /**
  51128. * Gets a boolean indicating that the given extension can be loaded
  51129. * @param extension defines the extension to load
  51130. * @returns true if the extension is supported
  51131. */
  51132. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  51133. return !!SceneLoader._registeredPlugins[extension];
  51134. };
  51135. /**
  51136. * Adds a new plugin to the list of registered plugins
  51137. * @param plugin defines the plugin to add
  51138. */
  51139. SceneLoader.RegisterPlugin = function (plugin) {
  51140. if (typeof plugin.extensions === "string") {
  51141. var extension = plugin.extensions;
  51142. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  51143. plugin: plugin,
  51144. isBinary: false
  51145. };
  51146. }
  51147. else {
  51148. var extensions = plugin.extensions;
  51149. Object.keys(extensions).forEach(function (extension) {
  51150. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  51151. plugin: plugin,
  51152. isBinary: extensions[extension].isBinary
  51153. };
  51154. });
  51155. }
  51156. };
  51157. /**
  51158. * Import meshes into a scene
  51159. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51160. * @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)
  51161. * @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)
  51162. * @param scene the instance of BABYLON.Scene to append to
  51163. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  51164. * @param onProgress a callback with a progress event for each file being loaded
  51165. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51166. * @param pluginExtension the extension used to determine the plugin
  51167. * @returns The loaded plugin
  51168. */
  51169. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  51170. if (sceneFilename === void 0) { sceneFilename = ""; }
  51171. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  51172. if (onSuccess === void 0) { onSuccess = null; }
  51173. if (onProgress === void 0) { onProgress = null; }
  51174. if (onError === void 0) { onError = null; }
  51175. if (pluginExtension === void 0) { pluginExtension = null; }
  51176. if (!scene) {
  51177. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  51178. return null;
  51179. }
  51180. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  51181. if (!fileInfo) {
  51182. return null;
  51183. }
  51184. var loadingToken = {};
  51185. scene._addPendingData(loadingToken);
  51186. var disposeHandler = function () {
  51187. scene._removePendingData(loadingToken);
  51188. };
  51189. var errorHandler = function (message, exception) {
  51190. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  51191. if (onError) {
  51192. onError(scene, errorMessage, exception);
  51193. }
  51194. else {
  51195. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  51196. // should the exception be thrown?
  51197. }
  51198. disposeHandler();
  51199. };
  51200. var progressHandler = onProgress ? function (event) {
  51201. try {
  51202. onProgress(event);
  51203. }
  51204. catch (e) {
  51205. errorHandler("Error in onProgress callback", e);
  51206. }
  51207. } : undefined;
  51208. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  51209. scene.importedMeshesFiles.push(fileInfo.url);
  51210. if (onSuccess) {
  51211. try {
  51212. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  51213. }
  51214. catch (e) {
  51215. errorHandler("Error in onSuccess callback", e);
  51216. }
  51217. }
  51218. scene._removePendingData(loadingToken);
  51219. };
  51220. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  51221. if (plugin.rewriteRootURL) {
  51222. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  51223. }
  51224. if (plugin.importMesh) {
  51225. var syncedPlugin = plugin;
  51226. var meshes = new Array();
  51227. var particleSystems = new Array();
  51228. var skeletons = new Array();
  51229. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  51230. return;
  51231. }
  51232. scene.loadingPluginName = plugin.name;
  51233. successHandler(meshes, particleSystems, skeletons, []);
  51234. }
  51235. else {
  51236. var asyncedPlugin = plugin;
  51237. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  51238. scene.loadingPluginName = plugin.name;
  51239. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  51240. }).catch(function (error) {
  51241. errorHandler(error.message, error);
  51242. });
  51243. }
  51244. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  51245. };
  51246. /**
  51247. * Import meshes into a scene
  51248. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51249. * @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)
  51250. * @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)
  51251. * @param scene the instance of BABYLON.Scene to append to
  51252. * @param onProgress a callback with a progress event for each file being loaded
  51253. * @param pluginExtension the extension used to determine the plugin
  51254. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51255. */
  51256. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  51257. if (sceneFilename === void 0) { sceneFilename = ""; }
  51258. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  51259. if (onProgress === void 0) { onProgress = null; }
  51260. if (pluginExtension === void 0) { pluginExtension = null; }
  51261. return new Promise(function (resolve, reject) {
  51262. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  51263. resolve({
  51264. meshes: meshes,
  51265. particleSystems: particleSystems,
  51266. skeletons: skeletons,
  51267. animationGroups: animationGroups
  51268. });
  51269. }, onProgress, function (scene, message, exception) {
  51270. reject(exception || new Error(message));
  51271. }, pluginExtension);
  51272. });
  51273. };
  51274. /**
  51275. * Load a scene
  51276. * @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)
  51277. * @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)
  51278. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51279. * @param onSuccess a callback with the scene when import succeeds
  51280. * @param onProgress a callback with a progress event for each file being loaded
  51281. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51282. * @param pluginExtension the extension used to determine the plugin
  51283. * @returns The loaded plugin
  51284. */
  51285. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  51286. if (sceneFilename === void 0) { sceneFilename = ""; }
  51287. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  51288. if (onSuccess === void 0) { onSuccess = null; }
  51289. if (onProgress === void 0) { onProgress = null; }
  51290. if (onError === void 0) { onError = null; }
  51291. if (pluginExtension === void 0) { pluginExtension = null; }
  51292. if (!engine) {
  51293. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  51294. return null;
  51295. }
  51296. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  51297. };
  51298. /**
  51299. * Load a scene
  51300. * @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)
  51301. * @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)
  51302. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51303. * @param onProgress a callback with a progress event for each file being loaded
  51304. * @param pluginExtension the extension used to determine the plugin
  51305. * @returns The loaded scene
  51306. */
  51307. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  51308. if (sceneFilename === void 0) { sceneFilename = ""; }
  51309. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  51310. if (onProgress === void 0) { onProgress = null; }
  51311. if (pluginExtension === void 0) { pluginExtension = null; }
  51312. return new Promise(function (resolve, reject) {
  51313. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  51314. resolve(scene);
  51315. }, onProgress, function (scene, message, exception) {
  51316. reject(exception || new Error(message));
  51317. }, pluginExtension);
  51318. });
  51319. };
  51320. /**
  51321. * Append a scene
  51322. * @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)
  51323. * @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)
  51324. * @param scene is the instance of BABYLON.Scene to append to
  51325. * @param onSuccess a callback with the scene when import succeeds
  51326. * @param onProgress a callback with a progress event for each file being loaded
  51327. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51328. * @param pluginExtension the extension used to determine the plugin
  51329. * @returns The loaded plugin
  51330. */
  51331. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  51332. if (sceneFilename === void 0) { sceneFilename = ""; }
  51333. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  51334. if (onSuccess === void 0) { onSuccess = null; }
  51335. if (onProgress === void 0) { onProgress = null; }
  51336. if (onError === void 0) { onError = null; }
  51337. if (pluginExtension === void 0) { pluginExtension = null; }
  51338. if (!scene) {
  51339. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  51340. return null;
  51341. }
  51342. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  51343. if (!fileInfo) {
  51344. return null;
  51345. }
  51346. if (SceneLoader.ShowLoadingScreen) {
  51347. scene.getEngine().displayLoadingUI();
  51348. }
  51349. var loadingToken = {};
  51350. scene._addPendingData(loadingToken);
  51351. var disposeHandler = function () {
  51352. scene._removePendingData(loadingToken);
  51353. scene.getEngine().hideLoadingUI();
  51354. };
  51355. var errorHandler = function (message, exception) {
  51356. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  51357. if (onError) {
  51358. onError(scene, errorMessage, exception);
  51359. }
  51360. else {
  51361. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  51362. // should the exception be thrown?
  51363. }
  51364. disposeHandler();
  51365. };
  51366. var progressHandler = onProgress ? function (event) {
  51367. try {
  51368. onProgress(event);
  51369. }
  51370. catch (e) {
  51371. errorHandler("Error in onProgress callback", e);
  51372. }
  51373. } : undefined;
  51374. var successHandler = function () {
  51375. if (onSuccess) {
  51376. try {
  51377. onSuccess(scene);
  51378. }
  51379. catch (e) {
  51380. errorHandler("Error in onSuccess callback", e);
  51381. }
  51382. }
  51383. scene._removePendingData(loadingToken);
  51384. };
  51385. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  51386. if (plugin.load) {
  51387. var syncedPlugin = plugin;
  51388. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  51389. return;
  51390. }
  51391. scene.loadingPluginName = plugin.name;
  51392. successHandler();
  51393. }
  51394. else {
  51395. var asyncedPlugin = plugin;
  51396. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  51397. scene.loadingPluginName = plugin.name;
  51398. successHandler();
  51399. }).catch(function (error) {
  51400. errorHandler(error.message, error);
  51401. });
  51402. }
  51403. if (SceneLoader.ShowLoadingScreen) {
  51404. scene.executeWhenReady(function () {
  51405. scene.getEngine().hideLoadingUI();
  51406. });
  51407. }
  51408. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  51409. };
  51410. /**
  51411. * Append a scene
  51412. * @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)
  51413. * @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)
  51414. * @param scene is the instance of BABYLON.Scene to append to
  51415. * @param onProgress a callback with a progress event for each file being loaded
  51416. * @param pluginExtension the extension used to determine the plugin
  51417. * @returns The given scene
  51418. */
  51419. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  51420. if (sceneFilename === void 0) { sceneFilename = ""; }
  51421. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  51422. if (onProgress === void 0) { onProgress = null; }
  51423. if (pluginExtension === void 0) { pluginExtension = null; }
  51424. return new Promise(function (resolve, reject) {
  51425. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  51426. resolve(scene);
  51427. }, onProgress, function (scene, message, exception) {
  51428. reject(exception || new Error(message));
  51429. }, pluginExtension);
  51430. });
  51431. };
  51432. /**
  51433. * Load a scene into an asset container
  51434. * @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)
  51435. * @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)
  51436. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51437. * @param onSuccess a callback with the scene when import succeeds
  51438. * @param onProgress a callback with a progress event for each file being loaded
  51439. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51440. * @param pluginExtension the extension used to determine the plugin
  51441. * @returns The loaded plugin
  51442. */
  51443. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  51444. if (sceneFilename === void 0) { sceneFilename = ""; }
  51445. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  51446. if (onSuccess === void 0) { onSuccess = null; }
  51447. if (onProgress === void 0) { onProgress = null; }
  51448. if (onError === void 0) { onError = null; }
  51449. if (pluginExtension === void 0) { pluginExtension = null; }
  51450. if (!scene) {
  51451. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  51452. return null;
  51453. }
  51454. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  51455. if (!fileInfo) {
  51456. return null;
  51457. }
  51458. var loadingToken = {};
  51459. scene._addPendingData(loadingToken);
  51460. var disposeHandler = function () {
  51461. scene._removePendingData(loadingToken);
  51462. };
  51463. var errorHandler = function (message, exception) {
  51464. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  51465. if (onError) {
  51466. onError(scene, errorMessage, exception);
  51467. }
  51468. else {
  51469. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  51470. // should the exception be thrown?
  51471. }
  51472. disposeHandler();
  51473. };
  51474. var progressHandler = onProgress ? function (event) {
  51475. try {
  51476. onProgress(event);
  51477. }
  51478. catch (e) {
  51479. errorHandler("Error in onProgress callback", e);
  51480. }
  51481. } : undefined;
  51482. var successHandler = function (assets) {
  51483. if (onSuccess) {
  51484. try {
  51485. onSuccess(assets);
  51486. }
  51487. catch (e) {
  51488. errorHandler("Error in onSuccess callback", e);
  51489. }
  51490. }
  51491. scene._removePendingData(loadingToken);
  51492. };
  51493. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  51494. if (plugin.loadAssetContainer) {
  51495. var syncedPlugin = plugin;
  51496. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  51497. if (!assetContainer) {
  51498. return;
  51499. }
  51500. scene.loadingPluginName = plugin.name;
  51501. successHandler(assetContainer);
  51502. }
  51503. else if (plugin.loadAssetContainerAsync) {
  51504. var asyncedPlugin = plugin;
  51505. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  51506. scene.loadingPluginName = plugin.name;
  51507. successHandler(assetContainer);
  51508. }).catch(function (error) {
  51509. errorHandler(error.message, error);
  51510. });
  51511. }
  51512. else {
  51513. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  51514. }
  51515. if (SceneLoader.ShowLoadingScreen) {
  51516. scene.executeWhenReady(function () {
  51517. scene.getEngine().hideLoadingUI();
  51518. });
  51519. }
  51520. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  51521. };
  51522. /**
  51523. * Load a scene into an asset container
  51524. * @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)
  51525. * @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)
  51526. * @param scene is the instance of Scene to append to
  51527. * @param onProgress a callback with a progress event for each file being loaded
  51528. * @param pluginExtension the extension used to determine the plugin
  51529. * @returns The loaded asset container
  51530. */
  51531. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  51532. if (sceneFilename === void 0) { sceneFilename = ""; }
  51533. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  51534. if (onProgress === void 0) { onProgress = null; }
  51535. if (pluginExtension === void 0) { pluginExtension = null; }
  51536. return new Promise(function (resolve, reject) {
  51537. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  51538. resolve(assetContainer);
  51539. }, onProgress, function (scene, message, exception) {
  51540. reject(exception || new Error(message));
  51541. }, pluginExtension);
  51542. });
  51543. };
  51544. /**
  51545. * No logging while loading
  51546. */
  51547. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  51548. /**
  51549. * Minimal logging while loading
  51550. */
  51551. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  51552. /**
  51553. * Summary logging while loading
  51554. */
  51555. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  51556. /**
  51557. * Detailled logging while loading
  51558. */
  51559. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  51560. // Members
  51561. /**
  51562. * Event raised when a plugin is used to load a scene
  51563. */
  51564. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  51565. SceneLoader._registeredPlugins = {};
  51566. return SceneLoader;
  51567. }());
  51568. /***/ }),
  51569. /***/ "./Loading/sceneLoaderFlags.ts":
  51570. /*!*************************************!*\
  51571. !*** ./Loading/sceneLoaderFlags.ts ***!
  51572. \*************************************/
  51573. /*! exports provided: SceneLoaderFlags */
  51574. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51575. "use strict";
  51576. __webpack_require__.r(__webpack_exports__);
  51577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  51578. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  51579. /**
  51580. * Class used to represent data loading progression
  51581. */
  51582. var SceneLoaderFlags = /** @class */ (function () {
  51583. function SceneLoaderFlags() {
  51584. }
  51585. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  51586. /**
  51587. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51588. */
  51589. get: function () {
  51590. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  51591. },
  51592. set: function (value) {
  51593. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  51594. },
  51595. enumerable: true,
  51596. configurable: true
  51597. });
  51598. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  51599. /**
  51600. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51601. */
  51602. get: function () {
  51603. return SceneLoaderFlags._ShowLoadingScreen;
  51604. },
  51605. set: function (value) {
  51606. SceneLoaderFlags._ShowLoadingScreen = value;
  51607. },
  51608. enumerable: true,
  51609. configurable: true
  51610. });
  51611. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  51612. /**
  51613. * Defines the current logging level (while loading the scene)
  51614. * @ignorenaming
  51615. */
  51616. get: function () {
  51617. return SceneLoaderFlags._loggingLevel;
  51618. },
  51619. set: function (value) {
  51620. SceneLoaderFlags._loggingLevel = value;
  51621. },
  51622. enumerable: true,
  51623. configurable: true
  51624. });
  51625. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  51626. /**
  51627. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51628. */
  51629. get: function () {
  51630. return SceneLoaderFlags._CleanBoneMatrixWeights;
  51631. },
  51632. set: function (value) {
  51633. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  51634. },
  51635. enumerable: true,
  51636. configurable: true
  51637. });
  51638. // Flags
  51639. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  51640. SceneLoaderFlags._ShowLoadingScreen = true;
  51641. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  51642. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  51643. return SceneLoaderFlags;
  51644. }());
  51645. /***/ }),
  51646. /***/ "./Materials/Background/backgroundMaterial.ts":
  51647. /*!****************************************************!*\
  51648. !*** ./Materials/Background/backgroundMaterial.ts ***!
  51649. \****************************************************/
  51650. /*! exports provided: BackgroundMaterial */
  51651. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51652. "use strict";
  51653. __webpack_require__.r(__webpack_exports__);
  51654. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  51655. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51656. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51657. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  51658. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  51659. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51660. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  51661. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  51662. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  51663. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  51664. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  51665. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  51666. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  51667. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  51668. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  51669. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  51670. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  51671. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  51672. /**
  51673. * Background material defines definition.
  51674. * @hidden Mainly internal Use
  51675. */
  51676. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  51677. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  51678. /**
  51679. * Constructor of the defines.
  51680. */
  51681. function BackgroundMaterialDefines() {
  51682. var _this = _super.call(this) || this;
  51683. /**
  51684. * True if the diffuse texture is in use.
  51685. */
  51686. _this.DIFFUSE = false;
  51687. /**
  51688. * The direct UV channel to use.
  51689. */
  51690. _this.DIFFUSEDIRECTUV = 0;
  51691. /**
  51692. * True if the diffuse texture is in gamma space.
  51693. */
  51694. _this.GAMMADIFFUSE = false;
  51695. /**
  51696. * True if the diffuse texture has opacity in the alpha channel.
  51697. */
  51698. _this.DIFFUSEHASALPHA = false;
  51699. /**
  51700. * True if you want the material to fade to transparent at grazing angle.
  51701. */
  51702. _this.OPACITYFRESNEL = false;
  51703. /**
  51704. * True if an extra blur needs to be added in the reflection.
  51705. */
  51706. _this.REFLECTIONBLUR = false;
  51707. /**
  51708. * True if you want the material to fade to reflection at grazing angle.
  51709. */
  51710. _this.REFLECTIONFRESNEL = false;
  51711. /**
  51712. * True if you want the material to falloff as far as you move away from the scene center.
  51713. */
  51714. _this.REFLECTIONFALLOFF = false;
  51715. /**
  51716. * False if the current Webgl implementation does not support the texture lod extension.
  51717. */
  51718. _this.TEXTURELODSUPPORT = false;
  51719. /**
  51720. * True to ensure the data are premultiplied.
  51721. */
  51722. _this.PREMULTIPLYALPHA = false;
  51723. /**
  51724. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  51725. */
  51726. _this.USERGBCOLOR = false;
  51727. /**
  51728. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  51729. * stays aligned with the desired configuration.
  51730. */
  51731. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  51732. /**
  51733. * True to add noise in order to reduce the banding effect.
  51734. */
  51735. _this.NOISE = false;
  51736. /**
  51737. * is the reflection texture in BGR color scheme?
  51738. * Mainly used to solve a bug in ios10 video tag
  51739. */
  51740. _this.REFLECTIONBGR = false;
  51741. _this.IMAGEPROCESSING = false;
  51742. _this.VIGNETTE = false;
  51743. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  51744. _this.VIGNETTEBLENDMODEOPAQUE = false;
  51745. _this.TONEMAPPING = false;
  51746. _this.TONEMAPPING_ACES = false;
  51747. _this.CONTRAST = false;
  51748. _this.COLORCURVES = false;
  51749. _this.COLORGRADING = false;
  51750. _this.COLORGRADING3D = false;
  51751. _this.SAMPLER3DGREENDEPTH = false;
  51752. _this.SAMPLER3DBGRMAP = false;
  51753. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  51754. _this.EXPOSURE = false;
  51755. _this.MULTIVIEW = false;
  51756. // Reflection.
  51757. _this.REFLECTION = false;
  51758. _this.REFLECTIONMAP_3D = false;
  51759. _this.REFLECTIONMAP_SPHERICAL = false;
  51760. _this.REFLECTIONMAP_PLANAR = false;
  51761. _this.REFLECTIONMAP_CUBIC = false;
  51762. _this.REFLECTIONMAP_PROJECTION = false;
  51763. _this.REFLECTIONMAP_SKYBOX = false;
  51764. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51765. _this.REFLECTIONMAP_EXPLICIT = false;
  51766. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51767. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51768. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51769. _this.INVERTCUBICMAP = false;
  51770. _this.REFLECTIONMAP_OPPOSITEZ = false;
  51771. _this.LODINREFLECTIONALPHA = false;
  51772. _this.GAMMAREFLECTION = false;
  51773. _this.RGBDREFLECTION = false;
  51774. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  51775. // Default BJS.
  51776. _this.MAINUV1 = false;
  51777. _this.MAINUV2 = false;
  51778. _this.UV1 = false;
  51779. _this.UV2 = false;
  51780. _this.CLIPPLANE = false;
  51781. _this.CLIPPLANE2 = false;
  51782. _this.CLIPPLANE3 = false;
  51783. _this.CLIPPLANE4 = false;
  51784. _this.POINTSIZE = false;
  51785. _this.FOG = false;
  51786. _this.NORMAL = false;
  51787. _this.NUM_BONE_INFLUENCERS = 0;
  51788. _this.BonesPerMesh = 0;
  51789. _this.INSTANCES = false;
  51790. _this.SHADOWFLOAT = false;
  51791. _this.rebuild();
  51792. return _this;
  51793. }
  51794. return BackgroundMaterialDefines;
  51795. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  51796. /**
  51797. * Background material used to create an efficient environement around your scene.
  51798. */
  51799. var BackgroundMaterial = /** @class */ (function (_super) {
  51800. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  51801. /**
  51802. * Instantiates a Background Material in the given scene
  51803. * @param name The friendly name of the material
  51804. * @param scene The scene to add the material to
  51805. */
  51806. function BackgroundMaterial(name, scene) {
  51807. var _this = _super.call(this, name, scene) || this;
  51808. /**
  51809. * Key light Color (multiply against the environement texture)
  51810. */
  51811. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  51812. _this._primaryColorShadowLevel = 0;
  51813. _this._primaryColorHighlightLevel = 0;
  51814. /**
  51815. * Reflection Texture used in the material.
  51816. * Should be author in a specific way for the best result (refer to the documentation).
  51817. */
  51818. _this.reflectionTexture = null;
  51819. /**
  51820. * Reflection Texture level of blur.
  51821. *
  51822. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51823. * texture twice.
  51824. */
  51825. _this.reflectionBlur = 0;
  51826. /**
  51827. * Diffuse Texture used in the material.
  51828. * Should be author in a specific way for the best result (refer to the documentation).
  51829. */
  51830. _this.diffuseTexture = null;
  51831. _this._shadowLights = null;
  51832. /**
  51833. * Specify the list of lights casting shadow on the material.
  51834. * All scene shadow lights will be included if null.
  51835. */
  51836. _this.shadowLights = null;
  51837. /**
  51838. * Helps adjusting the shadow to a softer level if required.
  51839. * 0 means black shadows and 1 means no shadows.
  51840. */
  51841. _this.shadowLevel = 0;
  51842. /**
  51843. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51844. * It is usually zero but might be interesting to modify according to your setup.
  51845. */
  51846. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  51847. /**
  51848. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51849. * This helps ensuring a nice transition when the camera goes under the ground.
  51850. */
  51851. _this.opacityFresnel = true;
  51852. /**
  51853. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51854. * This helps adding a mirror texture on the ground.
  51855. */
  51856. _this.reflectionFresnel = false;
  51857. /**
  51858. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51859. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51860. */
  51861. _this.reflectionFalloffDistance = 0.0;
  51862. /**
  51863. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51864. */
  51865. _this.reflectionAmount = 1.0;
  51866. /**
  51867. * This specifies the weight of the reflection at grazing angle.
  51868. */
  51869. _this.reflectionReflectance0 = 0.05;
  51870. /**
  51871. * This specifies the weight of the reflection at a perpendicular point of view.
  51872. */
  51873. _this.reflectionReflectance90 = 0.5;
  51874. /**
  51875. * Helps to directly use the maps channels instead of their level.
  51876. */
  51877. _this.useRGBColor = true;
  51878. /**
  51879. * This helps reducing the banding effect that could occur on the background.
  51880. */
  51881. _this.enableNoise = false;
  51882. _this._fovMultiplier = 1.0;
  51883. /**
  51884. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51885. */
  51886. _this.useEquirectangularFOV = false;
  51887. _this._maxSimultaneousLights = 4;
  51888. /**
  51889. * Number of Simultaneous lights allowed on the material.
  51890. */
  51891. _this.maxSimultaneousLights = 4;
  51892. /**
  51893. * Keep track of the image processing observer to allow dispose and replace.
  51894. */
  51895. _this._imageProcessingObserver = null;
  51896. /**
  51897. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51898. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51899. */
  51900. _this.switchToBGR = false;
  51901. // Temp values kept as cache in the material.
  51902. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  51903. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  51904. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  51905. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  51906. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  51907. // Setup the default processing configuration to the scene.
  51908. _this._attachImageProcessingConfiguration(null);
  51909. _this.getRenderTargetTextures = function () {
  51910. _this._renderTargets.reset();
  51911. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  51912. _this._renderTargets.push(_this._diffuseTexture);
  51913. }
  51914. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  51915. _this._renderTargets.push(_this._reflectionTexture);
  51916. }
  51917. return _this._renderTargets;
  51918. };
  51919. return _this;
  51920. }
  51921. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  51922. /**
  51923. * Experimental Internal Use Only.
  51924. *
  51925. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51926. * This acts as a helper to set the primary color to a more "human friendly" value.
  51927. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51928. * output color as close as possible from the chosen value.
  51929. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51930. * part of lighting setup.)
  51931. */
  51932. get: function () {
  51933. return this.__perceptualColor;
  51934. },
  51935. set: function (value) {
  51936. this.__perceptualColor = value;
  51937. this._computePrimaryColorFromPerceptualColor();
  51938. this._markAllSubMeshesAsLightsDirty();
  51939. },
  51940. enumerable: true,
  51941. configurable: true
  51942. });
  51943. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  51944. /**
  51945. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51946. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51947. */
  51948. get: function () {
  51949. return this._primaryColorShadowLevel;
  51950. },
  51951. set: function (value) {
  51952. this._primaryColorShadowLevel = value;
  51953. this._computePrimaryColors();
  51954. this._markAllSubMeshesAsLightsDirty();
  51955. },
  51956. enumerable: true,
  51957. configurable: true
  51958. });
  51959. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  51960. /**
  51961. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51962. * The primary color is used at the level chosen to define what the white area would look.
  51963. */
  51964. get: function () {
  51965. return this._primaryColorHighlightLevel;
  51966. },
  51967. set: function (value) {
  51968. this._primaryColorHighlightLevel = value;
  51969. this._computePrimaryColors();
  51970. this._markAllSubMeshesAsLightsDirty();
  51971. },
  51972. enumerable: true,
  51973. configurable: true
  51974. });
  51975. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  51976. /**
  51977. * Sets the reflection reflectance fresnel values according to the default standard
  51978. * empirically know to work well :-)
  51979. */
  51980. set: function (value) {
  51981. var reflectionWeight = value;
  51982. if (reflectionWeight < 0.5) {
  51983. reflectionWeight = reflectionWeight * 2.0;
  51984. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  51985. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  51986. }
  51987. else {
  51988. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  51989. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  51990. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  51991. }
  51992. },
  51993. enumerable: true,
  51994. configurable: true
  51995. });
  51996. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  51997. /**
  51998. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51999. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52000. * Recommended to be keep at 1.0 except for special cases.
  52001. */
  52002. get: function () {
  52003. return this._fovMultiplier;
  52004. },
  52005. set: function (value) {
  52006. if (isNaN(value)) {
  52007. value = 1.0;
  52008. }
  52009. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  52010. },
  52011. enumerable: true,
  52012. configurable: true
  52013. });
  52014. /**
  52015. * Attaches a new image processing configuration to the PBR Material.
  52016. * @param configuration (if null the scene configuration will be use)
  52017. */
  52018. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  52019. var _this = this;
  52020. if (configuration === this._imageProcessingConfiguration) {
  52021. return;
  52022. }
  52023. // Detaches observer.
  52024. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  52025. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  52026. }
  52027. // Pick the scene configuration if needed.
  52028. if (!configuration) {
  52029. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  52030. }
  52031. else {
  52032. this._imageProcessingConfiguration = configuration;
  52033. }
  52034. // Attaches observer.
  52035. if (this._imageProcessingConfiguration) {
  52036. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  52037. _this._computePrimaryColorFromPerceptualColor();
  52038. _this._markAllSubMeshesAsImageProcessingDirty();
  52039. });
  52040. }
  52041. };
  52042. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  52043. /**
  52044. * Gets the image processing configuration used either in this material.
  52045. */
  52046. get: function () {
  52047. return this._imageProcessingConfiguration;
  52048. },
  52049. /**
  52050. * Sets the Default image processing configuration used either in the this material.
  52051. *
  52052. * If sets to null, the scene one is in use.
  52053. */
  52054. set: function (value) {
  52055. this._attachImageProcessingConfiguration(value);
  52056. // Ensure the effect will be rebuilt.
  52057. this._markAllSubMeshesAsTexturesDirty();
  52058. },
  52059. enumerable: true,
  52060. configurable: true
  52061. });
  52062. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  52063. /**
  52064. * Gets wether the color curves effect is enabled.
  52065. */
  52066. get: function () {
  52067. return this.imageProcessingConfiguration.colorCurvesEnabled;
  52068. },
  52069. /**
  52070. * Sets wether the color curves effect is enabled.
  52071. */
  52072. set: function (value) {
  52073. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  52074. },
  52075. enumerable: true,
  52076. configurable: true
  52077. });
  52078. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  52079. /**
  52080. * Gets wether the color grading effect is enabled.
  52081. */
  52082. get: function () {
  52083. return this.imageProcessingConfiguration.colorGradingEnabled;
  52084. },
  52085. /**
  52086. * Gets wether the color grading effect is enabled.
  52087. */
  52088. set: function (value) {
  52089. this.imageProcessingConfiguration.colorGradingEnabled = value;
  52090. },
  52091. enumerable: true,
  52092. configurable: true
  52093. });
  52094. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  52095. /**
  52096. * Gets wether tonemapping is enabled or not.
  52097. */
  52098. get: function () {
  52099. return this._imageProcessingConfiguration.toneMappingEnabled;
  52100. },
  52101. /**
  52102. * Sets wether tonemapping is enabled or not
  52103. */
  52104. set: function (value) {
  52105. this._imageProcessingConfiguration.toneMappingEnabled = value;
  52106. },
  52107. enumerable: true,
  52108. configurable: true
  52109. });
  52110. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  52111. /**
  52112. * The camera exposure used on this material.
  52113. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52114. * This corresponds to a photographic exposure.
  52115. */
  52116. get: function () {
  52117. return this._imageProcessingConfiguration.exposure;
  52118. },
  52119. /**
  52120. * The camera exposure used on this material.
  52121. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52122. * This corresponds to a photographic exposure.
  52123. */
  52124. set: function (value) {
  52125. this._imageProcessingConfiguration.exposure = value;
  52126. },
  52127. enumerable: true,
  52128. configurable: true
  52129. });
  52130. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  52131. /**
  52132. * Gets The camera contrast used on this material.
  52133. */
  52134. get: function () {
  52135. return this._imageProcessingConfiguration.contrast;
  52136. },
  52137. /**
  52138. * Sets The camera contrast used on this material.
  52139. */
  52140. set: function (value) {
  52141. this._imageProcessingConfiguration.contrast = value;
  52142. },
  52143. enumerable: true,
  52144. configurable: true
  52145. });
  52146. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  52147. /**
  52148. * Gets the Color Grading 2D Lookup Texture.
  52149. */
  52150. get: function () {
  52151. return this._imageProcessingConfiguration.colorGradingTexture;
  52152. },
  52153. /**
  52154. * Sets the Color Grading 2D Lookup Texture.
  52155. */
  52156. set: function (value) {
  52157. this.imageProcessingConfiguration.colorGradingTexture = value;
  52158. },
  52159. enumerable: true,
  52160. configurable: true
  52161. });
  52162. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  52163. /**
  52164. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52165. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52166. * 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;
  52167. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52168. */
  52169. get: function () {
  52170. return this.imageProcessingConfiguration.colorCurves;
  52171. },
  52172. /**
  52173. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52174. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52175. * 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;
  52176. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52177. */
  52178. set: function (value) {
  52179. this.imageProcessingConfiguration.colorCurves = value;
  52180. },
  52181. enumerable: true,
  52182. configurable: true
  52183. });
  52184. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  52185. /**
  52186. * Gets a boolean indicating that current material needs to register RTT
  52187. */
  52188. get: function () {
  52189. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  52190. return true;
  52191. }
  52192. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  52193. return true;
  52194. }
  52195. return false;
  52196. },
  52197. enumerable: true,
  52198. configurable: true
  52199. });
  52200. /**
  52201. * The entire material has been created in order to prevent overdraw.
  52202. * @returns false
  52203. */
  52204. BackgroundMaterial.prototype.needAlphaTesting = function () {
  52205. return true;
  52206. };
  52207. /**
  52208. * The entire material has been created in order to prevent overdraw.
  52209. * @returns true if blending is enable
  52210. */
  52211. BackgroundMaterial.prototype.needAlphaBlending = function () {
  52212. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  52213. };
  52214. /**
  52215. * Checks wether the material is ready to be rendered for a given mesh.
  52216. * @param mesh The mesh to render
  52217. * @param subMesh The submesh to check against
  52218. * @param useInstances Specify wether or not the material is used with instances
  52219. * @returns true if all the dependencies are ready (Textures, Effects...)
  52220. */
  52221. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  52222. var _this = this;
  52223. if (useInstances === void 0) { useInstances = false; }
  52224. if (subMesh.effect && this.isFrozen) {
  52225. if (this._wasPreviouslyReady) {
  52226. return true;
  52227. }
  52228. }
  52229. if (!subMesh._materialDefines) {
  52230. subMesh._materialDefines = new BackgroundMaterialDefines();
  52231. }
  52232. var scene = this.getScene();
  52233. var defines = subMesh._materialDefines;
  52234. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  52235. if (defines._renderId === scene.getRenderId()) {
  52236. return true;
  52237. }
  52238. }
  52239. var engine = scene.getEngine();
  52240. // Lights
  52241. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  52242. defines._needNormals = true;
  52243. // Multiview
  52244. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  52245. // Textures
  52246. if (defines._areTexturesDirty) {
  52247. defines._needUVs = false;
  52248. if (scene.texturesEnabled) {
  52249. if (scene.getEngine().getCaps().textureLOD) {
  52250. defines.TEXTURELODSUPPORT = true;
  52251. }
  52252. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  52253. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  52254. return false;
  52255. }
  52256. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  52257. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  52258. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  52259. defines.OPACITYFRESNEL = this._opacityFresnel;
  52260. }
  52261. else {
  52262. defines.DIFFUSE = false;
  52263. defines.DIFFUSEHASALPHA = false;
  52264. defines.GAMMADIFFUSE = false;
  52265. defines.OPACITYFRESNEL = false;
  52266. }
  52267. var reflectionTexture = this._reflectionTexture;
  52268. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  52269. if (!reflectionTexture.isReadyOrNotBlocking()) {
  52270. return false;
  52271. }
  52272. defines.REFLECTION = true;
  52273. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  52274. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  52275. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  52276. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  52277. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  52278. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  52279. defines.REFLECTIONBGR = this.switchToBGR;
  52280. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  52281. defines.INVERTCUBICMAP = true;
  52282. }
  52283. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  52284. switch (reflectionTexture.coordinatesMode) {
  52285. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  52286. defines.REFLECTIONMAP_EXPLICIT = true;
  52287. break;
  52288. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  52289. defines.REFLECTIONMAP_PLANAR = true;
  52290. break;
  52291. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  52292. defines.REFLECTIONMAP_PROJECTION = true;
  52293. break;
  52294. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  52295. defines.REFLECTIONMAP_SKYBOX = true;
  52296. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  52297. break;
  52298. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  52299. defines.REFLECTIONMAP_SPHERICAL = true;
  52300. break;
  52301. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  52302. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  52303. break;
  52304. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  52305. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  52306. break;
  52307. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  52308. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  52309. break;
  52310. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  52311. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  52312. default:
  52313. defines.REFLECTIONMAP_CUBIC = true;
  52314. break;
  52315. }
  52316. if (this.reflectionFresnel) {
  52317. defines.REFLECTIONFRESNEL = true;
  52318. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  52319. this._reflectionControls.x = this.reflectionAmount;
  52320. this._reflectionControls.y = this.reflectionReflectance0;
  52321. this._reflectionControls.z = this.reflectionReflectance90;
  52322. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  52323. }
  52324. else {
  52325. defines.REFLECTIONFRESNEL = false;
  52326. defines.REFLECTIONFALLOFF = false;
  52327. }
  52328. }
  52329. else {
  52330. defines.REFLECTION = false;
  52331. defines.REFLECTIONFRESNEL = false;
  52332. defines.REFLECTIONFALLOFF = false;
  52333. defines.REFLECTIONBLUR = false;
  52334. defines.REFLECTIONMAP_3D = false;
  52335. defines.REFLECTIONMAP_SPHERICAL = false;
  52336. defines.REFLECTIONMAP_PLANAR = false;
  52337. defines.REFLECTIONMAP_CUBIC = false;
  52338. defines.REFLECTIONMAP_PROJECTION = false;
  52339. defines.REFLECTIONMAP_SKYBOX = false;
  52340. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  52341. defines.REFLECTIONMAP_EXPLICIT = false;
  52342. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  52343. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  52344. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  52345. defines.INVERTCUBICMAP = false;
  52346. defines.REFLECTIONMAP_OPPOSITEZ = false;
  52347. defines.LODINREFLECTIONALPHA = false;
  52348. defines.GAMMAREFLECTION = false;
  52349. defines.RGBDREFLECTION = false;
  52350. }
  52351. }
  52352. 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);
  52353. defines.USERGBCOLOR = this._useRGBColor;
  52354. defines.NOISE = this._enableNoise;
  52355. }
  52356. if (defines._areLightsDirty) {
  52357. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  52358. }
  52359. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  52360. if (!this._imageProcessingConfiguration.isReady()) {
  52361. return false;
  52362. }
  52363. this._imageProcessingConfiguration.prepareDefines(defines);
  52364. }
  52365. // Misc.
  52366. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  52367. // Values that need to be evaluated on every frame
  52368. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  52369. // Attribs
  52370. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  52371. if (mesh) {
  52372. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  52373. mesh.createNormals(true);
  52374. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  52375. }
  52376. }
  52377. }
  52378. // Get correct effect
  52379. if (defines.isDirty) {
  52380. defines.markAsProcessed();
  52381. scene.resetCachedMaterial();
  52382. // Fallbacks
  52383. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  52384. if (defines.FOG) {
  52385. fallbacks.addFallback(0, "FOG");
  52386. }
  52387. if (defines.POINTSIZE) {
  52388. fallbacks.addFallback(1, "POINTSIZE");
  52389. }
  52390. if (defines.MULTIVIEW) {
  52391. fallbacks.addFallback(0, "MULTIVIEW");
  52392. }
  52393. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  52394. if (defines.NUM_BONE_INFLUENCERS > 0) {
  52395. fallbacks.addCPUSkinningFallback(0, mesh);
  52396. }
  52397. //Attributes
  52398. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  52399. if (defines.NORMAL) {
  52400. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  52401. }
  52402. if (defines.UV1) {
  52403. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  52404. }
  52405. if (defines.UV2) {
  52406. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  52407. }
  52408. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  52409. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  52410. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  52411. "vFogInfos", "vFogColor", "pointSize",
  52412. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  52413. "vPrimaryColor", "vPrimaryColorShadow",
  52414. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  52415. "shadowLevel", "alpha",
  52416. "vBackgroundCenter", "vReflectionControl",
  52417. "vDiffuseInfos", "diffuseMatrix",
  52418. ];
  52419. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  52420. var uniformBuffers = ["Material", "Scene"];
  52421. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  52422. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  52423. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  52424. }
  52425. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  52426. uniformsNames: uniforms,
  52427. uniformBuffersNames: uniformBuffers,
  52428. samplers: samplers,
  52429. defines: defines,
  52430. maxSimultaneousLights: this._maxSimultaneousLights
  52431. });
  52432. var onCompiled = function (effect) {
  52433. if (_this.onCompiled) {
  52434. _this.onCompiled(effect);
  52435. }
  52436. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  52437. };
  52438. var join = defines.toString();
  52439. subMesh.setEffect(scene.getEngine().createEffect("background", {
  52440. attributes: attribs,
  52441. uniformsNames: uniforms,
  52442. uniformBuffersNames: uniformBuffers,
  52443. samplers: samplers,
  52444. defines: join,
  52445. fallbacks: fallbacks,
  52446. onCompiled: onCompiled,
  52447. onError: this.onError,
  52448. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  52449. }, engine), defines);
  52450. this.buildUniformLayout();
  52451. }
  52452. if (!subMesh.effect || !subMesh.effect.isReady()) {
  52453. return false;
  52454. }
  52455. defines._renderId = scene.getRenderId();
  52456. this._wasPreviouslyReady = true;
  52457. return true;
  52458. };
  52459. /**
  52460. * Compute the primary color according to the chosen perceptual color.
  52461. */
  52462. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  52463. if (!this.__perceptualColor) {
  52464. return;
  52465. }
  52466. this._primaryColor.copyFrom(this.__perceptualColor);
  52467. // Revert gamma space.
  52468. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  52469. // Revert image processing configuration.
  52470. if (this._imageProcessingConfiguration) {
  52471. // Revert Exposure.
  52472. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  52473. }
  52474. this._computePrimaryColors();
  52475. };
  52476. /**
  52477. * Compute the highlights and shadow colors according to their chosen levels.
  52478. */
  52479. BackgroundMaterial.prototype._computePrimaryColors = function () {
  52480. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  52481. return;
  52482. }
  52483. // Find the highlight color based on the configuration.
  52484. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  52485. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  52486. // Find the shadow color based on the configuration.
  52487. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  52488. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  52489. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  52490. };
  52491. /**
  52492. * Build the uniform buffer used in the material.
  52493. */
  52494. BackgroundMaterial.prototype.buildUniformLayout = function () {
  52495. // Order is important !
  52496. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  52497. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  52498. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  52499. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  52500. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  52501. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  52502. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  52503. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  52504. this._uniformBuffer.addUniform("pointSize", 1);
  52505. this._uniformBuffer.addUniform("shadowLevel", 1);
  52506. this._uniformBuffer.addUniform("alpha", 1);
  52507. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  52508. this._uniformBuffer.addUniform("vReflectionControl", 4);
  52509. this._uniformBuffer.create();
  52510. };
  52511. /**
  52512. * Unbind the material.
  52513. */
  52514. BackgroundMaterial.prototype.unbind = function () {
  52515. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  52516. this._uniformBuffer.setTexture("diffuseSampler", null);
  52517. }
  52518. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  52519. this._uniformBuffer.setTexture("reflectionSampler", null);
  52520. }
  52521. _super.prototype.unbind.call(this);
  52522. };
  52523. /**
  52524. * Bind only the world matrix to the material.
  52525. * @param world The world matrix to bind.
  52526. */
  52527. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  52528. this._activeEffect.setMatrix("world", world);
  52529. };
  52530. /**
  52531. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52532. * @param world The world matrix to bind.
  52533. * @param subMesh The submesh to bind for.
  52534. */
  52535. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  52536. var scene = this.getScene();
  52537. var defines = subMesh._materialDefines;
  52538. if (!defines) {
  52539. return;
  52540. }
  52541. var effect = subMesh.effect;
  52542. if (!effect) {
  52543. return;
  52544. }
  52545. this._activeEffect = effect;
  52546. // Matrices
  52547. this.bindOnlyWorldMatrix(world);
  52548. // Bones
  52549. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  52550. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  52551. if (mustRebind) {
  52552. this._uniformBuffer.bindToEffect(effect, "Material");
  52553. this.bindViewProjection(effect);
  52554. var reflectionTexture = this._reflectionTexture;
  52555. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  52556. // Texture uniforms
  52557. if (scene.texturesEnabled) {
  52558. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  52559. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  52560. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  52561. }
  52562. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  52563. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  52564. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  52565. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  52566. }
  52567. }
  52568. if (this.shadowLevel > 0) {
  52569. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  52570. }
  52571. this._uniformBuffer.updateFloat("alpha", this.alpha);
  52572. // Point size
  52573. if (this.pointsCloud) {
  52574. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  52575. }
  52576. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  52577. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  52578. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  52579. }
  52580. else {
  52581. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  52582. }
  52583. }
  52584. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  52585. // Textures
  52586. if (scene.texturesEnabled) {
  52587. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  52588. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  52589. }
  52590. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  52591. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  52592. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  52593. }
  52594. else if (!defines.REFLECTIONBLUR) {
  52595. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  52596. }
  52597. else {
  52598. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  52599. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  52600. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  52601. }
  52602. if (defines.REFLECTIONFRESNEL) {
  52603. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  52604. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  52605. }
  52606. }
  52607. }
  52608. // Clip plane
  52609. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  52610. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  52611. }
  52612. if (mustRebind || !this.isFrozen) {
  52613. if (scene.lightsEnabled) {
  52614. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  52615. }
  52616. // View
  52617. this.bindView(effect);
  52618. // Fog
  52619. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  52620. // image processing
  52621. if (this._imageProcessingConfiguration) {
  52622. this._imageProcessingConfiguration.bind(this._activeEffect);
  52623. }
  52624. }
  52625. this._uniformBuffer.update();
  52626. this._afterBind(mesh, this._activeEffect);
  52627. };
  52628. /**
  52629. * Dispose the material.
  52630. * @param forceDisposeEffect Force disposal of the associated effect.
  52631. * @param forceDisposeTextures Force disposal of the associated textures.
  52632. */
  52633. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  52634. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  52635. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  52636. if (forceDisposeTextures) {
  52637. if (this.diffuseTexture) {
  52638. this.diffuseTexture.dispose();
  52639. }
  52640. if (this.reflectionTexture) {
  52641. this.reflectionTexture.dispose();
  52642. }
  52643. }
  52644. this._renderTargets.dispose();
  52645. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  52646. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  52647. }
  52648. _super.prototype.dispose.call(this, forceDisposeEffect);
  52649. };
  52650. /**
  52651. * Clones the material.
  52652. * @param name The cloned name.
  52653. * @returns The cloned material.
  52654. */
  52655. BackgroundMaterial.prototype.clone = function (name) {
  52656. var _this = this;
  52657. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  52658. };
  52659. /**
  52660. * Serializes the current material to its JSON representation.
  52661. * @returns The JSON representation.
  52662. */
  52663. BackgroundMaterial.prototype.serialize = function () {
  52664. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52665. serializationObject.customType = "BABYLON.BackgroundMaterial";
  52666. return serializationObject;
  52667. };
  52668. /**
  52669. * Gets the class name of the material
  52670. * @returns "BackgroundMaterial"
  52671. */
  52672. BackgroundMaterial.prototype.getClassName = function () {
  52673. return "BackgroundMaterial";
  52674. };
  52675. /**
  52676. * Parse a JSON input to create back a background material.
  52677. * @param source The JSON data to parse
  52678. * @param scene The scene to create the parsed material in
  52679. * @param rootUrl The root url of the assets the material depends upon
  52680. * @returns the instantiated BackgroundMaterial.
  52681. */
  52682. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  52683. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  52684. };
  52685. /**
  52686. * Standard reflectance value at parallel view angle.
  52687. */
  52688. BackgroundMaterial.StandardReflectance0 = 0.05;
  52689. /**
  52690. * Standard reflectance value at grazing angle.
  52691. */
  52692. BackgroundMaterial.StandardReflectance90 = 0.5;
  52693. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52694. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  52695. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  52696. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52697. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52698. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  52699. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52700. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  52701. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  52702. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52703. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52704. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  52705. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52706. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52707. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  52708. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52710. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  52711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  52713. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  52714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52716. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  52717. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52718. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52719. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  52720. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52721. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52722. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  52723. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52724. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  52725. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  52726. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52727. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52728. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  52729. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52730. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52731. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  52732. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52733. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52734. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  52735. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52736. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52737. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  52738. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52739. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  52740. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  52741. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52742. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52743. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  52744. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52745. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52746. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  52747. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52748. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52749. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  52750. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52751. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52752. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  52753. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52754. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52755. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  52756. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52757. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52758. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  52759. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52760. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52761. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  52762. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52763. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52764. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  52765. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52766. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52767. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  52768. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52769. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52770. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  52771. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52772. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52773. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  52774. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52775. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52776. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  52777. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52778. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52779. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  52780. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52781. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52782. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  52783. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52784. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52785. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  52786. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52787. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52788. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  52789. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52790. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52791. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  52792. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52793. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52794. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  52795. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52796. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52797. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  52798. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52799. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  52800. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  52801. return BackgroundMaterial;
  52802. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  52803. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  52804. /***/ }),
  52805. /***/ "./Materials/Background/index.ts":
  52806. /*!***************************************!*\
  52807. !*** ./Materials/Background/index.ts ***!
  52808. \***************************************/
  52809. /*! exports provided: BackgroundMaterial */
  52810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52811. "use strict";
  52812. __webpack_require__.r(__webpack_exports__);
  52813. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  52814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  52815. /***/ }),
  52816. /***/ "./Materials/PBR/index.ts":
  52817. /*!********************************!*\
  52818. !*** ./Materials/PBR/index.ts ***!
  52819. \********************************/
  52820. /*! exports provided: PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  52821. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52822. "use strict";
  52823. __webpack_require__.r(__webpack_exports__);
  52824. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  52825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRMaterialDefines"]; });
  52826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  52827. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  52828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  52829. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  52830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  52831. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  52832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  52833. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  52834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  52835. /***/ }),
  52836. /***/ "./Materials/PBR/pbrAnisotropicConfiguration.ts":
  52837. /*!******************************************************!*\
  52838. !*** ./Materials/PBR/pbrAnisotropicConfiguration.ts ***!
  52839. \******************************************************/
  52840. /*! exports provided: PBRAnisotropicConfiguration */
  52841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52842. "use strict";
  52843. __webpack_require__.r(__webpack_exports__);
  52844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRAnisotropicConfiguration", function() { return PBRAnisotropicConfiguration; });
  52845. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52846. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52847. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  52848. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52849. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  52850. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  52851. /**
  52852. * Define the code related to the anisotropic parameters of the pbr material.
  52853. */
  52854. var PBRAnisotropicConfiguration = /** @class */ (function () {
  52855. /**
  52856. * Instantiate a new istance of anisotropy configuration.
  52857. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52858. */
  52859. function PBRAnisotropicConfiguration(markAllSubMeshesAsTexturesDirty) {
  52860. this._isEnabled = false;
  52861. /**
  52862. * Defines if the anisotropy is enabled in the material.
  52863. */
  52864. this.isEnabled = false;
  52865. /**
  52866. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52867. */
  52868. this.intensity = 1;
  52869. /**
  52870. * Defines if the effect is along the tangents, bitangents or in between.
  52871. * By default, the effect is "strectching" the highlights along the tangents.
  52872. */
  52873. this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 0);
  52874. this._texture = null;
  52875. /**
  52876. * Stores the anisotropy values in a texture.
  52877. * rg is direction (like normal from -1 to 1)
  52878. * b is a intensity
  52879. */
  52880. this.texture = null;
  52881. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  52882. }
  52883. /** @hidden */
  52884. PBRAnisotropicConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  52885. this._internalMarkAllSubMeshesAsTexturesDirty();
  52886. };
  52887. /**
  52888. * Specifies that the submesh is ready to be used.
  52889. * @param defines the list of "defines" to update.
  52890. * @param scene defines the scene the material belongs to.
  52891. * @returns - boolean indicating that the submesh is ready or not.
  52892. */
  52893. PBRAnisotropicConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  52894. if (defines._areTexturesDirty) {
  52895. if (scene.texturesEnabled) {
  52896. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  52897. if (!this._texture.isReadyOrNotBlocking()) {
  52898. return false;
  52899. }
  52900. }
  52901. }
  52902. }
  52903. return true;
  52904. };
  52905. /**
  52906. * Checks to see if a texture is used in the material.
  52907. * @param defines the list of "defines" to update.
  52908. * @param mesh the mesh we are preparing the defines for.
  52909. * @param scene defines the scene the material belongs to.
  52910. */
  52911. PBRAnisotropicConfiguration.prototype.prepareDefines = function (defines, mesh, scene) {
  52912. if (this._isEnabled) {
  52913. defines.ANISOTROPIC = this._isEnabled;
  52914. if (this._isEnabled && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  52915. defines._needUVs = true;
  52916. defines.MAINUV1 = true;
  52917. }
  52918. if (defines._areTexturesDirty) {
  52919. if (scene.texturesEnabled) {
  52920. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  52921. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "ANISOTROPIC_TEXTURE");
  52922. }
  52923. else {
  52924. defines.ANISOTROPIC_TEXTURE = false;
  52925. }
  52926. }
  52927. }
  52928. }
  52929. else {
  52930. defines.ANISOTROPIC = false;
  52931. defines.ANISOTROPIC_TEXTURE = false;
  52932. }
  52933. };
  52934. /**
  52935. * Binds the material data.
  52936. * @param uniformBuffer defines the Uniform buffer to fill in.
  52937. * @param scene defines the scene the material belongs to.
  52938. * @param isFrozen defines wether the material is frozen or not.
  52939. */
  52940. PBRAnisotropicConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  52941. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  52942. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  52943. uniformBuffer.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level);
  52944. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "anisotropy");
  52945. }
  52946. // Anisotropy
  52947. uniformBuffer.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity);
  52948. }
  52949. // Textures
  52950. if (scene.texturesEnabled) {
  52951. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  52952. uniformBuffer.setTexture("anisotropySampler", this._texture);
  52953. }
  52954. }
  52955. };
  52956. /**
  52957. * Checks to see if a texture is used in the material.
  52958. * @param texture - Base texture to use.
  52959. * @returns - Boolean specifying if a texture is used in the material.
  52960. */
  52961. PBRAnisotropicConfiguration.prototype.hasTexture = function (texture) {
  52962. if (this._texture === texture) {
  52963. return true;
  52964. }
  52965. return false;
  52966. };
  52967. /**
  52968. * Returns an array of the actively used textures.
  52969. * @param activeTextures Array of BaseTextures
  52970. */
  52971. PBRAnisotropicConfiguration.prototype.getActiveTextures = function (activeTextures) {
  52972. if (this._texture) {
  52973. activeTextures.push(this._texture);
  52974. }
  52975. };
  52976. /**
  52977. * Returns the animatable textures.
  52978. * @param animatables Array of animatable textures.
  52979. */
  52980. PBRAnisotropicConfiguration.prototype.getAnimatables = function (animatables) {
  52981. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  52982. animatables.push(this._texture);
  52983. }
  52984. };
  52985. /**
  52986. * Disposes the resources of the material.
  52987. * @param forceDisposeTextures - Forces the disposal of all textures.
  52988. */
  52989. PBRAnisotropicConfiguration.prototype.dispose = function (forceDisposeTextures) {
  52990. if (forceDisposeTextures) {
  52991. if (this._texture) {
  52992. this._texture.dispose();
  52993. }
  52994. }
  52995. };
  52996. /**
  52997. * Get the current class name of the texture useful for serialization or dynamic coding.
  52998. * @returns "PBRAnisotropicConfiguration"
  52999. */
  53000. PBRAnisotropicConfiguration.prototype.getClassName = function () {
  53001. return "PBRAnisotropicConfiguration";
  53002. };
  53003. /**
  53004. * Add fallbacks to the effect fallbacks list.
  53005. * @param defines defines the Base texture to use.
  53006. * @param fallbacks defines the current fallback list.
  53007. * @param currentRank defines the current fallback rank.
  53008. * @returns the new fallback rank.
  53009. */
  53010. PBRAnisotropicConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  53011. if (defines.ANISOTROPIC) {
  53012. fallbacks.addFallback(currentRank++, "ANISOTROPIC");
  53013. }
  53014. return currentRank;
  53015. };
  53016. /**
  53017. * Add the required uniforms to the current list.
  53018. * @param uniforms defines the current uniform list.
  53019. */
  53020. PBRAnisotropicConfiguration.AddUniforms = function (uniforms) {
  53021. uniforms.push("vAnisotropy", "vAnisotropyInfos", "anisotropyMatrix");
  53022. };
  53023. /**
  53024. * Add the required uniforms to the current buffer.
  53025. * @param uniformBuffer defines the current uniform buffer.
  53026. */
  53027. PBRAnisotropicConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  53028. uniformBuffer.addUniform("vAnisotropy", 3);
  53029. uniformBuffer.addUniform("vAnisotropyInfos", 2);
  53030. uniformBuffer.addUniform("anisotropyMatrix", 16);
  53031. };
  53032. /**
  53033. * Add the required samplers to the current list.
  53034. * @param samplers defines the current sampler list.
  53035. */
  53036. PBRAnisotropicConfiguration.AddSamplers = function (samplers) {
  53037. samplers.push("anisotropySampler");
  53038. };
  53039. /**
  53040. * Makes a duplicate of the current configuration into another one.
  53041. * @param anisotropicConfiguration define the config where to copy the info
  53042. */
  53043. PBRAnisotropicConfiguration.prototype.copyTo = function (anisotropicConfiguration) {
  53044. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return anisotropicConfiguration; }, this);
  53045. };
  53046. /**
  53047. * Serializes this anisotropy configuration.
  53048. * @returns - An object with the serialized config.
  53049. */
  53050. PBRAnisotropicConfiguration.prototype.serialize = function () {
  53051. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53052. };
  53053. /**
  53054. * Parses a anisotropy Configuration from a serialized object.
  53055. * @param source - Serialized object.
  53056. */
  53057. PBRAnisotropicConfiguration.prototype.parse = function (source) {
  53058. var _this = this;
  53059. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  53060. };
  53061. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53062. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53063. ], PBRAnisotropicConfiguration.prototype, "_isEnabled", void 0);
  53064. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53065. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53066. ], PBRAnisotropicConfiguration.prototype, "isEnabled", void 0);
  53067. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53068. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53069. ], PBRAnisotropicConfiguration.prototype, "intensity", void 0);
  53070. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53071. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector2"])()
  53072. ], PBRAnisotropicConfiguration.prototype, "direction", void 0);
  53073. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53074. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  53075. ], PBRAnisotropicConfiguration.prototype, "_texture", void 0);
  53076. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53077. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53078. ], PBRAnisotropicConfiguration.prototype, "texture", void 0);
  53079. return PBRAnisotropicConfiguration;
  53080. }());
  53081. /***/ }),
  53082. /***/ "./Materials/PBR/pbrBRDFConfiguration.ts":
  53083. /*!***********************************************!*\
  53084. !*** ./Materials/PBR/pbrBRDFConfiguration.ts ***!
  53085. \***********************************************/
  53086. /*! exports provided: PBRBRDFConfiguration */
  53087. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53088. "use strict";
  53089. __webpack_require__.r(__webpack_exports__);
  53090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBRDFConfiguration", function() { return PBRBRDFConfiguration; });
  53091. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53092. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53093. /**
  53094. * Define the code related to the BRDF parameters of the pbr material.
  53095. */
  53096. var PBRBRDFConfiguration = /** @class */ (function () {
  53097. /**
  53098. * Instantiate a new istance of clear coat configuration.
  53099. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53100. */
  53101. function PBRBRDFConfiguration(markAllSubMeshesAsMiscDirty) {
  53102. this._useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;
  53103. /**
  53104. * Defines if the material uses energy conservation.
  53105. */
  53106. this.useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;
  53107. this._useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;
  53108. /**
  53109. * LEGACY Mode set to false
  53110. * Defines if the material uses height smith correlated visibility term.
  53111. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53112. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53113. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53114. * Not relying on height correlated will also disable energy conservation.
  53115. */
  53116. this.useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;
  53117. this._useSphericalHarmonics = PBRBRDFConfiguration.DEFAULT_USE_SPHERICAL_HARMONICS;
  53118. /**
  53119. * LEGACY Mode set to false
  53120. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53121. * diffuse part of the IBL.
  53122. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53123. * to the ground truth.
  53124. */
  53125. this.useSphericalHarmonics = PBRBRDFConfiguration.DEFAULT_USE_SPHERICAL_HARMONICS;
  53126. this._internalMarkAllSubMeshesAsMiscDirty = markAllSubMeshesAsMiscDirty;
  53127. }
  53128. /** @hidden */
  53129. PBRBRDFConfiguration.prototype._markAllSubMeshesAsMiscDirty = function () {
  53130. this._internalMarkAllSubMeshesAsMiscDirty();
  53131. };
  53132. /**
  53133. * Checks to see if a texture is used in the material.
  53134. * @param defines the list of "defines" to update.
  53135. */
  53136. PBRBRDFConfiguration.prototype.prepareDefines = function (defines) {
  53137. defines.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated;
  53138. defines.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated;
  53139. defines.SPHERICAL_HARMONICS = this._useSphericalHarmonics;
  53140. };
  53141. /**
  53142. * Get the current class name of the texture useful for serialization or dynamic coding.
  53143. * @returns "PBRClearCoatConfiguration"
  53144. */
  53145. PBRBRDFConfiguration.prototype.getClassName = function () {
  53146. return "PBRBRDFConfiguration";
  53147. };
  53148. /**
  53149. * Makes a duplicate of the current configuration into another one.
  53150. * @param brdfConfiguration define the config where to copy the info
  53151. */
  53152. PBRBRDFConfiguration.prototype.copyTo = function (brdfConfiguration) {
  53153. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return brdfConfiguration; }, this);
  53154. };
  53155. /**
  53156. * Serializes this BRDF configuration.
  53157. * @returns - An object with the serialized config.
  53158. */
  53159. PBRBRDFConfiguration.prototype.serialize = function () {
  53160. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53161. };
  53162. /**
  53163. * Parses a BRDF Configuration from a serialized object.
  53164. * @param source - Serialized object.
  53165. */
  53166. PBRBRDFConfiguration.prototype.parse = function (source) {
  53167. var _this = this;
  53168. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  53169. };
  53170. /**
  53171. * Default value used for the energy conservation.
  53172. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53173. */
  53174. PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION = true;
  53175. /**
  53176. * Default value used for the Smith Visibility Height Correlated mode.
  53177. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53178. */
  53179. PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = true;
  53180. /**
  53181. * Default value used for the IBL diffuse part.
  53182. * This can help switching back to the polynomials mode globally which is a tiny bit
  53183. * less GPU intensive at the drawback of a lower quality.
  53184. */
  53185. PBRBRDFConfiguration.DEFAULT_USE_SPHERICAL_HARMONICS = true;
  53186. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53187. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53188. ], PBRBRDFConfiguration.prototype, "_useEnergyConservation", void 0);
  53189. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53190. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  53191. ], PBRBRDFConfiguration.prototype, "useEnergyConservation", void 0);
  53192. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53193. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53194. ], PBRBRDFConfiguration.prototype, "_useSmithVisibilityHeightCorrelated", void 0);
  53195. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53196. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  53197. ], PBRBRDFConfiguration.prototype, "useSmithVisibilityHeightCorrelated", void 0);
  53198. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53199. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53200. ], PBRBRDFConfiguration.prototype, "_useSphericalHarmonics", void 0);
  53201. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53202. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  53203. ], PBRBRDFConfiguration.prototype, "useSphericalHarmonics", void 0);
  53204. return PBRBRDFConfiguration;
  53205. }());
  53206. /***/ }),
  53207. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  53208. /*!******************************************!*\
  53209. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  53210. \******************************************/
  53211. /*! exports provided: PBRMaterialDefines, PBRBaseMaterial */
  53212. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53213. "use strict";
  53214. __webpack_require__.r(__webpack_exports__);
  53215. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return PBRMaterialDefines; });
  53216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  53217. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53218. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53219. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  53220. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  53221. /* harmony import */ var _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  53222. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  53223. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53224. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  53225. /* harmony import */ var _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./pbrClearCoatConfiguration */ "./Materials/PBR/pbrClearCoatConfiguration.ts");
  53226. /* harmony import */ var _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pbrAnisotropicConfiguration */ "./Materials/PBR/pbrAnisotropicConfiguration.ts");
  53227. /* harmony import */ var _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pbrBRDFConfiguration */ "./Materials/PBR/pbrBRDFConfiguration.ts");
  53228. /* harmony import */ var _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./pbrSheenConfiguration */ "./Materials/PBR/pbrSheenConfiguration.ts");
  53229. /* harmony import */ var _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./pbrSubSurfaceConfiguration */ "./Materials/PBR/pbrSubSurfaceConfiguration.ts");
  53230. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  53231. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  53232. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  53233. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  53234. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  53235. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  53236. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  53237. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  53238. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  53239. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  53240. /**
  53241. * Manages the defines for the PBR Material.
  53242. * @hidden
  53243. */
  53244. var PBRMaterialDefines = /** @class */ (function (_super) {
  53245. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  53246. /**
  53247. * Initializes the PBR Material defines.
  53248. */
  53249. function PBRMaterialDefines() {
  53250. var _this = _super.call(this) || this;
  53251. _this.PBR = true;
  53252. _this.MAINUV1 = false;
  53253. _this.MAINUV2 = false;
  53254. _this.UV1 = false;
  53255. _this.UV2 = false;
  53256. _this.ALBEDO = false;
  53257. _this.ALBEDODIRECTUV = 0;
  53258. _this.VERTEXCOLOR = false;
  53259. _this.AMBIENT = false;
  53260. _this.AMBIENTDIRECTUV = 0;
  53261. _this.AMBIENTINGRAYSCALE = false;
  53262. _this.OPACITY = false;
  53263. _this.VERTEXALPHA = false;
  53264. _this.OPACITYDIRECTUV = 0;
  53265. _this.OPACITYRGB = false;
  53266. _this.ALPHATEST = false;
  53267. _this.DEPTHPREPASS = false;
  53268. _this.ALPHABLEND = false;
  53269. _this.ALPHAFROMALBEDO = false;
  53270. _this.ALPHATESTVALUE = "0.5";
  53271. _this.SPECULAROVERALPHA = false;
  53272. _this.RADIANCEOVERALPHA = false;
  53273. _this.ALPHAFRESNEL = false;
  53274. _this.LINEARALPHAFRESNEL = false;
  53275. _this.PREMULTIPLYALPHA = false;
  53276. _this.EMISSIVE = false;
  53277. _this.EMISSIVEDIRECTUV = 0;
  53278. _this.REFLECTIVITY = false;
  53279. _this.REFLECTIVITYDIRECTUV = 0;
  53280. _this.SPECULARTERM = false;
  53281. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  53282. _this.MICROSURFACEAUTOMATIC = false;
  53283. _this.LODBASEDMICROSFURACE = false;
  53284. _this.MICROSURFACEMAP = false;
  53285. _this.MICROSURFACEMAPDIRECTUV = 0;
  53286. _this.METALLICWORKFLOW = false;
  53287. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  53288. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  53289. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  53290. _this.AOSTOREINMETALMAPRED = false;
  53291. _this.ENVIRONMENTBRDF = false;
  53292. _this.ENVIRONMENTBRDF_RGBD = false;
  53293. _this.NORMAL = false;
  53294. _this.TANGENT = false;
  53295. _this.BUMP = false;
  53296. _this.BUMPDIRECTUV = 0;
  53297. _this.OBJECTSPACE_NORMALMAP = false;
  53298. _this.PARALLAX = false;
  53299. _this.PARALLAXOCCLUSION = false;
  53300. _this.NORMALXYSCALE = true;
  53301. _this.LIGHTMAP = false;
  53302. _this.LIGHTMAPDIRECTUV = 0;
  53303. _this.USELIGHTMAPASSHADOWMAP = false;
  53304. _this.GAMMALIGHTMAP = false;
  53305. _this.REFLECTION = false;
  53306. _this.REFLECTIONMAP_3D = false;
  53307. _this.REFLECTIONMAP_SPHERICAL = false;
  53308. _this.REFLECTIONMAP_PLANAR = false;
  53309. _this.REFLECTIONMAP_CUBIC = false;
  53310. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  53311. _this.REFLECTIONMAP_PROJECTION = false;
  53312. _this.REFLECTIONMAP_SKYBOX = false;
  53313. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  53314. _this.REFLECTIONMAP_EXPLICIT = false;
  53315. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  53316. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  53317. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  53318. _this.INVERTCUBICMAP = false;
  53319. _this.USESPHERICALFROMREFLECTIONMAP = false;
  53320. _this.SPHERICAL_HARMONICS = false;
  53321. _this.USESPHERICALINVERTEX = false;
  53322. _this.REFLECTIONMAP_OPPOSITEZ = false;
  53323. _this.LODINREFLECTIONALPHA = false;
  53324. _this.GAMMAREFLECTION = false;
  53325. _this.RGBDREFLECTION = false;
  53326. _this.RADIANCEOCCLUSION = false;
  53327. _this.HORIZONOCCLUSION = false;
  53328. _this.INSTANCES = false;
  53329. _this.NUM_BONE_INFLUENCERS = 0;
  53330. _this.BonesPerMesh = 0;
  53331. _this.BONETEXTURE = false;
  53332. _this.NONUNIFORMSCALING = false;
  53333. _this.MORPHTARGETS = false;
  53334. _this.MORPHTARGETS_NORMAL = false;
  53335. _this.MORPHTARGETS_TANGENT = false;
  53336. _this.NUM_MORPH_INFLUENCERS = 0;
  53337. _this.IMAGEPROCESSING = false;
  53338. _this.VIGNETTE = false;
  53339. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  53340. _this.VIGNETTEBLENDMODEOPAQUE = false;
  53341. _this.TONEMAPPING = false;
  53342. _this.TONEMAPPING_ACES = false;
  53343. _this.CONTRAST = false;
  53344. _this.COLORCURVES = false;
  53345. _this.COLORGRADING = false;
  53346. _this.COLORGRADING3D = false;
  53347. _this.SAMPLER3DGREENDEPTH = false;
  53348. _this.SAMPLER3DBGRMAP = false;
  53349. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  53350. _this.EXPOSURE = false;
  53351. _this.MULTIVIEW = false;
  53352. _this.USEPHYSICALLIGHTFALLOFF = false;
  53353. _this.USEGLTFLIGHTFALLOFF = false;
  53354. _this.TWOSIDEDLIGHTING = false;
  53355. _this.SHADOWFLOAT = false;
  53356. _this.CLIPPLANE = false;
  53357. _this.CLIPPLANE2 = false;
  53358. _this.CLIPPLANE3 = false;
  53359. _this.CLIPPLANE4 = false;
  53360. _this.POINTSIZE = false;
  53361. _this.FOG = false;
  53362. _this.LOGARITHMICDEPTH = false;
  53363. _this.FORCENORMALFORWARD = false;
  53364. _this.SPECULARAA = false;
  53365. _this.CLEARCOAT = false;
  53366. _this.CLEARCOAT_DEFAULTIOR = false;
  53367. _this.CLEARCOAT_TEXTURE = false;
  53368. _this.CLEARCOAT_TEXTUREDIRECTUV = 0;
  53369. _this.CLEARCOAT_BUMP = false;
  53370. _this.CLEARCOAT_BUMPDIRECTUV = 0;
  53371. _this.CLEARCOAT_TINT = false;
  53372. _this.CLEARCOAT_TINT_TEXTURE = false;
  53373. _this.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0;
  53374. _this.ANISOTROPIC = false;
  53375. _this.ANISOTROPIC_TEXTURE = false;
  53376. _this.ANISOTROPIC_TEXTUREDIRECTUV = 0;
  53377. _this.BRDF_V_HEIGHT_CORRELATED = false;
  53378. _this.MS_BRDF_ENERGY_CONSERVATION = false;
  53379. _this.SHEEN = false;
  53380. _this.SHEEN_TEXTURE = false;
  53381. _this.SHEEN_TEXTUREDIRECTUV = 0;
  53382. _this.SHEEN_LINKWITHALBEDO = false;
  53383. _this.SUBSURFACE = false;
  53384. _this.SS_REFRACTION = false;
  53385. _this.SS_TRANSLUCENCY = false;
  53386. _this.SS_SCATERRING = false;
  53387. _this.SS_THICKNESSANDMASK_TEXTURE = false;
  53388. _this.SS_THICKNESSANDMASK_TEXTUREDIRECTUV = 0;
  53389. _this.SS_REFRACTIONMAP_3D = false;
  53390. _this.SS_REFRACTIONMAP_OPPOSITEZ = false;
  53391. _this.SS_LODINREFRACTIONALPHA = false;
  53392. _this.SS_GAMMAREFRACTION = false;
  53393. _this.SS_RGBDREFRACTION = false;
  53394. _this.SS_LINKREFRACTIONTOTRANSPARENCY = false;
  53395. _this.SS_MASK_FROM_THICKNESS_TEXTURE = false;
  53396. _this.UNLIT = false;
  53397. _this.DEBUGMODE = 0;
  53398. _this.rebuild();
  53399. return _this;
  53400. }
  53401. /**
  53402. * Resets the PBR Material defines.
  53403. */
  53404. PBRMaterialDefines.prototype.reset = function () {
  53405. _super.prototype.reset.call(this);
  53406. this.ALPHATESTVALUE = "0.5";
  53407. this.PBR = true;
  53408. };
  53409. return PBRMaterialDefines;
  53410. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_15__["MaterialDefines"]));
  53411. /**
  53412. * The Physically based material base class of BJS.
  53413. *
  53414. * This offers the main features of a standard PBR material.
  53415. * For more information, please refer to the documentation :
  53416. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  53417. */
  53418. var PBRBaseMaterial = /** @class */ (function (_super) {
  53419. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  53420. /**
  53421. * Instantiates a new PBRMaterial instance.
  53422. *
  53423. * @param name The material name
  53424. * @param scene The scene the material will be use in.
  53425. */
  53426. function PBRBaseMaterial(name, scene) {
  53427. var _this = _super.call(this, name, scene) || this;
  53428. /**
  53429. * Intensity of the direct lights e.g. the four lights available in your scene.
  53430. * This impacts both the direct diffuse and specular highlights.
  53431. */
  53432. _this._directIntensity = 1.0;
  53433. /**
  53434. * Intensity of the emissive part of the material.
  53435. * This helps controlling the emissive effect without modifying the emissive color.
  53436. */
  53437. _this._emissiveIntensity = 1.0;
  53438. /**
  53439. * Intensity of the environment e.g. how much the environment will light the object
  53440. * either through harmonics for rough material or through the refelction for shiny ones.
  53441. */
  53442. _this._environmentIntensity = 1.0;
  53443. /**
  53444. * This is a special control allowing the reduction of the specular highlights coming from the
  53445. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53446. */
  53447. _this._specularIntensity = 1.0;
  53448. /**
  53449. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53450. */
  53451. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  53452. /**
  53453. * Debug Control allowing disabling the bump map on this material.
  53454. */
  53455. _this._disableBumpMap = false;
  53456. /**
  53457. * AKA Diffuse Texture in standard nomenclature.
  53458. */
  53459. _this._albedoTexture = null;
  53460. /**
  53461. * AKA Occlusion Texture in other nomenclature.
  53462. */
  53463. _this._ambientTexture = null;
  53464. /**
  53465. * AKA Occlusion Texture Intensity in other nomenclature.
  53466. */
  53467. _this._ambientTextureStrength = 1.0;
  53468. /**
  53469. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53470. * 1 means it completely occludes it
  53471. * 0 mean it has no impact
  53472. */
  53473. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  53474. /**
  53475. * Stores the alpha values in a texture.
  53476. */
  53477. _this._opacityTexture = null;
  53478. /**
  53479. * Stores the reflection values in a texture.
  53480. */
  53481. _this._reflectionTexture = null;
  53482. /**
  53483. * Stores the emissive values in a texture.
  53484. */
  53485. _this._emissiveTexture = null;
  53486. /**
  53487. * AKA Specular texture in other nomenclature.
  53488. */
  53489. _this._reflectivityTexture = null;
  53490. /**
  53491. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53492. */
  53493. _this._metallicTexture = null;
  53494. /**
  53495. * Specifies the metallic scalar of the metallic/roughness workflow.
  53496. * Can also be used to scale the metalness values of the metallic texture.
  53497. */
  53498. _this._metallic = null;
  53499. /**
  53500. * Specifies the roughness scalar of the metallic/roughness workflow.
  53501. * Can also be used to scale the roughness values of the metallic texture.
  53502. */
  53503. _this._roughness = null;
  53504. /**
  53505. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53506. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53507. */
  53508. _this._microSurfaceTexture = null;
  53509. /**
  53510. * Stores surface normal data used to displace a mesh in a texture.
  53511. */
  53512. _this._bumpTexture = null;
  53513. /**
  53514. * Stores the pre-calculated light information of a mesh in a texture.
  53515. */
  53516. _this._lightmapTexture = null;
  53517. /**
  53518. * The color of a material in ambient lighting.
  53519. */
  53520. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  53521. /**
  53522. * AKA Diffuse Color in other nomenclature.
  53523. */
  53524. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  53525. /**
  53526. * AKA Specular Color in other nomenclature.
  53527. */
  53528. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  53529. /**
  53530. * The color applied when light is reflected from a material.
  53531. */
  53532. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  53533. /**
  53534. * The color applied when light is emitted from a material.
  53535. */
  53536. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  53537. /**
  53538. * AKA Glossiness in other nomenclature.
  53539. */
  53540. _this._microSurface = 0.9;
  53541. /**
  53542. * Specifies that the material will use the light map as a show map.
  53543. */
  53544. _this._useLightmapAsShadowmap = false;
  53545. /**
  53546. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53547. * makes the reflect vector face the model (under horizon).
  53548. */
  53549. _this._useHorizonOcclusion = true;
  53550. /**
  53551. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53552. * too much the area relying on ambient texture to define their ambient occlusion.
  53553. */
  53554. _this._useRadianceOcclusion = true;
  53555. /**
  53556. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53557. */
  53558. _this._useAlphaFromAlbedoTexture = false;
  53559. /**
  53560. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53561. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53562. */
  53563. _this._useSpecularOverAlpha = true;
  53564. /**
  53565. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53566. */
  53567. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  53568. /**
  53569. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53570. */
  53571. _this._useRoughnessFromMetallicTextureAlpha = true;
  53572. /**
  53573. * Specifies if the metallic texture contains the roughness information in its green channel.
  53574. */
  53575. _this._useRoughnessFromMetallicTextureGreen = false;
  53576. /**
  53577. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53578. */
  53579. _this._useMetallnessFromMetallicTextureBlue = false;
  53580. /**
  53581. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53582. */
  53583. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  53584. /**
  53585. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53586. */
  53587. _this._useAmbientInGrayScale = false;
  53588. /**
  53589. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53590. * The material will try to infer what glossiness each pixel should be.
  53591. */
  53592. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  53593. /**
  53594. * Defines the falloff type used in this material.
  53595. * It by default is Physical.
  53596. */
  53597. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  53598. /**
  53599. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53600. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53601. */
  53602. _this._useRadianceOverAlpha = true;
  53603. /**
  53604. * Allows using an object space normal map (instead of tangent space).
  53605. */
  53606. _this._useObjectSpaceNormalMap = false;
  53607. /**
  53608. * Allows using the bump map in parallax mode.
  53609. */
  53610. _this._useParallax = false;
  53611. /**
  53612. * Allows using the bump map in parallax occlusion mode.
  53613. */
  53614. _this._useParallaxOcclusion = false;
  53615. /**
  53616. * Controls the scale bias of the parallax mode.
  53617. */
  53618. _this._parallaxScaleBias = 0.05;
  53619. /**
  53620. * If sets to true, disables all the lights affecting the material.
  53621. */
  53622. _this._disableLighting = false;
  53623. /**
  53624. * Number of Simultaneous lights allowed on the material.
  53625. */
  53626. _this._maxSimultaneousLights = 4;
  53627. /**
  53628. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53629. */
  53630. _this._invertNormalMapX = false;
  53631. /**
  53632. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53633. */
  53634. _this._invertNormalMapY = false;
  53635. /**
  53636. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53637. */
  53638. _this._twoSidedLighting = false;
  53639. /**
  53640. * Defines the alpha limits in alpha test mode.
  53641. */
  53642. _this._alphaCutOff = 0.4;
  53643. /**
  53644. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53645. */
  53646. _this._forceAlphaTest = false;
  53647. /**
  53648. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53649. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53650. */
  53651. _this._useAlphaFresnel = false;
  53652. /**
  53653. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53654. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53655. */
  53656. _this._useLinearAlphaFresnel = false;
  53657. /**
  53658. * The transparency mode of the material.
  53659. */
  53660. _this._transparencyMode = null;
  53661. /**
  53662. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53663. * from cos thetav and roughness:
  53664. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53665. */
  53666. _this._environmentBRDFTexture = null;
  53667. /**
  53668. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53669. */
  53670. _this._forceIrradianceInFragment = false;
  53671. /**
  53672. * Force normal to face away from face.
  53673. */
  53674. _this._forceNormalForward = false;
  53675. /**
  53676. * Enables specular anti aliasing in the PBR shader.
  53677. * It will both interacts on the Geometry for analytical and IBL lighting.
  53678. * It also prefilter the roughness map based on the bump values.
  53679. */
  53680. _this._enableSpecularAntiAliasing = false;
  53681. /**
  53682. * Keep track of the image processing observer to allow dispose and replace.
  53683. */
  53684. _this._imageProcessingObserver = null;
  53685. /**
  53686. * Stores the available render targets.
  53687. */
  53688. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  53689. /**
  53690. * Sets the global ambient color for the material used in lighting calculations.
  53691. */
  53692. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  53693. /**
  53694. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53695. */
  53696. _this._useLogarithmicDepth = false;
  53697. /**
  53698. * If set to true, no lighting calculations will be applied.
  53699. */
  53700. _this._unlit = false;
  53701. _this._debugMode = 0;
  53702. /**
  53703. * @hidden
  53704. * This is reserved for the inspector.
  53705. * Defines the material debug mode.
  53706. * It helps seeing only some components of the material while troubleshooting.
  53707. */
  53708. _this.debugMode = 0;
  53709. /**
  53710. * @hidden
  53711. * This is reserved for the inspector.
  53712. * Specify from where on screen the debug mode should start.
  53713. * The value goes from -1 (full screen) to 1 (not visible)
  53714. * It helps with side by side comparison against the final render
  53715. * This defaults to -1
  53716. */
  53717. _this.debugLimit = -1;
  53718. /**
  53719. * @hidden
  53720. * This is reserved for the inspector.
  53721. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53722. * You can use the factor to better multiply the final value.
  53723. */
  53724. _this.debugFactor = 1;
  53725. /**
  53726. * Defines the clear coat layer parameters for the material.
  53727. */
  53728. _this.clearCoat = new _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  53729. /**
  53730. * Defines the anisotropic parameters for the material.
  53731. */
  53732. _this.anisotropy = new _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  53733. /**
  53734. * Defines the BRDF parameters for the material.
  53735. */
  53736. _this.brdf = new _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__["PBRBRDFConfiguration"](_this._markAllSubMeshesAsMiscDirty.bind(_this));
  53737. /**
  53738. * Defines the Sheen parameters for the material.
  53739. */
  53740. _this.sheen = new _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  53741. /**
  53742. * Defines the SubSurface parameters for the material.
  53743. */
  53744. _this.subSurface = new _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  53745. // Setup the default processing configuration to the scene.
  53746. _this._attachImageProcessingConfiguration(null);
  53747. _this.getRenderTargetTextures = function () {
  53748. _this._renderTargets.reset();
  53749. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  53750. _this._renderTargets.push(_this._reflectionTexture);
  53751. }
  53752. _this.subSurface.fillRenderTargetTextures(_this._renderTargets);
  53753. return _this._renderTargets;
  53754. };
  53755. _this._environmentBRDFTexture = _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_4__["BRDFTextureTools"].GetEnvironmentBRDFTexture(scene);
  53756. return _this;
  53757. }
  53758. /**
  53759. * Attaches a new image processing configuration to the PBR Material.
  53760. * @param configuration
  53761. */
  53762. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  53763. var _this = this;
  53764. if (configuration === this._imageProcessingConfiguration) {
  53765. return;
  53766. }
  53767. // Detaches observer.
  53768. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  53769. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  53770. }
  53771. // Pick the scene configuration if needed.
  53772. if (!configuration) {
  53773. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  53774. }
  53775. else {
  53776. this._imageProcessingConfiguration = configuration;
  53777. }
  53778. // Attaches observer.
  53779. if (this._imageProcessingConfiguration) {
  53780. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  53781. _this._markAllSubMeshesAsImageProcessingDirty();
  53782. });
  53783. }
  53784. };
  53785. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  53786. /**
  53787. * Gets a boolean indicating that current material needs to register RTT
  53788. */
  53789. get: function () {
  53790. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  53791. return true;
  53792. }
  53793. return this.subSurface.hasRenderTargetTextures();
  53794. },
  53795. enumerable: true,
  53796. configurable: true
  53797. });
  53798. /**
  53799. * Gets the name of the material class.
  53800. */
  53801. PBRBaseMaterial.prototype.getClassName = function () {
  53802. return "PBRBaseMaterial";
  53803. };
  53804. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  53805. /**
  53806. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53807. */
  53808. get: function () {
  53809. return this._useLogarithmicDepth;
  53810. },
  53811. /**
  53812. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53813. */
  53814. set: function (value) {
  53815. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  53816. },
  53817. enumerable: true,
  53818. configurable: true
  53819. });
  53820. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  53821. /**
  53822. * Gets the current transparency mode.
  53823. */
  53824. get: function () {
  53825. return this._transparencyMode;
  53826. },
  53827. /**
  53828. * Sets the transparency mode of the material.
  53829. *
  53830. * | Value | Type | Description |
  53831. * | ----- | ----------------------------------- | ----------- |
  53832. * | 0 | OPAQUE | |
  53833. * | 1 | ALPHATEST | |
  53834. * | 2 | ALPHABLEND | |
  53835. * | 3 | ALPHATESTANDBLEND | |
  53836. *
  53837. */
  53838. set: function (value) {
  53839. if (this._transparencyMode === value) {
  53840. return;
  53841. }
  53842. this._transparencyMode = value;
  53843. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  53844. this._markAllSubMeshesAsTexturesAndMiscDirty();
  53845. },
  53846. enumerable: true,
  53847. configurable: true
  53848. });
  53849. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  53850. /**
  53851. * Returns true if alpha blending should be disabled.
  53852. */
  53853. get: function () {
  53854. return (this.subSurface.disableAlphaBlending ||
  53855. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  53856. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  53857. },
  53858. enumerable: true,
  53859. configurable: true
  53860. });
  53861. /**
  53862. * Specifies whether or not this material should be rendered in alpha blend mode.
  53863. */
  53864. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  53865. if (this._disableAlphaBlending) {
  53866. return false;
  53867. }
  53868. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  53869. };
  53870. /**
  53871. * Specifies if the mesh will require alpha blending.
  53872. * @param mesh - BJS mesh.
  53873. */
  53874. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  53875. if (this._disableAlphaBlending && mesh.visibility >= 1.0) {
  53876. return false;
  53877. }
  53878. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  53879. };
  53880. /**
  53881. * Specifies whether or not this material should be rendered in alpha test mode.
  53882. */
  53883. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  53884. if (this._forceAlphaTest) {
  53885. return true;
  53886. }
  53887. if (this.subSurface.disableAlphaBlending) {
  53888. return false;
  53889. }
  53890. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  53891. };
  53892. /**
  53893. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53894. */
  53895. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  53896. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  53897. };
  53898. /**
  53899. * Gets the texture used for the alpha test.
  53900. */
  53901. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  53902. return this._albedoTexture;
  53903. };
  53904. /**
  53905. * Specifies that the submesh is ready to be used.
  53906. * @param mesh - BJS mesh.
  53907. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53908. * @param useInstances - Specifies that instances should be used.
  53909. * @returns - boolean indicating that the submesh is ready or not.
  53910. */
  53911. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  53912. if (subMesh.effect && this.isFrozen) {
  53913. if (this._wasPreviouslyReady) {
  53914. return true;
  53915. }
  53916. }
  53917. if (!subMesh._materialDefines) {
  53918. subMesh._materialDefines = new PBRMaterialDefines();
  53919. }
  53920. var defines = subMesh._materialDefines;
  53921. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  53922. if (defines._renderId === this.getScene().getRenderId()) {
  53923. return true;
  53924. }
  53925. }
  53926. var scene = this.getScene();
  53927. var engine = scene.getEngine();
  53928. if (defines._areTexturesDirty) {
  53929. if (scene.texturesEnabled) {
  53930. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  53931. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  53932. return false;
  53933. }
  53934. }
  53935. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  53936. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  53937. return false;
  53938. }
  53939. }
  53940. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  53941. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  53942. return false;
  53943. }
  53944. }
  53945. var reflectionTexture = this._getReflectionTexture();
  53946. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  53947. if (!reflectionTexture.isReadyOrNotBlocking()) {
  53948. return false;
  53949. }
  53950. }
  53951. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  53952. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  53953. return false;
  53954. }
  53955. }
  53956. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  53957. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  53958. return false;
  53959. }
  53960. }
  53961. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  53962. if (this._metallicTexture) {
  53963. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  53964. return false;
  53965. }
  53966. }
  53967. else if (this._reflectivityTexture) {
  53968. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  53969. return false;
  53970. }
  53971. }
  53972. if (this._microSurfaceTexture) {
  53973. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  53974. return false;
  53975. }
  53976. }
  53977. }
  53978. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53979. // Bump texture cannot be not blocking.
  53980. if (!this._bumpTexture.isReady()) {
  53981. return false;
  53982. }
  53983. }
  53984. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  53985. // This is blocking.
  53986. if (!this._environmentBRDFTexture.isReady()) {
  53987. return false;
  53988. }
  53989. }
  53990. }
  53991. }
  53992. if (!this.subSurface.isReadyForSubMesh(defines, scene) ||
  53993. !this.clearCoat.isReadyForSubMesh(defines, scene, engine, this._disableBumpMap) ||
  53994. !this.sheen.isReadyForSubMesh(defines, scene) ||
  53995. !this.anisotropy.isReadyForSubMesh(defines, scene)) {
  53996. return false;
  53997. }
  53998. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  53999. if (!this._imageProcessingConfiguration.isReady()) {
  54000. return false;
  54001. }
  54002. }
  54003. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  54004. mesh.createNormals(true);
  54005. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  54006. }
  54007. var previousEffect = subMesh.effect;
  54008. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  54009. if (effect) {
  54010. // Use previous effect while new one is compiling
  54011. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  54012. effect = previousEffect;
  54013. defines.markAsUnprocessed();
  54014. }
  54015. else {
  54016. scene.resetCachedMaterial();
  54017. subMesh.setEffect(effect, defines);
  54018. this.buildUniformLayout();
  54019. }
  54020. }
  54021. if (!subMesh.effect || !subMesh.effect.isReady()) {
  54022. return false;
  54023. }
  54024. defines._renderId = scene.getRenderId();
  54025. this._wasPreviouslyReady = true;
  54026. return true;
  54027. };
  54028. /**
  54029. * Specifies if the material uses metallic roughness workflow.
  54030. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54031. */
  54032. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  54033. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  54034. return true;
  54035. }
  54036. return false;
  54037. };
  54038. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  54039. if (onCompiled === void 0) { onCompiled = null; }
  54040. if (onError === void 0) { onError = null; }
  54041. if (useInstances === void 0) { useInstances = null; }
  54042. if (useClipPlane === void 0) { useClipPlane = null; }
  54043. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  54044. if (!defines.isDirty) {
  54045. return null;
  54046. }
  54047. defines.markAsProcessed();
  54048. var scene = this.getScene();
  54049. var engine = scene.getEngine();
  54050. // Fallbacks
  54051. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_14__["EffectFallbacks"]();
  54052. var fallbackRank = 0;
  54053. if (defines.USESPHERICALINVERTEX) {
  54054. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  54055. }
  54056. if (defines.FOG) {
  54057. fallbacks.addFallback(fallbackRank, "FOG");
  54058. }
  54059. if (defines.SPECULARAA) {
  54060. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  54061. }
  54062. if (defines.POINTSIZE) {
  54063. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  54064. }
  54065. if (defines.LOGARITHMICDEPTH) {
  54066. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  54067. }
  54068. if (defines.PARALLAX) {
  54069. fallbacks.addFallback(fallbackRank, "PARALLAX");
  54070. }
  54071. if (defines.PARALLAXOCCLUSION) {
  54072. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  54073. }
  54074. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  54075. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  54076. fallbackRank = _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  54077. fallbackRank = _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  54078. if (defines.ENVIRONMENTBRDF) {
  54079. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  54080. }
  54081. if (defines.TANGENT) {
  54082. fallbacks.addFallback(fallbackRank++, "TANGENT");
  54083. }
  54084. if (defines.BUMP) {
  54085. fallbacks.addFallback(fallbackRank++, "BUMP");
  54086. }
  54087. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  54088. if (defines.SPECULARTERM) {
  54089. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  54090. }
  54091. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  54092. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  54093. }
  54094. if (defines.LIGHTMAP) {
  54095. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  54096. }
  54097. if (defines.NORMAL) {
  54098. fallbacks.addFallback(fallbackRank++, "NORMAL");
  54099. }
  54100. if (defines.AMBIENT) {
  54101. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  54102. }
  54103. if (defines.EMISSIVE) {
  54104. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  54105. }
  54106. if (defines.VERTEXCOLOR) {
  54107. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  54108. }
  54109. if (defines.NUM_BONE_INFLUENCERS > 0) {
  54110. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  54111. }
  54112. if (defines.MORPHTARGETS) {
  54113. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  54114. }
  54115. if (defines.MULTIVIEW) {
  54116. fallbacks.addFallback(0, "MULTIVIEW");
  54117. }
  54118. //Attributes
  54119. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  54120. if (defines.NORMAL) {
  54121. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  54122. }
  54123. if (defines.TANGENT) {
  54124. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  54125. }
  54126. if (defines.UV1) {
  54127. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  54128. }
  54129. if (defines.UV2) {
  54130. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  54131. }
  54132. if (defines.VERTEXCOLOR) {
  54133. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  54134. }
  54135. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  54136. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  54137. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  54138. var shaderName = "pbr";
  54139. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "visibility", "vReflectionColor",
  54140. "vFogInfos", "vFogColor", "pointSize",
  54141. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  54142. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos",
  54143. "mBones",
  54144. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix",
  54145. "vLightingIntensity",
  54146. "logarithmicDepthConstant",
  54147. "vSphericalX", "vSphericalY", "vSphericalZ",
  54148. "vSphericalXX_ZZ", "vSphericalYY_ZZ", "vSphericalZZ",
  54149. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  54150. "vSphericalL00",
  54151. "vSphericalL1_1", "vSphericalL10", "vSphericalL11",
  54152. "vSphericalL2_2", "vSphericalL2_1", "vSphericalL20", "vSphericalL21", "vSphericalL22",
  54153. "vReflectionMicrosurfaceInfos",
  54154. "vTangentSpaceParams", "boneTextureWidth",
  54155. "vDebugMode"
  54156. ];
  54157. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  54158. "bumpSampler", "lightmapSampler", "opacitySampler",
  54159. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  54160. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  54161. var uniformBuffers = ["Material", "Scene"];
  54162. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddUniforms(uniforms);
  54163. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddSamplers(samplers);
  54164. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddUniforms(uniforms);
  54165. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddSamplers(samplers);
  54166. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddUniforms(uniforms);
  54167. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddSamplers(samplers);
  54168. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddUniforms(uniforms);
  54169. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddSamplers(samplers);
  54170. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"]) {
  54171. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  54172. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  54173. }
  54174. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareUniformsAndSamplersList({
  54175. uniformsNames: uniforms,
  54176. uniformBuffersNames: uniformBuffers,
  54177. samplers: samplers,
  54178. defines: defines,
  54179. maxSimultaneousLights: this._maxSimultaneousLights
  54180. });
  54181. if (this.customShaderNameResolve) {
  54182. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  54183. }
  54184. var join = defines.toString();
  54185. return engine.createEffect(shaderName, {
  54186. attributes: attribs,
  54187. uniformsNames: uniforms,
  54188. uniformBuffersNames: uniformBuffers,
  54189. samplers: samplers,
  54190. defines: join,
  54191. fallbacks: fallbacks,
  54192. onCompiled: onCompiled,
  54193. onError: onError,
  54194. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  54195. }, engine);
  54196. };
  54197. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  54198. if (useInstances === void 0) { useInstances = null; }
  54199. if (useClipPlane === void 0) { useClipPlane = null; }
  54200. var scene = this.getScene();
  54201. var engine = scene.getEngine();
  54202. // Lights
  54203. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  54204. defines._needNormals = true;
  54205. // Multiview
  54206. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  54207. // Textures
  54208. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  54209. if (defines._areTexturesDirty) {
  54210. defines._needUVs = false;
  54211. if (scene.texturesEnabled) {
  54212. if (scene.getEngine().getCaps().textureLOD) {
  54213. defines.LODBASEDMICROSFURACE = true;
  54214. }
  54215. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  54216. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  54217. }
  54218. else {
  54219. defines.ALBEDO = false;
  54220. }
  54221. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  54222. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  54223. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  54224. }
  54225. else {
  54226. defines.AMBIENT = false;
  54227. }
  54228. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  54229. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  54230. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  54231. }
  54232. else {
  54233. defines.OPACITY = false;
  54234. }
  54235. var reflectionTexture = this._getReflectionTexture();
  54236. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  54237. defines.REFLECTION = true;
  54238. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  54239. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  54240. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  54241. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  54242. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].INVCUBIC_MODE) {
  54243. defines.INVERTCUBICMAP = true;
  54244. }
  54245. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  54246. defines.REFLECTIONMAP_CUBIC = false;
  54247. defines.REFLECTIONMAP_EXPLICIT = false;
  54248. defines.REFLECTIONMAP_PLANAR = false;
  54249. defines.REFLECTIONMAP_PROJECTION = false;
  54250. defines.REFLECTIONMAP_SKYBOX = false;
  54251. defines.REFLECTIONMAP_SPHERICAL = false;
  54252. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  54253. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  54254. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  54255. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  54256. switch (reflectionTexture.coordinatesMode) {
  54257. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].EXPLICIT_MODE:
  54258. defines.REFLECTIONMAP_EXPLICIT = true;
  54259. break;
  54260. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].PLANAR_MODE:
  54261. defines.REFLECTIONMAP_PLANAR = true;
  54262. break;
  54263. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].PROJECTION_MODE:
  54264. defines.REFLECTIONMAP_PROJECTION = true;
  54265. break;
  54266. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].SKYBOX_MODE:
  54267. defines.REFLECTIONMAP_SKYBOX = true;
  54268. break;
  54269. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].SPHERICAL_MODE:
  54270. defines.REFLECTIONMAP_SPHERICAL = true;
  54271. break;
  54272. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].EQUIRECTANGULAR_MODE:
  54273. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  54274. break;
  54275. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  54276. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  54277. break;
  54278. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  54279. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  54280. break;
  54281. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].CUBIC_MODE:
  54282. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].INVCUBIC_MODE:
  54283. default:
  54284. defines.REFLECTIONMAP_CUBIC = true;
  54285. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  54286. break;
  54287. }
  54288. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].SKYBOX_MODE) {
  54289. if (reflectionTexture.sphericalPolynomial) {
  54290. defines.USESPHERICALFROMREFLECTIONMAP = true;
  54291. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  54292. defines.USESPHERICALINVERTEX = false;
  54293. }
  54294. else {
  54295. defines.USESPHERICALINVERTEX = true;
  54296. }
  54297. }
  54298. }
  54299. else {
  54300. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  54301. }
  54302. }
  54303. else {
  54304. defines.REFLECTION = false;
  54305. defines.REFLECTIONMAP_3D = false;
  54306. defines.REFLECTIONMAP_SPHERICAL = false;
  54307. defines.REFLECTIONMAP_PLANAR = false;
  54308. defines.REFLECTIONMAP_CUBIC = false;
  54309. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  54310. defines.REFLECTIONMAP_PROJECTION = false;
  54311. defines.REFLECTIONMAP_SKYBOX = false;
  54312. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  54313. defines.REFLECTIONMAP_EXPLICIT = false;
  54314. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  54315. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  54316. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  54317. defines.INVERTCUBICMAP = false;
  54318. defines.USESPHERICALFROMREFLECTIONMAP = false;
  54319. defines.USESPHERICALINVERTEX = false;
  54320. defines.REFLECTIONMAP_OPPOSITEZ = false;
  54321. defines.LODINREFLECTIONALPHA = false;
  54322. defines.GAMMAREFLECTION = false;
  54323. defines.RGBDREFLECTION = false;
  54324. }
  54325. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  54326. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  54327. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  54328. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  54329. }
  54330. else {
  54331. defines.LIGHTMAP = false;
  54332. }
  54333. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  54334. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  54335. }
  54336. else {
  54337. defines.EMISSIVE = false;
  54338. }
  54339. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  54340. if (this._metallicTexture) {
  54341. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  54342. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  54343. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  54344. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  54345. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  54346. }
  54347. else if (this._reflectivityTexture) {
  54348. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  54349. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  54350. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  54351. }
  54352. else {
  54353. defines.REFLECTIVITY = false;
  54354. }
  54355. if (this._microSurfaceTexture) {
  54356. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  54357. }
  54358. else {
  54359. defines.MICROSURFACEMAP = false;
  54360. }
  54361. }
  54362. else {
  54363. defines.REFLECTIVITY = false;
  54364. defines.MICROSURFACEMAP = false;
  54365. }
  54366. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  54367. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  54368. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  54369. defines.PARALLAX = true;
  54370. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  54371. }
  54372. else {
  54373. defines.PARALLAX = false;
  54374. }
  54375. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  54376. }
  54377. else {
  54378. defines.BUMP = false;
  54379. }
  54380. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  54381. defines.ENVIRONMENTBRDF = true;
  54382. // Not actual true RGBD, only the B chanel is encoded as RGBD for sheen.
  54383. defines.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD;
  54384. }
  54385. else {
  54386. defines.ENVIRONMENTBRDF = false;
  54387. defines.ENVIRONMENTBRDF_RGBD = false;
  54388. }
  54389. if (this._shouldUseAlphaFromAlbedoTexture()) {
  54390. defines.ALPHAFROMALBEDO = true;
  54391. }
  54392. else {
  54393. defines.ALPHAFROMALBEDO = false;
  54394. }
  54395. }
  54396. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  54397. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  54398. defines.USEPHYSICALLIGHTFALLOFF = false;
  54399. defines.USEGLTFLIGHTFALLOFF = false;
  54400. }
  54401. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  54402. defines.USEPHYSICALLIGHTFALLOFF = false;
  54403. defines.USEGLTFLIGHTFALLOFF = true;
  54404. }
  54405. else {
  54406. defines.USEPHYSICALLIGHTFALLOFF = true;
  54407. defines.USEGLTFLIGHTFALLOFF = false;
  54408. }
  54409. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  54410. if (!this.backFaceCulling && this._twoSidedLighting) {
  54411. defines.TWOSIDEDLIGHTING = true;
  54412. }
  54413. else {
  54414. defines.TWOSIDEDLIGHTING = false;
  54415. }
  54416. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  54417. 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);
  54418. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  54419. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  54420. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  54421. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  54422. }
  54423. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  54424. this._imageProcessingConfiguration.prepareDefines(defines);
  54425. }
  54426. defines.FORCENORMALFORWARD = this._forceNormalForward;
  54427. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  54428. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  54429. // Misc.
  54430. if (defines._areMiscDirty) {
  54431. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  54432. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  54433. defines.DEBUGMODE = this._debugMode;
  54434. }
  54435. // External config
  54436. this.subSurface.prepareDefines(defines, scene);
  54437. this.clearCoat.prepareDefines(defines, scene);
  54438. this.anisotropy.prepareDefines(defines, mesh, scene);
  54439. this.brdf.prepareDefines(defines);
  54440. this.sheen.prepareDefines(defines, scene);
  54441. // Values that need to be evaluated on every frame
  54442. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  54443. // Attribs
  54444. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  54445. };
  54446. /**
  54447. * Force shader compilation
  54448. */
  54449. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  54450. var _this = this;
  54451. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  54452. var defines = new PBRMaterialDefines();
  54453. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  54454. if (effect.isReady()) {
  54455. if (onCompiled) {
  54456. onCompiled(this);
  54457. }
  54458. }
  54459. else {
  54460. effect.onCompileObservable.add(function () {
  54461. if (onCompiled) {
  54462. onCompiled(_this);
  54463. }
  54464. });
  54465. }
  54466. };
  54467. /**
  54468. * Initializes the uniform buffer layout for the shader.
  54469. */
  54470. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  54471. // Order is important !
  54472. var ubo = this._uniformBuffer;
  54473. ubo.addUniform("vAlbedoInfos", 2);
  54474. ubo.addUniform("vAmbientInfos", 4);
  54475. ubo.addUniform("vOpacityInfos", 2);
  54476. ubo.addUniform("vEmissiveInfos", 2);
  54477. ubo.addUniform("vLightmapInfos", 2);
  54478. ubo.addUniform("vReflectivityInfos", 3);
  54479. ubo.addUniform("vMicroSurfaceSamplerInfos", 2);
  54480. ubo.addUniform("vReflectionInfos", 2);
  54481. ubo.addUniform("vReflectionPosition", 3);
  54482. ubo.addUniform("vReflectionSize", 3);
  54483. ubo.addUniform("vBumpInfos", 3);
  54484. ubo.addUniform("albedoMatrix", 16);
  54485. ubo.addUniform("ambientMatrix", 16);
  54486. ubo.addUniform("opacityMatrix", 16);
  54487. ubo.addUniform("emissiveMatrix", 16);
  54488. ubo.addUniform("lightmapMatrix", 16);
  54489. ubo.addUniform("reflectivityMatrix", 16);
  54490. ubo.addUniform("microSurfaceSamplerMatrix", 16);
  54491. ubo.addUniform("bumpMatrix", 16);
  54492. ubo.addUniform("vTangentSpaceParams", 2);
  54493. ubo.addUniform("reflectionMatrix", 16);
  54494. ubo.addUniform("vReflectionColor", 3);
  54495. ubo.addUniform("vAlbedoColor", 4);
  54496. ubo.addUniform("vLightingIntensity", 4);
  54497. ubo.addUniform("vReflectionMicrosurfaceInfos", 3);
  54498. ubo.addUniform("pointSize", 1);
  54499. ubo.addUniform("vReflectivityColor", 4);
  54500. ubo.addUniform("vEmissiveColor", 3);
  54501. ubo.addUniform("visibility", 1);
  54502. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].PrepareUniformBuffer(ubo);
  54503. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].PrepareUniformBuffer(ubo);
  54504. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].PrepareUniformBuffer(ubo);
  54505. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].PrepareUniformBuffer(ubo);
  54506. ubo.create();
  54507. };
  54508. /**
  54509. * Unbinds the material from the mesh
  54510. */
  54511. PBRBaseMaterial.prototype.unbind = function () {
  54512. if (this._activeEffect) {
  54513. var needFlag = false;
  54514. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  54515. this._activeEffect.setTexture("reflection2DSampler", null);
  54516. needFlag = true;
  54517. }
  54518. if (this.subSurface.unbind(this._activeEffect)) {
  54519. needFlag = true;
  54520. }
  54521. if (needFlag) {
  54522. this._markAllSubMeshesAsTexturesDirty();
  54523. }
  54524. }
  54525. _super.prototype.unbind.call(this);
  54526. };
  54527. /**
  54528. * Binds the submesh data.
  54529. * @param world - The world matrix.
  54530. * @param mesh - The BJS mesh.
  54531. * @param subMesh - A submesh of the BJS mesh.
  54532. */
  54533. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  54534. var scene = this.getScene();
  54535. var defines = subMesh._materialDefines;
  54536. if (!defines) {
  54537. return;
  54538. }
  54539. var effect = subMesh.effect;
  54540. if (!effect) {
  54541. return;
  54542. }
  54543. this._activeEffect = effect;
  54544. // Matrices
  54545. if (!defines.INSTANCES) {
  54546. this.bindOnlyWorldMatrix(world);
  54547. }
  54548. // Normal Matrix
  54549. if (defines.OBJECTSPACE_NORMALMAP) {
  54550. world.toNormalMatrix(this._normalMatrix);
  54551. this.bindOnlyNormalMatrix(this._normalMatrix);
  54552. }
  54553. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  54554. // Bones
  54555. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  54556. var reflectionTexture = null;
  54557. var ubo = this._uniformBuffer;
  54558. if (mustRebind) {
  54559. var engine = scene.getEngine();
  54560. ubo.bindToEffect(effect, "Material");
  54561. this.bindViewProjection(effect);
  54562. reflectionTexture = this._getReflectionTexture();
  54563. if (!ubo.useUbo || !this.isFrozen || !ubo.isSync) {
  54564. // Texture uniforms
  54565. if (scene.texturesEnabled) {
  54566. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  54567. ubo.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  54568. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, ubo, "albedo");
  54569. }
  54570. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  54571. ubo.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  54572. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, ubo, "ambient");
  54573. }
  54574. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  54575. ubo.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  54576. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, ubo, "opacity");
  54577. }
  54578. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  54579. ubo.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  54580. ubo.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  54581. if (reflectionTexture.boundingBoxSize) {
  54582. var cubeTexture = reflectionTexture;
  54583. ubo.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  54584. ubo.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  54585. }
  54586. var polynomials = reflectionTexture.sphericalPolynomial;
  54587. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  54588. if (defines.SPHERICAL_HARMONICS) {
  54589. var preScaledHarmonics = polynomials.preScaledHarmonics;
  54590. this._activeEffect.setVector3("vSphericalL00", preScaledHarmonics.l00);
  54591. this._activeEffect.setVector3("vSphericalL1_1", preScaledHarmonics.l1_1);
  54592. this._activeEffect.setVector3("vSphericalL10", preScaledHarmonics.l10);
  54593. this._activeEffect.setVector3("vSphericalL11", preScaledHarmonics.l11);
  54594. this._activeEffect.setVector3("vSphericalL2_2", preScaledHarmonics.l2_2);
  54595. this._activeEffect.setVector3("vSphericalL2_1", preScaledHarmonics.l2_1);
  54596. this._activeEffect.setVector3("vSphericalL20", preScaledHarmonics.l20);
  54597. this._activeEffect.setVector3("vSphericalL21", preScaledHarmonics.l21);
  54598. this._activeEffect.setVector3("vSphericalL22", preScaledHarmonics.l22);
  54599. }
  54600. else {
  54601. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  54602. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  54603. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  54604. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  54605. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  54606. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  54607. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  54608. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  54609. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  54610. }
  54611. }
  54612. ubo.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  54613. }
  54614. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  54615. ubo.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  54616. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, ubo, "emissive");
  54617. }
  54618. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  54619. ubo.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  54620. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, ubo, "lightmap");
  54621. }
  54622. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  54623. if (this._metallicTexture) {
  54624. ubo.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  54625. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, ubo, "reflectivity");
  54626. }
  54627. else if (this._reflectivityTexture) {
  54628. ubo.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  54629. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, ubo, "reflectivity");
  54630. }
  54631. if (this._microSurfaceTexture) {
  54632. ubo.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  54633. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, ubo, "microSurfaceSampler");
  54634. }
  54635. }
  54636. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  54637. ubo.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  54638. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, ubo, "bump");
  54639. if (scene._mirroredCameraPosition) {
  54640. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  54641. }
  54642. else {
  54643. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  54644. }
  54645. }
  54646. }
  54647. // Point size
  54648. if (this.pointsCloud) {
  54649. ubo.updateFloat("pointSize", this.pointSize);
  54650. }
  54651. // Colors
  54652. if (defines.METALLICWORKFLOW) {
  54653. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  54654. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  54655. ubo.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  54656. }
  54657. else {
  54658. ubo.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  54659. }
  54660. ubo.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  54661. ubo.updateColor3("vReflectionColor", this._reflectionColor);
  54662. ubo.updateColor4("vAlbedoColor", this._albedoColor, this.alpha);
  54663. // Visibility
  54664. ubo.updateFloat("visibility", mesh.visibility);
  54665. // Misc
  54666. this._lightingInfos.x = this._directIntensity;
  54667. this._lightingInfos.y = this._emissiveIntensity;
  54668. this._lightingInfos.z = this._environmentIntensity;
  54669. this._lightingInfos.w = this._specularIntensity;
  54670. ubo.updateVector4("vLightingIntensity", this._lightingInfos);
  54671. }
  54672. // Textures
  54673. if (scene.texturesEnabled) {
  54674. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  54675. ubo.setTexture("albedoSampler", this._albedoTexture);
  54676. }
  54677. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  54678. ubo.setTexture("ambientSampler", this._ambientTexture);
  54679. }
  54680. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  54681. ubo.setTexture("opacitySampler", this._opacityTexture);
  54682. }
  54683. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  54684. if (defines.LODBASEDMICROSFURACE) {
  54685. ubo.setTexture("reflectionSampler", reflectionTexture);
  54686. }
  54687. else {
  54688. ubo.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  54689. ubo.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  54690. ubo.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  54691. }
  54692. }
  54693. if (defines.ENVIRONMENTBRDF) {
  54694. ubo.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  54695. }
  54696. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  54697. ubo.setTexture("emissiveSampler", this._emissiveTexture);
  54698. }
  54699. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  54700. ubo.setTexture("lightmapSampler", this._lightmapTexture);
  54701. }
  54702. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  54703. if (this._metallicTexture) {
  54704. ubo.setTexture("reflectivitySampler", this._metallicTexture);
  54705. }
  54706. else if (this._reflectivityTexture) {
  54707. ubo.setTexture("reflectivitySampler", this._reflectivityTexture);
  54708. }
  54709. if (this._microSurfaceTexture) {
  54710. ubo.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  54711. }
  54712. }
  54713. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  54714. ubo.setTexture("bumpSampler", this._bumpTexture);
  54715. }
  54716. }
  54717. this.subSurface.bindForSubMesh(ubo, scene, engine, this.isFrozen, defines.LODBASEDMICROSFURACE);
  54718. this.clearCoat.bindForSubMesh(ubo, scene, engine, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY);
  54719. this.anisotropy.bindForSubMesh(ubo, scene, this.isFrozen);
  54720. this.sheen.bindForSubMesh(ubo, scene, this.isFrozen);
  54721. // Clip plane
  54722. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  54723. // Colors
  54724. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  54725. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  54726. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  54727. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  54728. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  54729. effect.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
  54730. }
  54731. if (mustRebind || !this.isFrozen) {
  54732. // Lights
  54733. if (scene.lightsEnabled && !this._disableLighting) {
  54734. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  54735. }
  54736. // View
  54737. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  54738. this.bindView(effect);
  54739. }
  54740. // Fog
  54741. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  54742. // Morph targets
  54743. if (defines.NUM_MORPH_INFLUENCERS) {
  54744. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  54745. }
  54746. // image processing
  54747. this._imageProcessingConfiguration.bind(this._activeEffect);
  54748. // Log. depth
  54749. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  54750. }
  54751. ubo.update();
  54752. this._afterBind(mesh, this._activeEffect);
  54753. };
  54754. /**
  54755. * Returns the animatable textures.
  54756. * @returns - Array of animatable textures.
  54757. */
  54758. PBRBaseMaterial.prototype.getAnimatables = function () {
  54759. var results = [];
  54760. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  54761. results.push(this._albedoTexture);
  54762. }
  54763. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  54764. results.push(this._ambientTexture);
  54765. }
  54766. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  54767. results.push(this._opacityTexture);
  54768. }
  54769. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  54770. results.push(this._reflectionTexture);
  54771. }
  54772. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  54773. results.push(this._emissiveTexture);
  54774. }
  54775. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  54776. results.push(this._metallicTexture);
  54777. }
  54778. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  54779. results.push(this._reflectivityTexture);
  54780. }
  54781. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  54782. results.push(this._bumpTexture);
  54783. }
  54784. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  54785. results.push(this._lightmapTexture);
  54786. }
  54787. this.subSurface.getAnimatables(results);
  54788. this.clearCoat.getAnimatables(results);
  54789. this.sheen.getAnimatables(results);
  54790. this.anisotropy.getAnimatables(results);
  54791. return results;
  54792. };
  54793. /**
  54794. * Returns the texture used for reflections.
  54795. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54796. */
  54797. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  54798. if (this._reflectionTexture) {
  54799. return this._reflectionTexture;
  54800. }
  54801. return this.getScene().environmentTexture;
  54802. };
  54803. /**
  54804. * Returns an array of the actively used textures.
  54805. * @returns - Array of BaseTextures
  54806. */
  54807. PBRBaseMaterial.prototype.getActiveTextures = function () {
  54808. var activeTextures = _super.prototype.getActiveTextures.call(this);
  54809. if (this._albedoTexture) {
  54810. activeTextures.push(this._albedoTexture);
  54811. }
  54812. if (this._ambientTexture) {
  54813. activeTextures.push(this._ambientTexture);
  54814. }
  54815. if (this._opacityTexture) {
  54816. activeTextures.push(this._opacityTexture);
  54817. }
  54818. if (this._reflectionTexture) {
  54819. activeTextures.push(this._reflectionTexture);
  54820. }
  54821. if (this._emissiveTexture) {
  54822. activeTextures.push(this._emissiveTexture);
  54823. }
  54824. if (this._reflectivityTexture) {
  54825. activeTextures.push(this._reflectivityTexture);
  54826. }
  54827. if (this._metallicTexture) {
  54828. activeTextures.push(this._metallicTexture);
  54829. }
  54830. if (this._microSurfaceTexture) {
  54831. activeTextures.push(this._microSurfaceTexture);
  54832. }
  54833. if (this._bumpTexture) {
  54834. activeTextures.push(this._bumpTexture);
  54835. }
  54836. if (this._lightmapTexture) {
  54837. activeTextures.push(this._lightmapTexture);
  54838. }
  54839. this.subSurface.getActiveTextures(activeTextures);
  54840. this.clearCoat.getActiveTextures(activeTextures);
  54841. this.sheen.getActiveTextures(activeTextures);
  54842. this.anisotropy.getActiveTextures(activeTextures);
  54843. return activeTextures;
  54844. };
  54845. /**
  54846. * Checks to see if a texture is used in the material.
  54847. * @param texture - Base texture to use.
  54848. * @returns - Boolean specifying if a texture is used in the material.
  54849. */
  54850. PBRBaseMaterial.prototype.hasTexture = function (texture) {
  54851. if (_super.prototype.hasTexture.call(this, texture)) {
  54852. return true;
  54853. }
  54854. if (this._albedoTexture === texture) {
  54855. return true;
  54856. }
  54857. if (this._ambientTexture === texture) {
  54858. return true;
  54859. }
  54860. if (this._opacityTexture === texture) {
  54861. return true;
  54862. }
  54863. if (this._reflectionTexture === texture) {
  54864. return true;
  54865. }
  54866. if (this._reflectivityTexture === texture) {
  54867. return true;
  54868. }
  54869. if (this._metallicTexture === texture) {
  54870. return true;
  54871. }
  54872. if (this._microSurfaceTexture === texture) {
  54873. return true;
  54874. }
  54875. if (this._bumpTexture === texture) {
  54876. return true;
  54877. }
  54878. if (this._lightmapTexture === texture) {
  54879. return true;
  54880. }
  54881. return this.subSurface.hasTexture(texture) ||
  54882. this.clearCoat.hasTexture(texture) ||
  54883. this.sheen.hasTexture(texture) ||
  54884. this.anisotropy.hasTexture(texture);
  54885. };
  54886. /**
  54887. * Disposes the resources of the material.
  54888. * @param forceDisposeEffect - Forces the disposal of effects.
  54889. * @param forceDisposeTextures - Forces the disposal of all textures.
  54890. */
  54891. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  54892. if (forceDisposeTextures) {
  54893. if (this._albedoTexture) {
  54894. this._albedoTexture.dispose();
  54895. }
  54896. if (this._ambientTexture) {
  54897. this._ambientTexture.dispose();
  54898. }
  54899. if (this._opacityTexture) {
  54900. this._opacityTexture.dispose();
  54901. }
  54902. if (this._reflectionTexture) {
  54903. this._reflectionTexture.dispose();
  54904. }
  54905. if (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture) {
  54906. this._environmentBRDFTexture.dispose();
  54907. }
  54908. if (this._emissiveTexture) {
  54909. this._emissiveTexture.dispose();
  54910. }
  54911. if (this._metallicTexture) {
  54912. this._metallicTexture.dispose();
  54913. }
  54914. if (this._reflectivityTexture) {
  54915. this._reflectivityTexture.dispose();
  54916. }
  54917. if (this._bumpTexture) {
  54918. this._bumpTexture.dispose();
  54919. }
  54920. if (this._lightmapTexture) {
  54921. this._lightmapTexture.dispose();
  54922. }
  54923. }
  54924. this.subSurface.dispose(forceDisposeTextures);
  54925. this.clearCoat.dispose(forceDisposeTextures);
  54926. this.sheen.dispose(forceDisposeTextures);
  54927. this.anisotropy.dispose(forceDisposeTextures);
  54928. this._renderTargets.dispose();
  54929. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  54930. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  54931. }
  54932. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  54933. };
  54934. /**
  54935. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54936. */
  54937. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  54938. /**
  54939. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54940. */
  54941. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  54942. /**
  54943. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54944. */
  54945. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  54946. /**
  54947. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54948. * They are also discarded below the alpha cutoff threshold to improve performances.
  54949. */
  54950. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  54951. /**
  54952. * Defines the default value of how much AO map is occluding the analytical lights
  54953. * (point spot...).
  54954. */
  54955. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0;
  54956. /**
  54957. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54958. */
  54959. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  54960. /**
  54961. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54962. * to enhance interoperability with other engines.
  54963. */
  54964. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  54965. /**
  54966. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54967. * to enhance interoperability with other materials.
  54968. */
  54969. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  54970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  54972. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  54973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  54975. ], PBRBaseMaterial.prototype, "debugMode", void 0);
  54976. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54977. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54978. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  54979. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54980. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54981. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  54982. return PBRBaseMaterial;
  54983. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_16__["PushMaterial"]));
  54984. /***/ }),
  54985. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  54986. /*!************************************************!*\
  54987. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  54988. \************************************************/
  54989. /*! exports provided: PBRBaseSimpleMaterial */
  54990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54991. "use strict";
  54992. __webpack_require__.r(__webpack_exports__);
  54993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  54994. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54995. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54996. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54997. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  54998. /**
  54999. * The Physically based simple base material of BJS.
  55000. *
  55001. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55002. * It is used as the base class for both the specGloss and metalRough conventions.
  55003. */
  55004. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  55005. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  55006. /**
  55007. * Instantiates a new PBRMaterial instance.
  55008. *
  55009. * @param name The material name
  55010. * @param scene The scene the material will be use in.
  55011. */
  55012. function PBRBaseSimpleMaterial(name, scene) {
  55013. var _this = _super.call(this, name, scene) || this;
  55014. /**
  55015. * Number of Simultaneous lights allowed on the material.
  55016. */
  55017. _this.maxSimultaneousLights = 4;
  55018. /**
  55019. * If sets to true, disables all the lights affecting the material.
  55020. */
  55021. _this.disableLighting = false;
  55022. /**
  55023. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55024. */
  55025. _this.invertNormalMapX = false;
  55026. /**
  55027. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55028. */
  55029. _this.invertNormalMapY = false;
  55030. /**
  55031. * Emissivie color used to self-illuminate the model.
  55032. */
  55033. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  55034. /**
  55035. * Occlusion Channel Strenght.
  55036. */
  55037. _this.occlusionStrength = 1.0;
  55038. /**
  55039. * If true, the light map contains occlusion information instead of lighting info.
  55040. */
  55041. _this.useLightmapAsShadowmap = false;
  55042. _this._useAlphaFromAlbedoTexture = true;
  55043. _this._useAmbientInGrayScale = true;
  55044. return _this;
  55045. }
  55046. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  55047. /**
  55048. * Gets the current double sided mode.
  55049. */
  55050. get: function () {
  55051. return this._twoSidedLighting;
  55052. },
  55053. /**
  55054. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55055. */
  55056. set: function (value) {
  55057. if (this._twoSidedLighting === value) {
  55058. return;
  55059. }
  55060. this._twoSidedLighting = value;
  55061. this.backFaceCulling = !value;
  55062. this._markAllSubMeshesAsTexturesDirty();
  55063. },
  55064. enumerable: true,
  55065. configurable: true
  55066. });
  55067. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  55068. return "PBRBaseSimpleMaterial";
  55069. };
  55070. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55071. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55072. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  55073. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  55074. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55075. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55076. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  55077. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  55078. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55079. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55080. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  55081. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  55082. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55083. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55084. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55085. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  55086. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55087. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55088. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55089. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  55090. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55091. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55092. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  55093. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  55094. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55095. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  55096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55097. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  55098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55100. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55101. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  55102. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55103. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55104. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  55105. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  55106. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55107. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  55109. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  55110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  55113. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  55114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55116. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  55117. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55118. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  55120. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  55121. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55122. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55124. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  55125. return PBRBaseSimpleMaterial;
  55126. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  55127. /***/ }),
  55128. /***/ "./Materials/PBR/pbrClearCoatConfiguration.ts":
  55129. /*!****************************************************!*\
  55130. !*** ./Materials/PBR/pbrClearCoatConfiguration.ts ***!
  55131. \****************************************************/
  55132. /*! exports provided: PBRClearCoatConfiguration */
  55133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55134. "use strict";
  55135. __webpack_require__.r(__webpack_exports__);
  55136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRClearCoatConfiguration", function() { return PBRClearCoatConfiguration; });
  55137. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55138. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55139. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55140. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  55141. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  55142. /**
  55143. * Define the code related to the clear coat parameters of the pbr material.
  55144. */
  55145. var PBRClearCoatConfiguration = /** @class */ (function () {
  55146. /**
  55147. * Instantiate a new istance of clear coat configuration.
  55148. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55149. */
  55150. function PBRClearCoatConfiguration(markAllSubMeshesAsTexturesDirty) {
  55151. this._isEnabled = false;
  55152. /**
  55153. * Defines if the clear coat is enabled in the material.
  55154. */
  55155. this.isEnabled = false;
  55156. /**
  55157. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55158. */
  55159. this.intensity = 1;
  55160. /**
  55161. * Defines the clear coat layer roughness.
  55162. */
  55163. this.roughness = 0;
  55164. this._indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  55165. /**
  55166. * Defines the indice of refraction of the clear coat.
  55167. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55168. * The default fits with a polyurethane material.
  55169. * Changing the default value is more performance intensive.
  55170. */
  55171. this.indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  55172. this._texture = null;
  55173. /**
  55174. * Stores the clear coat values in a texture.
  55175. */
  55176. this.texture = null;
  55177. this._bumpTexture = null;
  55178. /**
  55179. * Define the clear coat specific bump texture.
  55180. */
  55181. this.bumpTexture = null;
  55182. this._isTintEnabled = false;
  55183. /**
  55184. * Defines if the clear coat tint is enabled in the material.
  55185. */
  55186. this.isTintEnabled = false;
  55187. /**
  55188. * Defines the clear coat tint of the material.
  55189. * This is only use if tint is enabled
  55190. */
  55191. this.tintColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  55192. /**
  55193. * Defines the distance at which the tint color should be found in the
  55194. * clear coat media.
  55195. * This is only use if tint is enabled
  55196. */
  55197. this.tintColorAtDistance = 1;
  55198. /**
  55199. * Defines the clear coat layer thickness.
  55200. * This is only use if tint is enabled
  55201. */
  55202. this.tintThickness = 1;
  55203. this._tintTexture = null;
  55204. /**
  55205. * Stores the clear tint values in a texture.
  55206. * rgb is tint
  55207. * a is a thickness factor
  55208. */
  55209. this.tintTexture = null;
  55210. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  55211. }
  55212. /** @hidden */
  55213. PBRClearCoatConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  55214. this._internalMarkAllSubMeshesAsTexturesDirty();
  55215. };
  55216. /**
  55217. * Gets wehter the submesh is ready to be used or not.
  55218. * @param defines the list of "defines" to update.
  55219. * @param scene defines the scene the material belongs to.
  55220. * @param engine defines the engine the material belongs to.
  55221. * @param disableBumpMap defines wether the material disables bump or not.
  55222. * @returns - boolean indicating that the submesh is ready or not.
  55223. */
  55224. PBRClearCoatConfiguration.prototype.isReadyForSubMesh = function (defines, scene, engine, disableBumpMap) {
  55225. if (defines._areTexturesDirty) {
  55226. if (scene.texturesEnabled) {
  55227. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  55228. if (!this._texture.isReadyOrNotBlocking()) {
  55229. return false;
  55230. }
  55231. }
  55232. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  55233. // Bump texture cannot be not blocking.
  55234. if (!this._bumpTexture.isReady()) {
  55235. return false;
  55236. }
  55237. }
  55238. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  55239. if (!this._tintTexture.isReadyOrNotBlocking()) {
  55240. return false;
  55241. }
  55242. }
  55243. }
  55244. }
  55245. return true;
  55246. };
  55247. /**
  55248. * Checks to see if a texture is used in the material.
  55249. * @param defines the list of "defines" to update.
  55250. * @param scene defines the scene to the material belongs to.
  55251. */
  55252. PBRClearCoatConfiguration.prototype.prepareDefines = function (defines, scene) {
  55253. if (this._isEnabled) {
  55254. defines.CLEARCOAT = true;
  55255. if (defines._areTexturesDirty) {
  55256. if (scene.texturesEnabled) {
  55257. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  55258. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "CLEARCOAT_TEXTURE");
  55259. }
  55260. else {
  55261. defines.CLEARCOAT_TEXTURE = false;
  55262. }
  55263. if (this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled) {
  55264. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "CLEARCOAT_BUMP");
  55265. }
  55266. else {
  55267. defines.CLEARCOAT_BUMP = false;
  55268. }
  55269. defines.CLEARCOAT_DEFAULTIOR = this._indiceOfRefraction === PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  55270. if (this._isTintEnabled) {
  55271. defines.CLEARCOAT_TINT = true;
  55272. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  55273. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._tintTexture, defines, "CLEARCOAT_TINT_TEXTURE");
  55274. }
  55275. else {
  55276. defines.CLEARCOAT_TINT_TEXTURE = false;
  55277. }
  55278. }
  55279. else {
  55280. defines.CLEARCOAT_TINT = false;
  55281. defines.CLEARCOAT_TINT_TEXTURE = false;
  55282. }
  55283. }
  55284. }
  55285. }
  55286. else {
  55287. defines.CLEARCOAT = false;
  55288. defines.CLEARCOAT_TEXTURE = false;
  55289. defines.CLEARCOAT_BUMP = false;
  55290. defines.CLEARCOAT_TINT = false;
  55291. defines.CLEARCOAT_TINT_TEXTURE = false;
  55292. }
  55293. };
  55294. /**
  55295. * Binds the material data.
  55296. * @param uniformBuffer defines the Uniform buffer to fill in.
  55297. * @param scene defines the scene the material belongs to.
  55298. * @param engine defines the engine the material belongs to.
  55299. * @param disableBumpMap defines wether the material disables bump or not.
  55300. * @param isFrozen defines wether the material is frozen or not.
  55301. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55302. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55303. */
  55304. PBRClearCoatConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, disableBumpMap, isFrozen, invertNormalMapX, invertNormalMapY) {
  55305. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  55306. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  55307. uniformBuffer.updateFloat2("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level);
  55308. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "clearCoat");
  55309. }
  55310. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled && !disableBumpMap) {
  55311. uniformBuffer.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level);
  55312. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, uniformBuffer, "clearCoatBump");
  55313. if (scene._mirroredCameraPosition) {
  55314. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? 1.0 : -1.0, invertNormalMapY ? 1.0 : -1.0);
  55315. }
  55316. else {
  55317. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? -1.0 : 1.0, invertNormalMapY ? -1.0 : 1.0);
  55318. }
  55319. }
  55320. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  55321. uniformBuffer.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level);
  55322. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._tintTexture, uniformBuffer, "clearCoatTint");
  55323. }
  55324. // Clear Coat General params
  55325. uniformBuffer.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
  55326. // Clear Coat Refraction params
  55327. var a = 1 - this._indiceOfRefraction;
  55328. var b = 1 + this._indiceOfRefraction;
  55329. var f0 = Math.pow((-a / b), 2); // Schlicks approx: (ior1 - ior2) / (ior1 + ior2) where ior2 for air is close to vacuum = 1.
  55330. var eta = 1 / this._indiceOfRefraction;
  55331. uniformBuffer.updateFloat4("vClearCoatRefractionParams", f0, eta, a, b);
  55332. if (this._isTintEnabled) {
  55333. uniformBuffer.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(0.00001, this.tintThickness));
  55334. uniformBuffer.updateFloat("clearCoatColorAtDistance", Math.max(0.00001, this.tintColorAtDistance));
  55335. }
  55336. }
  55337. // Textures
  55338. if (scene.texturesEnabled) {
  55339. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  55340. uniformBuffer.setTexture("clearCoatSampler", this._texture);
  55341. }
  55342. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  55343. uniformBuffer.setTexture("clearCoatBumpSampler", this._bumpTexture);
  55344. }
  55345. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  55346. uniformBuffer.setTexture("clearCoatTintSampler", this._tintTexture);
  55347. }
  55348. }
  55349. };
  55350. /**
  55351. * Checks to see if a texture is used in the material.
  55352. * @param texture - Base texture to use.
  55353. * @returns - Boolean specifying if a texture is used in the material.
  55354. */
  55355. PBRClearCoatConfiguration.prototype.hasTexture = function (texture) {
  55356. if (this._texture === texture) {
  55357. return true;
  55358. }
  55359. if (this._bumpTexture === texture) {
  55360. return true;
  55361. }
  55362. if (this._tintTexture === texture) {
  55363. return true;
  55364. }
  55365. return false;
  55366. };
  55367. /**
  55368. * Returns an array of the actively used textures.
  55369. * @param activeTextures Array of BaseTextures
  55370. */
  55371. PBRClearCoatConfiguration.prototype.getActiveTextures = function (activeTextures) {
  55372. if (this._texture) {
  55373. activeTextures.push(this._texture);
  55374. }
  55375. if (this._bumpTexture) {
  55376. activeTextures.push(this._bumpTexture);
  55377. }
  55378. if (this._tintTexture) {
  55379. activeTextures.push(this._tintTexture);
  55380. }
  55381. };
  55382. /**
  55383. * Returns the animatable textures.
  55384. * @param animatables Array of animatable textures.
  55385. */
  55386. PBRClearCoatConfiguration.prototype.getAnimatables = function (animatables) {
  55387. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  55388. animatables.push(this._texture);
  55389. }
  55390. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  55391. animatables.push(this._bumpTexture);
  55392. }
  55393. if (this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0) {
  55394. animatables.push(this._tintTexture);
  55395. }
  55396. };
  55397. /**
  55398. * Disposes the resources of the material.
  55399. * @param forceDisposeTextures - Forces the disposal of all textures.
  55400. */
  55401. PBRClearCoatConfiguration.prototype.dispose = function (forceDisposeTextures) {
  55402. if (forceDisposeTextures) {
  55403. if (this._texture) {
  55404. this._texture.dispose();
  55405. }
  55406. if (this._bumpTexture) {
  55407. this._bumpTexture.dispose();
  55408. }
  55409. if (this._tintTexture) {
  55410. this._tintTexture.dispose();
  55411. }
  55412. }
  55413. };
  55414. /**
  55415. * Get the current class name of the texture useful for serialization or dynamic coding.
  55416. * @returns "PBRClearCoatConfiguration"
  55417. */
  55418. PBRClearCoatConfiguration.prototype.getClassName = function () {
  55419. return "PBRClearCoatConfiguration";
  55420. };
  55421. /**
  55422. * Add fallbacks to the effect fallbacks list.
  55423. * @param defines defines the Base texture to use.
  55424. * @param fallbacks defines the current fallback list.
  55425. * @param currentRank defines the current fallback rank.
  55426. * @returns the new fallback rank.
  55427. */
  55428. PBRClearCoatConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  55429. if (defines.CLEARCOAT_BUMP) {
  55430. fallbacks.addFallback(currentRank++, "CLEARCOAT_BUMP");
  55431. }
  55432. if (defines.CLEARCOAT_TINT) {
  55433. fallbacks.addFallback(currentRank++, "CLEARCOAT_TINT");
  55434. }
  55435. if (defines.CLEARCOAT) {
  55436. fallbacks.addFallback(currentRank++, "CLEARCOAT");
  55437. }
  55438. return currentRank;
  55439. };
  55440. /**
  55441. * Add the required uniforms to the current list.
  55442. * @param uniforms defines the current uniform list.
  55443. */
  55444. PBRClearCoatConfiguration.AddUniforms = function (uniforms) {
  55445. uniforms.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "vClearCoatRefractionParams", "vClearCoatTintParams", "clearCoatColorAtDistance", "clearCoatMatrix", "clearCoatBumpMatrix", "clearCoatTintMatrix", "vClearCoatInfos", "vClearCoatBumpInfos", "vClearCoatTintInfos");
  55446. };
  55447. /**
  55448. * Add the required samplers to the current list.
  55449. * @param samplers defines the current sampler list.
  55450. */
  55451. PBRClearCoatConfiguration.AddSamplers = function (samplers) {
  55452. samplers.push("clearCoatSampler", "clearCoatBumpSampler", "clearCoatTintSampler");
  55453. };
  55454. /**
  55455. * Add the required uniforms to the current buffer.
  55456. * @param uniformBuffer defines the current uniform buffer.
  55457. */
  55458. PBRClearCoatConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  55459. uniformBuffer.addUniform("vClearCoatParams", 2);
  55460. uniformBuffer.addUniform("vClearCoatRefractionParams", 4);
  55461. uniformBuffer.addUniform("vClearCoatInfos", 2);
  55462. uniformBuffer.addUniform("clearCoatMatrix", 16);
  55463. uniformBuffer.addUniform("vClearCoatBumpInfos", 2);
  55464. uniformBuffer.addUniform("vClearCoatTangentSpaceParams", 2);
  55465. uniformBuffer.addUniform("clearCoatBumpMatrix", 16);
  55466. uniformBuffer.addUniform("vClearCoatTintParams", 4);
  55467. uniformBuffer.addUniform("clearCoatColorAtDistance", 1);
  55468. uniformBuffer.addUniform("vClearCoatTintInfos", 2);
  55469. uniformBuffer.addUniform("clearCoatTintMatrix", 16);
  55470. };
  55471. /**
  55472. * Makes a duplicate of the current configuration into another one.
  55473. * @param clearCoatConfiguration define the config where to copy the info
  55474. */
  55475. PBRClearCoatConfiguration.prototype.copyTo = function (clearCoatConfiguration) {
  55476. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return clearCoatConfiguration; }, this);
  55477. };
  55478. /**
  55479. * Serializes this clear coat configuration.
  55480. * @returns - An object with the serialized config.
  55481. */
  55482. PBRClearCoatConfiguration.prototype.serialize = function () {
  55483. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55484. };
  55485. /**
  55486. * Parses a Clear Coat Configuration from a serialized object.
  55487. * @param source - Serialized object.
  55488. */
  55489. PBRClearCoatConfiguration.prototype.parse = function (source) {
  55490. var _this = this;
  55491. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  55492. };
  55493. /**
  55494. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55495. * The default fits with a polyurethane material.
  55496. */
  55497. PBRClearCoatConfiguration._DefaultIndiceOfRefraction = 1.5;
  55498. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55499. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55500. ], PBRClearCoatConfiguration.prototype, "_isEnabled", void 0);
  55501. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55502. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55503. ], PBRClearCoatConfiguration.prototype, "isEnabled", void 0);
  55504. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55505. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55506. ], PBRClearCoatConfiguration.prototype, "intensity", void 0);
  55507. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55508. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55509. ], PBRClearCoatConfiguration.prototype, "roughness", void 0);
  55510. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55511. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55512. ], PBRClearCoatConfiguration.prototype, "_indiceOfRefraction", void 0);
  55513. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55514. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55515. ], PBRClearCoatConfiguration.prototype, "indiceOfRefraction", void 0);
  55516. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55517. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  55518. ], PBRClearCoatConfiguration.prototype, "_texture", void 0);
  55519. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55520. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55521. ], PBRClearCoatConfiguration.prototype, "texture", void 0);
  55522. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55523. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  55524. ], PBRClearCoatConfiguration.prototype, "_bumpTexture", void 0);
  55525. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55526. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55527. ], PBRClearCoatConfiguration.prototype, "bumpTexture", void 0);
  55528. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55529. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55530. ], PBRClearCoatConfiguration.prototype, "_isTintEnabled", void 0);
  55531. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55532. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55533. ], PBRClearCoatConfiguration.prototype, "isTintEnabled", void 0);
  55534. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  55536. ], PBRClearCoatConfiguration.prototype, "tintColor", void 0);
  55537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55539. ], PBRClearCoatConfiguration.prototype, "tintColorAtDistance", void 0);
  55540. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55541. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55542. ], PBRClearCoatConfiguration.prototype, "tintThickness", void 0);
  55543. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55544. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  55545. ], PBRClearCoatConfiguration.prototype, "_tintTexture", void 0);
  55546. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55548. ], PBRClearCoatConfiguration.prototype, "tintTexture", void 0);
  55549. return PBRClearCoatConfiguration;
  55550. }());
  55551. /***/ }),
  55552. /***/ "./Materials/PBR/pbrMaterial.ts":
  55553. /*!**************************************!*\
  55554. !*** ./Materials/PBR/pbrMaterial.ts ***!
  55555. \**************************************/
  55556. /*! exports provided: PBRMaterial */
  55557. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55558. "use strict";
  55559. __webpack_require__.r(__webpack_exports__);
  55560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  55561. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55562. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55563. /* harmony import */ var _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  55564. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55565. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  55566. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55567. /**
  55568. * The Physically based material of BJS.
  55569. *
  55570. * This offers the main features of a standard PBR material.
  55571. * For more information, please refer to the documentation :
  55572. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  55573. */
  55574. var PBRMaterial = /** @class */ (function (_super) {
  55575. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  55576. /**
  55577. * Instantiates a new PBRMaterial instance.
  55578. *
  55579. * @param name The material name
  55580. * @param scene The scene the material will be use in.
  55581. */
  55582. function PBRMaterial(name, scene) {
  55583. var _this = _super.call(this, name, scene) || this;
  55584. /**
  55585. * Intensity of the direct lights e.g. the four lights available in your scene.
  55586. * This impacts both the direct diffuse and specular highlights.
  55587. */
  55588. _this.directIntensity = 1.0;
  55589. /**
  55590. * Intensity of the emissive part of the material.
  55591. * This helps controlling the emissive effect without modifying the emissive color.
  55592. */
  55593. _this.emissiveIntensity = 1.0;
  55594. /**
  55595. * Intensity of the environment e.g. how much the environment will light the object
  55596. * either through harmonics for rough material or through the refelction for shiny ones.
  55597. */
  55598. _this.environmentIntensity = 1.0;
  55599. /**
  55600. * This is a special control allowing the reduction of the specular highlights coming from the
  55601. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55602. */
  55603. _this.specularIntensity = 1.0;
  55604. /**
  55605. * Debug Control allowing disabling the bump map on this material.
  55606. */
  55607. _this.disableBumpMap = false;
  55608. /**
  55609. * AKA Occlusion Texture Intensity in other nomenclature.
  55610. */
  55611. _this.ambientTextureStrength = 1.0;
  55612. /**
  55613. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55614. * 1 means it completely occludes it
  55615. * 0 mean it has no impact
  55616. */
  55617. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  55618. /**
  55619. * The color of a material in ambient lighting.
  55620. */
  55621. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  55622. /**
  55623. * AKA Diffuse Color in other nomenclature.
  55624. */
  55625. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  55626. /**
  55627. * AKA Specular Color in other nomenclature.
  55628. */
  55629. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  55630. /**
  55631. * The color reflected from the material.
  55632. */
  55633. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  55634. /**
  55635. * The color emitted from the material.
  55636. */
  55637. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  55638. /**
  55639. * AKA Glossiness in other nomenclature.
  55640. */
  55641. _this.microSurface = 1.0;
  55642. /**
  55643. * If true, the light map contains occlusion information instead of lighting info.
  55644. */
  55645. _this.useLightmapAsShadowmap = false;
  55646. /**
  55647. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55648. */
  55649. _this.useAlphaFromAlbedoTexture = false;
  55650. /**
  55651. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55652. */
  55653. _this.forceAlphaTest = false;
  55654. /**
  55655. * Defines the alpha limits in alpha test mode.
  55656. */
  55657. _this.alphaCutOff = 0.4;
  55658. /**
  55659. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55660. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55661. */
  55662. _this.useSpecularOverAlpha = true;
  55663. /**
  55664. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55665. */
  55666. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  55667. /**
  55668. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55669. */
  55670. _this.useRoughnessFromMetallicTextureAlpha = true;
  55671. /**
  55672. * Specifies if the metallic texture contains the roughness information in its green channel.
  55673. */
  55674. _this.useRoughnessFromMetallicTextureGreen = false;
  55675. /**
  55676. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55677. */
  55678. _this.useMetallnessFromMetallicTextureBlue = false;
  55679. /**
  55680. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55681. */
  55682. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  55683. /**
  55684. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55685. */
  55686. _this.useAmbientInGrayScale = false;
  55687. /**
  55688. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55689. * The material will try to infer what glossiness each pixel should be.
  55690. */
  55691. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  55692. /**
  55693. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55694. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55695. */
  55696. _this.useRadianceOverAlpha = true;
  55697. /**
  55698. * Allows using an object space normal map (instead of tangent space).
  55699. */
  55700. _this.useObjectSpaceNormalMap = false;
  55701. /**
  55702. * Allows using the bump map in parallax mode.
  55703. */
  55704. _this.useParallax = false;
  55705. /**
  55706. * Allows using the bump map in parallax occlusion mode.
  55707. */
  55708. _this.useParallaxOcclusion = false;
  55709. /**
  55710. * Controls the scale bias of the parallax mode.
  55711. */
  55712. _this.parallaxScaleBias = 0.05;
  55713. /**
  55714. * If sets to true, disables all the lights affecting the material.
  55715. */
  55716. _this.disableLighting = false;
  55717. /**
  55718. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55719. */
  55720. _this.forceIrradianceInFragment = false;
  55721. /**
  55722. * Number of Simultaneous lights allowed on the material.
  55723. */
  55724. _this.maxSimultaneousLights = 4;
  55725. /**
  55726. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55727. */
  55728. _this.invertNormalMapX = false;
  55729. /**
  55730. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55731. */
  55732. _this.invertNormalMapY = false;
  55733. /**
  55734. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55735. */
  55736. _this.twoSidedLighting = false;
  55737. /**
  55738. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55739. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55740. */
  55741. _this.useAlphaFresnel = false;
  55742. /**
  55743. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55744. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55745. */
  55746. _this.useLinearAlphaFresnel = false;
  55747. /**
  55748. * Let user defines the brdf lookup texture used for IBL.
  55749. * A default 8bit version is embedded but you could point at :
  55750. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  55751. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55752. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55753. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55754. */
  55755. _this.environmentBRDFTexture = null;
  55756. /**
  55757. * Force normal to face away from face.
  55758. */
  55759. _this.forceNormalForward = false;
  55760. /**
  55761. * Enables specular anti aliasing in the PBR shader.
  55762. * It will both interacts on the Geometry for analytical and IBL lighting.
  55763. * It also prefilter the roughness map based on the bump values.
  55764. */
  55765. _this.enableSpecularAntiAliasing = false;
  55766. /**
  55767. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55768. * makes the reflect vector face the model (under horizon).
  55769. */
  55770. _this.useHorizonOcclusion = true;
  55771. /**
  55772. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55773. * too much the area relying on ambient texture to define their ambient occlusion.
  55774. */
  55775. _this.useRadianceOcclusion = true;
  55776. /**
  55777. * If set to true, no lighting calculations will be applied.
  55778. */
  55779. _this.unlit = false;
  55780. _this._environmentBRDFTexture = _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_2__["BRDFTextureTools"].GetEnvironmentBRDFTexture(scene);
  55781. return _this;
  55782. }
  55783. Object.defineProperty(PBRMaterial.prototype, "refractionTexture", {
  55784. /**
  55785. * Stores the refracted light information in a texture.
  55786. */
  55787. get: function () {
  55788. return this.subSurface.refractionTexture;
  55789. },
  55790. set: function (value) {
  55791. this.subSurface.refractionTexture = value;
  55792. if (value) {
  55793. this.subSurface.isRefractionEnabled = true;
  55794. }
  55795. else if (!this.subSurface.linkRefractionWithTransparency) {
  55796. this.subSurface.isRefractionEnabled = false;
  55797. }
  55798. },
  55799. enumerable: true,
  55800. configurable: true
  55801. });
  55802. Object.defineProperty(PBRMaterial.prototype, "indexOfRefraction", {
  55803. /**
  55804. * source material index of refraction (IOR)' / 'destination material IOR.
  55805. */
  55806. get: function () {
  55807. return 1 / this.subSurface.indexOfRefraction;
  55808. },
  55809. set: function (value) {
  55810. this.subSurface.indexOfRefraction = 1 / value;
  55811. },
  55812. enumerable: true,
  55813. configurable: true
  55814. });
  55815. Object.defineProperty(PBRMaterial.prototype, "invertRefractionY", {
  55816. /**
  55817. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55818. */
  55819. get: function () {
  55820. return this.subSurface.invertRefractionY;
  55821. },
  55822. set: function (value) {
  55823. this.subSurface.invertRefractionY = value;
  55824. },
  55825. enumerable: true,
  55826. configurable: true
  55827. });
  55828. Object.defineProperty(PBRMaterial.prototype, "linkRefractionWithTransparency", {
  55829. /**
  55830. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55831. * Materials half opaque for instance using refraction could benefit from this control.
  55832. */
  55833. get: function () {
  55834. return this.subSurface.linkRefractionWithTransparency;
  55835. },
  55836. set: function (value) {
  55837. this.subSurface.linkRefractionWithTransparency = value;
  55838. if (value) {
  55839. this.subSurface.isRefractionEnabled = true;
  55840. }
  55841. },
  55842. enumerable: true,
  55843. configurable: true
  55844. });
  55845. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  55846. /**
  55847. * BJS is using an harcoded light falloff based on a manually sets up range.
  55848. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55849. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55850. */
  55851. get: function () {
  55852. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  55853. },
  55854. /**
  55855. * BJS is using an harcoded light falloff based on a manually sets up range.
  55856. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55857. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55858. */
  55859. set: function (value) {
  55860. if (value !== this.usePhysicalLightFalloff) {
  55861. // Ensure the effect will be rebuilt.
  55862. this._markAllSubMeshesAsTexturesDirty();
  55863. if (value) {
  55864. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  55865. }
  55866. else {
  55867. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  55868. }
  55869. }
  55870. },
  55871. enumerable: true,
  55872. configurable: true
  55873. });
  55874. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  55875. /**
  55876. * In order to support the falloff compatibility with gltf, a special mode has been added
  55877. * to reproduce the gltf light falloff.
  55878. */
  55879. get: function () {
  55880. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  55881. },
  55882. /**
  55883. * In order to support the falloff compatibility with gltf, a special mode has been added
  55884. * to reproduce the gltf light falloff.
  55885. */
  55886. set: function (value) {
  55887. if (value !== this.useGLTFLightFalloff) {
  55888. // Ensure the effect will be rebuilt.
  55889. this._markAllSubMeshesAsTexturesDirty();
  55890. if (value) {
  55891. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  55892. }
  55893. else {
  55894. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  55895. }
  55896. }
  55897. },
  55898. enumerable: true,
  55899. configurable: true
  55900. });
  55901. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  55902. /**
  55903. * Gets the image processing configuration used either in this material.
  55904. */
  55905. get: function () {
  55906. return this._imageProcessingConfiguration;
  55907. },
  55908. /**
  55909. * Sets the Default image processing configuration used either in the this material.
  55910. *
  55911. * If sets to null, the scene one is in use.
  55912. */
  55913. set: function (value) {
  55914. this._attachImageProcessingConfiguration(value);
  55915. // Ensure the effect will be rebuilt.
  55916. this._markAllSubMeshesAsTexturesDirty();
  55917. },
  55918. enumerable: true,
  55919. configurable: true
  55920. });
  55921. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  55922. /**
  55923. * Gets wether the color curves effect is enabled.
  55924. */
  55925. get: function () {
  55926. return this.imageProcessingConfiguration.colorCurvesEnabled;
  55927. },
  55928. /**
  55929. * Sets wether the color curves effect is enabled.
  55930. */
  55931. set: function (value) {
  55932. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  55933. },
  55934. enumerable: true,
  55935. configurable: true
  55936. });
  55937. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  55938. /**
  55939. * Gets wether the color grading effect is enabled.
  55940. */
  55941. get: function () {
  55942. return this.imageProcessingConfiguration.colorGradingEnabled;
  55943. },
  55944. /**
  55945. * Gets wether the color grading effect is enabled.
  55946. */
  55947. set: function (value) {
  55948. this.imageProcessingConfiguration.colorGradingEnabled = value;
  55949. },
  55950. enumerable: true,
  55951. configurable: true
  55952. });
  55953. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  55954. /**
  55955. * Gets wether tonemapping is enabled or not.
  55956. */
  55957. get: function () {
  55958. return this._imageProcessingConfiguration.toneMappingEnabled;
  55959. },
  55960. /**
  55961. * Sets wether tonemapping is enabled or not
  55962. */
  55963. set: function (value) {
  55964. this._imageProcessingConfiguration.toneMappingEnabled = value;
  55965. },
  55966. enumerable: true,
  55967. configurable: true
  55968. });
  55969. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  55970. /**
  55971. * The camera exposure used on this material.
  55972. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55973. * This corresponds to a photographic exposure.
  55974. */
  55975. get: function () {
  55976. return this._imageProcessingConfiguration.exposure;
  55977. },
  55978. /**
  55979. * The camera exposure used on this material.
  55980. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55981. * This corresponds to a photographic exposure.
  55982. */
  55983. set: function (value) {
  55984. this._imageProcessingConfiguration.exposure = value;
  55985. },
  55986. enumerable: true,
  55987. configurable: true
  55988. });
  55989. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  55990. /**
  55991. * Gets The camera contrast used on this material.
  55992. */
  55993. get: function () {
  55994. return this._imageProcessingConfiguration.contrast;
  55995. },
  55996. /**
  55997. * Sets The camera contrast used on this material.
  55998. */
  55999. set: function (value) {
  56000. this._imageProcessingConfiguration.contrast = value;
  56001. },
  56002. enumerable: true,
  56003. configurable: true
  56004. });
  56005. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  56006. /**
  56007. * Gets the Color Grading 2D Lookup Texture.
  56008. */
  56009. get: function () {
  56010. return this._imageProcessingConfiguration.colorGradingTexture;
  56011. },
  56012. /**
  56013. * Sets the Color Grading 2D Lookup Texture.
  56014. */
  56015. set: function (value) {
  56016. this._imageProcessingConfiguration.colorGradingTexture = value;
  56017. },
  56018. enumerable: true,
  56019. configurable: true
  56020. });
  56021. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  56022. /**
  56023. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56024. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56025. * 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;
  56026. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56027. */
  56028. get: function () {
  56029. return this._imageProcessingConfiguration.colorCurves;
  56030. },
  56031. /**
  56032. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56033. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56034. * 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;
  56035. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56036. */
  56037. set: function (value) {
  56038. this._imageProcessingConfiguration.colorCurves = value;
  56039. },
  56040. enumerable: true,
  56041. configurable: true
  56042. });
  56043. /**
  56044. * Returns the name of this material class.
  56045. */
  56046. PBRMaterial.prototype.getClassName = function () {
  56047. return "PBRMaterial";
  56048. };
  56049. /**
  56050. * Makes a duplicate of the current material.
  56051. * @param name - name to use for the new material.
  56052. */
  56053. PBRMaterial.prototype.clone = function (name) {
  56054. var _this = this;
  56055. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  56056. clone.id = name;
  56057. clone.name = name;
  56058. this.clearCoat.copyTo(clone.clearCoat);
  56059. this.anisotropy.copyTo(clone.anisotropy);
  56060. this.brdf.copyTo(clone.brdf);
  56061. this.sheen.copyTo(clone.sheen);
  56062. return clone;
  56063. };
  56064. /**
  56065. * Serializes this PBR Material.
  56066. * @returns - An object with the serialized material.
  56067. */
  56068. PBRMaterial.prototype.serialize = function () {
  56069. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  56070. serializationObject.customType = "BABYLON.PBRMaterial";
  56071. serializationObject.clearCoat = this.clearCoat.serialize();
  56072. serializationObject.anisotropy = this.anisotropy.serialize();
  56073. serializationObject.brdf = this.brdf.serialize();
  56074. serializationObject.sheen = this.sheen.serialize();
  56075. return serializationObject;
  56076. };
  56077. // Statics
  56078. /**
  56079. * Parses a PBR Material from a serialized object.
  56080. * @param source - Serialized object.
  56081. * @param scene - BJS scene instance.
  56082. * @param rootUrl - url for the scene object
  56083. * @returns - PBRMaterial
  56084. */
  56085. PBRMaterial.Parse = function (source, scene, rootUrl) {
  56086. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  56087. if (source.clearCoat) {
  56088. material.clearCoat.parse(source.clearCoat);
  56089. }
  56090. if (source.anisotropy) {
  56091. material.anisotropy.parse(source.anisotropy);
  56092. }
  56093. if (source.brdf) {
  56094. material.brdf.parse(source.brdf);
  56095. }
  56096. if (source.sheen) {
  56097. material.sheen.parse(source.brdf);
  56098. }
  56099. return material;
  56100. };
  56101. /**
  56102. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56103. */
  56104. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  56105. /**
  56106. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56107. */
  56108. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  56109. /**
  56110. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56111. */
  56112. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  56113. /**
  56114. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56115. * They are also discarded below the alpha cutoff threshold to improve performances.
  56116. */
  56117. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  56118. /**
  56119. * Defines the default value of how much AO map is occluding the analytical lights
  56120. * (point spot...).
  56121. */
  56122. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  56123. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56125. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56126. ], PBRMaterial.prototype, "directIntensity", void 0);
  56127. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56130. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  56131. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56133. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56134. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  56135. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56137. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56138. ], PBRMaterial.prototype, "specularIntensity", void 0);
  56139. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56141. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56142. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  56143. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56145. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56146. ], PBRMaterial.prototype, "albedoTexture", void 0);
  56147. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56148. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56149. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56150. ], PBRMaterial.prototype, "ambientTexture", void 0);
  56151. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56152. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56153. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56154. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  56155. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56156. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56157. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56158. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  56159. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56160. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56161. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  56162. ], PBRMaterial.prototype, "opacityTexture", void 0);
  56163. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56164. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56165. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56166. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  56167. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56168. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56169. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56170. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  56171. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56172. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56173. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56174. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  56175. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56176. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56177. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56178. ], PBRMaterial.prototype, "metallicTexture", void 0);
  56179. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56180. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56181. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56182. ], PBRMaterial.prototype, "metallic", void 0);
  56183. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56184. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56185. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56186. ], PBRMaterial.prototype, "roughness", void 0);
  56187. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56188. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56189. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56190. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  56191. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56192. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56193. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56194. ], PBRMaterial.prototype, "bumpTexture", void 0);
  56195. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56196. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56197. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  56198. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  56199. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56200. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  56201. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56202. ], PBRMaterial.prototype, "ambientColor", void 0);
  56203. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56204. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  56205. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56206. ], PBRMaterial.prototype, "albedoColor", void 0);
  56207. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56208. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  56209. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56210. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  56211. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56212. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  56213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56214. ], PBRMaterial.prototype, "reflectionColor", void 0);
  56215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  56217. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56218. ], PBRMaterial.prototype, "emissiveColor", void 0);
  56219. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56220. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56222. ], PBRMaterial.prototype, "microSurface", void 0);
  56223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56226. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  56227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  56230. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  56231. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56232. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  56234. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  56235. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56236. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  56238. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  56239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56241. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56242. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  56243. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56244. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56246. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  56247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56250. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  56251. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56252. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56253. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56254. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  56255. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56256. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56258. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  56259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56262. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  56263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56265. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56266. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  56267. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56268. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56270. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  56271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56273. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  56274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56276. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  56277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56280. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  56281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56283. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56284. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  56285. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56286. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56288. ], PBRMaterial.prototype, "useParallax", void 0);
  56289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56292. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  56293. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56295. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56296. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  56297. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56298. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  56300. ], PBRMaterial.prototype, "disableLighting", void 0);
  56301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56303. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56304. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  56305. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56306. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56307. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  56308. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  56309. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56310. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56312. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  56313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56316. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  56317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56319. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56320. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  56321. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56322. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56324. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  56325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56328. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  56329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56331. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56332. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  56333. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56334. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56336. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  56337. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56339. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56340. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  56341. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56343. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56344. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  56345. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56346. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56347. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56348. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  56349. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56350. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56351. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  56352. ], PBRMaterial.prototype, "unlit", void 0);
  56353. return PBRMaterial;
  56354. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  56355. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  56356. /***/ }),
  56357. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  56358. /*!*******************************************************!*\
  56359. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  56360. \*******************************************************/
  56361. /*! exports provided: PBRMetallicRoughnessMaterial */
  56362. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56363. "use strict";
  56364. __webpack_require__.r(__webpack_exports__);
  56365. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  56366. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56367. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  56368. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  56369. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  56370. /**
  56371. * The PBR material of BJS following the metal roughness convention.
  56372. *
  56373. * This fits to the PBR convention in the GLTF definition:
  56374. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56375. */
  56376. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  56377. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  56378. /**
  56379. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56380. *
  56381. * @param name The material name
  56382. * @param scene The scene the material will be use in.
  56383. */
  56384. function PBRMetallicRoughnessMaterial(name, scene) {
  56385. var _this = _super.call(this, name, scene) || this;
  56386. _this._useRoughnessFromMetallicTextureAlpha = false;
  56387. _this._useRoughnessFromMetallicTextureGreen = true;
  56388. _this._useMetallnessFromMetallicTextureBlue = true;
  56389. _this.metallic = 1.0;
  56390. _this.roughness = 1.0;
  56391. return _this;
  56392. }
  56393. /**
  56394. * Return the currrent class name of the material.
  56395. */
  56396. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  56397. return "PBRMetallicRoughnessMaterial";
  56398. };
  56399. /**
  56400. * Makes a duplicate of the current material.
  56401. * @param name - name to use for the new material.
  56402. */
  56403. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  56404. var _this = this;
  56405. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  56406. clone.id = name;
  56407. clone.name = name;
  56408. this.clearCoat.copyTo(clone.clearCoat);
  56409. this.anisotropy.copyTo(clone.anisotropy);
  56410. this.brdf.copyTo(clone.brdf);
  56411. this.sheen.copyTo(clone.sheen);
  56412. return clone;
  56413. };
  56414. /**
  56415. * Serialize the material to a parsable JSON object.
  56416. */
  56417. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  56418. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  56419. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  56420. serializationObject.clearCoat = this.clearCoat.serialize();
  56421. serializationObject.anisotropy = this.anisotropy.serialize();
  56422. serializationObject.brdf = this.brdf.serialize();
  56423. serializationObject.sheen = this.sheen.serialize();
  56424. return serializationObject;
  56425. };
  56426. /**
  56427. * Parses a JSON object correponding to the serialize function.
  56428. */
  56429. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  56430. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  56431. if (source.clearCoat) {
  56432. material.clearCoat.parse(source.clearCoat);
  56433. }
  56434. if (source.anisotropy) {
  56435. material.anisotropy.parse(source.anisotropy);
  56436. }
  56437. if (source.brdf) {
  56438. material.brdf.parse(source.brdf);
  56439. }
  56440. if (source.sheen) {
  56441. material.sheen.parse(source.brdf);
  56442. }
  56443. return material;
  56444. };
  56445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  56447. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  56448. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  56449. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56450. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  56452. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  56453. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56456. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  56457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56460. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  56461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56463. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  56464. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  56465. return PBRMetallicRoughnessMaterial;
  56466. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  56467. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  56468. /***/ }),
  56469. /***/ "./Materials/PBR/pbrSheenConfiguration.ts":
  56470. /*!************************************************!*\
  56471. !*** ./Materials/PBR/pbrSheenConfiguration.ts ***!
  56472. \************************************************/
  56473. /*! exports provided: PBRSheenConfiguration */
  56474. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56475. "use strict";
  56476. __webpack_require__.r(__webpack_exports__);
  56477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSheenConfiguration", function() { return PBRSheenConfiguration; });
  56478. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56479. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  56480. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56481. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  56482. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  56483. /**
  56484. * Define the code related to the Sheen parameters of the pbr material.
  56485. */
  56486. var PBRSheenConfiguration = /** @class */ (function () {
  56487. /**
  56488. * Instantiate a new istance of clear coat configuration.
  56489. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56490. */
  56491. function PBRSheenConfiguration(markAllSubMeshesAsTexturesDirty) {
  56492. this._isEnabled = false;
  56493. /**
  56494. * Defines if the material uses sheen.
  56495. */
  56496. this.isEnabled = false;
  56497. this._linkSheenWithAlbedo = false;
  56498. /**
  56499. * Defines if the sheen is linked to the sheen color.
  56500. */
  56501. this.linkSheenWithAlbedo = false;
  56502. /**
  56503. * Defines the sheen intensity.
  56504. */
  56505. this.intensity = 1;
  56506. /**
  56507. * Defines the sheen color.
  56508. */
  56509. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  56510. this._texture = null;
  56511. /**
  56512. * Stores the sheen tint values in a texture.
  56513. * rgb is tint
  56514. * a is a intensity
  56515. */
  56516. this.texture = null;
  56517. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  56518. }
  56519. /** @hidden */
  56520. PBRSheenConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  56521. this._internalMarkAllSubMeshesAsTexturesDirty();
  56522. };
  56523. /**
  56524. * Specifies that the submesh is ready to be used.
  56525. * @param defines the list of "defines" to update.
  56526. * @param scene defines the scene the material belongs to.
  56527. * @returns - boolean indicating that the submesh is ready or not.
  56528. */
  56529. PBRSheenConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  56530. if (defines._areTexturesDirty) {
  56531. if (scene.texturesEnabled) {
  56532. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  56533. if (!this._texture.isReadyOrNotBlocking()) {
  56534. return false;
  56535. }
  56536. }
  56537. }
  56538. }
  56539. return true;
  56540. };
  56541. /**
  56542. * Checks to see if a texture is used in the material.
  56543. * @param defines the list of "defines" to update.
  56544. * @param scene defines the scene the material belongs to.
  56545. */
  56546. PBRSheenConfiguration.prototype.prepareDefines = function (defines, scene) {
  56547. if (this._isEnabled) {
  56548. defines.SHEEN = this._isEnabled;
  56549. defines.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo;
  56550. if (defines._areTexturesDirty) {
  56551. if (scene.texturesEnabled) {
  56552. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  56553. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "SHEEN_TEXTURE");
  56554. }
  56555. else {
  56556. defines.SHEEN_TEXTURE = false;
  56557. }
  56558. }
  56559. }
  56560. }
  56561. else {
  56562. defines.SHEEN = false;
  56563. defines.SHEEN_TEXTURE = false;
  56564. defines.SHEEN_LINKWITHALBEDO = false;
  56565. }
  56566. };
  56567. /**
  56568. * Binds the material data.
  56569. * @param uniformBuffer defines the Uniform buffer to fill in.
  56570. * @param scene defines the scene the material belongs to.
  56571. * @param isFrozen defines wether the material is frozen or not.
  56572. */
  56573. PBRSheenConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  56574. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  56575. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  56576. uniformBuffer.updateFloat2("vSheenInfos", this._texture.coordinatesIndex, this._texture.level);
  56577. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "sheen");
  56578. }
  56579. // Sheen
  56580. uniformBuffer.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity);
  56581. }
  56582. // Textures
  56583. if (scene.texturesEnabled) {
  56584. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  56585. uniformBuffer.setTexture("sheenSampler", this._texture);
  56586. }
  56587. }
  56588. };
  56589. /**
  56590. * Checks to see if a texture is used in the material.
  56591. * @param texture - Base texture to use.
  56592. * @returns - Boolean specifying if a texture is used in the material.
  56593. */
  56594. PBRSheenConfiguration.prototype.hasTexture = function (texture) {
  56595. if (this._texture === texture) {
  56596. return true;
  56597. }
  56598. return false;
  56599. };
  56600. /**
  56601. * Returns an array of the actively used textures.
  56602. * @param activeTextures Array of BaseTextures
  56603. */
  56604. PBRSheenConfiguration.prototype.getActiveTextures = function (activeTextures) {
  56605. if (this._texture) {
  56606. activeTextures.push(this._texture);
  56607. }
  56608. };
  56609. /**
  56610. * Returns the animatable textures.
  56611. * @param animatables Array of animatable textures.
  56612. */
  56613. PBRSheenConfiguration.prototype.getAnimatables = function (animatables) {
  56614. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  56615. animatables.push(this._texture);
  56616. }
  56617. };
  56618. /**
  56619. * Disposes the resources of the material.
  56620. * @param forceDisposeTextures - Forces the disposal of all textures.
  56621. */
  56622. PBRSheenConfiguration.prototype.dispose = function (forceDisposeTextures) {
  56623. if (forceDisposeTextures) {
  56624. if (this._texture) {
  56625. this._texture.dispose();
  56626. }
  56627. }
  56628. };
  56629. /**
  56630. * Get the current class name of the texture useful for serialization or dynamic coding.
  56631. * @returns "PBRSheenConfiguration"
  56632. */
  56633. PBRSheenConfiguration.prototype.getClassName = function () {
  56634. return "PBRSheenConfiguration";
  56635. };
  56636. /**
  56637. * Add fallbacks to the effect fallbacks list.
  56638. * @param defines defines the Base texture to use.
  56639. * @param fallbacks defines the current fallback list.
  56640. * @param currentRank defines the current fallback rank.
  56641. * @returns the new fallback rank.
  56642. */
  56643. PBRSheenConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  56644. if (defines.SHEEN) {
  56645. fallbacks.addFallback(currentRank++, "SHEEN");
  56646. }
  56647. return currentRank;
  56648. };
  56649. /**
  56650. * Add the required uniforms to the current list.
  56651. * @param uniforms defines the current uniform list.
  56652. */
  56653. PBRSheenConfiguration.AddUniforms = function (uniforms) {
  56654. uniforms.push("vSheenColor", "vSheenInfos", "sheenMatrix");
  56655. };
  56656. /**
  56657. * Add the required uniforms to the current buffer.
  56658. * @param uniformBuffer defines the current uniform buffer.
  56659. */
  56660. PBRSheenConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  56661. uniformBuffer.addUniform("vSheenColor", 4);
  56662. uniformBuffer.addUniform("vSheenInfos", 2);
  56663. uniformBuffer.addUniform("sheenMatrix", 16);
  56664. };
  56665. /**
  56666. * Add the required samplers to the current list.
  56667. * @param samplers defines the current sampler list.
  56668. */
  56669. PBRSheenConfiguration.AddSamplers = function (samplers) {
  56670. samplers.push("sheenSampler");
  56671. };
  56672. /**
  56673. * Makes a duplicate of the current configuration into another one.
  56674. * @param sheenConfiguration define the config where to copy the info
  56675. */
  56676. PBRSheenConfiguration.prototype.copyTo = function (sheenConfiguration) {
  56677. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return sheenConfiguration; }, this);
  56678. };
  56679. /**
  56680. * Serializes this BRDF configuration.
  56681. * @returns - An object with the serialized config.
  56682. */
  56683. PBRSheenConfiguration.prototype.serialize = function () {
  56684. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  56685. };
  56686. /**
  56687. * Parses a Sheen Configuration from a serialized object.
  56688. * @param source - Serialized object.
  56689. */
  56690. PBRSheenConfiguration.prototype.parse = function (source) {
  56691. var _this = this;
  56692. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  56693. };
  56694. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56695. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56696. ], PBRSheenConfiguration.prototype, "_isEnabled", void 0);
  56697. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56698. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56699. ], PBRSheenConfiguration.prototype, "isEnabled", void 0);
  56700. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56702. ], PBRSheenConfiguration.prototype, "_linkSheenWithAlbedo", void 0);
  56703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56705. ], PBRSheenConfiguration.prototype, "linkSheenWithAlbedo", void 0);
  56706. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56707. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56708. ], PBRSheenConfiguration.prototype, "intensity", void 0);
  56709. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56710. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  56711. ], PBRSheenConfiguration.prototype, "color", void 0);
  56712. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56713. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  56714. ], PBRSheenConfiguration.prototype, "_texture", void 0);
  56715. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56716. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56717. ], PBRSheenConfiguration.prototype, "texture", void 0);
  56718. return PBRSheenConfiguration;
  56719. }());
  56720. /***/ }),
  56721. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  56722. /*!********************************************************!*\
  56723. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  56724. \********************************************************/
  56725. /*! exports provided: PBRSpecularGlossinessMaterial */
  56726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56727. "use strict";
  56728. __webpack_require__.r(__webpack_exports__);
  56729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  56730. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56731. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  56732. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  56733. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  56734. /**
  56735. * The PBR material of BJS following the specular glossiness convention.
  56736. *
  56737. * This fits to the PBR convention in the GLTF definition:
  56738. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56739. */
  56740. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  56741. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  56742. /**
  56743. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56744. *
  56745. * @param name The material name
  56746. * @param scene The scene the material will be use in.
  56747. */
  56748. function PBRSpecularGlossinessMaterial(name, scene) {
  56749. var _this = _super.call(this, name, scene) || this;
  56750. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  56751. return _this;
  56752. }
  56753. /**
  56754. * Return the currrent class name of the material.
  56755. */
  56756. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  56757. return "PBRSpecularGlossinessMaterial";
  56758. };
  56759. /**
  56760. * Makes a duplicate of the current material.
  56761. * @param name - name to use for the new material.
  56762. */
  56763. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  56764. var _this = this;
  56765. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  56766. clone.id = name;
  56767. clone.name = name;
  56768. this.clearCoat.copyTo(clone.clearCoat);
  56769. this.anisotropy.copyTo(clone.anisotropy);
  56770. this.brdf.copyTo(clone.brdf);
  56771. this.sheen.copyTo(clone.sheen);
  56772. return clone;
  56773. };
  56774. /**
  56775. * Serialize the material to a parsable JSON object.
  56776. */
  56777. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  56778. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  56779. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  56780. serializationObject.clearCoat = this.clearCoat.serialize();
  56781. serializationObject.anisotropy = this.anisotropy.serialize();
  56782. serializationObject.brdf = this.brdf.serialize();
  56783. serializationObject.sheen = this.sheen.serialize();
  56784. return serializationObject;
  56785. };
  56786. /**
  56787. * Parses a JSON object correponding to the serialize function.
  56788. */
  56789. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  56790. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  56791. if (source.clearCoat) {
  56792. material.clearCoat.parse(source.clearCoat);
  56793. }
  56794. if (source.anisotropy) {
  56795. material.anisotropy.parse(source.anisotropy);
  56796. }
  56797. if (source.brdf) {
  56798. material.brdf.parse(source.brdf);
  56799. }
  56800. if (source.sheen) {
  56801. material.sheen.parse(source.brdf);
  56802. }
  56803. return material;
  56804. };
  56805. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56806. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  56807. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  56808. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  56809. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56811. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  56812. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  56813. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56814. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  56815. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  56816. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  56817. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  56820. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  56821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56823. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  56824. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  56825. return PBRSpecularGlossinessMaterial;
  56826. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  56827. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  56828. /***/ }),
  56829. /***/ "./Materials/PBR/pbrSubSurfaceConfiguration.ts":
  56830. /*!*****************************************************!*\
  56831. !*** ./Materials/PBR/pbrSubSurfaceConfiguration.ts ***!
  56832. \*****************************************************/
  56833. /*! exports provided: PBRSubSurfaceConfiguration */
  56834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56835. "use strict";
  56836. __webpack_require__.r(__webpack_exports__);
  56837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSubSurfaceConfiguration", function() { return PBRSubSurfaceConfiguration; });
  56838. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56839. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  56840. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56841. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  56842. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  56843. /**
  56844. * Define the code related to the sub surface parameters of the pbr material.
  56845. */
  56846. var PBRSubSurfaceConfiguration = /** @class */ (function () {
  56847. /**
  56848. * Instantiate a new istance of sub surface configuration.
  56849. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56850. */
  56851. function PBRSubSurfaceConfiguration(markAllSubMeshesAsTexturesDirty) {
  56852. this._isRefractionEnabled = false;
  56853. /**
  56854. * Defines if the refraction is enabled in the material.
  56855. */
  56856. this.isRefractionEnabled = false;
  56857. this._isTranslucencyEnabled = false;
  56858. /**
  56859. * Defines if the translucency is enabled in the material.
  56860. */
  56861. this.isTranslucencyEnabled = false;
  56862. this._isScatteringEnabled = false;
  56863. // /**
  56864. // * Defines if the sub surface scattering is enabled in the material.
  56865. // */
  56866. // @expandToProperty("_markAllSubMeshesAsTexturesDirty")
  56867. // public isScatteringEnabled = false;
  56868. /**
  56869. * Defines the refraction intensity of the material.
  56870. * The refraction when enabled replaces the Diffuse part of the material.
  56871. * The intensity helps transitionning between diffuse and refraction.
  56872. */
  56873. this.refractionIntensity = 1;
  56874. /**
  56875. * Defines the translucency intensity of the material.
  56876. * When translucency has been enabled, this defines how much of the "translucency"
  56877. * is addded to the diffuse part of the material.
  56878. */
  56879. this.translucencyIntensity = 1;
  56880. /**
  56881. * Defines the scattering intensity of the material.
  56882. * When scattering has been enabled, this defines how much of the "scattered light"
  56883. * is addded to the diffuse part of the material.
  56884. */
  56885. this.scatteringIntensity = 1;
  56886. this._thicknessTexture = null;
  56887. /**
  56888. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56889. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56890. * 0 would mean minimumThickness
  56891. * 1 would mean maximumThickness
  56892. * The other channels might be use as a mask to vary the different effects intensity.
  56893. */
  56894. this.thicknessTexture = null;
  56895. this._refractionTexture = null;
  56896. /**
  56897. * Defines the texture to use for refraction.
  56898. */
  56899. this.refractionTexture = null;
  56900. this._indexOfRefraction = 1;
  56901. /**
  56902. * Defines the indice of refraction used in the material.
  56903. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56904. */
  56905. this.indexOfRefraction = 1;
  56906. this._invertRefractionY = false;
  56907. /**
  56908. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56909. */
  56910. this.invertRefractionY = false;
  56911. this._linkRefractionWithTransparency = false;
  56912. /**
  56913. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56914. * Materials half opaque for instance using refraction could benefit from this control.
  56915. */
  56916. this.linkRefractionWithTransparency = false;
  56917. /**
  56918. * Defines the minimum thickness stored in the thickness map.
  56919. * If no thickness map is defined, this value will be used to simulate thickness.
  56920. */
  56921. this.minimumThickness = 0;
  56922. /**
  56923. * Defines the maximum thickness stored in the thickness map.
  56924. */
  56925. this.maximumThickness = 1;
  56926. /**
  56927. * Defines the volume tint of the material.
  56928. * This is used for both translucency and scattering.
  56929. */
  56930. this.tintColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  56931. /**
  56932. * Defines the distance at which the tint color should be found in the media.
  56933. * This is used for refraction only.
  56934. */
  56935. this.tintColorAtDistance = 1;
  56936. /**
  56937. * Defines how far each channel transmit through the media.
  56938. * It is defined as a color to simplify it selection.
  56939. */
  56940. this.diffusionDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  56941. this._useMaskFromThicknessTexture = false;
  56942. /**
  56943. * Stores the intensity of the different subsurface effects in the thickness texture.
  56944. * * the green channel is the translucency intensity.
  56945. * * the blue channel is the scattering intensity.
  56946. * * the alpha channel is the refraction intensity.
  56947. */
  56948. this.useMaskFromThicknessTexture = false;
  56949. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  56950. }
  56951. /** @hidden */
  56952. PBRSubSurfaceConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  56953. this._internalMarkAllSubMeshesAsTexturesDirty();
  56954. };
  56955. /**
  56956. * Gets wehter the submesh is ready to be used or not.
  56957. * @param defines the list of "defines" to update.
  56958. * @param scene defines the scene the material belongs to.
  56959. * @returns - boolean indicating that the submesh is ready or not.
  56960. */
  56961. PBRSubSurfaceConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  56962. if (defines._areTexturesDirty) {
  56963. if (scene.texturesEnabled) {
  56964. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  56965. if (!this._thicknessTexture.isReadyOrNotBlocking()) {
  56966. return false;
  56967. }
  56968. }
  56969. var refractionTexture = this._getRefractionTexture(scene);
  56970. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  56971. if (!refractionTexture.isReadyOrNotBlocking()) {
  56972. return false;
  56973. }
  56974. }
  56975. }
  56976. }
  56977. return true;
  56978. };
  56979. /**
  56980. * Checks to see if a texture is used in the material.
  56981. * @param defines the list of "defines" to update.
  56982. * @param scene defines the scene to the material belongs to.
  56983. */
  56984. PBRSubSurfaceConfiguration.prototype.prepareDefines = function (defines, scene) {
  56985. if (defines._areTexturesDirty) {
  56986. defines.SUBSURFACE = false;
  56987. defines.SS_TRANSLUCENCY = this._isTranslucencyEnabled;
  56988. defines.SS_SCATERRING = this._isScatteringEnabled;
  56989. defines.SS_THICKNESSANDMASK_TEXTURE = false;
  56990. defines.SS_MASK_FROM_THICKNESS_TEXTURE = false;
  56991. defines.SS_REFRACTION = false;
  56992. defines.SS_REFRACTIONMAP_3D = false;
  56993. defines.SS_GAMMAREFRACTION = false;
  56994. defines.SS_RGBDREFRACTION = false;
  56995. defines.SS_REFRACTIONMAP_OPPOSITEZ = false;
  56996. defines.SS_LODINREFRACTIONALPHA = false;
  56997. defines.SS_LINKREFRACTIONTOTRANSPARENCY = false;
  56998. if (this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
  56999. defines.SUBSURFACE = true;
  57000. if (defines._areTexturesDirty) {
  57001. if (scene.texturesEnabled) {
  57002. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  57003. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._thicknessTexture, defines, "SS_THICKNESSANDMASK_TEXTURE");
  57004. }
  57005. }
  57006. }
  57007. defines.SS_MASK_FROM_THICKNESS_TEXTURE = this._useMaskFromThicknessTexture;
  57008. }
  57009. if (this._isRefractionEnabled) {
  57010. if (scene.texturesEnabled) {
  57011. var refractionTexture = this._getRefractionTexture(scene);
  57012. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  57013. defines.SS_REFRACTION = true;
  57014. defines.SS_REFRACTIONMAP_3D = refractionTexture.isCube;
  57015. defines.SS_GAMMAREFRACTION = refractionTexture.gammaSpace;
  57016. defines.SS_RGBDREFRACTION = refractionTexture.isRGBD;
  57017. defines.SS_REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  57018. defines.SS_LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  57019. defines.SS_LINKREFRACTIONTOTRANSPARENCY = this._linkRefractionWithTransparency;
  57020. }
  57021. }
  57022. }
  57023. }
  57024. };
  57025. /**
  57026. * Binds the material data.
  57027. * @param uniformBuffer defines the Uniform buffer to fill in.
  57028. * @param scene defines the scene the material belongs to.
  57029. * @param engine defines the engine the material belongs to.
  57030. * @param isFrozen defines wether the material is frozen or not.
  57031. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  57032. */
  57033. PBRSubSurfaceConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, isFrozen, lodBasedMicrosurface) {
  57034. var refractionTexture = this._getRefractionTexture(scene);
  57035. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  57036. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  57037. uniformBuffer.updateFloat2("vThicknessInfos", this._thicknessTexture.coordinatesIndex, this._thicknessTexture.level);
  57038. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._thicknessTexture, uniformBuffer, "thickness");
  57039. }
  57040. uniformBuffer.updateFloat2("vThicknessParam", this.minimumThickness, this.maximumThickness - this.minimumThickness);
  57041. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  57042. uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  57043. var depth = 1.0;
  57044. if (!refractionTexture.isCube) {
  57045. if (refractionTexture.depth) {
  57046. depth = refractionTexture.depth;
  57047. }
  57048. }
  57049. uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, 1 / this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  57050. uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  57051. }
  57052. uniformBuffer.updateColor3("vDiffusionDistance", this.diffusionDistance);
  57053. uniformBuffer.updateFloat4("vTintColor", this.tintColor.r, this.tintColor.g, this.tintColor.b, this.tintColorAtDistance);
  57054. uniformBuffer.updateFloat3("vSubSurfaceIntensity", this.refractionIntensity, this.translucencyIntensity, this.scatteringIntensity);
  57055. }
  57056. // Textures
  57057. if (scene.texturesEnabled) {
  57058. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  57059. uniformBuffer.setTexture("thicknessSampler", this._thicknessTexture);
  57060. }
  57061. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  57062. if (lodBasedMicrosurface) {
  57063. uniformBuffer.setTexture("refractionSampler", refractionTexture);
  57064. }
  57065. else {
  57066. uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  57067. uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  57068. uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  57069. }
  57070. }
  57071. }
  57072. };
  57073. /**
  57074. * Unbinds the material from the mesh.
  57075. * @param activeEffect defines the effect that should be unbound from.
  57076. * @returns true if unbound, otherwise false
  57077. */
  57078. PBRSubSurfaceConfiguration.prototype.unbind = function (activeEffect) {
  57079. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  57080. activeEffect.setTexture("refractionSampler", null);
  57081. return true;
  57082. }
  57083. return false;
  57084. };
  57085. /**
  57086. * Returns the texture used for refraction or null if none is used.
  57087. * @param scene defines the scene the material belongs to.
  57088. * @returns - Refraction texture if present. If no refraction texture and refraction
  57089. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57090. */
  57091. PBRSubSurfaceConfiguration.prototype._getRefractionTexture = function (scene) {
  57092. if (this._refractionTexture) {
  57093. return this._refractionTexture;
  57094. }
  57095. if (this._isRefractionEnabled) {
  57096. return scene.environmentTexture;
  57097. }
  57098. return null;
  57099. };
  57100. Object.defineProperty(PBRSubSurfaceConfiguration.prototype, "disableAlphaBlending", {
  57101. /**
  57102. * Returns true if alpha blending should be disabled.
  57103. */
  57104. get: function () {
  57105. return this.isRefractionEnabled && this._linkRefractionWithTransparency;
  57106. },
  57107. enumerable: true,
  57108. configurable: true
  57109. });
  57110. /**
  57111. * Fills the list of render target textures.
  57112. * @param renderTargets the list of render targets to update
  57113. */
  57114. PBRSubSurfaceConfiguration.prototype.fillRenderTargetTextures = function (renderTargets) {
  57115. if (_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  57116. renderTargets.push(this._refractionTexture);
  57117. }
  57118. };
  57119. /**
  57120. * Checks to see if a texture is used in the material.
  57121. * @param texture - Base texture to use.
  57122. * @returns - Boolean specifying if a texture is used in the material.
  57123. */
  57124. PBRSubSurfaceConfiguration.prototype.hasTexture = function (texture) {
  57125. if (this._thicknessTexture === texture) {
  57126. return true;
  57127. }
  57128. if (this._refractionTexture === texture) {
  57129. return true;
  57130. }
  57131. return false;
  57132. };
  57133. /**
  57134. * Gets a boolean indicating that current material needs to register RTT
  57135. * @returns true if this uses a render target otherwise false.
  57136. */
  57137. PBRSubSurfaceConfiguration.prototype.hasRenderTargetTextures = function () {
  57138. if (_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  57139. return true;
  57140. }
  57141. return false;
  57142. };
  57143. /**
  57144. * Returns an array of the actively used textures.
  57145. * @param activeTextures Array of BaseTextures
  57146. */
  57147. PBRSubSurfaceConfiguration.prototype.getActiveTextures = function (activeTextures) {
  57148. if (this._thicknessTexture) {
  57149. activeTextures.push(this._thicknessTexture);
  57150. }
  57151. if (this._refractionTexture) {
  57152. activeTextures.push(this._refractionTexture);
  57153. }
  57154. };
  57155. /**
  57156. * Returns the animatable textures.
  57157. * @param animatables Array of animatable textures.
  57158. */
  57159. PBRSubSurfaceConfiguration.prototype.getAnimatables = function (animatables) {
  57160. if (this._thicknessTexture && this._thicknessTexture.animations && this._thicknessTexture.animations.length > 0) {
  57161. animatables.push(this._thicknessTexture);
  57162. }
  57163. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  57164. animatables.push(this._refractionTexture);
  57165. }
  57166. };
  57167. /**
  57168. * Disposes the resources of the material.
  57169. * @param forceDisposeTextures - Forces the disposal of all textures.
  57170. */
  57171. PBRSubSurfaceConfiguration.prototype.dispose = function (forceDisposeTextures) {
  57172. if (forceDisposeTextures) {
  57173. if (this._thicknessTexture) {
  57174. this._thicknessTexture.dispose();
  57175. }
  57176. if (this._refractionTexture) {
  57177. this._refractionTexture.dispose();
  57178. }
  57179. }
  57180. };
  57181. /**
  57182. * Get the current class name of the texture useful for serialization or dynamic coding.
  57183. * @returns "PBRSubSurfaceConfiguration"
  57184. */
  57185. PBRSubSurfaceConfiguration.prototype.getClassName = function () {
  57186. return "PBRSubSurfaceConfiguration";
  57187. };
  57188. /**
  57189. * Add fallbacks to the effect fallbacks list.
  57190. * @param defines defines the Base texture to use.
  57191. * @param fallbacks defines the current fallback list.
  57192. * @param currentRank defines the current fallback rank.
  57193. * @returns the new fallback rank.
  57194. */
  57195. PBRSubSurfaceConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  57196. if (defines.SS_SCATERRING) {
  57197. fallbacks.addFallback(currentRank++, "SS_SCATERRING");
  57198. }
  57199. if (defines.SS_TRANSLUCENCY) {
  57200. fallbacks.addFallback(currentRank++, "SS_TRANSLUCENCY");
  57201. }
  57202. return currentRank;
  57203. };
  57204. /**
  57205. * Add the required uniforms to the current list.
  57206. * @param uniforms defines the current uniform list.
  57207. */
  57208. PBRSubSurfaceConfiguration.AddUniforms = function (uniforms) {
  57209. uniforms.push("vDiffusionDistance", "vTintColor", "vSubSurfaceIntensity", "vRefractionMicrosurfaceInfos", "vRefractionInfos", "vThicknessInfos", "vThicknessParam", "refractionMatrix", "thicknessMatrix");
  57210. };
  57211. /**
  57212. * Add the required samplers to the current list.
  57213. * @param samplers defines the current sampler list.
  57214. */
  57215. PBRSubSurfaceConfiguration.AddSamplers = function (samplers) {
  57216. samplers.push("thicknessSampler", "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh");
  57217. };
  57218. /**
  57219. * Add the required uniforms to the current buffer.
  57220. * @param uniformBuffer defines the current uniform buffer.
  57221. */
  57222. PBRSubSurfaceConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  57223. uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  57224. uniformBuffer.addUniform("vRefractionInfos", 4);
  57225. uniformBuffer.addUniform("refractionMatrix", 16);
  57226. uniformBuffer.addUniform("vThicknessInfos", 2);
  57227. uniformBuffer.addUniform("thicknessMatrix", 16);
  57228. uniformBuffer.addUniform("vThicknessParam", 2);
  57229. uniformBuffer.addUniform("vDiffusionDistance", 3);
  57230. uniformBuffer.addUniform("vTintColor", 4);
  57231. uniformBuffer.addUniform("vSubSurfaceIntensity", 3);
  57232. };
  57233. /**
  57234. * Makes a duplicate of the current configuration into another one.
  57235. * @param configuration define the config where to copy the info
  57236. */
  57237. PBRSubSurfaceConfiguration.prototype.copyTo = function (configuration) {
  57238. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return configuration; }, this);
  57239. };
  57240. /**
  57241. * Serializes this Sub Surface configuration.
  57242. * @returns - An object with the serialized config.
  57243. */
  57244. PBRSubSurfaceConfiguration.prototype.serialize = function () {
  57245. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  57246. };
  57247. /**
  57248. * Parses a Sub Surface Configuration from a serialized object.
  57249. * @param source - Serialized object.
  57250. */
  57251. PBRSubSurfaceConfiguration.prototype.parse = function (source) {
  57252. var _this = this;
  57253. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  57254. };
  57255. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57256. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57257. ], PBRSubSurfaceConfiguration.prototype, "_isRefractionEnabled", void 0);
  57258. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57259. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  57260. ], PBRSubSurfaceConfiguration.prototype, "isRefractionEnabled", void 0);
  57261. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57262. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57263. ], PBRSubSurfaceConfiguration.prototype, "_isTranslucencyEnabled", void 0);
  57264. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57265. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  57266. ], PBRSubSurfaceConfiguration.prototype, "isTranslucencyEnabled", void 0);
  57267. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57268. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57269. ], PBRSubSurfaceConfiguration.prototype, "_isScatteringEnabled", void 0);
  57270. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57271. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57272. ], PBRSubSurfaceConfiguration.prototype, "refractionIntensity", void 0);
  57273. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57274. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57275. ], PBRSubSurfaceConfiguration.prototype, "translucencyIntensity", void 0);
  57276. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57277. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57278. ], PBRSubSurfaceConfiguration.prototype, "scatteringIntensity", void 0);
  57279. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57280. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  57281. ], PBRSubSurfaceConfiguration.prototype, "_thicknessTexture", void 0);
  57282. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57283. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  57284. ], PBRSubSurfaceConfiguration.prototype, "thicknessTexture", void 0);
  57285. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57286. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  57287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  57288. ], PBRSubSurfaceConfiguration.prototype, "refractionTexture", void 0);
  57289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  57291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  57292. ], PBRSubSurfaceConfiguration.prototype, "indexOfRefraction", void 0);
  57293. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  57295. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  57296. ], PBRSubSurfaceConfiguration.prototype, "invertRefractionY", void 0);
  57297. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57298. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  57299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  57300. ], PBRSubSurfaceConfiguration.prototype, "linkRefractionWithTransparency", void 0);
  57301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57303. ], PBRSubSurfaceConfiguration.prototype, "minimumThickness", void 0);
  57304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57306. ], PBRSubSurfaceConfiguration.prototype, "maximumThickness", void 0);
  57307. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57308. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  57309. ], PBRSubSurfaceConfiguration.prototype, "tintColor", void 0);
  57310. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57312. ], PBRSubSurfaceConfiguration.prototype, "tintColorAtDistance", void 0);
  57313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  57315. ], PBRSubSurfaceConfiguration.prototype, "diffusionDistance", void 0);
  57316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57318. ], PBRSubSurfaceConfiguration.prototype, "_useMaskFromThicknessTexture", void 0);
  57319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  57321. ], PBRSubSurfaceConfiguration.prototype, "useMaskFromThicknessTexture", void 0);
  57322. return PBRSubSurfaceConfiguration;
  57323. }());
  57324. /***/ }),
  57325. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  57326. /*!********************************************************!*\
  57327. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  57328. \********************************************************/
  57329. /*! exports provided: _DDSTextureLoader */
  57330. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57331. "use strict";
  57332. __webpack_require__.r(__webpack_exports__);
  57333. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  57334. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  57335. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  57336. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  57337. /**
  57338. * Implementation of the DDS Texture Loader.
  57339. * @hidden
  57340. */
  57341. var _DDSTextureLoader = /** @class */ (function () {
  57342. function _DDSTextureLoader() {
  57343. /**
  57344. * Defines wether the loader supports cascade loading the different faces.
  57345. */
  57346. this.supportCascades = true;
  57347. }
  57348. /**
  57349. * This returns if the loader support the current file information.
  57350. * @param extension defines the file extension of the file being loaded
  57351. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57352. * @param fallback defines the fallback internal texture if any
  57353. * @param isBase64 defines whether the texture is encoded as a base64
  57354. * @param isBuffer defines whether the texture data are stored as a buffer
  57355. * @returns true if the loader can load the specified file
  57356. */
  57357. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  57358. return extension.indexOf(".dds") === 0;
  57359. };
  57360. /**
  57361. * Transform the url before loading if required.
  57362. * @param rootUrl the url of the texture
  57363. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57364. * @returns the transformed texture
  57365. */
  57366. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  57367. return rootUrl;
  57368. };
  57369. /**
  57370. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57371. * @param rootUrl the url of the texture
  57372. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57373. * @returns the fallback texture
  57374. */
  57375. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  57376. return null;
  57377. };
  57378. /**
  57379. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  57380. * @param data contains the texture data
  57381. * @param texture defines the BabylonJS internal texture
  57382. * @param createPolynomials will be true if polynomials have been requested
  57383. * @param onLoad defines the callback to trigger once the texture is ready
  57384. * @param onError defines the callback to trigger in case of error
  57385. */
  57386. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  57387. var engine = texture.getEngine();
  57388. var info;
  57389. var loadMipmap = false;
  57390. if (Array.isArray(imgs)) {
  57391. for (var index = 0; index < imgs.length; index++) {
  57392. var data_1 = imgs[index];
  57393. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  57394. texture.width = info.width;
  57395. texture.height = info.height;
  57396. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  57397. engine._unpackFlipY(info.isCompressed);
  57398. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  57399. if (!info.isFourCC && info.mipmapCount === 1) {
  57400. engine.generateMipMapsForCubemap(texture);
  57401. }
  57402. }
  57403. }
  57404. else {
  57405. var data = imgs;
  57406. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  57407. texture.width = info.width;
  57408. texture.height = info.height;
  57409. if (createPolynomials) {
  57410. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  57411. }
  57412. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  57413. engine._unpackFlipY(info.isCompressed);
  57414. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  57415. if (!info.isFourCC && info.mipmapCount === 1) {
  57416. engine.generateMipMapsForCubemap(texture);
  57417. }
  57418. }
  57419. engine._setCubeMapTextureParams(loadMipmap);
  57420. texture.isReady = true;
  57421. if (onLoad) {
  57422. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  57423. }
  57424. };
  57425. /**
  57426. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57427. * @param data contains the texture data
  57428. * @param texture defines the BabylonJS internal texture
  57429. * @param callback defines the method to call once ready to upload
  57430. */
  57431. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  57432. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  57433. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  57434. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  57435. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  57436. });
  57437. };
  57438. return _DDSTextureLoader;
  57439. }());
  57440. // Register the loader.
  57441. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  57442. /***/ }),
  57443. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  57444. /*!********************************************************!*\
  57445. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  57446. \********************************************************/
  57447. /*! exports provided: _ENVTextureLoader */
  57448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57449. "use strict";
  57450. __webpack_require__.r(__webpack_exports__);
  57451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  57452. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  57453. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  57454. /**
  57455. * Implementation of the ENV Texture Loader.
  57456. * @hidden
  57457. */
  57458. var _ENVTextureLoader = /** @class */ (function () {
  57459. function _ENVTextureLoader() {
  57460. /**
  57461. * Defines wether the loader supports cascade loading the different faces.
  57462. */
  57463. this.supportCascades = false;
  57464. }
  57465. /**
  57466. * This returns if the loader support the current file information.
  57467. * @param extension defines the file extension of the file being loaded
  57468. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57469. * @param fallback defines the fallback internal texture if any
  57470. * @param isBase64 defines whether the texture is encoded as a base64
  57471. * @param isBuffer defines whether the texture data are stored as a buffer
  57472. * @returns true if the loader can load the specified file
  57473. */
  57474. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  57475. return extension.indexOf(".env") === 0;
  57476. };
  57477. /**
  57478. * Transform the url before loading if required.
  57479. * @param rootUrl the url of the texture
  57480. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57481. * @returns the transformed texture
  57482. */
  57483. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  57484. return rootUrl;
  57485. };
  57486. /**
  57487. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57488. * @param rootUrl the url of the texture
  57489. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57490. * @returns the fallback texture
  57491. */
  57492. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  57493. return null;
  57494. };
  57495. /**
  57496. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  57497. * @param data contains the texture data
  57498. * @param texture defines the BabylonJS internal texture
  57499. * @param createPolynomials will be true if polynomials have been requested
  57500. * @param onLoad defines the callback to trigger once the texture is ready
  57501. * @param onError defines the callback to trigger in case of error
  57502. */
  57503. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  57504. if (Array.isArray(data)) {
  57505. return;
  57506. }
  57507. data = data;
  57508. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  57509. if (info) {
  57510. texture.width = info.width;
  57511. texture.height = info.width;
  57512. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  57513. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  57514. texture.isReady = true;
  57515. if (onLoad) {
  57516. onLoad();
  57517. }
  57518. });
  57519. }
  57520. else if (onError) {
  57521. onError("Can not parse the environment file", null);
  57522. }
  57523. };
  57524. /**
  57525. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57526. * @param data contains the texture data
  57527. * @param texture defines the BabylonJS internal texture
  57528. * @param callback defines the method to call once ready to upload
  57529. */
  57530. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  57531. throw ".env not supported in 2d.";
  57532. };
  57533. return _ENVTextureLoader;
  57534. }());
  57535. // Register the loader.
  57536. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  57537. /***/ }),
  57538. /***/ "./Materials/Textures/Loaders/index.ts":
  57539. /*!*********************************************!*\
  57540. !*** ./Materials/Textures/Loaders/index.ts ***!
  57541. \*********************************************/
  57542. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  57543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57544. "use strict";
  57545. __webpack_require__.r(__webpack_exports__);
  57546. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  57547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  57548. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  57549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  57550. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  57551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  57552. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  57553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  57554. /***/ }),
  57555. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  57556. /*!********************************************************!*\
  57557. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  57558. \********************************************************/
  57559. /*! exports provided: _KTXTextureLoader */
  57560. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57561. "use strict";
  57562. __webpack_require__.r(__webpack_exports__);
  57563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  57564. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  57565. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  57566. /**
  57567. * Implementation of the KTX Texture Loader.
  57568. * @hidden
  57569. */
  57570. var _KTXTextureLoader = /** @class */ (function () {
  57571. function _KTXTextureLoader() {
  57572. /**
  57573. * Defines wether the loader supports cascade loading the different faces.
  57574. */
  57575. this.supportCascades = false;
  57576. }
  57577. /**
  57578. * This returns if the loader support the current file information.
  57579. * @param extension defines the file extension of the file being loaded
  57580. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57581. * @param fallback defines the fallback internal texture if any
  57582. * @param isBase64 defines whether the texture is encoded as a base64
  57583. * @param isBuffer defines whether the texture data are stored as a buffer
  57584. * @returns true if the loader can load the specified file
  57585. */
  57586. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  57587. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  57588. return true;
  57589. }
  57590. return false;
  57591. };
  57592. /**
  57593. * Transform the url before loading if required.
  57594. * @param rootUrl the url of the texture
  57595. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57596. * @returns the transformed texture
  57597. */
  57598. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  57599. var lastDot = rootUrl.lastIndexOf('.');
  57600. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  57601. // Already transformed
  57602. return rootUrl;
  57603. }
  57604. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  57605. };
  57606. /**
  57607. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57608. * @param rootUrl the url of the texture
  57609. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57610. * @returns the fallback texture
  57611. */
  57612. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  57613. // remove the format appended to the rootUrl in the original createCubeTexture call.
  57614. var exp = new RegExp("" + textureFormatInUse + "$");
  57615. return rootUrl.replace(exp, "");
  57616. };
  57617. /**
  57618. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  57619. * @param data contains the texture data
  57620. * @param texture defines the BabylonJS internal texture
  57621. * @param createPolynomials will be true if polynomials have been requested
  57622. * @param onLoad defines the callback to trigger once the texture is ready
  57623. * @param onError defines the callback to trigger in case of error
  57624. */
  57625. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  57626. if (Array.isArray(data)) {
  57627. return;
  57628. }
  57629. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  57630. texture._invertVScale = !texture.invertY;
  57631. var engine = texture.getEngine();
  57632. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  57633. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  57634. engine._unpackFlipY(true);
  57635. ktx.uploadLevels(texture, texture.generateMipMaps);
  57636. texture.width = ktx.pixelWidth;
  57637. texture.height = ktx.pixelHeight;
  57638. engine._setCubeMapTextureParams(loadMipmap);
  57639. texture.isReady = true;
  57640. };
  57641. /**
  57642. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57643. * @param data contains the texture data
  57644. * @param texture defines the BabylonJS internal texture
  57645. * @param callback defines the method to call once ready to upload
  57646. */
  57647. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  57648. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  57649. texture._invertVScale = !texture.invertY;
  57650. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  57651. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  57652. ktx.uploadLevels(texture, texture.generateMipMaps);
  57653. }, ktx.isInvalid);
  57654. };
  57655. return _KTXTextureLoader;
  57656. }());
  57657. // Register the loader.
  57658. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  57659. /***/ }),
  57660. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  57661. /*!********************************************************!*\
  57662. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  57663. \********************************************************/
  57664. /*! exports provided: _TGATextureLoader */
  57665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57666. "use strict";
  57667. __webpack_require__.r(__webpack_exports__);
  57668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  57669. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  57670. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  57671. /**
  57672. * Implementation of the TGA Texture Loader.
  57673. * @hidden
  57674. */
  57675. var _TGATextureLoader = /** @class */ (function () {
  57676. function _TGATextureLoader() {
  57677. /**
  57678. * Defines wether the loader supports cascade loading the different faces.
  57679. */
  57680. this.supportCascades = false;
  57681. }
  57682. /**
  57683. * This returns if the loader support the current file information.
  57684. * @param extension defines the file extension of the file being loaded
  57685. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57686. * @param fallback defines the fallback internal texture if any
  57687. * @param isBase64 defines whether the texture is encoded as a base64
  57688. * @param isBuffer defines whether the texture data are stored as a buffer
  57689. * @returns true if the loader can load the specified file
  57690. */
  57691. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  57692. return extension.indexOf(".tga") === 0;
  57693. };
  57694. /**
  57695. * Transform the url before loading if required.
  57696. * @param rootUrl the url of the texture
  57697. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57698. * @returns the transformed texture
  57699. */
  57700. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  57701. return rootUrl;
  57702. };
  57703. /**
  57704. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57705. * @param rootUrl the url of the texture
  57706. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57707. * @returns the fallback texture
  57708. */
  57709. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  57710. return null;
  57711. };
  57712. /**
  57713. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  57714. * @param data contains the texture data
  57715. * @param texture defines the BabylonJS internal texture
  57716. * @param createPolynomials will be true if polynomials have been requested
  57717. * @param onLoad defines the callback to trigger once the texture is ready
  57718. * @param onError defines the callback to trigger in case of error
  57719. */
  57720. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  57721. throw ".env not supported in Cube.";
  57722. };
  57723. /**
  57724. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57725. * @param data contains the texture data
  57726. * @param texture defines the BabylonJS internal texture
  57727. * @param callback defines the method to call once ready to upload
  57728. */
  57729. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  57730. var uintData = new Uint8Array(data);
  57731. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  57732. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  57733. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  57734. });
  57735. };
  57736. return _TGATextureLoader;
  57737. }());
  57738. // Register the loader.
  57739. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  57740. /***/ }),
  57741. /***/ "./Materials/Textures/MultiviewRenderTarget.ts":
  57742. /*!*****************************************************!*\
  57743. !*** ./Materials/Textures/MultiviewRenderTarget.ts ***!
  57744. \*****************************************************/
  57745. /*! exports provided: MultiviewRenderTarget */
  57746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57747. "use strict";
  57748. __webpack_require__.r(__webpack_exports__);
  57749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiviewRenderTarget", function() { return MultiviewRenderTarget; });
  57750. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57751. /* harmony import */ var _Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  57752. /* harmony import */ var _Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  57753. /**
  57754. * Renders to multiple views with a single draw call
  57755. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  57756. */
  57757. var MultiviewRenderTarget = /** @class */ (function (_super) {
  57758. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiviewRenderTarget, _super);
  57759. /**
  57760. * Creates a multiview render target
  57761. * @param scene scene used with the render target
  57762. * @param size the size of the render target (used for each view)
  57763. */
  57764. function MultiviewRenderTarget(scene, size) {
  57765. if (size === void 0) { size = 512; }
  57766. 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;
  57767. var internalTexture = scene.getEngine().createMultiviewRenderTargetTexture(_this.getRenderWidth(), _this.getRenderHeight());
  57768. internalTexture.isMultiview = true;
  57769. _this._texture = internalTexture;
  57770. return _this;
  57771. }
  57772. /**
  57773. * @hidden
  57774. * @param faceIndex the face index, if its a cube texture
  57775. */
  57776. MultiviewRenderTarget.prototype._bindFrameBuffer = function (faceIndex) {
  57777. if (faceIndex === void 0) { faceIndex = 0; }
  57778. if (!this._texture) {
  57779. return;
  57780. }
  57781. this.getScene().getEngine().bindMultiviewFramebuffer(this._texture);
  57782. };
  57783. /**
  57784. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  57785. * @returns the view count
  57786. */
  57787. MultiviewRenderTarget.prototype.getViewCount = function () {
  57788. return 2;
  57789. };
  57790. return MultiviewRenderTarget;
  57791. }(_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__["RenderTargetTexture"]));
  57792. /***/ }),
  57793. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  57794. /*!*******************************************************************!*\
  57795. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  57796. \*******************************************************************/
  57797. /*! exports provided: CustomProceduralTexture */
  57798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57799. "use strict";
  57800. __webpack_require__.r(__webpack_exports__);
  57801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  57802. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57803. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  57804. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  57805. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57806. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  57807. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Misc/webRequest */ "./Misc/webRequest.ts");
  57808. /**
  57809. * 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.
  57810. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57811. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57812. */
  57813. var CustomProceduralTexture = /** @class */ (function (_super) {
  57814. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  57815. /**
  57816. * Instantiates a new Custom Procedural Texture.
  57817. * 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.
  57818. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57819. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57820. * @param name Define the name of the texture
  57821. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57822. * @param size Define the size of the texture to create
  57823. * @param scene Define the scene the texture belongs to
  57824. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57825. * @param generateMipMaps Define if the texture should creates mip maps or not
  57826. */
  57827. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  57828. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  57829. _this._animate = true;
  57830. _this._time = 0;
  57831. _this._texturePath = texturePath;
  57832. //Try to load json
  57833. _this._loadJson(texturePath);
  57834. _this.refreshRate = 1;
  57835. return _this;
  57836. }
  57837. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  57838. var _this = this;
  57839. var noConfigFile = function () {
  57840. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  57841. try {
  57842. _this.setFragment(_this._texturePath);
  57843. }
  57844. catch (ex) {
  57845. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  57846. }
  57847. };
  57848. var configFileUrl = jsonUrl + "/config.json";
  57849. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_5__["WebRequest"]();
  57850. xhr.open("GET", configFileUrl);
  57851. xhr.addEventListener("load", function () {
  57852. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  57853. try {
  57854. _this._config = JSON.parse(xhr.response);
  57855. _this.updateShaderUniforms();
  57856. _this.updateTextures();
  57857. _this.setFragment(_this._texturePath + "/custom");
  57858. _this._animate = _this._config.animate;
  57859. _this.refreshRate = _this._config.refreshrate;
  57860. }
  57861. catch (ex) {
  57862. noConfigFile();
  57863. }
  57864. }
  57865. else {
  57866. noConfigFile();
  57867. }
  57868. }, false);
  57869. xhr.addEventListener("error", function () {
  57870. noConfigFile();
  57871. }, false);
  57872. try {
  57873. xhr.send();
  57874. }
  57875. catch (ex) {
  57876. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  57877. }
  57878. };
  57879. /**
  57880. * Is the texture ready to be used ? (rendered at least once)
  57881. * @returns true if ready, otherwise, false.
  57882. */
  57883. CustomProceduralTexture.prototype.isReady = function () {
  57884. if (!_super.prototype.isReady.call(this)) {
  57885. return false;
  57886. }
  57887. for (var name in this._textures) {
  57888. var texture = this._textures[name];
  57889. if (!texture.isReady()) {
  57890. return false;
  57891. }
  57892. }
  57893. return true;
  57894. };
  57895. /**
  57896. * Render the texture to its associated render target.
  57897. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57898. */
  57899. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  57900. var scene = this.getScene();
  57901. if (this._animate && scene) {
  57902. this._time += scene.getAnimationRatio() * 0.03;
  57903. this.updateShaderUniforms();
  57904. }
  57905. _super.prototype.render.call(this, useCameraPostProcess);
  57906. };
  57907. /**
  57908. * Update the list of dependant textures samplers in the shader.
  57909. */
  57910. CustomProceduralTexture.prototype.updateTextures = function () {
  57911. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  57912. 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()));
  57913. }
  57914. };
  57915. /**
  57916. * Update the uniform values of the procedural texture in the shader.
  57917. */
  57918. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  57919. if (this._config) {
  57920. for (var j = 0; j < this._config.uniforms.length; j++) {
  57921. var uniform = this._config.uniforms[j];
  57922. switch (uniform.type) {
  57923. case "float":
  57924. this.setFloat(uniform.name, uniform.value);
  57925. break;
  57926. case "color3":
  57927. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](uniform.r, uniform.g, uniform.b));
  57928. break;
  57929. case "color4":
  57930. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  57931. break;
  57932. case "vector2":
  57933. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](uniform.x, uniform.y));
  57934. break;
  57935. case "vector3":
  57936. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](uniform.x, uniform.y, uniform.z));
  57937. break;
  57938. }
  57939. }
  57940. }
  57941. this.setFloat("time", this._time);
  57942. };
  57943. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  57944. /**
  57945. * Define if the texture animates or not.
  57946. */
  57947. get: function () {
  57948. return this._animate;
  57949. },
  57950. set: function (value) {
  57951. this._animate = value;
  57952. },
  57953. enumerable: true,
  57954. configurable: true
  57955. });
  57956. return CustomProceduralTexture;
  57957. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_4__["ProceduralTexture"]));
  57958. /***/ }),
  57959. /***/ "./Materials/Textures/Procedurals/index.ts":
  57960. /*!*************************************************!*\
  57961. !*** ./Materials/Textures/Procedurals/index.ts ***!
  57962. \*************************************************/
  57963. /*! exports provided: ProceduralTexture, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  57964. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57965. "use strict";
  57966. __webpack_require__.r(__webpack_exports__);
  57967. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  57968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  57969. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  57970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  57971. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  57972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  57973. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  57974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  57975. /***/ }),
  57976. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  57977. /*!******************************************************************!*\
  57978. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  57979. \******************************************************************/
  57980. /*! exports provided: NoiseProceduralTexture */
  57981. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57982. "use strict";
  57983. __webpack_require__.r(__webpack_exports__);
  57984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  57985. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57986. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  57987. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  57988. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  57989. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  57990. /**
  57991. * Class used to generate noise procedural textures
  57992. */
  57993. var NoiseProceduralTexture = /** @class */ (function (_super) {
  57994. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  57995. /**
  57996. * Creates a new NoiseProceduralTexture
  57997. * @param name defines the name fo the texture
  57998. * @param size defines the size of the texture (default is 256)
  57999. * @param scene defines the hosting scene
  58000. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58001. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58002. */
  58003. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  58004. if (size === void 0) { size = 256; }
  58005. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  58006. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  58007. _this._time = 0;
  58008. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58009. _this.brightness = 0.2;
  58010. /** Defines the number of octaves to process */
  58011. _this.octaves = 3;
  58012. /** Defines the level of persistence (0.8 by default) */
  58013. _this.persistence = 0.8;
  58014. /** Gets or sets animation speed factor (default is 1) */
  58015. _this.animationSpeedFactor = 1;
  58016. _this.autoClear = false;
  58017. _this._updateShaderUniforms();
  58018. return _this;
  58019. }
  58020. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  58021. var scene = this.getScene();
  58022. if (!scene) {
  58023. return;
  58024. }
  58025. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  58026. this.setFloat("brightness", this.brightness);
  58027. this.setFloat("persistence", this.persistence);
  58028. this.setFloat("timeScale", this._time);
  58029. };
  58030. NoiseProceduralTexture.prototype._getDefines = function () {
  58031. return "#define OCTAVES " + (this.octaves | 0);
  58032. };
  58033. /** Generate the current state of the procedural texture */
  58034. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  58035. this._updateShaderUniforms();
  58036. _super.prototype.render.call(this, useCameraPostProcess);
  58037. };
  58038. /**
  58039. * Serializes this noise procedural texture
  58040. * @returns a serialized noise procedural texture object
  58041. */
  58042. NoiseProceduralTexture.prototype.serialize = function () {
  58043. var serializationObject = {};
  58044. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  58045. serializationObject.brightness = this.brightness;
  58046. serializationObject.octaves = this.octaves;
  58047. serializationObject.persistence = this.persistence;
  58048. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  58049. serializationObject.size = this.getSize().width;
  58050. serializationObject.generateMipMaps = this._generateMipMaps;
  58051. return serializationObject;
  58052. };
  58053. /**
  58054. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58055. * @param parsedTexture defines parsed texture data
  58056. * @param scene defines the current scene
  58057. * @param rootUrl defines the root URL containing noise procedural texture information
  58058. * @returns a parsed NoiseProceduralTexture
  58059. */
  58060. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  58061. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  58062. texture.brightness = parsedTexture.brightness;
  58063. texture.octaves = parsedTexture.octaves;
  58064. texture.persistence = parsedTexture.persistence;
  58065. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  58066. return texture;
  58067. };
  58068. return NoiseProceduralTexture;
  58069. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  58070. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  58071. /***/ }),
  58072. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  58073. /*!*************************************************************!*\
  58074. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  58075. \*************************************************************/
  58076. /*! exports provided: ProceduralTexture */
  58077. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58078. "use strict";
  58079. __webpack_require__.r(__webpack_exports__);
  58080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  58081. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58082. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  58083. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  58084. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  58085. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  58086. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  58087. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58088. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  58089. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  58090. /* harmony import */ var _Engines_Extensions_engine_renderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/Extensions/engine.renderTarget */ "./Engines/Extensions/engine.renderTarget.ts");
  58091. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  58092. /**
  58093. * 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.
  58094. * This is the base class of any Procedural texture and contains most of the shareable code.
  58095. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  58096. */
  58097. var ProceduralTexture = /** @class */ (function (_super) {
  58098. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  58099. /**
  58100. * Instantiates a new procedural texture.
  58101. * 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.
  58102. * This is the base class of any Procedural texture and contains most of the shareable code.
  58103. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  58104. * @param name Define the name of the texture
  58105. * @param size Define the size of the texture to create
  58106. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  58107. * @param scene Define the scene the texture belongs to
  58108. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58109. * @param generateMipMaps Define if the texture should creates mip maps or not
  58110. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  58111. */
  58112. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  58113. if (fallbackTexture === void 0) { fallbackTexture = null; }
  58114. if (generateMipMaps === void 0) { generateMipMaps = true; }
  58115. if (isCube === void 0) { isCube = false; }
  58116. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  58117. _this.isCube = isCube;
  58118. /**
  58119. * Define if the texture is enabled or not (disabled texture will not render)
  58120. */
  58121. _this.isEnabled = true;
  58122. /**
  58123. * Define if the texture must be cleared before rendering (default is true)
  58124. */
  58125. _this.autoClear = true;
  58126. /**
  58127. * Event raised when the texture is generated
  58128. */
  58129. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  58130. /** @hidden */
  58131. _this._textures = {};
  58132. _this._currentRefreshId = -1;
  58133. _this._refreshRate = 1;
  58134. _this._vertexBuffers = {};
  58135. _this._uniforms = new Array();
  58136. _this._samplers = new Array();
  58137. _this._floats = {};
  58138. _this._ints = {};
  58139. _this._floatsArrays = {};
  58140. _this._colors3 = {};
  58141. _this._colors4 = {};
  58142. _this._vectors2 = {};
  58143. _this._vectors3 = {};
  58144. _this._matrices = {};
  58145. _this._fallbackTextureUsed = false;
  58146. _this._cachedDefines = "";
  58147. _this._contentUpdateId = -1;
  58148. scene = _this.getScene();
  58149. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  58150. if (!component) {
  58151. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  58152. scene._addComponent(component);
  58153. }
  58154. scene.proceduralTextures.push(_this);
  58155. _this._engine = scene.getEngine();
  58156. _this.name = name;
  58157. _this.isRenderTarget = true;
  58158. _this._size = size;
  58159. _this._generateMipMaps = generateMipMaps;
  58160. _this.setFragment(fragment);
  58161. _this._fallbackTexture = fallbackTexture;
  58162. if (isCube) {
  58163. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  58164. _this.setFloat("face", 0);
  58165. }
  58166. else {
  58167. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  58168. }
  58169. // VBO
  58170. var vertices = [];
  58171. vertices.push(1, 1);
  58172. vertices.push(-1, 1);
  58173. vertices.push(-1, -1);
  58174. vertices.push(1, -1);
  58175. _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);
  58176. _this._createIndexBuffer();
  58177. return _this;
  58178. }
  58179. /**
  58180. * The effect that is created when initializing the post process.
  58181. * @returns The created effect corrisponding the the postprocess.
  58182. */
  58183. ProceduralTexture.prototype.getEffect = function () {
  58184. return this._effect;
  58185. };
  58186. /**
  58187. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  58188. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  58189. */
  58190. ProceduralTexture.prototype.getContent = function () {
  58191. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  58192. return this._contentData;
  58193. }
  58194. this._contentData = this.readPixels(0, 0, this._contentData);
  58195. this._contentUpdateId = this._currentRefreshId;
  58196. return this._contentData;
  58197. };
  58198. ProceduralTexture.prototype._createIndexBuffer = function () {
  58199. var engine = this._engine;
  58200. // Indices
  58201. var indices = [];
  58202. indices.push(0);
  58203. indices.push(1);
  58204. indices.push(2);
  58205. indices.push(0);
  58206. indices.push(2);
  58207. indices.push(3);
  58208. this._indexBuffer = engine.createIndexBuffer(indices);
  58209. };
  58210. /** @hidden */
  58211. ProceduralTexture.prototype._rebuild = function () {
  58212. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  58213. if (vb) {
  58214. vb._rebuild();
  58215. }
  58216. this._createIndexBuffer();
  58217. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  58218. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  58219. }
  58220. };
  58221. /**
  58222. * Resets the texture in order to recreate its associated resources.
  58223. * This can be called in case of context loss
  58224. */
  58225. ProceduralTexture.prototype.reset = function () {
  58226. if (this._effect === undefined) {
  58227. return;
  58228. }
  58229. this._effect.dispose();
  58230. };
  58231. ProceduralTexture.prototype._getDefines = function () {
  58232. return "";
  58233. };
  58234. /**
  58235. * Is the texture ready to be used ? (rendered at least once)
  58236. * @returns true if ready, otherwise, false.
  58237. */
  58238. ProceduralTexture.prototype.isReady = function () {
  58239. var _this = this;
  58240. var engine = this._engine;
  58241. var shaders;
  58242. if (!this._fragment) {
  58243. return false;
  58244. }
  58245. if (this._fallbackTextureUsed) {
  58246. return true;
  58247. }
  58248. var defines = this._getDefines();
  58249. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  58250. return true;
  58251. }
  58252. if (this._fragment.fragmentElement !== undefined) {
  58253. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  58254. }
  58255. else {
  58256. shaders = { vertex: "procedural", fragment: this._fragment };
  58257. }
  58258. this._cachedDefines = defines;
  58259. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  58260. _this.releaseInternalTexture();
  58261. if (_this._fallbackTexture) {
  58262. _this._texture = _this._fallbackTexture._texture;
  58263. if (_this._texture) {
  58264. _this._texture.incrementReferences();
  58265. }
  58266. }
  58267. _this._fallbackTextureUsed = true;
  58268. });
  58269. return this._effect.isReady();
  58270. };
  58271. /**
  58272. * Resets the refresh counter of the texture and start bak from scratch.
  58273. * Could be useful to regenerate the texture if it is setup to render only once.
  58274. */
  58275. ProceduralTexture.prototype.resetRefreshCounter = function () {
  58276. this._currentRefreshId = -1;
  58277. };
  58278. /**
  58279. * Set the fragment shader to use in order to render the texture.
  58280. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  58281. */
  58282. ProceduralTexture.prototype.setFragment = function (fragment) {
  58283. this._fragment = fragment;
  58284. };
  58285. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  58286. /**
  58287. * Define the refresh rate of the texture or the rendering frequency.
  58288. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  58289. */
  58290. get: function () {
  58291. return this._refreshRate;
  58292. },
  58293. set: function (value) {
  58294. this._refreshRate = value;
  58295. this.resetRefreshCounter();
  58296. },
  58297. enumerable: true,
  58298. configurable: true
  58299. });
  58300. /** @hidden */
  58301. ProceduralTexture.prototype._shouldRender = function () {
  58302. if (!this.isEnabled || !this.isReady() || !this._texture) {
  58303. if (this._texture) {
  58304. this._texture.isReady = false;
  58305. }
  58306. return false;
  58307. }
  58308. if (this._fallbackTextureUsed) {
  58309. return false;
  58310. }
  58311. if (this._currentRefreshId === -1) { // At least render once
  58312. this._currentRefreshId = 1;
  58313. return true;
  58314. }
  58315. if (this.refreshRate === this._currentRefreshId) {
  58316. this._currentRefreshId = 1;
  58317. return true;
  58318. }
  58319. this._currentRefreshId++;
  58320. return false;
  58321. };
  58322. /**
  58323. * Get the size the texture is rendering at.
  58324. * @returns the size (texture is always squared)
  58325. */
  58326. ProceduralTexture.prototype.getRenderSize = function () {
  58327. return this._size;
  58328. };
  58329. /**
  58330. * Resize the texture to new value.
  58331. * @param size Define the new size the texture should have
  58332. * @param generateMipMaps Define whether the new texture should create mip maps
  58333. */
  58334. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  58335. if (this._fallbackTextureUsed) {
  58336. return;
  58337. }
  58338. this.releaseInternalTexture();
  58339. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  58340. // Update properties
  58341. this._size = size;
  58342. this._generateMipMaps = generateMipMaps;
  58343. };
  58344. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  58345. if (this._uniforms.indexOf(uniformName) === -1) {
  58346. this._uniforms.push(uniformName);
  58347. }
  58348. };
  58349. /**
  58350. * Set a texture in the shader program used to render.
  58351. * @param name Define the name of the uniform samplers as defined in the shader
  58352. * @param texture Define the texture to bind to this sampler
  58353. * @return the texture itself allowing "fluent" like uniform updates
  58354. */
  58355. ProceduralTexture.prototype.setTexture = function (name, texture) {
  58356. if (this._samplers.indexOf(name) === -1) {
  58357. this._samplers.push(name);
  58358. }
  58359. this._textures[name] = texture;
  58360. return this;
  58361. };
  58362. /**
  58363. * Set a float in the shader.
  58364. * @param name Define the name of the uniform as defined in the shader
  58365. * @param value Define the value to give to the uniform
  58366. * @return the texture itself allowing "fluent" like uniform updates
  58367. */
  58368. ProceduralTexture.prototype.setFloat = function (name, value) {
  58369. this._checkUniform(name);
  58370. this._floats[name] = value;
  58371. return this;
  58372. };
  58373. /**
  58374. * Set a int in the shader.
  58375. * @param name Define the name of the uniform as defined in the shader
  58376. * @param value Define the value to give to the uniform
  58377. * @return the texture itself allowing "fluent" like uniform updates
  58378. */
  58379. ProceduralTexture.prototype.setInt = function (name, value) {
  58380. this._checkUniform(name);
  58381. this._ints[name] = value;
  58382. return this;
  58383. };
  58384. /**
  58385. * Set an array of floats in the shader.
  58386. * @param name Define the name of the uniform as defined in the shader
  58387. * @param value Define the value to give to the uniform
  58388. * @return the texture itself allowing "fluent" like uniform updates
  58389. */
  58390. ProceduralTexture.prototype.setFloats = function (name, value) {
  58391. this._checkUniform(name);
  58392. this._floatsArrays[name] = value;
  58393. return this;
  58394. };
  58395. /**
  58396. * Set a vec3 in the shader from a Color3.
  58397. * @param name Define the name of the uniform as defined in the shader
  58398. * @param value Define the value to give to the uniform
  58399. * @return the texture itself allowing "fluent" like uniform updates
  58400. */
  58401. ProceduralTexture.prototype.setColor3 = function (name, value) {
  58402. this._checkUniform(name);
  58403. this._colors3[name] = value;
  58404. return this;
  58405. };
  58406. /**
  58407. * Set a vec4 in the shader from a Color4.
  58408. * @param name Define the name of the uniform as defined in the shader
  58409. * @param value Define the value to give to the uniform
  58410. * @return the texture itself allowing "fluent" like uniform updates
  58411. */
  58412. ProceduralTexture.prototype.setColor4 = function (name, value) {
  58413. this._checkUniform(name);
  58414. this._colors4[name] = value;
  58415. return this;
  58416. };
  58417. /**
  58418. * Set a vec2 in the shader from a Vector2.
  58419. * @param name Define the name of the uniform as defined in the shader
  58420. * @param value Define the value to give to the uniform
  58421. * @return the texture itself allowing "fluent" like uniform updates
  58422. */
  58423. ProceduralTexture.prototype.setVector2 = function (name, value) {
  58424. this._checkUniform(name);
  58425. this._vectors2[name] = value;
  58426. return this;
  58427. };
  58428. /**
  58429. * Set a vec3 in the shader from a Vector3.
  58430. * @param name Define the name of the uniform as defined in the shader
  58431. * @param value Define the value to give to the uniform
  58432. * @return the texture itself allowing "fluent" like uniform updates
  58433. */
  58434. ProceduralTexture.prototype.setVector3 = function (name, value) {
  58435. this._checkUniform(name);
  58436. this._vectors3[name] = value;
  58437. return this;
  58438. };
  58439. /**
  58440. * Set a mat4 in the shader from a MAtrix.
  58441. * @param name Define the name of the uniform as defined in the shader
  58442. * @param value Define the value to give to the uniform
  58443. * @return the texture itself allowing "fluent" like uniform updates
  58444. */
  58445. ProceduralTexture.prototype.setMatrix = function (name, value) {
  58446. this._checkUniform(name);
  58447. this._matrices[name] = value;
  58448. return this;
  58449. };
  58450. /**
  58451. * Render the texture to its associated render target.
  58452. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58453. */
  58454. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  58455. var scene = this.getScene();
  58456. if (!scene) {
  58457. return;
  58458. }
  58459. var engine = this._engine;
  58460. // Render
  58461. engine.enableEffect(this._effect);
  58462. engine.setState(false);
  58463. // Texture
  58464. for (var name in this._textures) {
  58465. this._effect.setTexture(name, this._textures[name]);
  58466. }
  58467. // Float
  58468. for (name in this._ints) {
  58469. this._effect.setInt(name, this._ints[name]);
  58470. }
  58471. // Float
  58472. for (name in this._floats) {
  58473. this._effect.setFloat(name, this._floats[name]);
  58474. }
  58475. // Floats
  58476. for (name in this._floatsArrays) {
  58477. this._effect.setArray(name, this._floatsArrays[name]);
  58478. }
  58479. // Color3
  58480. for (name in this._colors3) {
  58481. this._effect.setColor3(name, this._colors3[name]);
  58482. }
  58483. // Color4
  58484. for (name in this._colors4) {
  58485. var color = this._colors4[name];
  58486. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  58487. }
  58488. // Vector2
  58489. for (name in this._vectors2) {
  58490. this._effect.setVector2(name, this._vectors2[name]);
  58491. }
  58492. // Vector3
  58493. for (name in this._vectors3) {
  58494. this._effect.setVector3(name, this._vectors3[name]);
  58495. }
  58496. // Matrix
  58497. for (name in this._matrices) {
  58498. this._effect.setMatrix(name, this._matrices[name]);
  58499. }
  58500. if (!this._texture) {
  58501. return;
  58502. }
  58503. if (this.isCube) {
  58504. for (var face = 0; face < 6; face++) {
  58505. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  58506. // VBOs
  58507. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  58508. this._effect.setFloat("face", face);
  58509. // Clear
  58510. if (this.autoClear) {
  58511. engine.clear(scene.clearColor, true, false, false);
  58512. }
  58513. // Draw order
  58514. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  58515. // Mipmaps
  58516. if (face === 5) {
  58517. engine.generateMipMapsForCubemap(this._texture);
  58518. }
  58519. }
  58520. }
  58521. else {
  58522. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  58523. // VBOs
  58524. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  58525. // Clear
  58526. if (this.autoClear) {
  58527. engine.clear(scene.clearColor, true, false, false);
  58528. }
  58529. // Draw order
  58530. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  58531. }
  58532. // Unbind
  58533. engine.unBindFramebuffer(this._texture, this.isCube);
  58534. if (this.onGenerated) {
  58535. this.onGenerated();
  58536. }
  58537. this.onGeneratedObservable.notifyObservers(this);
  58538. };
  58539. /**
  58540. * Clone the texture.
  58541. * @returns the cloned texture
  58542. */
  58543. ProceduralTexture.prototype.clone = function () {
  58544. var textureSize = this.getSize();
  58545. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  58546. // Base texture
  58547. newTexture.hasAlpha = this.hasAlpha;
  58548. newTexture.level = this.level;
  58549. // RenderTarget Texture
  58550. newTexture.coordinatesMode = this.coordinatesMode;
  58551. return newTexture;
  58552. };
  58553. /**
  58554. * Dispose the texture and release its asoociated resources.
  58555. */
  58556. ProceduralTexture.prototype.dispose = function () {
  58557. var scene = this.getScene();
  58558. if (!scene) {
  58559. return;
  58560. }
  58561. var index = scene.proceduralTextures.indexOf(this);
  58562. if (index >= 0) {
  58563. scene.proceduralTextures.splice(index, 1);
  58564. }
  58565. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  58566. if (vertexBuffer) {
  58567. vertexBuffer.dispose();
  58568. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  58569. }
  58570. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  58571. this._indexBuffer = null;
  58572. }
  58573. _super.prototype.dispose.call(this);
  58574. };
  58575. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58576. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58577. ], ProceduralTexture.prototype, "isEnabled", void 0);
  58578. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58579. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58580. ], ProceduralTexture.prototype, "autoClear", void 0);
  58581. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58582. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58583. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  58584. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58585. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58586. ], ProceduralTexture.prototype, "_size", void 0);
  58587. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58588. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58589. ], ProceduralTexture.prototype, "refreshRate", null);
  58590. return ProceduralTexture;
  58591. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  58592. /***/ }),
  58593. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  58594. /*!***************************************************************************!*\
  58595. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  58596. \***************************************************************************/
  58597. /*! exports provided: ProceduralTextureSceneComponent */
  58598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58599. "use strict";
  58600. __webpack_require__.r(__webpack_exports__);
  58601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  58602. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  58603. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  58604. /**
  58605. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  58606. * in a given scene.
  58607. */
  58608. var ProceduralTextureSceneComponent = /** @class */ (function () {
  58609. /**
  58610. * Creates a new instance of the component for the given scene
  58611. * @param scene Defines the scene to register the component in
  58612. */
  58613. function ProceduralTextureSceneComponent(scene) {
  58614. /**
  58615. * The component name helpfull to identify the component in the list of scene components.
  58616. */
  58617. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  58618. this.scene = scene;
  58619. this.scene.proceduralTextures = new Array();
  58620. scene.layers = new Array();
  58621. }
  58622. /**
  58623. * Registers the component in a given scene
  58624. */
  58625. ProceduralTextureSceneComponent.prototype.register = function () {
  58626. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  58627. };
  58628. /**
  58629. * Rebuilds the elements related to this component in case of
  58630. * context lost for instance.
  58631. */
  58632. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  58633. // Nothing to do here.
  58634. };
  58635. /**
  58636. * Disposes the component and the associated ressources.
  58637. */
  58638. ProceduralTextureSceneComponent.prototype.dispose = function () {
  58639. // Nothing to do here.
  58640. };
  58641. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  58642. if (this.scene.proceduralTexturesEnabled) {
  58643. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  58644. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  58645. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  58646. if (proceduralTexture._shouldRender()) {
  58647. proceduralTexture.render();
  58648. }
  58649. }
  58650. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  58651. }
  58652. };
  58653. return ProceduralTextureSceneComponent;
  58654. }());
  58655. /***/ }),
  58656. /***/ "./Materials/Textures/baseTexture.ts":
  58657. /*!*******************************************!*\
  58658. !*** ./Materials/Textures/baseTexture.ts ***!
  58659. \*******************************************/
  58660. /*! exports provided: BaseTexture */
  58661. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58662. "use strict";
  58663. __webpack_require__.r(__webpack_exports__);
  58664. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  58665. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58666. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  58667. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58668. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58669. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  58670. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58671. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  58672. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58673. /**
  58674. * Base class of all the textures in babylon.
  58675. * It groups all the common properties the materials, post process, lights... might need
  58676. * in order to make a correct use of the texture.
  58677. */
  58678. var BaseTexture = /** @class */ (function () {
  58679. /**
  58680. * Instantiates a new BaseTexture.
  58681. * Base class of all the textures in babylon.
  58682. * It groups all the common properties the materials, post process, lights... might need
  58683. * in order to make a correct use of the texture.
  58684. * @param scene Define the scene the texture blongs to
  58685. */
  58686. function BaseTexture(scene) {
  58687. /**
  58688. * Gets or sets an object used to store user defined information.
  58689. */
  58690. this.metadata = null;
  58691. /**
  58692. * For internal use only. Please do not use.
  58693. */
  58694. this.reservedDataStore = null;
  58695. this._hasAlpha = false;
  58696. /**
  58697. * Defines if the alpha value should be determined via the rgb values.
  58698. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  58699. */
  58700. this.getAlphaFromRGB = false;
  58701. /**
  58702. * Intensity or strength of the texture.
  58703. * It is commonly used by materials to fine tune the intensity of the texture
  58704. */
  58705. this.level = 1;
  58706. /**
  58707. * Define the UV chanel to use starting from 0 and defaulting to 0.
  58708. * This is part of the texture as textures usually maps to one uv set.
  58709. */
  58710. this.coordinatesIndex = 0;
  58711. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  58712. /**
  58713. * | Value | Type | Description |
  58714. * | ----- | ------------------ | ----------- |
  58715. * | 0 | CLAMP_ADDRESSMODE | |
  58716. * | 1 | WRAP_ADDRESSMODE | |
  58717. * | 2 | MIRROR_ADDRESSMODE | |
  58718. */
  58719. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  58720. /**
  58721. * | Value | Type | Description |
  58722. * | ----- | ------------------ | ----------- |
  58723. * | 0 | CLAMP_ADDRESSMODE | |
  58724. * | 1 | WRAP_ADDRESSMODE | |
  58725. * | 2 | MIRROR_ADDRESSMODE | |
  58726. */
  58727. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  58728. /**
  58729. * | Value | Type | Description |
  58730. * | ----- | ------------------ | ----------- |
  58731. * | 0 | CLAMP_ADDRESSMODE | |
  58732. * | 1 | WRAP_ADDRESSMODE | |
  58733. * | 2 | MIRROR_ADDRESSMODE | |
  58734. */
  58735. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  58736. /**
  58737. * With compliant hardware and browser (supporting anisotropic filtering)
  58738. * this defines the level of anisotropic filtering in the texture.
  58739. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  58740. */
  58741. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  58742. /**
  58743. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  58744. * HDR texture are usually stored in linear space.
  58745. * This only impacts the PBR and Background materials
  58746. */
  58747. this.gammaSpace = true;
  58748. /**
  58749. * Is Z inverted in the texture (useful in a cube texture).
  58750. */
  58751. this.invertZ = false;
  58752. /**
  58753. * @hidden
  58754. */
  58755. this.lodLevelInAlpha = false;
  58756. /**
  58757. * Define if the texture is a render target.
  58758. */
  58759. this.isRenderTarget = false;
  58760. /**
  58761. * Define the list of animation attached to the texture.
  58762. */
  58763. this.animations = new Array();
  58764. /**
  58765. * An event triggered when the texture is disposed.
  58766. */
  58767. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  58768. this._onDisposeObserver = null;
  58769. /**
  58770. * Define the current state of the loading sequence when in delayed load mode.
  58771. */
  58772. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  58773. this._scene = null;
  58774. /** @hidden */
  58775. this._texture = null;
  58776. this._uid = null;
  58777. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  58778. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  58779. if (this._scene) {
  58780. this.uniqueId = this._scene.getUniqueId();
  58781. this._scene.addTexture(this);
  58782. }
  58783. this._uid = null;
  58784. }
  58785. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  58786. get: function () {
  58787. return this._hasAlpha;
  58788. },
  58789. /**
  58790. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  58791. */
  58792. set: function (value) {
  58793. if (this._hasAlpha === value) {
  58794. return;
  58795. }
  58796. this._hasAlpha = value;
  58797. if (this._scene) {
  58798. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  58799. }
  58800. },
  58801. enumerable: true,
  58802. configurable: true
  58803. });
  58804. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  58805. get: function () {
  58806. return this._coordinatesMode;
  58807. },
  58808. /**
  58809. * How a texture is mapped.
  58810. *
  58811. * | Value | Type | Description |
  58812. * | ----- | ----------------------------------- | ----------- |
  58813. * | 0 | EXPLICIT_MODE | |
  58814. * | 1 | SPHERICAL_MODE | |
  58815. * | 2 | PLANAR_MODE | |
  58816. * | 3 | CUBIC_MODE | |
  58817. * | 4 | PROJECTION_MODE | |
  58818. * | 5 | SKYBOX_MODE | |
  58819. * | 6 | INVCUBIC_MODE | |
  58820. * | 7 | EQUIRECTANGULAR_MODE | |
  58821. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  58822. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  58823. */
  58824. set: function (value) {
  58825. if (this._coordinatesMode === value) {
  58826. return;
  58827. }
  58828. this._coordinatesMode = value;
  58829. if (this._scene) {
  58830. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  58831. }
  58832. },
  58833. enumerable: true,
  58834. configurable: true
  58835. });
  58836. Object.defineProperty(BaseTexture.prototype, "isCube", {
  58837. /**
  58838. * Define if the texture is a cube texture or if false a 2d texture.
  58839. */
  58840. get: function () {
  58841. if (!this._texture) {
  58842. return false;
  58843. }
  58844. return this._texture.isCube;
  58845. },
  58846. set: function (value) {
  58847. if (!this._texture) {
  58848. return;
  58849. }
  58850. this._texture.isCube = value;
  58851. },
  58852. enumerable: true,
  58853. configurable: true
  58854. });
  58855. Object.defineProperty(BaseTexture.prototype, "is3D", {
  58856. /**
  58857. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  58858. */
  58859. get: function () {
  58860. if (!this._texture) {
  58861. return false;
  58862. }
  58863. return this._texture.is3D;
  58864. },
  58865. set: function (value) {
  58866. if (!this._texture) {
  58867. return;
  58868. }
  58869. this._texture.is3D = value;
  58870. },
  58871. enumerable: true,
  58872. configurable: true
  58873. });
  58874. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  58875. /**
  58876. * Gets whether or not the texture contains RGBD data.
  58877. */
  58878. get: function () {
  58879. return this._texture != null && this._texture._isRGBD;
  58880. },
  58881. enumerable: true,
  58882. configurable: true
  58883. });
  58884. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  58885. /**
  58886. * Are mip maps generated for this texture or not.
  58887. */
  58888. get: function () {
  58889. return false;
  58890. },
  58891. enumerable: true,
  58892. configurable: true
  58893. });
  58894. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  58895. /**
  58896. * With prefiltered texture, defined the offset used during the prefiltering steps.
  58897. */
  58898. get: function () {
  58899. if (this._texture) {
  58900. return this._texture._lodGenerationOffset;
  58901. }
  58902. return 0.0;
  58903. },
  58904. set: function (value) {
  58905. if (this._texture) {
  58906. this._texture._lodGenerationOffset = value;
  58907. }
  58908. },
  58909. enumerable: true,
  58910. configurable: true
  58911. });
  58912. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  58913. /**
  58914. * With prefiltered texture, defined the scale used during the prefiltering steps.
  58915. */
  58916. get: function () {
  58917. if (this._texture) {
  58918. return this._texture._lodGenerationScale;
  58919. }
  58920. return 0.0;
  58921. },
  58922. set: function (value) {
  58923. if (this._texture) {
  58924. this._texture._lodGenerationScale = value;
  58925. }
  58926. },
  58927. enumerable: true,
  58928. configurable: true
  58929. });
  58930. Object.defineProperty(BaseTexture.prototype, "uid", {
  58931. /**
  58932. * Define the unique id of the texture in the scene.
  58933. */
  58934. get: function () {
  58935. if (!this._uid) {
  58936. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  58937. }
  58938. return this._uid;
  58939. },
  58940. enumerable: true,
  58941. configurable: true
  58942. });
  58943. /**
  58944. * Return a string representation of the texture.
  58945. * @returns the texture as a string
  58946. */
  58947. BaseTexture.prototype.toString = function () {
  58948. return this.name;
  58949. };
  58950. /**
  58951. * Get the class name of the texture.
  58952. * @returns "BaseTexture"
  58953. */
  58954. BaseTexture.prototype.getClassName = function () {
  58955. return "BaseTexture";
  58956. };
  58957. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  58958. /**
  58959. * Callback triggered when the texture has been disposed.
  58960. * Kept for back compatibility, you can use the onDisposeObservable instead.
  58961. */
  58962. set: function (callback) {
  58963. if (this._onDisposeObserver) {
  58964. this.onDisposeObservable.remove(this._onDisposeObserver);
  58965. }
  58966. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  58967. },
  58968. enumerable: true,
  58969. configurable: true
  58970. });
  58971. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  58972. /**
  58973. * Define if the texture is preventinga material to render or not.
  58974. * If not and the texture is not ready, the engine will use a default black texture instead.
  58975. */
  58976. get: function () {
  58977. return true;
  58978. },
  58979. enumerable: true,
  58980. configurable: true
  58981. });
  58982. /**
  58983. * Get the scene the texture belongs to.
  58984. * @returns the scene or null if undefined
  58985. */
  58986. BaseTexture.prototype.getScene = function () {
  58987. return this._scene;
  58988. };
  58989. /**
  58990. * Get the texture transform matrix used to offset tile the texture for istance.
  58991. * @returns the transformation matrix
  58992. */
  58993. BaseTexture.prototype.getTextureMatrix = function () {
  58994. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  58995. };
  58996. /**
  58997. * Get the texture reflection matrix used to rotate/transform the reflection.
  58998. * @returns the reflection matrix
  58999. */
  59000. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  59001. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  59002. };
  59003. /**
  59004. * Get the underlying lower level texture from Babylon.
  59005. * @returns the insternal texture
  59006. */
  59007. BaseTexture.prototype.getInternalTexture = function () {
  59008. return this._texture;
  59009. };
  59010. /**
  59011. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  59012. * @returns true if ready or not blocking
  59013. */
  59014. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  59015. return !this.isBlocking || this.isReady();
  59016. };
  59017. /**
  59018. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  59019. * @returns true if fully ready
  59020. */
  59021. BaseTexture.prototype.isReady = function () {
  59022. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  59023. this.delayLoad();
  59024. return false;
  59025. }
  59026. if (this._texture) {
  59027. return this._texture.isReady;
  59028. }
  59029. return false;
  59030. };
  59031. /**
  59032. * Get the size of the texture.
  59033. * @returns the texture size.
  59034. */
  59035. BaseTexture.prototype.getSize = function () {
  59036. if (this._texture) {
  59037. if (this._texture.width) {
  59038. this._cachedSize.width = this._texture.width;
  59039. this._cachedSize.height = this._texture.height;
  59040. return this._cachedSize;
  59041. }
  59042. if (this._texture._size) {
  59043. this._cachedSize.width = this._texture._size;
  59044. this._cachedSize.height = this._texture._size;
  59045. return this._cachedSize;
  59046. }
  59047. }
  59048. return this._cachedSize;
  59049. };
  59050. /**
  59051. * Get the base size of the texture.
  59052. * It can be different from the size if the texture has been resized for POT for instance
  59053. * @returns the base size
  59054. */
  59055. BaseTexture.prototype.getBaseSize = function () {
  59056. if (!this.isReady() || !this._texture) {
  59057. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  59058. }
  59059. if (this._texture._size) {
  59060. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  59061. }
  59062. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  59063. };
  59064. /**
  59065. * Update the sampling mode of the texture.
  59066. * Default is Trilinear mode.
  59067. *
  59068. * | Value | Type | Description |
  59069. * | ----- | ------------------ | ----------- |
  59070. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  59071. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  59072. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  59073. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  59074. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  59075. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  59076. * | 7 | NEAREST_LINEAR | |
  59077. * | 8 | NEAREST_NEAREST | |
  59078. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  59079. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  59080. * | 11 | LINEAR_LINEAR | |
  59081. * | 12 | LINEAR_NEAREST | |
  59082. *
  59083. * > _mag_: magnification filter (close to the viewer)
  59084. * > _min_: minification filter (far from the viewer)
  59085. * > _mip_: filter used between mip map levels
  59086. *@param samplingMode Define the new sampling mode of the texture
  59087. */
  59088. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  59089. if (!this._texture) {
  59090. return;
  59091. }
  59092. var scene = this.getScene();
  59093. if (!scene) {
  59094. return;
  59095. }
  59096. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  59097. };
  59098. /**
  59099. * Scales the texture if is `canRescale()`
  59100. * @param ratio the resize factor we want to use to rescale
  59101. */
  59102. BaseTexture.prototype.scale = function (ratio) {
  59103. };
  59104. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  59105. /**
  59106. * Get if the texture can rescale.
  59107. */
  59108. get: function () {
  59109. return false;
  59110. },
  59111. enumerable: true,
  59112. configurable: true
  59113. });
  59114. /** @hidden */
  59115. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling, invertY) {
  59116. if (!this._scene) {
  59117. return null;
  59118. }
  59119. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  59120. for (var index = 0; index < texturesCache.length; index++) {
  59121. var texturesCacheEntry = texturesCache[index];
  59122. if (invertY === undefined || invertY === texturesCacheEntry.invertY) {
  59123. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  59124. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  59125. texturesCacheEntry.incrementReferences();
  59126. return texturesCacheEntry;
  59127. }
  59128. }
  59129. }
  59130. }
  59131. return null;
  59132. };
  59133. /** @hidden */
  59134. BaseTexture.prototype._rebuild = function () {
  59135. };
  59136. /**
  59137. * Triggers the load sequence in delayed load mode.
  59138. */
  59139. BaseTexture.prototype.delayLoad = function () {
  59140. };
  59141. /**
  59142. * Clones the texture.
  59143. * @returns the cloned texture
  59144. */
  59145. BaseTexture.prototype.clone = function () {
  59146. return null;
  59147. };
  59148. Object.defineProperty(BaseTexture.prototype, "textureType", {
  59149. /**
  59150. * Get the texture underlying type (INT, FLOAT...)
  59151. */
  59152. get: function () {
  59153. if (!this._texture) {
  59154. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  59155. }
  59156. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  59157. },
  59158. enumerable: true,
  59159. configurable: true
  59160. });
  59161. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  59162. /**
  59163. * Get the texture underlying format (RGB, RGBA...)
  59164. */
  59165. get: function () {
  59166. if (!this._texture) {
  59167. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  59168. }
  59169. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  59170. },
  59171. enumerable: true,
  59172. configurable: true
  59173. });
  59174. /**
  59175. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  59176. * This will returns an RGBA array buffer containing either in values (0-255) or
  59177. * float values (0-1) depending of the underlying buffer type.
  59178. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  59179. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  59180. * @param buffer defines a user defined buffer to fill with data (can be null)
  59181. * @returns The Array buffer containing the pixels data.
  59182. */
  59183. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  59184. if (faceIndex === void 0) { faceIndex = 0; }
  59185. if (level === void 0) { level = 0; }
  59186. if (buffer === void 0) { buffer = null; }
  59187. if (!this._texture) {
  59188. return null;
  59189. }
  59190. var size = this.getSize();
  59191. var width = size.width;
  59192. var height = size.height;
  59193. var scene = this.getScene();
  59194. if (!scene) {
  59195. return null;
  59196. }
  59197. var engine = scene.getEngine();
  59198. if (level != 0) {
  59199. width = width / Math.pow(2, level);
  59200. height = height / Math.pow(2, level);
  59201. width = Math.round(width);
  59202. height = Math.round(height);
  59203. }
  59204. if (this._texture.isCube) {
  59205. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  59206. }
  59207. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  59208. };
  59209. /**
  59210. * Release and destroy the underlying lower level texture aka internalTexture.
  59211. */
  59212. BaseTexture.prototype.releaseInternalTexture = function () {
  59213. if (this._texture) {
  59214. this._texture.dispose();
  59215. this._texture = null;
  59216. }
  59217. };
  59218. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  59219. /**
  59220. * Get the polynomial representation of the texture data.
  59221. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  59222. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  59223. */
  59224. get: function () {
  59225. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  59226. return null;
  59227. }
  59228. if (!this._texture._sphericalPolynomial) {
  59229. this._texture._sphericalPolynomial =
  59230. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  59231. }
  59232. return this._texture._sphericalPolynomial;
  59233. },
  59234. set: function (value) {
  59235. if (this._texture) {
  59236. this._texture._sphericalPolynomial = value;
  59237. }
  59238. },
  59239. enumerable: true,
  59240. configurable: true
  59241. });
  59242. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  59243. /** @hidden */
  59244. get: function () {
  59245. if (this._texture) {
  59246. return this._texture._lodTextureHigh;
  59247. }
  59248. return null;
  59249. },
  59250. enumerable: true,
  59251. configurable: true
  59252. });
  59253. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  59254. /** @hidden */
  59255. get: function () {
  59256. if (this._texture) {
  59257. return this._texture._lodTextureMid;
  59258. }
  59259. return null;
  59260. },
  59261. enumerable: true,
  59262. configurable: true
  59263. });
  59264. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  59265. /** @hidden */
  59266. get: function () {
  59267. if (this._texture) {
  59268. return this._texture._lodTextureLow;
  59269. }
  59270. return null;
  59271. },
  59272. enumerable: true,
  59273. configurable: true
  59274. });
  59275. /**
  59276. * Dispose the texture and release its associated resources.
  59277. */
  59278. BaseTexture.prototype.dispose = function () {
  59279. if (!this._scene) {
  59280. return;
  59281. }
  59282. // Animations
  59283. if (this._scene.stopAnimation) {
  59284. this._scene.stopAnimation(this);
  59285. }
  59286. // Remove from scene
  59287. this._scene._removePendingData(this);
  59288. var index = this._scene.textures.indexOf(this);
  59289. if (index >= 0) {
  59290. this._scene.textures.splice(index, 1);
  59291. }
  59292. this._scene.onTextureRemovedObservable.notifyObservers(this);
  59293. if (this._texture === undefined) {
  59294. return;
  59295. }
  59296. // Release
  59297. this.releaseInternalTexture();
  59298. // Callback
  59299. this.onDisposeObservable.notifyObservers(this);
  59300. this.onDisposeObservable.clear();
  59301. };
  59302. /**
  59303. * Serialize the texture into a JSON representation that can be parsed later on.
  59304. * @returns the JSON representation of the texture
  59305. */
  59306. BaseTexture.prototype.serialize = function () {
  59307. if (!this.name) {
  59308. return null;
  59309. }
  59310. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  59311. // Animations
  59312. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  59313. return serializationObject;
  59314. };
  59315. /**
  59316. * Helper function to be called back once a list of texture contains only ready textures.
  59317. * @param textures Define the list of textures to wait for
  59318. * @param callback Define the callback triggered once the entire list will be ready
  59319. */
  59320. BaseTexture.WhenAllReady = function (textures, callback) {
  59321. var numRemaining = textures.length;
  59322. if (numRemaining === 0) {
  59323. callback();
  59324. return;
  59325. }
  59326. var _loop_1 = function () {
  59327. texture = textures[i];
  59328. if (texture.isReady()) {
  59329. if (--numRemaining === 0) {
  59330. callback();
  59331. }
  59332. }
  59333. else {
  59334. onLoadObservable = texture.onLoadObservable;
  59335. var onLoadCallback_1 = function () {
  59336. onLoadObservable.removeCallback(onLoadCallback_1);
  59337. if (--numRemaining === 0) {
  59338. callback();
  59339. }
  59340. };
  59341. onLoadObservable.add(onLoadCallback_1);
  59342. }
  59343. };
  59344. var texture, onLoadObservable;
  59345. for (var i = 0; i < textures.length; i++) {
  59346. _loop_1();
  59347. }
  59348. };
  59349. /**
  59350. * Default anisotropic filtering level for the application.
  59351. * It is set to 4 as a good tradeoff between perf and quality.
  59352. */
  59353. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  59354. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59355. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59356. ], BaseTexture.prototype, "uniqueId", void 0);
  59357. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59358. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59359. ], BaseTexture.prototype, "name", void 0);
  59360. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59361. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59362. ], BaseTexture.prototype, "metadata", void 0);
  59363. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59364. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  59365. ], BaseTexture.prototype, "_hasAlpha", void 0);
  59366. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59367. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59368. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  59369. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59370. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59371. ], BaseTexture.prototype, "level", void 0);
  59372. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59373. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59374. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  59375. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59376. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  59377. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  59378. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59379. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59380. ], BaseTexture.prototype, "wrapU", void 0);
  59381. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59382. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59383. ], BaseTexture.prototype, "wrapV", void 0);
  59384. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59385. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59386. ], BaseTexture.prototype, "wrapR", void 0);
  59387. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59389. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  59390. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59391. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59392. ], BaseTexture.prototype, "isCube", null);
  59393. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59394. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59395. ], BaseTexture.prototype, "is3D", null);
  59396. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59397. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59398. ], BaseTexture.prototype, "gammaSpace", void 0);
  59399. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59400. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59401. ], BaseTexture.prototype, "invertZ", void 0);
  59402. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59403. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59404. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  59405. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59406. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59407. ], BaseTexture.prototype, "lodGenerationOffset", null);
  59408. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59409. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59410. ], BaseTexture.prototype, "lodGenerationScale", null);
  59411. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59412. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59413. ], BaseTexture.prototype, "isRenderTarget", void 0);
  59414. return BaseTexture;
  59415. }());
  59416. /***/ }),
  59417. /***/ "./Materials/Textures/colorGradingTexture.ts":
  59418. /*!***************************************************!*\
  59419. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  59420. \***************************************************/
  59421. /*! exports provided: ColorGradingTexture */
  59422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59423. "use strict";
  59424. __webpack_require__.r(__webpack_exports__);
  59425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  59426. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59427. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59428. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  59429. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59430. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  59431. /**
  59432. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59433. * It can help converting any input color in a desired output one. This can then be used to create effects
  59434. * from sepia, black and white to sixties or futuristic rendering...
  59435. *
  59436. * The only supported format is currently 3dl.
  59437. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59438. */
  59439. var ColorGradingTexture = /** @class */ (function (_super) {
  59440. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  59441. /**
  59442. * Instantiates a ColorGradingTexture from the following parameters.
  59443. *
  59444. * @param url The location of the color gradind data (currently only supporting 3dl)
  59445. * @param scene The scene the texture will be used in
  59446. */
  59447. function ColorGradingTexture(url, scene) {
  59448. var _this = _super.call(this, scene) || this;
  59449. if (!url) {
  59450. return _this;
  59451. }
  59452. _this._engine = scene.getEngine();
  59453. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  59454. _this.name = url;
  59455. _this.url = url;
  59456. _this.hasAlpha = false;
  59457. _this.isCube = false;
  59458. _this.is3D = _this._engine.webGLVersion > 1;
  59459. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  59460. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  59461. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  59462. _this.anisotropicFilteringLevel = 1;
  59463. _this._texture = _this._getFromCache(url, true);
  59464. if (!_this._texture) {
  59465. if (!scene.useDelayedTextureLoading) {
  59466. _this.loadTexture();
  59467. }
  59468. else {
  59469. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  59470. }
  59471. }
  59472. return _this;
  59473. }
  59474. /**
  59475. * Returns the texture matrix used in most of the material.
  59476. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59477. */
  59478. ColorGradingTexture.prototype.getTextureMatrix = function () {
  59479. return this._textureMatrix;
  59480. };
  59481. /**
  59482. * Occurs when the file being loaded is a .3dl LUT file.
  59483. */
  59484. ColorGradingTexture.prototype.load3dlTexture = function () {
  59485. var engine = this._engine;
  59486. var texture;
  59487. if (engine.webGLVersion === 1) {
  59488. 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);
  59489. }
  59490. else {
  59491. 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);
  59492. }
  59493. this._texture = texture;
  59494. var callback = function (text) {
  59495. if (typeof text !== "string") {
  59496. return;
  59497. }
  59498. var data = null;
  59499. var tempData = null;
  59500. var line;
  59501. var lines = text.split('\n');
  59502. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  59503. var maxColor = 0;
  59504. for (var i = 0; i < lines.length; i++) {
  59505. line = lines[i];
  59506. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  59507. continue;
  59508. }
  59509. if (line.indexOf('#') === 0) {
  59510. continue;
  59511. }
  59512. var words = line.split(" ");
  59513. if (size === 0) {
  59514. // Number of space + one
  59515. size = words.length;
  59516. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  59517. tempData = new Float32Array(size * size * size * 4);
  59518. continue;
  59519. }
  59520. if (size != 0) {
  59521. var r = Math.max(parseInt(words[0]), 0);
  59522. var g = Math.max(parseInt(words[1]), 0);
  59523. var b = Math.max(parseInt(words[2]), 0);
  59524. maxColor = Math.max(r, maxColor);
  59525. maxColor = Math.max(g, maxColor);
  59526. maxColor = Math.max(b, maxColor);
  59527. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  59528. if (tempData) {
  59529. tempData[pixelStorageIndex + 0] = r;
  59530. tempData[pixelStorageIndex + 1] = g;
  59531. tempData[pixelStorageIndex + 2] = b;
  59532. }
  59533. // Keep for reference in case of back compat problems.
  59534. // pixelIndexSlice++;
  59535. // if (pixelIndexSlice % size == 0) {
  59536. // pixelIndexH++;
  59537. // pixelIndexSlice = 0;
  59538. // if (pixelIndexH % size == 0) {
  59539. // pixelIndexW++;
  59540. // pixelIndexH = 0;
  59541. // }
  59542. // }
  59543. pixelIndexH++;
  59544. if (pixelIndexH % size == 0) {
  59545. pixelIndexSlice++;
  59546. pixelIndexH = 0;
  59547. if (pixelIndexSlice % size == 0) {
  59548. pixelIndexW++;
  59549. pixelIndexSlice = 0;
  59550. }
  59551. }
  59552. }
  59553. }
  59554. if (tempData && data) {
  59555. for (var i = 0; i < tempData.length; i++) {
  59556. if (i > 0 && (i + 1) % 4 === 0) {
  59557. data[i] = 255;
  59558. }
  59559. else {
  59560. var value = tempData[i];
  59561. data[i] = (value / maxColor * 255);
  59562. }
  59563. }
  59564. }
  59565. if (texture.is3D) {
  59566. texture.updateSize(size, size, size);
  59567. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  59568. }
  59569. else {
  59570. texture.updateSize(size * size, size);
  59571. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  59572. }
  59573. };
  59574. var scene = this.getScene();
  59575. if (scene) {
  59576. scene._loadFile(this.url, callback);
  59577. }
  59578. else {
  59579. this._engine._loadFile(this.url, callback);
  59580. }
  59581. return this._texture;
  59582. };
  59583. /**
  59584. * Starts the loading process of the texture.
  59585. */
  59586. ColorGradingTexture.prototype.loadTexture = function () {
  59587. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  59588. this.load3dlTexture();
  59589. }
  59590. };
  59591. /**
  59592. * Clones the color gradind texture.
  59593. */
  59594. ColorGradingTexture.prototype.clone = function () {
  59595. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  59596. // Base texture
  59597. newTexture.level = this.level;
  59598. return newTexture;
  59599. };
  59600. /**
  59601. * Called during delayed load for textures.
  59602. */
  59603. ColorGradingTexture.prototype.delayLoad = function () {
  59604. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  59605. return;
  59606. }
  59607. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  59608. this._texture = this._getFromCache(this.url, true);
  59609. if (!this._texture) {
  59610. this.loadTexture();
  59611. }
  59612. };
  59613. /**
  59614. * Parses a color grading texture serialized by Babylon.
  59615. * @param parsedTexture The texture information being parsedTexture
  59616. * @param scene The scene to load the texture in
  59617. * @param rootUrl The root url of the data assets to load
  59618. * @return A color gradind texture
  59619. */
  59620. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  59621. var texture = null;
  59622. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  59623. texture = new ColorGradingTexture(parsedTexture.name, scene);
  59624. texture.name = parsedTexture.name;
  59625. texture.level = parsedTexture.level;
  59626. }
  59627. return texture;
  59628. };
  59629. /**
  59630. * Serializes the LUT texture to json format.
  59631. */
  59632. ColorGradingTexture.prototype.serialize = function () {
  59633. if (!this.name) {
  59634. return null;
  59635. }
  59636. var serializationObject = {};
  59637. serializationObject.name = this.name;
  59638. serializationObject.level = this.level;
  59639. serializationObject.customType = "BABYLON.ColorGradingTexture";
  59640. return serializationObject;
  59641. };
  59642. /**
  59643. * Empty line regex stored for GC.
  59644. */
  59645. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  59646. return ColorGradingTexture;
  59647. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  59648. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  59649. /***/ }),
  59650. /***/ "./Materials/Textures/cubeTexture.ts":
  59651. /*!*******************************************!*\
  59652. !*** ./Materials/Textures/cubeTexture.ts ***!
  59653. \*******************************************/
  59654. /*! exports provided: CubeTexture */
  59655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59656. "use strict";
  59657. __webpack_require__.r(__webpack_exports__);
  59658. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  59659. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59660. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  59661. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  59662. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59663. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  59664. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59665. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59666. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  59667. /* harmony import */ var _Engines_Extensions_engine_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Engines/Extensions/engine.cubeTexture */ "./Engines/Extensions/engine.cubeTexture.ts");
  59668. /**
  59669. * Class for creating a cube texture
  59670. */
  59671. var CubeTexture = /** @class */ (function (_super) {
  59672. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  59673. /**
  59674. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  59675. * as prefiltered data.
  59676. * @param rootUrl defines the url of the texture or the root name of the six images
  59677. * @param scene defines the scene the texture is attached to
  59678. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  59679. * @param noMipmap defines if mipmaps should be created or not
  59680. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  59681. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  59682. * @param onError defines a callback triggered in case of error during load
  59683. * @param format defines the internal format to use for the texture once loaded
  59684. * @param prefiltered defines whether or not the texture is created from prefiltered data
  59685. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  59686. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  59687. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59688. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59689. * @return the cube texture
  59690. */
  59691. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  59692. if (extensions === void 0) { extensions = null; }
  59693. if (noMipmap === void 0) { noMipmap = false; }
  59694. if (files === void 0) { files = null; }
  59695. if (onLoad === void 0) { onLoad = null; }
  59696. if (onError === void 0) { onError = null; }
  59697. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  59698. if (prefiltered === void 0) { prefiltered = false; }
  59699. if (forcedExtension === void 0) { forcedExtension = null; }
  59700. if (createPolynomials === void 0) { createPolynomials = false; }
  59701. if (lodScale === void 0) { lodScale = 0.8; }
  59702. if (lodOffset === void 0) { lodOffset = 0; }
  59703. var _this = _super.call(this, scene) || this;
  59704. /**
  59705. * Gets or sets the center of the bounding box associated with the cube texture.
  59706. * It must define where the camera used to render the texture was set
  59707. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  59708. */
  59709. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  59710. _this._rotationY = 0;
  59711. /** @hidden */
  59712. _this._prefiltered = false;
  59713. _this.name = rootUrl;
  59714. _this.url = rootUrl;
  59715. _this._noMipmap = noMipmap;
  59716. _this.hasAlpha = false;
  59717. _this._format = format;
  59718. _this.isCube = true;
  59719. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  59720. _this._createPolynomials = createPolynomials;
  59721. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  59722. if (!rootUrl && !files) {
  59723. return _this;
  59724. }
  59725. var lastDot = rootUrl.lastIndexOf(".");
  59726. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  59727. var isDDS = (extension === ".dds");
  59728. var isEnv = (extension === ".env");
  59729. if (isEnv) {
  59730. _this.gammaSpace = false;
  59731. _this._prefiltered = false;
  59732. }
  59733. else {
  59734. _this._prefiltered = prefiltered;
  59735. if (prefiltered) {
  59736. _this.gammaSpace = false;
  59737. }
  59738. }
  59739. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  59740. if (!files) {
  59741. if (!isEnv && !isDDS && !extensions) {
  59742. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  59743. }
  59744. files = [];
  59745. if (extensions) {
  59746. for (var index = 0; index < extensions.length; index++) {
  59747. files.push(rootUrl + extensions[index]);
  59748. }
  59749. }
  59750. }
  59751. _this._files = files;
  59752. if (!_this._texture) {
  59753. if (!scene.useDelayedTextureLoading) {
  59754. if (prefiltered) {
  59755. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  59756. }
  59757. else {
  59758. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  59759. }
  59760. }
  59761. else {
  59762. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  59763. }
  59764. }
  59765. else if (onLoad) {
  59766. if (_this._texture.isReady) {
  59767. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  59768. }
  59769. else {
  59770. _this._texture.onLoadedObservable.add(onLoad);
  59771. }
  59772. }
  59773. return _this;
  59774. }
  59775. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  59776. /**
  59777. * Returns the bounding box size
  59778. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  59779. */
  59780. get: function () {
  59781. return this._boundingBoxSize;
  59782. },
  59783. /**
  59784. * Gets or sets the size of the bounding box associated with the cube texture
  59785. * When defined, the cubemap will switch to local mode
  59786. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59787. * @example https://www.babylonjs-playground.com/#RNASML
  59788. */
  59789. set: function (value) {
  59790. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  59791. return;
  59792. }
  59793. this._boundingBoxSize = value;
  59794. var scene = this.getScene();
  59795. if (scene) {
  59796. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  59797. }
  59798. },
  59799. enumerable: true,
  59800. configurable: true
  59801. });
  59802. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  59803. /**
  59804. * Gets texture matrix rotation angle around Y axis radians.
  59805. */
  59806. get: function () {
  59807. return this._rotationY;
  59808. },
  59809. /**
  59810. * Sets texture matrix rotation angle around Y axis in radians.
  59811. */
  59812. set: function (value) {
  59813. this._rotationY = value;
  59814. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  59815. },
  59816. enumerable: true,
  59817. configurable: true
  59818. });
  59819. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  59820. /**
  59821. * Are mip maps generated for this texture or not.
  59822. */
  59823. get: function () {
  59824. return this._noMipmap;
  59825. },
  59826. enumerable: true,
  59827. configurable: true
  59828. });
  59829. /**
  59830. * Creates a cube texture from an array of image urls
  59831. * @param files defines an array of image urls
  59832. * @param scene defines the hosting scene
  59833. * @param noMipmap specifies if mip maps are not used
  59834. * @returns a cube texture
  59835. */
  59836. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  59837. var rootUrlKey = "";
  59838. files.forEach(function (url) { return rootUrlKey += url; });
  59839. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  59840. };
  59841. /**
  59842. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  59843. * @param url defines the url of the prefiltered texture
  59844. * @param scene defines the scene the texture is attached to
  59845. * @param forcedExtension defines the extension of the file if different from the url
  59846. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  59847. * @return the prefiltered texture
  59848. */
  59849. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  59850. if (forcedExtension === void 0) { forcedExtension = null; }
  59851. if (createPolynomials === void 0) { createPolynomials = true; }
  59852. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  59853. };
  59854. Object.defineProperty(CubeTexture.prototype, "isPrefiltered", {
  59855. /**
  59856. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  59857. */
  59858. get: function () {
  59859. return this._prefiltered;
  59860. },
  59861. enumerable: true,
  59862. configurable: true
  59863. });
  59864. /**
  59865. * Get the current class name of the texture useful for serialization or dynamic coding.
  59866. * @returns "CubeTexture"
  59867. */
  59868. CubeTexture.prototype.getClassName = function () {
  59869. return "CubeTexture";
  59870. };
  59871. /**
  59872. * Update the url (and optional buffer) of this texture if url was null during construction.
  59873. * @param url the url of the texture
  59874. * @param forcedExtension defines the extension to use
  59875. * @param onLoad callback called when the texture is loaded (defaults to null)
  59876. */
  59877. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  59878. if (this.url) {
  59879. this.releaseInternalTexture();
  59880. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  59881. }
  59882. this.url = url;
  59883. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  59884. this._prefiltered = false;
  59885. if (onLoad) {
  59886. this._delayedOnLoad = onLoad;
  59887. }
  59888. this.delayLoad(forcedExtension);
  59889. };
  59890. /**
  59891. * Delays loading of the cube texture
  59892. * @param forcedExtension defines the extension to use
  59893. */
  59894. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  59895. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  59896. return;
  59897. }
  59898. var scene = this.getScene();
  59899. if (!scene) {
  59900. return;
  59901. }
  59902. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  59903. this._texture = this._getFromCache(this.url, this._noMipmap);
  59904. if (!this._texture) {
  59905. if (this._prefiltered) {
  59906. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  59907. }
  59908. else {
  59909. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, null, this._format, forcedExtension);
  59910. }
  59911. }
  59912. };
  59913. /**
  59914. * Returns the reflection texture matrix
  59915. * @returns the reflection texture matrix
  59916. */
  59917. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  59918. return this._textureMatrix;
  59919. };
  59920. /**
  59921. * Sets the reflection texture matrix
  59922. * @param value Reflection texture matrix
  59923. */
  59924. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  59925. var _this = this;
  59926. if (value.updateFlag === this._textureMatrix.updateFlag) {
  59927. return;
  59928. }
  59929. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  59930. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  59931. }
  59932. this._textureMatrix = value;
  59933. };
  59934. /**
  59935. * Parses text to create a cube texture
  59936. * @param parsedTexture define the serialized text to read from
  59937. * @param scene defines the hosting scene
  59938. * @param rootUrl defines the root url of the cube texture
  59939. * @returns a cube texture
  59940. */
  59941. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  59942. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  59943. var prefiltered = false;
  59944. if (parsedTexture.prefiltered) {
  59945. prefiltered = parsedTexture.prefiltered;
  59946. }
  59947. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  59948. }, parsedTexture, scene);
  59949. // Local Cubemaps
  59950. if (parsedTexture.boundingBoxPosition) {
  59951. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  59952. }
  59953. if (parsedTexture.boundingBoxSize) {
  59954. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  59955. }
  59956. // Animations
  59957. if (parsedTexture.animations) {
  59958. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  59959. var parsedAnimation = parsedTexture.animations[animationIndex];
  59960. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  59961. if (internalClass) {
  59962. texture.animations.push(internalClass.Parse(parsedAnimation));
  59963. }
  59964. }
  59965. }
  59966. return texture;
  59967. };
  59968. /**
  59969. * Makes a clone, or deep copy, of the cube texture
  59970. * @returns a new cube texture
  59971. */
  59972. CubeTexture.prototype.clone = function () {
  59973. var _this = this;
  59974. var scene = this.getScene();
  59975. var uniqueId = 0;
  59976. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  59977. if (!scene) {
  59978. return _this;
  59979. }
  59980. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  59981. uniqueId = cubeTexture.uniqueId;
  59982. return cubeTexture;
  59983. }, this);
  59984. newCubeTexture.uniqueId = uniqueId;
  59985. return newCubeTexture;
  59986. };
  59987. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  59989. ], CubeTexture.prototype, "rotationY", null);
  59990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMatrix"])("textureMatrix")
  59992. ], CubeTexture.prototype, "_textureMatrix", void 0);
  59993. return CubeTexture;
  59994. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  59995. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  59996. // Some exporters relies on Tools.Instantiate
  59997. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.CubeTexture"] = CubeTexture;
  59998. /***/ }),
  59999. /***/ "./Materials/Textures/dynamicTexture.ts":
  60000. /*!**********************************************!*\
  60001. !*** ./Materials/Textures/dynamicTexture.ts ***!
  60002. \**********************************************/
  60003. /*! exports provided: DynamicTexture */
  60004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60005. "use strict";
  60006. __webpack_require__.r(__webpack_exports__);
  60007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  60008. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60009. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  60010. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60011. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60012. /**
  60013. * A class extending Texture allowing drawing on a texture
  60014. * @see http://doc.babylonjs.com/how_to/dynamictexture
  60015. */
  60016. var DynamicTexture = /** @class */ (function (_super) {
  60017. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  60018. /**
  60019. * Creates a DynamicTexture
  60020. * @param name defines the name of the texture
  60021. * @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
  60022. * @param scene defines the scene where you want the texture
  60023. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  60024. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60025. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  60026. */
  60027. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  60028. if (scene === void 0) { scene = null; }
  60029. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60030. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  60031. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  60032. _this.name = name;
  60033. _this._engine = _this.getScene().getEngine();
  60034. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  60035. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  60036. _this._generateMipMaps = generateMipMaps;
  60037. if (options.getContext) {
  60038. _this._canvas = options;
  60039. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  60040. }
  60041. else {
  60042. _this._canvas = document.createElement("canvas");
  60043. if (options.width || options.width === 0) {
  60044. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  60045. }
  60046. else {
  60047. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  60048. }
  60049. }
  60050. var textureSize = _this.getSize();
  60051. _this._canvas.width = textureSize.width;
  60052. _this._canvas.height = textureSize.height;
  60053. _this._context = _this._canvas.getContext("2d");
  60054. return _this;
  60055. }
  60056. /**
  60057. * Get the current class name of the texture useful for serialization or dynamic coding.
  60058. * @returns "DynamicTexture"
  60059. */
  60060. DynamicTexture.prototype.getClassName = function () {
  60061. return "DynamicTexture";
  60062. };
  60063. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  60064. /**
  60065. * Gets the current state of canRescale
  60066. */
  60067. get: function () {
  60068. return true;
  60069. },
  60070. enumerable: true,
  60071. configurable: true
  60072. });
  60073. DynamicTexture.prototype._recreate = function (textureSize) {
  60074. this._canvas.width = textureSize.width;
  60075. this._canvas.height = textureSize.height;
  60076. this.releaseInternalTexture();
  60077. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  60078. };
  60079. /**
  60080. * Scales the texture
  60081. * @param ratio the scale factor to apply to both width and height
  60082. */
  60083. DynamicTexture.prototype.scale = function (ratio) {
  60084. var textureSize = this.getSize();
  60085. textureSize.width *= ratio;
  60086. textureSize.height *= ratio;
  60087. this._recreate(textureSize);
  60088. };
  60089. /**
  60090. * Resizes the texture
  60091. * @param width the new width
  60092. * @param height the new height
  60093. */
  60094. DynamicTexture.prototype.scaleTo = function (width, height) {
  60095. var textureSize = this.getSize();
  60096. textureSize.width = width;
  60097. textureSize.height = height;
  60098. this._recreate(textureSize);
  60099. };
  60100. /**
  60101. * Gets the context of the canvas used by the texture
  60102. * @returns the canvas context of the dynamic texture
  60103. */
  60104. DynamicTexture.prototype.getContext = function () {
  60105. return this._context;
  60106. };
  60107. /**
  60108. * Clears the texture
  60109. */
  60110. DynamicTexture.prototype.clear = function () {
  60111. var size = this.getSize();
  60112. this._context.fillRect(0, 0, size.width, size.height);
  60113. };
  60114. /**
  60115. * Updates the texture
  60116. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  60117. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  60118. */
  60119. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  60120. if (premulAlpha === void 0) { premulAlpha = false; }
  60121. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  60122. };
  60123. /**
  60124. * Draws text onto the texture
  60125. * @param text defines the text to be drawn
  60126. * @param x defines the placement of the text from the left
  60127. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  60128. * @param font defines the font to be used with font-style, font-size, font-name
  60129. * @param color defines the color used for the text
  60130. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  60131. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  60132. * @param update defines whether texture is immediately update (default is true)
  60133. */
  60134. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  60135. if (update === void 0) { update = true; }
  60136. var size = this.getSize();
  60137. if (clearColor) {
  60138. this._context.fillStyle = clearColor;
  60139. this._context.fillRect(0, 0, size.width, size.height);
  60140. }
  60141. this._context.font = font;
  60142. if (x === null || x === undefined) {
  60143. var textSize = this._context.measureText(text);
  60144. x = (size.width - textSize.width) / 2;
  60145. }
  60146. if (y === null || y === undefined) {
  60147. var fontSize = parseInt((font.replace(/\D/g, '')));
  60148. y = (size.height / 2) + (fontSize / 3.65);
  60149. }
  60150. this._context.fillStyle = color;
  60151. this._context.fillText(text, x, y);
  60152. if (update) {
  60153. this.update(invertY);
  60154. }
  60155. };
  60156. /**
  60157. * Clones the texture
  60158. * @returns the clone of the texture.
  60159. */
  60160. DynamicTexture.prototype.clone = function () {
  60161. var scene = this.getScene();
  60162. if (!scene) {
  60163. return this;
  60164. }
  60165. var textureSize = this.getSize();
  60166. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  60167. // Base texture
  60168. newTexture.hasAlpha = this.hasAlpha;
  60169. newTexture.level = this.level;
  60170. // Dynamic Texture
  60171. newTexture.wrapU = this.wrapU;
  60172. newTexture.wrapV = this.wrapV;
  60173. return newTexture;
  60174. };
  60175. /**
  60176. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  60177. * @returns a serialized dynamic texture object
  60178. */
  60179. DynamicTexture.prototype.serialize = function () {
  60180. var scene = this.getScene();
  60181. if (scene && !scene.isReady()) {
  60182. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  60183. }
  60184. var serializationObject = _super.prototype.serialize.call(this);
  60185. serializationObject.base64String = this._canvas.toDataURL();
  60186. serializationObject.invertY = this._invertY;
  60187. serializationObject.samplingMode = this.samplingMode;
  60188. return serializationObject;
  60189. };
  60190. /** @hidden */
  60191. DynamicTexture.prototype._rebuild = function () {
  60192. this.update();
  60193. };
  60194. return DynamicTexture;
  60195. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  60196. /***/ }),
  60197. /***/ "./Materials/Textures/equiRectangularCubeTexture.ts":
  60198. /*!**********************************************************!*\
  60199. !*** ./Materials/Textures/equiRectangularCubeTexture.ts ***!
  60200. \**********************************************************/
  60201. /*! exports provided: EquiRectangularCubeTexture */
  60202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60203. "use strict";
  60204. __webpack_require__.r(__webpack_exports__);
  60205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return EquiRectangularCubeTexture; });
  60206. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60207. /* harmony import */ var _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  60208. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  60209. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  60210. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  60211. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  60212. /* harmony import */ var _Engines_Extensions_engine_rawTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/Extensions/engine.rawTexture */ "./Engines/Extensions/engine.rawTexture.ts");
  60213. /**
  60214. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60215. */
  60216. var EquiRectangularCubeTexture = /** @class */ (function (_super) {
  60217. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](EquiRectangularCubeTexture, _super);
  60218. /**
  60219. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60220. * @param url The location of the image
  60221. * @param scene The scene the texture will be used in
  60222. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60223. * @param noMipmap Forces to not generate the mipmap if true
  60224. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60225. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60226. * @param onLoad — defines a callback called when texture is loaded
  60227. * @param onError — defines a callback called if there is an error
  60228. */
  60229. function EquiRectangularCubeTexture(url, scene, size, noMipmap, gammaSpace, onLoad, onError) {
  60230. if (noMipmap === void 0) { noMipmap = false; }
  60231. if (gammaSpace === void 0) { gammaSpace = true; }
  60232. if (onLoad === void 0) { onLoad = null; }
  60233. if (onError === void 0) { onError = null; }
  60234. var _this = _super.call(this, scene) || this;
  60235. _this._onLoad = null;
  60236. _this._onError = null;
  60237. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60238. _this.coordinatesMode = _texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  60239. if (!url) {
  60240. throw new Error('Image url is not set');
  60241. }
  60242. _this.name = url;
  60243. _this.url = url;
  60244. _this._size = size;
  60245. _this._noMipmap = noMipmap;
  60246. _this.gammaSpace = gammaSpace;
  60247. _this._onLoad = onLoad;
  60248. _this._onError = onError;
  60249. _this.hasAlpha = false;
  60250. _this.isCube = true;
  60251. _this._texture = _this._getFromCache(url, _this._noMipmap);
  60252. if (!_this._texture) {
  60253. if (!scene.useDelayedTextureLoading) {
  60254. _this.loadImage(_this.loadTexture.bind(_this), _this._onError);
  60255. }
  60256. else {
  60257. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  60258. }
  60259. }
  60260. else if (onLoad) {
  60261. if (_this._texture.isReady) {
  60262. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].SetImmediate(function () { return onLoad(); });
  60263. }
  60264. else {
  60265. _this._texture.onLoadedObservable.add(onLoad);
  60266. }
  60267. }
  60268. return _this;
  60269. }
  60270. /**
  60271. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60272. */
  60273. EquiRectangularCubeTexture.prototype.loadImage = function (loadTextureCallback, onError) {
  60274. var _this = this;
  60275. var canvas = document.createElement('canvas');
  60276. var image = new Image();
  60277. image.addEventListener('load', function () {
  60278. _this._width = image.width;
  60279. _this._height = image.height;
  60280. canvas.width = _this._width;
  60281. canvas.height = _this._height;
  60282. var ctx = canvas.getContext('2d');
  60283. ctx.drawImage(image, 0, 0);
  60284. var imageData = ctx.getImageData(0, 0, image.width, image.height);
  60285. _this._buffer = imageData.data.buffer;
  60286. canvas.remove();
  60287. loadTextureCallback();
  60288. });
  60289. image.addEventListener('error', function (error) {
  60290. if (onError) {
  60291. onError(_this.getClassName() + " could not be loaded", error);
  60292. }
  60293. });
  60294. image.src = this.url;
  60295. };
  60296. /**
  60297. * Convert the image buffer into a cubemap and create a CubeTexture.
  60298. */
  60299. EquiRectangularCubeTexture.prototype.loadTexture = function () {
  60300. var _this = this;
  60301. var scene = this.getScene();
  60302. var callback = function () {
  60303. var imageData = _this.getFloat32ArrayFromArrayBuffer(_this._buffer);
  60304. // Extract the raw linear data.
  60305. var data = _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(imageData, _this._width, _this._height, _this._size);
  60306. var results = [];
  60307. // Push each faces.
  60308. for (var i = 0; i < 6; i++) {
  60309. var dataFace = data[EquiRectangularCubeTexture._FacesMapping[i]];
  60310. results.push(dataFace);
  60311. }
  60312. return results;
  60313. };
  60314. if (!scene) {
  60315. return;
  60316. }
  60317. this._texture = scene
  60318. .getEngine()
  60319. .createRawCubeTextureFromUrl(this.url, scene, this._size, _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat
  60320. ? _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_FLOAT
  60321. : _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_UNSIGNED_INTEGER, this._noMipmap, callback, null, this._onLoad, this._onError);
  60322. };
  60323. /**
  60324. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60325. * @param buffer The ArrayBuffer that should be converted.
  60326. * @returns The buffer as Float32Array.
  60327. */
  60328. EquiRectangularCubeTexture.prototype.getFloat32ArrayFromArrayBuffer = function (buffer) {
  60329. var dataView = new DataView(buffer);
  60330. var floatImageData = new Float32Array((buffer.byteLength * 3) / 4);
  60331. var k = 0;
  60332. for (var i = 0; i < buffer.byteLength; i++) {
  60333. // We drop the transparency channel, because we do not need/want it
  60334. if ((i + 1) % 4 !== 0) {
  60335. floatImageData[k++] = dataView.getUint8(i) / 255;
  60336. }
  60337. }
  60338. return floatImageData;
  60339. };
  60340. /**
  60341. * Get the current class name of the texture useful for serialization or dynamic coding.
  60342. * @returns "EquiRectangularCubeTexture"
  60343. */
  60344. EquiRectangularCubeTexture.prototype.getClassName = function () {
  60345. return "EquiRectangularCubeTexture";
  60346. };
  60347. /**
  60348. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60349. * @returns A clone of the current EquiRectangularCubeTexture.
  60350. */
  60351. EquiRectangularCubeTexture.prototype.clone = function () {
  60352. var scene = this.getScene();
  60353. if (!scene) {
  60354. return this;
  60355. }
  60356. var newTexture = new EquiRectangularCubeTexture(this.url, scene, this._size, this._noMipmap, this.gammaSpace);
  60357. // Base texture
  60358. newTexture.level = this.level;
  60359. newTexture.wrapU = this.wrapU;
  60360. newTexture.wrapV = this.wrapV;
  60361. newTexture.coordinatesIndex = this.coordinatesIndex;
  60362. newTexture.coordinatesMode = this.coordinatesMode;
  60363. return newTexture;
  60364. };
  60365. /** The six faces of the cube. */
  60366. EquiRectangularCubeTexture._FacesMapping = ['right', 'left', 'up', 'down', 'front', 'back'];
  60367. return EquiRectangularCubeTexture;
  60368. }(_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  60369. /***/ }),
  60370. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  60371. /*!**********************************************!*\
  60372. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  60373. \**********************************************/
  60374. /*! exports provided: HDRCubeTexture */
  60375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60376. "use strict";
  60377. __webpack_require__.r(__webpack_exports__);
  60378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  60379. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60380. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  60381. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  60382. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  60383. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60384. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60385. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  60386. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  60387. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  60388. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  60389. /* harmony import */ var _Engines_Extensions_engine_rawTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/Extensions/engine.rawTexture */ "./Engines/Extensions/engine.rawTexture.ts");
  60390. /**
  60391. * This represents a texture coming from an HDR input.
  60392. *
  60393. * The only supported format is currently panorama picture stored in RGBE format.
  60394. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60395. */
  60396. var HDRCubeTexture = /** @class */ (function (_super) {
  60397. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  60398. /**
  60399. * Instantiates an HDRTexture from the following parameters.
  60400. *
  60401. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60402. * @param scene The scene the texture will be used in
  60403. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60404. * @param noMipmap Forces to not generate the mipmap if true
  60405. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60406. * @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)
  60407. * @param reserved Reserved flag for internal use.
  60408. */
  60409. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  60410. if (noMipmap === void 0) { noMipmap = false; }
  60411. if (generateHarmonics === void 0) { generateHarmonics = true; }
  60412. if (gammaSpace === void 0) { gammaSpace = false; }
  60413. if (reserved === void 0) { reserved = false; }
  60414. if (onLoad === void 0) { onLoad = null; }
  60415. if (onError === void 0) { onError = null; }
  60416. var _this = _super.call(this, scene) || this;
  60417. _this._generateHarmonics = true;
  60418. _this._onLoad = null;
  60419. _this._onError = null;
  60420. /**
  60421. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  60422. */
  60423. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  60424. _this._isBlocking = true;
  60425. _this._rotationY = 0;
  60426. /**
  60427. * Gets or sets the center of the bounding box associated with the cube texture
  60428. * It must define where the camera used to render the texture was set
  60429. */
  60430. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  60431. if (!url) {
  60432. return _this;
  60433. }
  60434. _this.name = url;
  60435. _this.url = url;
  60436. _this.hasAlpha = false;
  60437. _this.isCube = true;
  60438. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  60439. _this._onLoad = onLoad;
  60440. _this._onError = onError;
  60441. _this.gammaSpace = gammaSpace;
  60442. _this._noMipmap = noMipmap;
  60443. _this._size = size;
  60444. _this._texture = _this._getFromCache(url, _this._noMipmap);
  60445. if (!_this._texture) {
  60446. if (!scene.useDelayedTextureLoading) {
  60447. _this.loadTexture();
  60448. }
  60449. else {
  60450. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  60451. }
  60452. }
  60453. else if (onLoad) {
  60454. if (_this._texture.isReady) {
  60455. _Misc_tools__WEBPACK_IMPORTED_MODULE_9__["Tools"].SetImmediate(function () { return onLoad(); });
  60456. }
  60457. else {
  60458. _this._texture.onLoadedObservable.add(onLoad);
  60459. }
  60460. }
  60461. return _this;
  60462. }
  60463. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  60464. /**
  60465. * Gets wether or not the texture is blocking during loading.
  60466. */
  60467. get: function () {
  60468. return this._isBlocking;
  60469. },
  60470. /**
  60471. * Sets wether or not the texture is blocking during loading.
  60472. */
  60473. set: function (value) {
  60474. this._isBlocking = value;
  60475. },
  60476. enumerable: true,
  60477. configurable: true
  60478. });
  60479. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  60480. /**
  60481. * Gets texture matrix rotation angle around Y axis radians.
  60482. */
  60483. get: function () {
  60484. return this._rotationY;
  60485. },
  60486. /**
  60487. * Sets texture matrix rotation angle around Y axis in radians.
  60488. */
  60489. set: function (value) {
  60490. this._rotationY = value;
  60491. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  60492. },
  60493. enumerable: true,
  60494. configurable: true
  60495. });
  60496. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  60497. get: function () {
  60498. return this._boundingBoxSize;
  60499. },
  60500. /**
  60501. * Gets or sets the size of the bounding box associated with the cube texture
  60502. * When defined, the cubemap will switch to local mode
  60503. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60504. * @example https://www.babylonjs-playground.com/#RNASML
  60505. */
  60506. set: function (value) {
  60507. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  60508. return;
  60509. }
  60510. this._boundingBoxSize = value;
  60511. var scene = this.getScene();
  60512. if (scene) {
  60513. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  60514. }
  60515. },
  60516. enumerable: true,
  60517. configurable: true
  60518. });
  60519. /**
  60520. * Get the current class name of the texture useful for serialization or dynamic coding.
  60521. * @returns "HDRCubeTexture"
  60522. */
  60523. HDRCubeTexture.prototype.getClassName = function () {
  60524. return "HDRCubeTexture";
  60525. };
  60526. /**
  60527. * Occurs when the file is raw .hdr file.
  60528. */
  60529. HDRCubeTexture.prototype.loadTexture = function () {
  60530. var _this = this;
  60531. var callback = function (buffer) {
  60532. _this.lodGenerationOffset = 0.0;
  60533. _this.lodGenerationScale = 0.8;
  60534. var scene = _this.getScene();
  60535. if (!scene) {
  60536. return null;
  60537. }
  60538. // Extract the raw linear data.
  60539. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  60540. // Generate harmonics if needed.
  60541. if (_this._generateHarmonics) {
  60542. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  60543. _this.sphericalPolynomial = sphericalPolynomial;
  60544. }
  60545. var results = [];
  60546. var byteArray = null;
  60547. // Push each faces.
  60548. for (var j = 0; j < 6; j++) {
  60549. // Create uintarray fallback.
  60550. if (!scene.getEngine().getCaps().textureFloat) {
  60551. // 3 channels of 1 bytes per pixel in bytes.
  60552. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  60553. byteArray = new Uint8Array(byteBuffer);
  60554. }
  60555. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  60556. // If special cases.
  60557. if (_this.gammaSpace || byteArray) {
  60558. for (var i = 0; i < _this._size * _this._size; i++) {
  60559. // Put in gamma space if requested.
  60560. if (_this.gammaSpace) {
  60561. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  60562. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  60563. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  60564. }
  60565. // Convert to int texture for fallback.
  60566. if (byteArray) {
  60567. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  60568. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  60569. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  60570. // May use luminance instead if the result is not accurate.
  60571. var max = Math.max(Math.max(r, g), b);
  60572. if (max > 255) {
  60573. var scale = 255 / max;
  60574. r *= scale;
  60575. g *= scale;
  60576. b *= scale;
  60577. }
  60578. byteArray[(i * 3) + 0] = r;
  60579. byteArray[(i * 3) + 1] = g;
  60580. byteArray[(i * 3) + 2] = b;
  60581. }
  60582. }
  60583. }
  60584. if (byteArray) {
  60585. results.push(byteArray);
  60586. }
  60587. else {
  60588. results.push(dataFace);
  60589. }
  60590. }
  60591. return results;
  60592. };
  60593. var scene = this.getScene();
  60594. if (scene) {
  60595. 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);
  60596. }
  60597. };
  60598. HDRCubeTexture.prototype.clone = function () {
  60599. var scene = this.getScene();
  60600. if (!scene) {
  60601. return this;
  60602. }
  60603. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  60604. // Base texture
  60605. newTexture.level = this.level;
  60606. newTexture.wrapU = this.wrapU;
  60607. newTexture.wrapV = this.wrapV;
  60608. newTexture.coordinatesIndex = this.coordinatesIndex;
  60609. newTexture.coordinatesMode = this.coordinatesMode;
  60610. return newTexture;
  60611. };
  60612. // Methods
  60613. HDRCubeTexture.prototype.delayLoad = function () {
  60614. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  60615. return;
  60616. }
  60617. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  60618. this._texture = this._getFromCache(this.url, this._noMipmap);
  60619. if (!this._texture) {
  60620. this.loadTexture();
  60621. }
  60622. };
  60623. /**
  60624. * Get the texture reflection matrix used to rotate/transform the reflection.
  60625. * @returns the reflection matrix
  60626. */
  60627. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  60628. return this._textureMatrix;
  60629. };
  60630. /**
  60631. * Set the texture reflection matrix used to rotate/transform the reflection.
  60632. * @param value Define the reflection matrix to set
  60633. */
  60634. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  60635. var _this = this;
  60636. this._textureMatrix = value;
  60637. if (value.updateFlag === this._textureMatrix.updateFlag) {
  60638. return;
  60639. }
  60640. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  60641. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  60642. }
  60643. };
  60644. /**
  60645. * Parses a JSON representation of an HDR Texture in order to create the texture
  60646. * @param parsedTexture Define the JSON representation
  60647. * @param scene Define the scene the texture should be created in
  60648. * @param rootUrl Define the root url in case we need to load relative dependencies
  60649. * @returns the newly created texture after parsing
  60650. */
  60651. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  60652. var texture = null;
  60653. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  60654. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  60655. texture.name = parsedTexture.name;
  60656. texture.hasAlpha = parsedTexture.hasAlpha;
  60657. texture.level = parsedTexture.level;
  60658. texture.coordinatesMode = parsedTexture.coordinatesMode;
  60659. texture.isBlocking = parsedTexture.isBlocking;
  60660. }
  60661. if (texture) {
  60662. if (parsedTexture.boundingBoxPosition) {
  60663. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  60664. }
  60665. if (parsedTexture.boundingBoxSize) {
  60666. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  60667. }
  60668. if (parsedTexture.rotationY) {
  60669. texture.rotationY = parsedTexture.rotationY;
  60670. }
  60671. }
  60672. return texture;
  60673. };
  60674. HDRCubeTexture.prototype.serialize = function () {
  60675. if (!this.name) {
  60676. return null;
  60677. }
  60678. var serializationObject = {};
  60679. serializationObject.name = this.name;
  60680. serializationObject.hasAlpha = this.hasAlpha;
  60681. serializationObject.isCube = true;
  60682. serializationObject.level = this.level;
  60683. serializationObject.size = this._size;
  60684. serializationObject.coordinatesMode = this.coordinatesMode;
  60685. serializationObject.useInGammaSpace = this.gammaSpace;
  60686. serializationObject.generateHarmonics = this._generateHarmonics;
  60687. serializationObject.customType = "BABYLON.HDRCubeTexture";
  60688. serializationObject.noMipmap = this._noMipmap;
  60689. serializationObject.isBlocking = this._isBlocking;
  60690. serializationObject.rotationY = this._rotationY;
  60691. return serializationObject;
  60692. };
  60693. HDRCubeTexture._facesMapping = [
  60694. "right",
  60695. "left",
  60696. "up",
  60697. "down",
  60698. "front",
  60699. "back"
  60700. ];
  60701. return HDRCubeTexture;
  60702. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  60703. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  60704. /***/ }),
  60705. /***/ "./Materials/Textures/htmlElementTexture.ts":
  60706. /*!**************************************************!*\
  60707. !*** ./Materials/Textures/htmlElementTexture.ts ***!
  60708. \**************************************************/
  60709. /*! exports provided: HtmlElementTexture */
  60710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60711. "use strict";
  60712. __webpack_require__.r(__webpack_exports__);
  60713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HtmlElementTexture", function() { return HtmlElementTexture; });
  60714. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60715. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  60716. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60717. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  60718. /**
  60719. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60720. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60721. * is automatically managed.
  60722. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60723. * in your application.
  60724. *
  60725. * As the update is not automatic, you need to call them manually.
  60726. */
  60727. var HtmlElementTexture = /** @class */ (function (_super) {
  60728. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HtmlElementTexture, _super);
  60729. /**
  60730. * Instantiates a HtmlElementTexture from the following parameters.
  60731. *
  60732. * @param name Defines the name of the texture
  60733. * @param element Defines the video or canvas the texture is filled with
  60734. * @param options Defines the other none mandatory texture creation options
  60735. */
  60736. function HtmlElementTexture(name, element, options) {
  60737. var _this = _super.call(this, options.scene) || this;
  60738. if (!element || (!options.engine && !options.scene)) {
  60739. return _this;
  60740. }
  60741. options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, HtmlElementTexture.DefaultOptions, options);
  60742. _this._engine = options.engine || options.scene.getEngine();
  60743. _this._generateMipMaps = options.generateMipMaps;
  60744. _this._samplingMode = options.samplingMode;
  60745. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  60746. _this.name = name;
  60747. _this.element = element;
  60748. _this._isVideo = (element instanceof HTMLVideoElement);
  60749. _this.anisotropicFilteringLevel = 1;
  60750. _this._createInternalTexture();
  60751. return _this;
  60752. }
  60753. HtmlElementTexture.prototype._createInternalTexture = function () {
  60754. var width = 0;
  60755. var height = 0;
  60756. if (this._isVideo) {
  60757. width = this.element.videoWidth;
  60758. height = this.element.videoHeight;
  60759. }
  60760. else {
  60761. width = this.element.width;
  60762. height = this.element.height;
  60763. }
  60764. this._texture = this._engine.createDynamicTexture(width, height, this._generateMipMaps, this._samplingMode);
  60765. this.update();
  60766. };
  60767. /**
  60768. * Returns the texture matrix used in most of the material.
  60769. */
  60770. HtmlElementTexture.prototype.getTextureMatrix = function () {
  60771. return this._textureMatrix;
  60772. };
  60773. /**
  60774. * Updates the content of the texture.
  60775. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60776. */
  60777. HtmlElementTexture.prototype.update = function (invertY) {
  60778. if (invertY === void 0) { invertY = null; }
  60779. if (this._texture == null) {
  60780. return;
  60781. }
  60782. if (this._isVideo) {
  60783. var videoElement = this.element;
  60784. if (videoElement.readyState < videoElement.HAVE_CURRENT_DATA) {
  60785. return;
  60786. }
  60787. this._engine.updateVideoTexture(this._texture, videoElement, invertY === null ? true : invertY);
  60788. }
  60789. else {
  60790. var canvasElement = this.element;
  60791. this._engine.updateDynamicTexture(this._texture, canvasElement, invertY === null ? true : invertY, false);
  60792. }
  60793. };
  60794. HtmlElementTexture.DefaultOptions = {
  60795. generateMipMaps: false,
  60796. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  60797. engine: null,
  60798. scene: null
  60799. };
  60800. return HtmlElementTexture;
  60801. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_1__["BaseTexture"]));
  60802. /***/ }),
  60803. /***/ "./Materials/Textures/index.ts":
  60804. /*!*************************************!*\
  60805. !*** ./Materials/Textures/index.ts ***!
  60806. \*************************************/
  60807. /*! exports provided: BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, MultiRenderTarget, RenderTargetTexture, Texture, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, HtmlElementTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  60808. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60809. "use strict";
  60810. __webpack_require__.r(__webpack_exports__);
  60811. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  60812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  60813. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  60814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  60815. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  60816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  60817. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  60818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  60819. /* harmony import */ var _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./equiRectangularCubeTexture */ "./Materials/Textures/equiRectangularCubeTexture.ts");
  60820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__["EquiRectangularCubeTexture"]; });
  60821. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  60822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__["HDRCubeTexture"]; });
  60823. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  60824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_6__["InternalTexture"]; });
  60825. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  60826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  60827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  60828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  60829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  60830. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  60831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  60832. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  60833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  60834. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  60835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  60836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  60837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  60838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  60839. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  60840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  60841. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  60842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  60843. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  60844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  60845. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  60846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  60847. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  60848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  60849. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  60850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  60851. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  60852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  60853. /* harmony import */ var _htmlElementTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./htmlElementTexture */ "./Materials/Textures/htmlElementTexture.ts");
  60854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HtmlElementTexture", function() { return _htmlElementTexture__WEBPACK_IMPORTED_MODULE_18__["HtmlElementTexture"]; });
  60855. /***/ }),
  60856. /***/ "./Materials/Textures/internalTexture.ts":
  60857. /*!***********************************************!*\
  60858. !*** ./Materials/Textures/internalTexture.ts ***!
  60859. \***********************************************/
  60860. /*! exports provided: InternalTexture */
  60861. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60862. "use strict";
  60863. __webpack_require__.r(__webpack_exports__);
  60864. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  60865. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  60866. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  60867. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60868. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  60869. /**
  60870. * Class used to store data associated with WebGL texture data for the engine
  60871. * This class should not be used directly
  60872. */
  60873. var InternalTexture = /** @class */ (function () {
  60874. /**
  60875. * Creates a new InternalTexture
  60876. * @param engine defines the engine to use
  60877. * @param dataSource defines the type of data that will be used
  60878. * @param delayAllocation if the texture allocation should be delayed (default: false)
  60879. */
  60880. function InternalTexture(engine, dataSource, delayAllocation) {
  60881. if (delayAllocation === void 0) { delayAllocation = false; }
  60882. /**
  60883. * Defines if the texture is ready
  60884. */
  60885. this.isReady = false;
  60886. /**
  60887. * Defines if the texture is a cube texture
  60888. */
  60889. this.isCube = false;
  60890. /**
  60891. * Defines if the texture contains 3D data
  60892. */
  60893. this.is3D = false;
  60894. /**
  60895. * Defines if the texture contains multiview data
  60896. */
  60897. this.isMultiview = false;
  60898. /**
  60899. * Gets the URL used to load this texture
  60900. */
  60901. this.url = "";
  60902. /**
  60903. * Gets the sampling mode of the texture
  60904. */
  60905. this.samplingMode = -1;
  60906. /**
  60907. * Gets a boolean indicating if the texture needs mipmaps generation
  60908. */
  60909. this.generateMipMaps = false;
  60910. /**
  60911. * Gets the number of samples used by the texture (WebGL2+ only)
  60912. */
  60913. this.samples = 0;
  60914. /**
  60915. * Gets the type of the texture (int, float...)
  60916. */
  60917. this.type = -1;
  60918. /**
  60919. * Gets the format of the texture (RGB, RGBA...)
  60920. */
  60921. this.format = -1;
  60922. /**
  60923. * Observable called when the texture is loaded
  60924. */
  60925. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60926. /**
  60927. * Gets the width of the texture
  60928. */
  60929. this.width = 0;
  60930. /**
  60931. * Gets the height of the texture
  60932. */
  60933. this.height = 0;
  60934. /**
  60935. * Gets the depth of the texture
  60936. */
  60937. this.depth = 0;
  60938. /**
  60939. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  60940. */
  60941. this.baseWidth = 0;
  60942. /**
  60943. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  60944. */
  60945. this.baseHeight = 0;
  60946. /**
  60947. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  60948. */
  60949. this.baseDepth = 0;
  60950. /**
  60951. * Gets a boolean indicating if the texture is inverted on Y axis
  60952. */
  60953. this.invertY = false;
  60954. // Private
  60955. /** @hidden */
  60956. this._invertVScale = false;
  60957. /** @hidden */
  60958. this._associatedChannel = -1;
  60959. /** @hidden */
  60960. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  60961. /** @hidden */
  60962. this._buffer = null;
  60963. /** @hidden */
  60964. this._bufferView = null;
  60965. /** @hidden */
  60966. this._bufferViewArray = null;
  60967. /** @hidden */
  60968. this._bufferViewArrayArray = null;
  60969. /** @hidden */
  60970. this._size = 0;
  60971. /** @hidden */
  60972. this._extension = "";
  60973. /** @hidden */
  60974. this._files = null;
  60975. /** @hidden */
  60976. this._workingCanvas = null;
  60977. /** @hidden */
  60978. this._workingContext = null;
  60979. /** @hidden */
  60980. this._framebuffer = null;
  60981. /** @hidden */
  60982. this._depthStencilBuffer = null;
  60983. /** @hidden */
  60984. this._MSAAFramebuffer = null;
  60985. /** @hidden */
  60986. this._MSAARenderBuffer = null;
  60987. /** @hidden */
  60988. this._attachments = null;
  60989. /** @hidden */
  60990. this._cachedCoordinatesMode = null;
  60991. /** @hidden */
  60992. this._cachedWrapU = null;
  60993. /** @hidden */
  60994. this._cachedWrapV = null;
  60995. /** @hidden */
  60996. this._cachedWrapR = null;
  60997. /** @hidden */
  60998. this._cachedAnisotropicFilteringLevel = null;
  60999. /** @hidden */
  61000. this._isDisabled = false;
  61001. /** @hidden */
  61002. this._compression = null;
  61003. /** @hidden */
  61004. this._generateStencilBuffer = false;
  61005. /** @hidden */
  61006. this._generateDepthBuffer = false;
  61007. /** @hidden */
  61008. this._comparisonFunction = 0;
  61009. /** @hidden */
  61010. this._sphericalPolynomial = null;
  61011. /** @hidden */
  61012. this._lodGenerationScale = 0;
  61013. /** @hidden */
  61014. this._lodGenerationOffset = 0;
  61015. // Multiview
  61016. /** @hidden */
  61017. this._colorTextureArray = null;
  61018. /** @hidden */
  61019. this._depthStencilTextureArray = null;
  61020. // The following three fields helps sharing generated fixed LODs for texture filtering
  61021. // In environment not supporting the textureLOD extension like EDGE. They are for internal use only.
  61022. // They are at the level of the gl texture to benefit from the cache.
  61023. /** @hidden */
  61024. this._lodTextureHigh = null;
  61025. /** @hidden */
  61026. this._lodTextureMid = null;
  61027. /** @hidden */
  61028. this._lodTextureLow = null;
  61029. /** @hidden */
  61030. this._isRGBD = false;
  61031. /** @hidden */
  61032. this._webGLTexture = null;
  61033. /** @hidden */
  61034. this._references = 1;
  61035. this._engine = engine;
  61036. this._dataSource = dataSource;
  61037. if (!delayAllocation) {
  61038. this._webGLTexture = engine._createTexture();
  61039. }
  61040. }
  61041. /**
  61042. * Gets the Engine the texture belongs to.
  61043. * @returns The babylon engine
  61044. */
  61045. InternalTexture.prototype.getEngine = function () {
  61046. return this._engine;
  61047. };
  61048. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  61049. /**
  61050. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  61051. */
  61052. get: function () {
  61053. return this._dataSource;
  61054. },
  61055. enumerable: true,
  61056. configurable: true
  61057. });
  61058. /**
  61059. * Increments the number of references (ie. the number of Texture that point to it)
  61060. */
  61061. InternalTexture.prototype.incrementReferences = function () {
  61062. this._references++;
  61063. };
  61064. /**
  61065. * Change the size of the texture (not the size of the content)
  61066. * @param width defines the new width
  61067. * @param height defines the new height
  61068. * @param depth defines the new depth (1 by default)
  61069. */
  61070. InternalTexture.prototype.updateSize = function (width, height, depth) {
  61071. if (depth === void 0) { depth = 1; }
  61072. this.width = width;
  61073. this.height = height;
  61074. this.depth = depth;
  61075. this.baseWidth = width;
  61076. this.baseHeight = height;
  61077. this.baseDepth = depth;
  61078. this._size = width * height * depth;
  61079. };
  61080. /** @hidden */
  61081. InternalTexture.prototype._rebuild = function () {
  61082. var _this = this;
  61083. var proxy;
  61084. this.isReady = false;
  61085. this._cachedCoordinatesMode = null;
  61086. this._cachedWrapU = null;
  61087. this._cachedWrapV = null;
  61088. this._cachedAnisotropicFilteringLevel = null;
  61089. switch (this._dataSource) {
  61090. case InternalTexture.DATASOURCE_TEMP:
  61091. return;
  61092. case InternalTexture.DATASOURCE_URL:
  61093. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  61094. proxy._swapAndDie(_this);
  61095. _this.isReady = true;
  61096. }, null, this._buffer, undefined, this.format);
  61097. return;
  61098. case InternalTexture.DATASOURCE_RAW:
  61099. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  61100. proxy._swapAndDie(this);
  61101. this.isReady = true;
  61102. return;
  61103. case InternalTexture.DATASOURCE_RAW3D:
  61104. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  61105. proxy._swapAndDie(this);
  61106. this.isReady = true;
  61107. return;
  61108. case InternalTexture.DATASOURCE_DYNAMIC:
  61109. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  61110. proxy._swapAndDie(this);
  61111. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  61112. // The engine will make sure to update content so no need to flag it as isReady = true
  61113. return;
  61114. case InternalTexture.DATASOURCE_RENDERTARGET:
  61115. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  61116. options.generateDepthBuffer = this._generateDepthBuffer;
  61117. options.generateMipMaps = this.generateMipMaps;
  61118. options.generateStencilBuffer = this._generateStencilBuffer;
  61119. options.samplingMode = this.samplingMode;
  61120. options.type = this.type;
  61121. if (this.isCube) {
  61122. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  61123. }
  61124. else {
  61125. var size = {
  61126. width: this.width,
  61127. height: this.height
  61128. };
  61129. proxy = this._engine.createRenderTargetTexture(size, options);
  61130. }
  61131. proxy._swapAndDie(this);
  61132. this.isReady = true;
  61133. return;
  61134. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  61135. var depthTextureOptions = {
  61136. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  61137. comparisonFunction: this._comparisonFunction,
  61138. generateStencil: this._generateStencilBuffer,
  61139. isCube: this.isCube
  61140. };
  61141. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  61142. proxy._swapAndDie(this);
  61143. this.isReady = true;
  61144. return;
  61145. case InternalTexture.DATASOURCE_CUBE:
  61146. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  61147. proxy._swapAndDie(_this);
  61148. _this.isReady = true;
  61149. }, null, this.format, this._extension);
  61150. return;
  61151. case InternalTexture.DATASOURCE_CUBERAW:
  61152. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  61153. proxy._swapAndDie(this);
  61154. this.isReady = true;
  61155. return;
  61156. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  61157. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  61158. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  61159. proxy._swapAndDie(_this);
  61160. _this.isReady = true;
  61161. });
  61162. return;
  61163. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  61164. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  61165. if (proxy) {
  61166. proxy._swapAndDie(_this);
  61167. }
  61168. _this.isReady = true;
  61169. }, null, this.format, this._extension);
  61170. proxy._sphericalPolynomial = this._sphericalPolynomial;
  61171. return;
  61172. }
  61173. };
  61174. /** @hidden */
  61175. InternalTexture.prototype._swapAndDie = function (target) {
  61176. target._webGLTexture = this._webGLTexture;
  61177. target._isRGBD = this._isRGBD;
  61178. if (this._framebuffer) {
  61179. target._framebuffer = this._framebuffer;
  61180. }
  61181. if (this._depthStencilBuffer) {
  61182. target._depthStencilBuffer = this._depthStencilBuffer;
  61183. }
  61184. if (this._lodTextureHigh) {
  61185. if (target._lodTextureHigh) {
  61186. target._lodTextureHigh.dispose();
  61187. }
  61188. target._lodTextureHigh = this._lodTextureHigh;
  61189. }
  61190. if (this._lodTextureMid) {
  61191. if (target._lodTextureMid) {
  61192. target._lodTextureMid.dispose();
  61193. }
  61194. target._lodTextureMid = this._lodTextureMid;
  61195. }
  61196. if (this._lodTextureLow) {
  61197. if (target._lodTextureLow) {
  61198. target._lodTextureLow.dispose();
  61199. }
  61200. target._lodTextureLow = this._lodTextureLow;
  61201. }
  61202. var cache = this._engine.getLoadedTexturesCache();
  61203. var index = cache.indexOf(this);
  61204. if (index !== -1) {
  61205. cache.splice(index, 1);
  61206. }
  61207. };
  61208. /**
  61209. * Dispose the current allocated resources
  61210. */
  61211. InternalTexture.prototype.dispose = function () {
  61212. if (!this._webGLTexture) {
  61213. return;
  61214. }
  61215. this._references--;
  61216. if (this._references === 0) {
  61217. this._engine._releaseTexture(this);
  61218. this._webGLTexture = null;
  61219. }
  61220. };
  61221. /** hidden */
  61222. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  61223. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  61224. };
  61225. /**
  61226. * The source of the texture data is unknown
  61227. */
  61228. InternalTexture.DATASOURCE_UNKNOWN = 0;
  61229. /**
  61230. * Texture data comes from an URL
  61231. */
  61232. InternalTexture.DATASOURCE_URL = 1;
  61233. /**
  61234. * Texture data is only used for temporary storage
  61235. */
  61236. InternalTexture.DATASOURCE_TEMP = 2;
  61237. /**
  61238. * Texture data comes from raw data (ArrayBuffer)
  61239. */
  61240. InternalTexture.DATASOURCE_RAW = 3;
  61241. /**
  61242. * Texture content is dynamic (video or dynamic texture)
  61243. */
  61244. InternalTexture.DATASOURCE_DYNAMIC = 4;
  61245. /**
  61246. * Texture content is generated by rendering to it
  61247. */
  61248. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  61249. /**
  61250. * Texture content is part of a multi render target process
  61251. */
  61252. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  61253. /**
  61254. * Texture data comes from a cube data file
  61255. */
  61256. InternalTexture.DATASOURCE_CUBE = 7;
  61257. /**
  61258. * Texture data comes from a raw cube data
  61259. */
  61260. InternalTexture.DATASOURCE_CUBERAW = 8;
  61261. /**
  61262. * Texture data come from a prefiltered cube data file
  61263. */
  61264. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  61265. /**
  61266. * Texture content is raw 3D data
  61267. */
  61268. InternalTexture.DATASOURCE_RAW3D = 10;
  61269. /**
  61270. * Texture content is a depth texture
  61271. */
  61272. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  61273. /**
  61274. * Texture data comes from a raw cube data encoded with RGBD
  61275. */
  61276. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  61277. return InternalTexture;
  61278. }());
  61279. /***/ }),
  61280. /***/ "./Materials/Textures/mirrorTexture.ts":
  61281. /*!*********************************************!*\
  61282. !*** ./Materials/Textures/mirrorTexture.ts ***!
  61283. \*********************************************/
  61284. /*! exports provided: MirrorTexture */
  61285. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61286. "use strict";
  61287. __webpack_require__.r(__webpack_exports__);
  61288. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  61289. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61290. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  61291. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  61292. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  61293. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  61294. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  61295. /**
  61296. * Mirror texture can be used to simulate the view from a mirror in a scene.
  61297. * It will dynamically be rendered every frame to adapt to the camera point of view.
  61298. * You can then easily use it as a reflectionTexture on a flat surface.
  61299. * In case the surface is not a plane, please consider relying on reflection probes.
  61300. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  61301. */
  61302. var MirrorTexture = /** @class */ (function (_super) {
  61303. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  61304. /**
  61305. * Instantiates a Mirror Texture.
  61306. * Mirror texture can be used to simulate the view from a mirror in a scene.
  61307. * It will dynamically be rendered every frame to adapt to the camera point of view.
  61308. * You can then easily use it as a reflectionTexture on a flat surface.
  61309. * In case the surface is not a plane, please consider relying on reflection probes.
  61310. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  61311. * @param name
  61312. * @param size
  61313. * @param scene
  61314. * @param generateMipMaps
  61315. * @param type
  61316. * @param samplingMode
  61317. * @param generateDepthBuffer
  61318. */
  61319. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  61320. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  61321. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  61322. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  61323. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  61324. _this.scene = scene;
  61325. /**
  61326. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  61327. * 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.
  61328. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  61329. */
  61330. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  61331. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  61332. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  61333. _this._adaptiveBlurKernel = 0;
  61334. _this._blurKernelX = 0;
  61335. _this._blurKernelY = 0;
  61336. _this._blurRatio = 1.0;
  61337. _this.ignoreCameraViewport = true;
  61338. _this._updateGammaSpace();
  61339. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  61340. _this._updateGammaSpace;
  61341. });
  61342. _this.onBeforeRenderObservable.add(function () {
  61343. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  61344. _this._savedViewMatrix = scene.getViewMatrix();
  61345. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  61346. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  61347. scene.clipPlane = _this.mirrorPlane;
  61348. scene.getEngine().cullBackFaces = false;
  61349. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  61350. });
  61351. _this.onAfterRenderObservable.add(function () {
  61352. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  61353. scene.getEngine().cullBackFaces = true;
  61354. scene._mirroredCameraPosition = null;
  61355. scene.clipPlane = null;
  61356. });
  61357. return _this;
  61358. }
  61359. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  61360. get: function () {
  61361. return this._blurRatio;
  61362. },
  61363. /**
  61364. * Define the blur ratio used to blur the reflection if needed.
  61365. */
  61366. set: function (value) {
  61367. if (this._blurRatio === value) {
  61368. return;
  61369. }
  61370. this._blurRatio = value;
  61371. this._preparePostProcesses();
  61372. },
  61373. enumerable: true,
  61374. configurable: true
  61375. });
  61376. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  61377. /**
  61378. * Define the adaptive blur kernel used to blur the reflection if needed.
  61379. * This will autocompute the closest best match for the `blurKernel`
  61380. */
  61381. set: function (value) {
  61382. this._adaptiveBlurKernel = value;
  61383. this._autoComputeBlurKernel();
  61384. },
  61385. enumerable: true,
  61386. configurable: true
  61387. });
  61388. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  61389. /**
  61390. * Define the blur kernel used to blur the reflection if needed.
  61391. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  61392. */
  61393. set: function (value) {
  61394. this.blurKernelX = value;
  61395. this.blurKernelY = value;
  61396. },
  61397. enumerable: true,
  61398. configurable: true
  61399. });
  61400. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  61401. get: function () {
  61402. return this._blurKernelX;
  61403. },
  61404. /**
  61405. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  61406. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  61407. */
  61408. set: function (value) {
  61409. if (this._blurKernelX === value) {
  61410. return;
  61411. }
  61412. this._blurKernelX = value;
  61413. this._preparePostProcesses();
  61414. },
  61415. enumerable: true,
  61416. configurable: true
  61417. });
  61418. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  61419. get: function () {
  61420. return this._blurKernelY;
  61421. },
  61422. /**
  61423. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  61424. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  61425. */
  61426. set: function (value) {
  61427. if (this._blurKernelY === value) {
  61428. return;
  61429. }
  61430. this._blurKernelY = value;
  61431. this._preparePostProcesses();
  61432. },
  61433. enumerable: true,
  61434. configurable: true
  61435. });
  61436. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  61437. var engine = this.getScene().getEngine();
  61438. var dw = this.getRenderWidth() / engine.getRenderWidth();
  61439. var dh = this.getRenderHeight() / engine.getRenderHeight();
  61440. this.blurKernelX = this._adaptiveBlurKernel * dw;
  61441. this.blurKernelY = this._adaptiveBlurKernel * dh;
  61442. };
  61443. MirrorTexture.prototype._onRatioRescale = function () {
  61444. if (this._sizeRatio) {
  61445. this.resize(this._initialSizeParameter);
  61446. if (!this._adaptiveBlurKernel) {
  61447. this._preparePostProcesses();
  61448. }
  61449. }
  61450. if (this._adaptiveBlurKernel) {
  61451. this._autoComputeBlurKernel();
  61452. }
  61453. };
  61454. MirrorTexture.prototype._updateGammaSpace = function () {
  61455. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  61456. };
  61457. MirrorTexture.prototype._preparePostProcesses = function () {
  61458. this.clearPostProcesses(true);
  61459. if (this._blurKernelX && this._blurKernelY) {
  61460. var engine = this.getScene().getEngine();
  61461. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  61462. 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);
  61463. this._blurX.autoClear = false;
  61464. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  61465. this._blurX.inputTexture = this._texture;
  61466. }
  61467. else {
  61468. this._blurX.alwaysForcePOT = true;
  61469. }
  61470. 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);
  61471. this._blurY.autoClear = false;
  61472. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  61473. this.addPostProcess(this._blurX);
  61474. this.addPostProcess(this._blurY);
  61475. }
  61476. else {
  61477. if (this._blurY) {
  61478. this.removePostProcess(this._blurY);
  61479. this._blurY.dispose();
  61480. this._blurY = null;
  61481. }
  61482. if (this._blurX) {
  61483. this.removePostProcess(this._blurX);
  61484. this._blurX.dispose();
  61485. this._blurX = null;
  61486. }
  61487. }
  61488. };
  61489. /**
  61490. * Clone the mirror texture.
  61491. * @returns the cloned texture
  61492. */
  61493. MirrorTexture.prototype.clone = function () {
  61494. var scene = this.getScene();
  61495. if (!scene) {
  61496. return this;
  61497. }
  61498. var textureSize = this.getSize();
  61499. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  61500. // Base texture
  61501. newTexture.hasAlpha = this.hasAlpha;
  61502. newTexture.level = this.level;
  61503. // Mirror Texture
  61504. newTexture.mirrorPlane = this.mirrorPlane.clone();
  61505. if (this.renderList) {
  61506. newTexture.renderList = this.renderList.slice(0);
  61507. }
  61508. return newTexture;
  61509. };
  61510. /**
  61511. * Serialize the texture to a JSON representation you could use in Parse later on
  61512. * @returns the serialized JSON representation
  61513. */
  61514. MirrorTexture.prototype.serialize = function () {
  61515. if (!this.name) {
  61516. return null;
  61517. }
  61518. var serializationObject = _super.prototype.serialize.call(this);
  61519. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  61520. return serializationObject;
  61521. };
  61522. /**
  61523. * Dispose the texture and release its associated resources.
  61524. */
  61525. MirrorTexture.prototype.dispose = function () {
  61526. _super.prototype.dispose.call(this);
  61527. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  61528. };
  61529. return MirrorTexture;
  61530. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  61531. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  61532. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  61533. };
  61534. /***/ }),
  61535. /***/ "./Materials/Textures/multiRenderTarget.ts":
  61536. /*!*************************************************!*\
  61537. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  61538. \*************************************************/
  61539. /*! exports provided: MultiRenderTarget */
  61540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61541. "use strict";
  61542. __webpack_require__.r(__webpack_exports__);
  61543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  61544. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61545. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  61546. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  61547. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  61548. /* harmony import */ var _Engines_Extensions_engine_multiRender__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/Extensions/engine.multiRender */ "./Engines/Extensions/engine.multiRender.ts");
  61549. /**
  61550. * A multi render target, like a render target provides the ability to render to a texture.
  61551. * Unlike the render target, it can render to several draw buffers in one draw.
  61552. * This is specially interesting in deferred rendering or for any effects requiring more than
  61553. * just one color from a single pass.
  61554. */
  61555. var MultiRenderTarget = /** @class */ (function (_super) {
  61556. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  61557. /**
  61558. * Instantiate a new multi render target texture.
  61559. * A multi render target, like a render target provides the ability to render to a texture.
  61560. * Unlike the render target, it can render to several draw buffers in one draw.
  61561. * This is specially interesting in deferred rendering or for any effects requiring more than
  61562. * just one color from a single pass.
  61563. * @param name Define the name of the texture
  61564. * @param size Define the size of the buffers to render to
  61565. * @param count Define the number of target we are rendering into
  61566. * @param scene Define the scene the texture belongs to
  61567. * @param options Define the options used to create the multi render target
  61568. */
  61569. function MultiRenderTarget(name, size, count, scene, options) {
  61570. var _this = this;
  61571. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  61572. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  61573. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  61574. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  61575. _this._engine = scene.getEngine();
  61576. if (!_this.isSupported) {
  61577. _this.dispose();
  61578. return;
  61579. }
  61580. var types = [];
  61581. var samplingModes = [];
  61582. for (var i = 0; i < count; i++) {
  61583. if (options && options.types && options.types[i] !== undefined) {
  61584. types.push(options.types[i]);
  61585. }
  61586. else {
  61587. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  61588. }
  61589. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  61590. samplingModes.push(options.samplingModes[i]);
  61591. }
  61592. else {
  61593. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  61594. }
  61595. }
  61596. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  61597. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  61598. _this._size = size;
  61599. _this._multiRenderTargetOptions = {
  61600. samplingModes: samplingModes,
  61601. generateMipMaps: generateMipMaps,
  61602. generateDepthBuffer: generateDepthBuffer,
  61603. generateStencilBuffer: generateStencilBuffer,
  61604. generateDepthTexture: generateDepthTexture,
  61605. types: types,
  61606. textureCount: count
  61607. };
  61608. _this._createInternalTextures();
  61609. _this._createTextures();
  61610. return _this;
  61611. }
  61612. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  61613. /**
  61614. * Get if draw buffers are currently supported by the used hardware and browser.
  61615. */
  61616. get: function () {
  61617. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  61618. },
  61619. enumerable: true,
  61620. configurable: true
  61621. });
  61622. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  61623. /**
  61624. * Get the list of textures generated by the multi render target.
  61625. */
  61626. get: function () {
  61627. return this._textures;
  61628. },
  61629. enumerable: true,
  61630. configurable: true
  61631. });
  61632. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  61633. /**
  61634. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  61635. */
  61636. get: function () {
  61637. return this._textures[this._textures.length - 1];
  61638. },
  61639. enumerable: true,
  61640. configurable: true
  61641. });
  61642. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  61643. /**
  61644. * Set the wrapping mode on U of all the textures we are rendering to.
  61645. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  61646. */
  61647. set: function (wrap) {
  61648. if (this._textures) {
  61649. for (var i = 0; i < this._textures.length; i++) {
  61650. this._textures[i].wrapU = wrap;
  61651. }
  61652. }
  61653. },
  61654. enumerable: true,
  61655. configurable: true
  61656. });
  61657. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  61658. /**
  61659. * Set the wrapping mode on V of all the textures we are rendering to.
  61660. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  61661. */
  61662. set: function (wrap) {
  61663. if (this._textures) {
  61664. for (var i = 0; i < this._textures.length; i++) {
  61665. this._textures[i].wrapV = wrap;
  61666. }
  61667. }
  61668. },
  61669. enumerable: true,
  61670. configurable: true
  61671. });
  61672. /** @hidden */
  61673. MultiRenderTarget.prototype._rebuild = function () {
  61674. this.releaseInternalTextures();
  61675. this._createInternalTextures();
  61676. for (var i = 0; i < this._internalTextures.length; i++) {
  61677. var texture = this._textures[i];
  61678. texture._texture = this._internalTextures[i];
  61679. }
  61680. // Keeps references to frame buffer and stencil/depth buffer
  61681. this._texture = this._internalTextures[0];
  61682. };
  61683. MultiRenderTarget.prototype._createInternalTextures = function () {
  61684. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  61685. };
  61686. MultiRenderTarget.prototype._createTextures = function () {
  61687. this._textures = [];
  61688. for (var i = 0; i < this._internalTextures.length; i++) {
  61689. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  61690. texture._texture = this._internalTextures[i];
  61691. this._textures.push(texture);
  61692. }
  61693. // Keeps references to frame buffer and stencil/depth buffer
  61694. this._texture = this._internalTextures[0];
  61695. };
  61696. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  61697. /**
  61698. * Define the number of samples used if MSAA is enabled.
  61699. */
  61700. get: function () {
  61701. return this._samples;
  61702. },
  61703. set: function (value) {
  61704. if (this._samples === value) {
  61705. return;
  61706. }
  61707. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  61708. },
  61709. enumerable: true,
  61710. configurable: true
  61711. });
  61712. /**
  61713. * Resize all the textures in the multi render target.
  61714. * Be carrefull as it will recreate all the data in the new texture.
  61715. * @param size Define the new size
  61716. */
  61717. MultiRenderTarget.prototype.resize = function (size) {
  61718. this.releaseInternalTextures();
  61719. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  61720. this._createInternalTextures();
  61721. };
  61722. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  61723. var _this = this;
  61724. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  61725. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  61726. });
  61727. };
  61728. /**
  61729. * Dispose the render targets and their associated resources
  61730. */
  61731. MultiRenderTarget.prototype.dispose = function () {
  61732. this.releaseInternalTextures();
  61733. _super.prototype.dispose.call(this);
  61734. };
  61735. /**
  61736. * Release all the underlying texture used as draw buffers.
  61737. */
  61738. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  61739. if (!this._internalTextures) {
  61740. return;
  61741. }
  61742. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  61743. if (this._internalTextures[i] !== undefined) {
  61744. this._internalTextures[i].dispose();
  61745. this._internalTextures.splice(i, 1);
  61746. }
  61747. }
  61748. };
  61749. return MultiRenderTarget;
  61750. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  61751. /***/ }),
  61752. /***/ "./Materials/Textures/rawCubeTexture.ts":
  61753. /*!**********************************************!*\
  61754. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  61755. \**********************************************/
  61756. /*! exports provided: RawCubeTexture */
  61757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61758. "use strict";
  61759. __webpack_require__.r(__webpack_exports__);
  61760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  61761. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61762. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  61763. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  61764. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  61765. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  61766. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  61767. /* harmony import */ var _Engines_Extensions_engine_rawTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/Extensions/engine.rawTexture */ "./Engines/Extensions/engine.rawTexture.ts");
  61768. /**
  61769. * Raw cube texture where the raw buffers are passed in
  61770. */
  61771. var RawCubeTexture = /** @class */ (function (_super) {
  61772. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  61773. /**
  61774. * Creates a cube texture where the raw buffers are passed in.
  61775. * @param scene defines the scene the texture is attached to
  61776. * @param data defines the array of data to use to create each face
  61777. * @param size defines the size of the textures
  61778. * @param format defines the format of the data
  61779. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61780. * @param generateMipMaps defines if the engine should generate the mip levels
  61781. * @param invertY defines if data must be stored with Y axis inverted
  61782. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61783. * @param compression defines the compression used (null by default)
  61784. */
  61785. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  61786. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  61787. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  61788. if (generateMipMaps === void 0) { generateMipMaps = false; }
  61789. if (invertY === void 0) { invertY = false; }
  61790. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  61791. if (compression === void 0) { compression = null; }
  61792. var _this = _super.call(this, "", scene) || this;
  61793. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  61794. return _this;
  61795. }
  61796. /**
  61797. * Updates the raw cube texture.
  61798. * @param data defines the data to store
  61799. * @param format defines the data format
  61800. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61801. * @param invertY defines if data must be stored with Y axis inverted
  61802. * @param compression defines the compression used (null by default)
  61803. * @param level defines which level of the texture to update
  61804. */
  61805. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  61806. if (compression === void 0) { compression = null; }
  61807. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  61808. };
  61809. /**
  61810. * Updates a raw cube texture with RGBD encoded data.
  61811. * @param data defines the array of data [mipmap][face] to use to create each face
  61812. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61813. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61814. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61815. * @returns a promsie that resolves when the operation is complete
  61816. */
  61817. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  61818. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  61819. if (lodScale === void 0) { lodScale = 0.8; }
  61820. if (lodOffset === void 0) { lodOffset = 0; }
  61821. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  61822. };
  61823. /**
  61824. * Clones the raw cube texture.
  61825. * @return a new cube texture
  61826. */
  61827. RawCubeTexture.prototype.clone = function () {
  61828. var _this = this;
  61829. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  61830. var scene = _this.getScene();
  61831. var internalTexture = _this._texture;
  61832. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  61833. if (internalTexture.dataSource === _internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  61834. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  61835. }
  61836. return texture;
  61837. }, this);
  61838. };
  61839. /** @hidden */
  61840. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  61841. internalTexture._dataSource = _internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  61842. internalTexture._bufferViewArrayArray = data;
  61843. internalTexture._lodGenerationScale = lodScale;
  61844. internalTexture._lodGenerationOffset = lodOffset;
  61845. internalTexture._sphericalPolynomial = sphericalPolynomial;
  61846. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  61847. internalTexture.isReady = true;
  61848. });
  61849. };
  61850. return RawCubeTexture;
  61851. }(_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  61852. /***/ }),
  61853. /***/ "./Materials/Textures/rawTexture.ts":
  61854. /*!******************************************!*\
  61855. !*** ./Materials/Textures/rawTexture.ts ***!
  61856. \******************************************/
  61857. /*! exports provided: RawTexture */
  61858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61859. "use strict";
  61860. __webpack_require__.r(__webpack_exports__);
  61861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  61862. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61863. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  61864. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  61865. /* harmony import */ var _Engines_Extensions_engine_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/Extensions/engine.rawTexture */ "./Engines/Extensions/engine.rawTexture.ts");
  61866. /**
  61867. * Raw texture can help creating a texture directly from an array of data.
  61868. * This can be super useful if you either get the data from an uncompressed source or
  61869. * if you wish to create your texture pixel by pixel.
  61870. */
  61871. var RawTexture = /** @class */ (function (_super) {
  61872. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  61873. /**
  61874. * Instantiates a new RawTexture.
  61875. * Raw texture can help creating a texture directly from an array of data.
  61876. * This can be super useful if you either get the data from an uncompressed source or
  61877. * if you wish to create your texture pixel by pixel.
  61878. * @param data define the array of data to use to create the texture
  61879. * @param width define the width of the texture
  61880. * @param height define the height of the texture
  61881. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  61882. * @param scene define the scene the texture belongs to
  61883. * @param generateMipMaps define whether mip maps should be generated or not
  61884. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  61885. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  61886. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  61887. */
  61888. function RawTexture(data, width, height,
  61889. /**
  61890. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  61891. */
  61892. format, scene, generateMipMaps, invertY, samplingMode, type) {
  61893. if (generateMipMaps === void 0) { generateMipMaps = true; }
  61894. if (invertY === void 0) { invertY = false; }
  61895. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  61896. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  61897. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  61898. _this.format = format;
  61899. _this._engine = scene.getEngine();
  61900. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  61901. _this.wrapU = _texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  61902. _this.wrapV = _texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  61903. return _this;
  61904. }
  61905. /**
  61906. * Updates the texture underlying data.
  61907. * @param data Define the new data of the texture
  61908. */
  61909. RawTexture.prototype.update = function (data) {
  61910. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, null, this._texture.type);
  61911. };
  61912. /**
  61913. * Creates a luminance texture from some data.
  61914. * @param data Define the texture data
  61915. * @param width Define the width of the texture
  61916. * @param height Define the height of the texture
  61917. * @param scene Define the scene the texture belongs to
  61918. * @param generateMipMaps Define whether or not to create mip maps for the texture
  61919. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  61920. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  61921. * @returns the luminance texture
  61922. */
  61923. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  61924. if (generateMipMaps === void 0) { generateMipMaps = true; }
  61925. if (invertY === void 0) { invertY = false; }
  61926. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  61927. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  61928. };
  61929. /**
  61930. * Creates a luminance alpha texture from some data.
  61931. * @param data Define the texture data
  61932. * @param width Define the width of the texture
  61933. * @param height Define the height of the texture
  61934. * @param scene Define the scene the texture belongs to
  61935. * @param generateMipMaps Define whether or not to create mip maps for the texture
  61936. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  61937. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  61938. * @returns the luminance alpha texture
  61939. */
  61940. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  61941. if (generateMipMaps === void 0) { generateMipMaps = true; }
  61942. if (invertY === void 0) { invertY = false; }
  61943. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  61944. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  61945. };
  61946. /**
  61947. * Creates an alpha texture from some data.
  61948. * @param data Define the texture data
  61949. * @param width Define the width of the texture
  61950. * @param height Define the height of the texture
  61951. * @param scene Define the scene the texture belongs to
  61952. * @param generateMipMaps Define whether or not to create mip maps for the texture
  61953. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  61954. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  61955. * @returns the alpha texture
  61956. */
  61957. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  61958. if (generateMipMaps === void 0) { generateMipMaps = true; }
  61959. if (invertY === void 0) { invertY = false; }
  61960. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  61961. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  61962. };
  61963. /**
  61964. * Creates a RGB texture from some data.
  61965. * @param data Define the texture data
  61966. * @param width Define the width of the texture
  61967. * @param height Define the height of the texture
  61968. * @param scene Define the scene the texture belongs to
  61969. * @param generateMipMaps Define whether or not to create mip maps for the texture
  61970. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  61971. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  61972. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  61973. * @returns the RGB alpha texture
  61974. */
  61975. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  61976. if (generateMipMaps === void 0) { generateMipMaps = true; }
  61977. if (invertY === void 0) { invertY = false; }
  61978. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  61979. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  61980. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  61981. };
  61982. /**
  61983. * Creates a RGBA texture from some data.
  61984. * @param data Define the texture data
  61985. * @param width Define the width of the texture
  61986. * @param height Define the height of the texture
  61987. * @param scene Define the scene the texture belongs to
  61988. * @param generateMipMaps Define whether or not to create mip maps for the texture
  61989. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  61990. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  61991. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  61992. * @returns the RGBA texture
  61993. */
  61994. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  61995. if (generateMipMaps === void 0) { generateMipMaps = true; }
  61996. if (invertY === void 0) { invertY = false; }
  61997. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  61998. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  61999. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  62000. };
  62001. /**
  62002. * Creates a R texture from some data.
  62003. * @param data Define the texture data
  62004. * @param width Define the width of the texture
  62005. * @param height Define the height of the texture
  62006. * @param scene Define the scene the texture belongs to
  62007. * @param generateMipMaps Define whether or not to create mip maps for the texture
  62008. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  62009. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  62010. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  62011. * @returns the R texture
  62012. */
  62013. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  62014. if (generateMipMaps === void 0) { generateMipMaps = true; }
  62015. if (invertY === void 0) { invertY = false; }
  62016. if (samplingMode === void 0) { samplingMode = _texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  62017. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  62018. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  62019. };
  62020. return RawTexture;
  62021. }(_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  62022. /***/ }),
  62023. /***/ "./Materials/Textures/rawTexture3D.ts":
  62024. /*!********************************************!*\
  62025. !*** ./Materials/Textures/rawTexture3D.ts ***!
  62026. \********************************************/
  62027. /*! exports provided: RawTexture3D */
  62028. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62029. "use strict";
  62030. __webpack_require__.r(__webpack_exports__);
  62031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  62032. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62033. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  62034. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  62035. /* harmony import */ var _Engines_Extensions_engine_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/Extensions/engine.rawTexture */ "./Engines/Extensions/engine.rawTexture.ts");
  62036. /**
  62037. * Class used to store 3D textures containing user data
  62038. */
  62039. var RawTexture3D = /** @class */ (function (_super) {
  62040. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  62041. /**
  62042. * Create a new RawTexture3D
  62043. * @param data defines the data of the texture
  62044. * @param width defines the width of the texture
  62045. * @param height defines the height of the texture
  62046. * @param depth defines the depth of the texture
  62047. * @param format defines the texture format to use
  62048. * @param scene defines the hosting scene
  62049. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62050. * @param invertY defines if texture must be stored with Y axis inverted
  62051. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62052. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62053. */
  62054. function RawTexture3D(data, width, height, depth,
  62055. /** Gets or sets the texture format to use */
  62056. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  62057. if (generateMipMaps === void 0) { generateMipMaps = true; }
  62058. if (invertY === void 0) { invertY = false; }
  62059. if (samplingMode === void 0) { samplingMode = _texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  62060. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  62061. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  62062. _this.format = format;
  62063. _this._engine = scene.getEngine();
  62064. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  62065. _this.is3D = true;
  62066. return _this;
  62067. }
  62068. /**
  62069. * Update the texture with new data
  62070. * @param data defines the data to store in the texture
  62071. */
  62072. RawTexture3D.prototype.update = function (data) {
  62073. if (!this._texture) {
  62074. return;
  62075. }
  62076. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, null, this._texture.type);
  62077. };
  62078. return RawTexture3D;
  62079. }(_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  62080. /***/ }),
  62081. /***/ "./Materials/Textures/refractionTexture.ts":
  62082. /*!*************************************************!*\
  62083. !*** ./Materials/Textures/refractionTexture.ts ***!
  62084. \*************************************************/
  62085. /*! exports provided: RefractionTexture */
  62086. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62087. "use strict";
  62088. __webpack_require__.r(__webpack_exports__);
  62089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  62090. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62091. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  62092. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  62093. /**
  62094. * Creates a refraction texture used by refraction channel of the standard material.
  62095. * It is like a mirror but to see through a material.
  62096. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62097. */
  62098. var RefractionTexture = /** @class */ (function (_super) {
  62099. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  62100. /**
  62101. * Creates a refraction texture used by refraction channel of the standard material.
  62102. * It is like a mirror but to see through a material.
  62103. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62104. * @param name Define the texture name
  62105. * @param size Define the size of the underlying texture
  62106. * @param scene Define the scene the refraction belongs to
  62107. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62108. */
  62109. function RefractionTexture(name, size, scene, generateMipMaps) {
  62110. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  62111. /**
  62112. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62113. * 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.
  62114. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62115. */
  62116. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  62117. /**
  62118. * Define how deep under the surface we should see.
  62119. */
  62120. _this.depth = 2.0;
  62121. _this.onBeforeRenderObservable.add(function () {
  62122. scene.clipPlane = _this.refractionPlane;
  62123. });
  62124. _this.onAfterRenderObservable.add(function () {
  62125. scene.clipPlane = null;
  62126. });
  62127. return _this;
  62128. }
  62129. /**
  62130. * Clone the refraction texture.
  62131. * @returns the cloned texture
  62132. */
  62133. RefractionTexture.prototype.clone = function () {
  62134. var scene = this.getScene();
  62135. if (!scene) {
  62136. return this;
  62137. }
  62138. var textureSize = this.getSize();
  62139. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  62140. // Base texture
  62141. newTexture.hasAlpha = this.hasAlpha;
  62142. newTexture.level = this.level;
  62143. // Refraction Texture
  62144. newTexture.refractionPlane = this.refractionPlane.clone();
  62145. if (this.renderList) {
  62146. newTexture.renderList = this.renderList.slice(0);
  62147. }
  62148. newTexture.depth = this.depth;
  62149. return newTexture;
  62150. };
  62151. /**
  62152. * Serialize the texture to a JSON representation you could use in Parse later on
  62153. * @returns the serialized JSON representation
  62154. */
  62155. RefractionTexture.prototype.serialize = function () {
  62156. if (!this.name) {
  62157. return null;
  62158. }
  62159. var serializationObject = _super.prototype.serialize.call(this);
  62160. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  62161. serializationObject.depth = this.depth;
  62162. return serializationObject;
  62163. };
  62164. return RefractionTexture;
  62165. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  62166. /***/ }),
  62167. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  62168. /*!***********************************************************!*\
  62169. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  62170. \***********************************************************/
  62171. /*! exports provided: RenderTargetCreationOptions */
  62172. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62173. "use strict";
  62174. __webpack_require__.r(__webpack_exports__);
  62175. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  62176. /**
  62177. * Define options used to create a render target texture
  62178. */
  62179. var RenderTargetCreationOptions = /** @class */ (function () {
  62180. function RenderTargetCreationOptions() {
  62181. }
  62182. return RenderTargetCreationOptions;
  62183. }());
  62184. /***/ }),
  62185. /***/ "./Materials/Textures/renderTargetTexture.ts":
  62186. /*!***************************************************!*\
  62187. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  62188. \***************************************************/
  62189. /*! exports provided: RenderTargetTexture */
  62190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62191. "use strict";
  62192. __webpack_require__.r(__webpack_exports__);
  62193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  62194. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62195. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  62196. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  62197. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  62198. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  62199. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  62200. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  62201. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  62202. /* harmony import */ var _Engines_Extensions_engine_renderTarget__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Engines/Extensions/engine.renderTarget */ "./Engines/Extensions/engine.renderTarget.ts");
  62203. /**
  62204. * This Helps creating a texture that will be created from a camera in your scene.
  62205. * It is basically a dynamic texture that could be used to create special effects for instance.
  62206. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  62207. */
  62208. var RenderTargetTexture = /** @class */ (function (_super) {
  62209. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  62210. /**
  62211. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  62212. * or used a shadow, depth texture...
  62213. * @param name The friendly name of the texture
  62214. * @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)
  62215. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  62216. * @param generateMipMaps True if mip maps need to be generated after render.
  62217. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  62218. * @param type The type of the buffer in the RTT (int, half float, float...)
  62219. * @param isCube True if a cube texture needs to be created
  62220. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  62221. * @param generateDepthBuffer True to generate a depth buffer
  62222. * @param generateStencilBuffer True to generate a stencil buffer
  62223. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  62224. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  62225. * @param delayAllocation if the texture allocation should be delayed (default: false)
  62226. */
  62227. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  62228. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  62229. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  62230. if (isCube === void 0) { isCube = false; }
  62231. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  62232. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  62233. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  62234. if (isMulti === void 0) { isMulti = false; }
  62235. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  62236. if (delayAllocation === void 0) { delayAllocation = false; }
  62237. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  62238. _this.isCube = isCube;
  62239. /**
  62240. * Define if particles should be rendered in your texture.
  62241. */
  62242. _this.renderParticles = true;
  62243. /**
  62244. * Define if sprites should be rendered in your texture.
  62245. */
  62246. _this.renderSprites = false;
  62247. /**
  62248. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  62249. */
  62250. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  62251. /**
  62252. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  62253. */
  62254. _this.ignoreCameraViewport = false;
  62255. /**
  62256. * An event triggered when the texture is unbind.
  62257. */
  62258. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  62259. /**
  62260. * An event triggered when the texture is unbind.
  62261. */
  62262. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  62263. /**
  62264. * An event triggered before rendering the texture
  62265. */
  62266. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  62267. /**
  62268. * An event triggered after rendering the texture
  62269. */
  62270. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  62271. /**
  62272. * An event triggered after the texture clear
  62273. */
  62274. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  62275. _this._currentRefreshId = -1;
  62276. _this._refreshRate = 1;
  62277. _this._samples = 1;
  62278. /**
  62279. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  62280. * It must define where the camera used to render the texture is set
  62281. */
  62282. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  62283. scene = _this.getScene();
  62284. if (!scene) {
  62285. return _this;
  62286. }
  62287. _this.renderList = new Array();
  62288. _this._engine = scene.getEngine();
  62289. _this.name = name;
  62290. _this.isRenderTarget = true;
  62291. _this._initialSizeParameter = size;
  62292. _this._processSizeParameter(size);
  62293. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  62294. });
  62295. _this._generateMipMaps = generateMipMaps ? true : false;
  62296. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  62297. // Rendering groups
  62298. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  62299. _this._renderingManager._useSceneAutoClearSetup = true;
  62300. if (isMulti) {
  62301. return _this;
  62302. }
  62303. _this._renderTargetOptions = {
  62304. generateMipMaps: generateMipMaps,
  62305. type: type,
  62306. format: format,
  62307. samplingMode: samplingMode,
  62308. generateDepthBuffer: generateDepthBuffer,
  62309. generateStencilBuffer: generateStencilBuffer
  62310. };
  62311. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  62312. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  62313. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  62314. }
  62315. if (!delayAllocation) {
  62316. if (isCube) {
  62317. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  62318. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  62319. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  62320. }
  62321. else {
  62322. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  62323. }
  62324. }
  62325. return _this;
  62326. }
  62327. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  62328. /**
  62329. * Use this list to define the list of mesh you want to render.
  62330. */
  62331. get: function () {
  62332. return this._renderList;
  62333. },
  62334. set: function (value) {
  62335. this._renderList = value;
  62336. if (this._renderList) {
  62337. this._hookArray(this._renderList);
  62338. }
  62339. },
  62340. enumerable: true,
  62341. configurable: true
  62342. });
  62343. RenderTargetTexture.prototype._hookArray = function (array) {
  62344. var _this = this;
  62345. var oldPush = array.push;
  62346. array.push = function () {
  62347. var items = [];
  62348. for (var _i = 0; _i < arguments.length; _i++) {
  62349. items[_i] = arguments[_i];
  62350. }
  62351. var wasEmpty = array.length === 0;
  62352. var result = oldPush.apply(array, items);
  62353. if (wasEmpty) {
  62354. _this.getScene().meshes.forEach(function (mesh) {
  62355. mesh._markSubMeshesAsLightDirty();
  62356. });
  62357. }
  62358. return result;
  62359. };
  62360. var oldSplice = array.splice;
  62361. array.splice = function (index, deleteCount) {
  62362. var deleted = oldSplice.apply(array, [index, deleteCount]);
  62363. if (array.length === 0) {
  62364. _this.getScene().meshes.forEach(function (mesh) {
  62365. mesh._markSubMeshesAsLightDirty();
  62366. });
  62367. }
  62368. return deleted;
  62369. };
  62370. };
  62371. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  62372. /**
  62373. * Set a after unbind callback in the texture.
  62374. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  62375. */
  62376. set: function (callback) {
  62377. if (this._onAfterUnbindObserver) {
  62378. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  62379. }
  62380. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  62381. },
  62382. enumerable: true,
  62383. configurable: true
  62384. });
  62385. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  62386. /**
  62387. * Set a before render callback in the texture.
  62388. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  62389. */
  62390. set: function (callback) {
  62391. if (this._onBeforeRenderObserver) {
  62392. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  62393. }
  62394. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  62395. },
  62396. enumerable: true,
  62397. configurable: true
  62398. });
  62399. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  62400. /**
  62401. * Set a after render callback in the texture.
  62402. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  62403. */
  62404. set: function (callback) {
  62405. if (this._onAfterRenderObserver) {
  62406. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  62407. }
  62408. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  62409. },
  62410. enumerable: true,
  62411. configurable: true
  62412. });
  62413. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  62414. /**
  62415. * Set a clear callback in the texture.
  62416. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  62417. */
  62418. set: function (callback) {
  62419. if (this._onClearObserver) {
  62420. this.onClearObservable.remove(this._onClearObserver);
  62421. }
  62422. this._onClearObserver = this.onClearObservable.add(callback);
  62423. },
  62424. enumerable: true,
  62425. configurable: true
  62426. });
  62427. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  62428. /**
  62429. * Gets render target creation options that were used.
  62430. */
  62431. get: function () {
  62432. return this._renderTargetOptions;
  62433. },
  62434. enumerable: true,
  62435. configurable: true
  62436. });
  62437. RenderTargetTexture.prototype._onRatioRescale = function () {
  62438. if (this._sizeRatio) {
  62439. this.resize(this._initialSizeParameter);
  62440. }
  62441. };
  62442. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  62443. get: function () {
  62444. return this._boundingBoxSize;
  62445. },
  62446. /**
  62447. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  62448. * When defined, the cubemap will switch to local mode
  62449. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62450. * @example https://www.babylonjs-playground.com/#RNASML
  62451. */
  62452. set: function (value) {
  62453. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  62454. return;
  62455. }
  62456. this._boundingBoxSize = value;
  62457. var scene = this.getScene();
  62458. if (scene) {
  62459. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  62460. }
  62461. },
  62462. enumerable: true,
  62463. configurable: true
  62464. });
  62465. /**
  62466. * Creates a depth stencil texture.
  62467. * This is only available in WebGL 2 or with the depth texture extension available.
  62468. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  62469. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  62470. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  62471. */
  62472. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  62473. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  62474. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  62475. if (generateStencil === void 0) { generateStencil = false; }
  62476. if (!this.getScene()) {
  62477. return;
  62478. }
  62479. var engine = this.getScene().getEngine();
  62480. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  62481. bilinearFiltering: bilinearFiltering,
  62482. comparisonFunction: comparisonFunction,
  62483. generateStencil: generateStencil,
  62484. isCube: this.isCube
  62485. });
  62486. engine.setFrameBufferDepthStencilTexture(this);
  62487. };
  62488. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  62489. if (size.ratio) {
  62490. this._sizeRatio = size.ratio;
  62491. this._size = {
  62492. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  62493. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  62494. };
  62495. }
  62496. else {
  62497. this._size = size;
  62498. }
  62499. };
  62500. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  62501. /**
  62502. * Define the number of samples to use in case of MSAA.
  62503. * It defaults to one meaning no MSAA has been enabled.
  62504. */
  62505. get: function () {
  62506. return this._samples;
  62507. },
  62508. set: function (value) {
  62509. if (this._samples === value) {
  62510. return;
  62511. }
  62512. var scene = this.getScene();
  62513. if (!scene) {
  62514. return;
  62515. }
  62516. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  62517. },
  62518. enumerable: true,
  62519. configurable: true
  62520. });
  62521. /**
  62522. * Resets the refresh counter of the texture and start bak from scratch.
  62523. * Could be useful to regenerate the texture if it is setup to render only once.
  62524. */
  62525. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  62526. this._currentRefreshId = -1;
  62527. };
  62528. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  62529. /**
  62530. * Define the refresh rate of the texture or the rendering frequency.
  62531. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  62532. */
  62533. get: function () {
  62534. return this._refreshRate;
  62535. },
  62536. set: function (value) {
  62537. this._refreshRate = value;
  62538. this.resetRefreshCounter();
  62539. },
  62540. enumerable: true,
  62541. configurable: true
  62542. });
  62543. /**
  62544. * Adds a post process to the render target rendering passes.
  62545. * @param postProcess define the post process to add
  62546. */
  62547. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  62548. if (!this._postProcessManager) {
  62549. var scene = this.getScene();
  62550. if (!scene) {
  62551. return;
  62552. }
  62553. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  62554. this._postProcesses = new Array();
  62555. }
  62556. this._postProcesses.push(postProcess);
  62557. this._postProcesses[0].autoClear = false;
  62558. };
  62559. /**
  62560. * Clear all the post processes attached to the render target
  62561. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  62562. */
  62563. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  62564. if (dispose === void 0) { dispose = false; }
  62565. if (!this._postProcesses) {
  62566. return;
  62567. }
  62568. if (dispose) {
  62569. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  62570. var postProcess = _a[_i];
  62571. postProcess.dispose();
  62572. }
  62573. }
  62574. this._postProcesses = [];
  62575. };
  62576. /**
  62577. * Remove one of the post process from the list of attached post processes to the texture
  62578. * @param postProcess define the post process to remove from the list
  62579. */
  62580. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  62581. if (!this._postProcesses) {
  62582. return;
  62583. }
  62584. var index = this._postProcesses.indexOf(postProcess);
  62585. if (index === -1) {
  62586. return;
  62587. }
  62588. this._postProcesses.splice(index, 1);
  62589. if (this._postProcesses.length > 0) {
  62590. this._postProcesses[0].autoClear = false;
  62591. }
  62592. };
  62593. /** @hidden */
  62594. RenderTargetTexture.prototype._shouldRender = function () {
  62595. if (this._currentRefreshId === -1) { // At least render once
  62596. this._currentRefreshId = 1;
  62597. return true;
  62598. }
  62599. if (this.refreshRate === this._currentRefreshId) {
  62600. this._currentRefreshId = 1;
  62601. return true;
  62602. }
  62603. this._currentRefreshId++;
  62604. return false;
  62605. };
  62606. /**
  62607. * Gets the actual render size of the texture.
  62608. * @returns the width of the render size
  62609. */
  62610. RenderTargetTexture.prototype.getRenderSize = function () {
  62611. return this.getRenderWidth();
  62612. };
  62613. /**
  62614. * Gets the actual render width of the texture.
  62615. * @returns the width of the render size
  62616. */
  62617. RenderTargetTexture.prototype.getRenderWidth = function () {
  62618. if (this._size.width) {
  62619. return this._size.width;
  62620. }
  62621. return this._size;
  62622. };
  62623. /**
  62624. * Gets the actual render height of the texture.
  62625. * @returns the height of the render size
  62626. */
  62627. RenderTargetTexture.prototype.getRenderHeight = function () {
  62628. if (this._size.width) {
  62629. return this._size.height;
  62630. }
  62631. return this._size;
  62632. };
  62633. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  62634. /**
  62635. * Get if the texture can be rescaled or not.
  62636. */
  62637. get: function () {
  62638. return true;
  62639. },
  62640. enumerable: true,
  62641. configurable: true
  62642. });
  62643. /**
  62644. * Resize the texture using a ratio.
  62645. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  62646. */
  62647. RenderTargetTexture.prototype.scale = function (ratio) {
  62648. var newSize = this.getRenderSize() * ratio;
  62649. this.resize(newSize);
  62650. };
  62651. /**
  62652. * Get the texture reflection matrix used to rotate/transform the reflection.
  62653. * @returns the reflection matrix
  62654. */
  62655. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  62656. if (this.isCube) {
  62657. return this._textureMatrix;
  62658. }
  62659. return _super.prototype.getReflectionTextureMatrix.call(this);
  62660. };
  62661. /**
  62662. * Resize the texture to a new desired size.
  62663. * Be carrefull as it will recreate all the data in the new texture.
  62664. * @param size Define the new size. It can be:
  62665. * - a number for squared texture,
  62666. * - an object containing { width: number, height: number }
  62667. * - or an object containing a ratio { ratio: number }
  62668. */
  62669. RenderTargetTexture.prototype.resize = function (size) {
  62670. var wasCube = this.isCube;
  62671. this.releaseInternalTexture();
  62672. var scene = this.getScene();
  62673. if (!scene) {
  62674. return;
  62675. }
  62676. this._processSizeParameter(size);
  62677. if (wasCube) {
  62678. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  62679. }
  62680. else {
  62681. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  62682. }
  62683. };
  62684. /**
  62685. * Renders all the objects from the render list into the texture.
  62686. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  62687. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  62688. */
  62689. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  62690. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  62691. if (dumpForDebug === void 0) { dumpForDebug = false; }
  62692. var scene = this.getScene();
  62693. if (!scene) {
  62694. return;
  62695. }
  62696. var engine = scene.getEngine();
  62697. if (this.useCameraPostProcesses !== undefined) {
  62698. useCameraPostProcess = this.useCameraPostProcesses;
  62699. }
  62700. if (this._waitingRenderList) {
  62701. this.renderList = [];
  62702. for (var index = 0; index < this._waitingRenderList.length; index++) {
  62703. var id = this._waitingRenderList[index];
  62704. var mesh_1 = scene.getMeshByID(id);
  62705. if (mesh_1) {
  62706. this.renderList.push(mesh_1);
  62707. }
  62708. }
  62709. delete this._waitingRenderList;
  62710. }
  62711. // Is predicate defined?
  62712. if (this.renderListPredicate) {
  62713. if (this.renderList) {
  62714. this.renderList.length = 0; // Clear previous renderList
  62715. }
  62716. else {
  62717. this.renderList = [];
  62718. }
  62719. var scene = this.getScene();
  62720. if (!scene) {
  62721. return;
  62722. }
  62723. var sceneMeshes = scene.meshes;
  62724. for (var index = 0; index < sceneMeshes.length; index++) {
  62725. var mesh = sceneMeshes[index];
  62726. if (this.renderListPredicate(mesh)) {
  62727. this.renderList.push(mesh);
  62728. }
  62729. }
  62730. }
  62731. this.onBeforeBindObservable.notifyObservers(this);
  62732. // Set custom projection.
  62733. // Needs to be before binding to prevent changing the aspect ratio.
  62734. var camera;
  62735. if (this.activeCamera) {
  62736. camera = this.activeCamera;
  62737. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  62738. if (this.activeCamera !== scene.activeCamera) {
  62739. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  62740. }
  62741. }
  62742. else {
  62743. camera = scene.activeCamera;
  62744. if (camera) {
  62745. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  62746. }
  62747. }
  62748. // Prepare renderingManager
  62749. this._renderingManager.reset();
  62750. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  62751. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  62752. var sceneRenderId = scene.getRenderId();
  62753. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  62754. var mesh = currentRenderList[meshIndex];
  62755. if (mesh) {
  62756. if (!mesh.isReady(this.refreshRate === 0)) {
  62757. this.resetRefreshCounter();
  62758. continue;
  62759. }
  62760. mesh._preActivateForIntermediateRendering(sceneRenderId);
  62761. var isMasked = void 0;
  62762. if (!this.renderList && camera) {
  62763. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  62764. }
  62765. else {
  62766. isMasked = false;
  62767. }
  62768. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  62769. if (mesh._activate(sceneRenderId, true)) {
  62770. if (!mesh.isAnInstance) {
  62771. mesh._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = false;
  62772. }
  62773. else {
  62774. mesh = mesh.sourceMesh;
  62775. }
  62776. mesh._internalAbstractMeshDataInfo._isActiveIntermediate = true;
  62777. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  62778. var subMesh = mesh.subMeshes[subIndex];
  62779. scene._activeIndices.addCount(subMesh.indexCount, false);
  62780. this._renderingManager.dispatch(subMesh, mesh);
  62781. }
  62782. }
  62783. }
  62784. }
  62785. }
  62786. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  62787. var particleSystem = scene.particleSystems[particleIndex];
  62788. var emitter = particleSystem.emitter;
  62789. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  62790. continue;
  62791. }
  62792. if (currentRenderList.indexOf(emitter) >= 0) {
  62793. this._renderingManager.dispatchParticles(particleSystem);
  62794. }
  62795. }
  62796. if (this.isCube) {
  62797. for (var face = 0; face < 6; face++) {
  62798. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  62799. scene.incrementRenderId();
  62800. scene.resetCachedMaterial();
  62801. }
  62802. }
  62803. else {
  62804. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  62805. }
  62806. this.onAfterUnbindObservable.notifyObservers(this);
  62807. if (scene.activeCamera) {
  62808. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  62809. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  62810. }
  62811. engine.setViewport(scene.activeCamera.viewport);
  62812. }
  62813. scene.resetCachedMaterial();
  62814. };
  62815. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  62816. var minimum = 128;
  62817. var x = renderDimension * scale;
  62818. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  62819. // Ensure we don't exceed the render dimension (while staying POT)
  62820. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  62821. };
  62822. /**
  62823. * @hidden
  62824. * @param faceIndex face index to bind to if this is a cubetexture
  62825. */
  62826. RenderTargetTexture.prototype._bindFrameBuffer = function (faceIndex) {
  62827. if (faceIndex === void 0) { faceIndex = 0; }
  62828. var scene = this.getScene();
  62829. if (!scene) {
  62830. return;
  62831. }
  62832. var engine = scene.getEngine();
  62833. if (this._texture) {
  62834. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  62835. }
  62836. };
  62837. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  62838. var _this = this;
  62839. if (!this._texture) {
  62840. return;
  62841. }
  62842. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  62843. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  62844. });
  62845. };
  62846. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  62847. var scene = this.getScene();
  62848. if (!scene) {
  62849. return;
  62850. }
  62851. var engine = scene.getEngine();
  62852. if (!this._texture) {
  62853. return;
  62854. }
  62855. // Bind
  62856. if (this._postProcessManager) {
  62857. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  62858. }
  62859. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  62860. this._bindFrameBuffer(faceIndex);
  62861. }
  62862. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  62863. // Clear
  62864. if (this.onClearObservable.hasObservers()) {
  62865. this.onClearObservable.notifyObservers(engine);
  62866. }
  62867. else {
  62868. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  62869. }
  62870. if (!this._doNotChangeAspectRatio) {
  62871. scene.updateTransformMatrix(true);
  62872. }
  62873. // Before Camera Draw
  62874. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  62875. var step = _a[_i];
  62876. step.action(this);
  62877. }
  62878. // Render
  62879. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  62880. // After Camera Draw
  62881. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  62882. var step = _c[_b];
  62883. step.action(this);
  62884. }
  62885. if (this._postProcessManager) {
  62886. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  62887. }
  62888. else if (useCameraPostProcess) {
  62889. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  62890. }
  62891. if (!this._doNotChangeAspectRatio) {
  62892. scene.updateTransformMatrix(true);
  62893. }
  62894. // Dump ?
  62895. if (dumpForDebug) {
  62896. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  62897. }
  62898. // Unbind
  62899. if (!this.isCube || faceIndex === 5) {
  62900. if (this.isCube) {
  62901. if (faceIndex === 5) {
  62902. engine.generateMipMapsForCubemap(this._texture);
  62903. }
  62904. }
  62905. this.unbindFrameBuffer(engine, faceIndex);
  62906. }
  62907. else {
  62908. this.onAfterRenderObservable.notifyObservers(faceIndex);
  62909. }
  62910. };
  62911. /**
  62912. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  62913. * This allowed control for front to back rendering or reversly depending of the special needs.
  62914. *
  62915. * @param renderingGroupId The rendering group id corresponding to its index
  62916. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  62917. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  62918. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  62919. */
  62920. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  62921. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  62922. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  62923. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  62924. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  62925. };
  62926. /**
  62927. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  62928. *
  62929. * @param renderingGroupId The rendering group id corresponding to its index
  62930. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62931. */
  62932. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  62933. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  62934. this._renderingManager._useSceneAutoClearSetup = false;
  62935. };
  62936. /**
  62937. * Clones the texture.
  62938. * @returns the cloned texture
  62939. */
  62940. RenderTargetTexture.prototype.clone = function () {
  62941. var textureSize = this.getSize();
  62942. 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);
  62943. // Base texture
  62944. newTexture.hasAlpha = this.hasAlpha;
  62945. newTexture.level = this.level;
  62946. // RenderTarget Texture
  62947. newTexture.coordinatesMode = this.coordinatesMode;
  62948. if (this.renderList) {
  62949. newTexture.renderList = this.renderList.slice(0);
  62950. }
  62951. return newTexture;
  62952. };
  62953. /**
  62954. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  62955. * @returns The JSON representation of the texture
  62956. */
  62957. RenderTargetTexture.prototype.serialize = function () {
  62958. if (!this.name) {
  62959. return null;
  62960. }
  62961. var serializationObject = _super.prototype.serialize.call(this);
  62962. serializationObject.renderTargetSize = this.getRenderSize();
  62963. serializationObject.renderList = [];
  62964. if (this.renderList) {
  62965. for (var index = 0; index < this.renderList.length; index++) {
  62966. serializationObject.renderList.push(this.renderList[index].id);
  62967. }
  62968. }
  62969. return serializationObject;
  62970. };
  62971. /**
  62972. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  62973. */
  62974. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  62975. var objBuffer = this.getInternalTexture();
  62976. var scene = this.getScene();
  62977. if (objBuffer && scene) {
  62978. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  62979. }
  62980. };
  62981. /**
  62982. * Dispose the texture and release its associated resources.
  62983. */
  62984. RenderTargetTexture.prototype.dispose = function () {
  62985. if (this._postProcessManager) {
  62986. this._postProcessManager.dispose();
  62987. this._postProcessManager = null;
  62988. }
  62989. this.clearPostProcesses(true);
  62990. if (this._resizeObserver) {
  62991. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  62992. this._resizeObserver = null;
  62993. }
  62994. this.renderList = null;
  62995. // Remove from custom render targets
  62996. var scene = this.getScene();
  62997. if (!scene) {
  62998. return;
  62999. }
  63000. var index = scene.customRenderTargets.indexOf(this);
  63001. if (index >= 0) {
  63002. scene.customRenderTargets.splice(index, 1);
  63003. }
  63004. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  63005. var camera = _a[_i];
  63006. index = camera.customRenderTargets.indexOf(this);
  63007. if (index >= 0) {
  63008. camera.customRenderTargets.splice(index, 1);
  63009. }
  63010. }
  63011. _super.prototype.dispose.call(this);
  63012. };
  63013. /** @hidden */
  63014. RenderTargetTexture.prototype._rebuild = function () {
  63015. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  63016. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  63017. }
  63018. if (this._postProcessManager) {
  63019. this._postProcessManager._rebuild();
  63020. }
  63021. };
  63022. /**
  63023. * Clear the info related to rendering groups preventing retention point in material dispose.
  63024. */
  63025. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  63026. if (this._renderingManager) {
  63027. this._renderingManager.freeRenderingGroups();
  63028. }
  63029. };
  63030. /**
  63031. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  63032. * @returns the view count
  63033. */
  63034. RenderTargetTexture.prototype.getViewCount = function () {
  63035. return 1;
  63036. };
  63037. /**
  63038. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  63039. */
  63040. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  63041. /**
  63042. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  63043. */
  63044. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  63045. /**
  63046. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  63047. * the central point of your effect and can save a lot of performances.
  63048. */
  63049. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  63050. return RenderTargetTexture;
  63051. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  63052. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  63053. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  63054. };
  63055. /***/ }),
  63056. /***/ "./Materials/Textures/texture.ts":
  63057. /*!***************************************!*\
  63058. !*** ./Materials/Textures/texture.ts ***!
  63059. \***************************************/
  63060. /*! exports provided: Texture */
  63061. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63062. "use strict";
  63063. __webpack_require__.r(__webpack_exports__);
  63064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  63065. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63066. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  63067. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  63068. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  63069. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  63070. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  63071. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  63072. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  63073. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  63074. /**
  63075. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  63076. * @see http://doc.babylonjs.com/babylon101/materials#texture
  63077. */
  63078. var Texture = /** @class */ (function (_super) {
  63079. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  63080. /**
  63081. * Instantiates a new texture.
  63082. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  63083. * @see http://doc.babylonjs.com/babylon101/materials#texture
  63084. * @param url define the url of the picture to load as a texture
  63085. * @param scene define the scene the texture will belong to
  63086. * @param noMipmap define if the texture will require mip maps or not
  63087. * @param invertY define if the texture needs to be inverted on the y axis during loading
  63088. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  63089. * @param onLoad define a callback triggered when the texture has been loaded
  63090. * @param onError define a callback triggered when an error occurred during the loading session
  63091. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  63092. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  63093. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  63094. */
  63095. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  63096. if (noMipmap === void 0) { noMipmap = false; }
  63097. if (invertY === void 0) { invertY = true; }
  63098. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  63099. if (onLoad === void 0) { onLoad = null; }
  63100. if (onError === void 0) { onError = null; }
  63101. if (buffer === void 0) { buffer = null; }
  63102. if (deleteBuffer === void 0) { deleteBuffer = false; }
  63103. var _this = _super.call(this, scene) || this;
  63104. /**
  63105. * Define the url of the texture.
  63106. */
  63107. _this.url = null;
  63108. /**
  63109. * Define an offset on the texture to offset the u coordinates of the UVs
  63110. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  63111. */
  63112. _this.uOffset = 0;
  63113. /**
  63114. * Define an offset on the texture to offset the v coordinates of the UVs
  63115. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  63116. */
  63117. _this.vOffset = 0;
  63118. /**
  63119. * Define an offset on the texture to scale the u coordinates of the UVs
  63120. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  63121. */
  63122. _this.uScale = 1.0;
  63123. /**
  63124. * Define an offset on the texture to scale the v coordinates of the UVs
  63125. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  63126. */
  63127. _this.vScale = 1.0;
  63128. /**
  63129. * Define an offset on the texture to rotate around the u coordinates of the UVs
  63130. * @see http://doc.babylonjs.com/how_to/more_materials
  63131. */
  63132. _this.uAng = 0;
  63133. /**
  63134. * Define an offset on the texture to rotate around the v coordinates of the UVs
  63135. * @see http://doc.babylonjs.com/how_to/more_materials
  63136. */
  63137. _this.vAng = 0;
  63138. /**
  63139. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  63140. * @see http://doc.babylonjs.com/how_to/more_materials
  63141. */
  63142. _this.wAng = 0;
  63143. /**
  63144. * Defines the center of rotation (U)
  63145. */
  63146. _this.uRotationCenter = 0.5;
  63147. /**
  63148. * Defines the center of rotation (V)
  63149. */
  63150. _this.vRotationCenter = 0.5;
  63151. /**
  63152. * Defines the center of rotation (W)
  63153. */
  63154. _this.wRotationCenter = 0.5;
  63155. /**
  63156. * List of inspectable custom properties (used by the Inspector)
  63157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63158. */
  63159. _this.inspectableCustomProperties = null;
  63160. _this._noMipmap = false;
  63161. /** @hidden */
  63162. _this._invertY = false;
  63163. _this._rowGenerationMatrix = null;
  63164. _this._cachedTextureMatrix = null;
  63165. _this._projectionModeMatrix = null;
  63166. _this._t0 = null;
  63167. _this._t1 = null;
  63168. _this._t2 = null;
  63169. _this._cachedUOffset = -1;
  63170. _this._cachedVOffset = -1;
  63171. _this._cachedUScale = 0;
  63172. _this._cachedVScale = 0;
  63173. _this._cachedUAng = -1;
  63174. _this._cachedVAng = -1;
  63175. _this._cachedWAng = -1;
  63176. _this._cachedProjectionMatrixId = -1;
  63177. _this._cachedCoordinatesMode = -1;
  63178. /** @hidden */
  63179. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  63180. /** @hidden */
  63181. _this._buffer = null;
  63182. _this._deleteBuffer = false;
  63183. _this._format = null;
  63184. _this._delayedOnLoad = null;
  63185. _this._delayedOnError = null;
  63186. /**
  63187. * Observable triggered once the texture has been loaded.
  63188. */
  63189. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  63190. _this._isBlocking = true;
  63191. _this.name = url || "";
  63192. _this.url = url;
  63193. _this._noMipmap = noMipmap;
  63194. _this._invertY = invertY;
  63195. _this._initialSamplingMode = samplingMode;
  63196. _this._buffer = buffer;
  63197. _this._deleteBuffer = deleteBuffer;
  63198. if (format) {
  63199. _this._format = format;
  63200. }
  63201. scene = _this.getScene();
  63202. if (!scene) {
  63203. return _this;
  63204. }
  63205. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  63206. var load = function () {
  63207. if (_this._texture && _this._texture._invertVScale) {
  63208. _this.vScale = -1;
  63209. }
  63210. if (_this.onLoadObservable.hasObservers()) {
  63211. _this.onLoadObservable.notifyObservers(_this);
  63212. }
  63213. if (onLoad) {
  63214. onLoad();
  63215. }
  63216. if (!_this.isBlocking && scene) {
  63217. scene.resetCachedMaterial();
  63218. }
  63219. };
  63220. if (!_this.url) {
  63221. _this._delayedOnLoad = load;
  63222. _this._delayedOnError = onError;
  63223. return _this;
  63224. }
  63225. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode, invertY);
  63226. if (!_this._texture) {
  63227. if (!scene.useDelayedTextureLoading) {
  63228. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  63229. if (deleteBuffer) {
  63230. delete _this._buffer;
  63231. }
  63232. }
  63233. else {
  63234. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  63235. _this._delayedOnLoad = load;
  63236. _this._delayedOnError = onError;
  63237. }
  63238. }
  63239. else {
  63240. if (_this._texture.isReady) {
  63241. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  63242. }
  63243. else {
  63244. _this._texture.onLoadedObservable.add(load);
  63245. }
  63246. }
  63247. return _this;
  63248. }
  63249. Object.defineProperty(Texture.prototype, "noMipmap", {
  63250. /**
  63251. * Are mip maps generated for this texture or not.
  63252. */
  63253. get: function () {
  63254. return this._noMipmap;
  63255. },
  63256. enumerable: true,
  63257. configurable: true
  63258. });
  63259. Object.defineProperty(Texture.prototype, "isBlocking", {
  63260. get: function () {
  63261. return this._isBlocking;
  63262. },
  63263. /**
  63264. * Is the texture preventing material to render while loading.
  63265. * If false, a default texture will be used instead of the loading one during the preparation step.
  63266. */
  63267. set: function (value) {
  63268. this._isBlocking = value;
  63269. },
  63270. enumerable: true,
  63271. configurable: true
  63272. });
  63273. Object.defineProperty(Texture.prototype, "samplingMode", {
  63274. /**
  63275. * Get the current sampling mode associated with the texture.
  63276. */
  63277. get: function () {
  63278. if (!this._texture) {
  63279. return this._initialSamplingMode;
  63280. }
  63281. return this._texture.samplingMode;
  63282. },
  63283. enumerable: true,
  63284. configurable: true
  63285. });
  63286. Object.defineProperty(Texture.prototype, "invertY", {
  63287. /**
  63288. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  63289. */
  63290. get: function () {
  63291. return this._invertY;
  63292. },
  63293. enumerable: true,
  63294. configurable: true
  63295. });
  63296. /**
  63297. * Update the url (and optional buffer) of this texture if url was null during construction.
  63298. * @param url the url of the texture
  63299. * @param buffer the buffer of the texture (defaults to null)
  63300. * @param onLoad callback called when the texture is loaded (defaults to null)
  63301. */
  63302. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  63303. if (buffer === void 0) { buffer = null; }
  63304. if (this.url) {
  63305. this.releaseInternalTexture();
  63306. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  63307. }
  63308. this.url = url;
  63309. this._buffer = buffer;
  63310. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  63311. if (onLoad) {
  63312. this._delayedOnLoad = onLoad;
  63313. }
  63314. this.delayLoad();
  63315. };
  63316. /**
  63317. * Finish the loading sequence of a texture flagged as delayed load.
  63318. * @hidden
  63319. */
  63320. Texture.prototype.delayLoad = function () {
  63321. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  63322. return;
  63323. }
  63324. var scene = this.getScene();
  63325. if (!scene) {
  63326. return;
  63327. }
  63328. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  63329. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY);
  63330. if (!this._texture) {
  63331. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  63332. if (this._deleteBuffer) {
  63333. delete this._buffer;
  63334. }
  63335. }
  63336. else {
  63337. if (this._delayedOnLoad) {
  63338. if (this._texture.isReady) {
  63339. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  63340. }
  63341. else {
  63342. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  63343. }
  63344. }
  63345. }
  63346. this._delayedOnLoad = null;
  63347. this._delayedOnError = null;
  63348. };
  63349. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  63350. x *= this.uScale;
  63351. y *= this.vScale;
  63352. x -= this.uRotationCenter * this.uScale;
  63353. y -= this.vRotationCenter * this.vScale;
  63354. z -= this.wRotationCenter;
  63355. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  63356. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  63357. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  63358. t.z += this.wRotationCenter;
  63359. };
  63360. /**
  63361. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  63362. * @returns the transform matrix of the texture.
  63363. */
  63364. Texture.prototype.getTextureMatrix = function () {
  63365. var _this = this;
  63366. if (this.uOffset === this._cachedUOffset &&
  63367. this.vOffset === this._cachedVOffset &&
  63368. this.uScale === this._cachedUScale &&
  63369. this.vScale === this._cachedVScale &&
  63370. this.uAng === this._cachedUAng &&
  63371. this.vAng === this._cachedVAng &&
  63372. this.wAng === this._cachedWAng) {
  63373. return this._cachedTextureMatrix;
  63374. }
  63375. this._cachedUOffset = this.uOffset;
  63376. this._cachedVOffset = this.vOffset;
  63377. this._cachedUScale = this.uScale;
  63378. this._cachedVScale = this.vScale;
  63379. this._cachedUAng = this.uAng;
  63380. this._cachedVAng = this.vAng;
  63381. this._cachedWAng = this.wAng;
  63382. if (!this._cachedTextureMatrix) {
  63383. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  63384. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  63385. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  63386. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  63387. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  63388. }
  63389. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  63390. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  63391. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  63392. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  63393. this._t1.subtractInPlace(this._t0);
  63394. this._t2.subtractInPlace(this._t0);
  63395. _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);
  63396. var scene = this.getScene();
  63397. if (!scene) {
  63398. return this._cachedTextureMatrix;
  63399. }
  63400. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  63401. return mat.hasTexture(_this);
  63402. });
  63403. return this._cachedTextureMatrix;
  63404. };
  63405. /**
  63406. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  63407. * @returns The reflection texture transform
  63408. */
  63409. Texture.prototype.getReflectionTextureMatrix = function () {
  63410. var _this = this;
  63411. var scene = this.getScene();
  63412. if (!scene) {
  63413. return this._cachedTextureMatrix;
  63414. }
  63415. if (this.uOffset === this._cachedUOffset &&
  63416. this.vOffset === this._cachedVOffset &&
  63417. this.uScale === this._cachedUScale &&
  63418. this.vScale === this._cachedVScale &&
  63419. this.coordinatesMode === this._cachedCoordinatesMode) {
  63420. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  63421. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  63422. return this._cachedTextureMatrix;
  63423. }
  63424. }
  63425. else {
  63426. return this._cachedTextureMatrix;
  63427. }
  63428. }
  63429. if (!this._cachedTextureMatrix) {
  63430. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  63431. }
  63432. if (!this._projectionModeMatrix) {
  63433. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  63434. }
  63435. this._cachedUOffset = this.uOffset;
  63436. this._cachedVOffset = this.vOffset;
  63437. this._cachedUScale = this.uScale;
  63438. this._cachedVScale = this.vScale;
  63439. this._cachedCoordinatesMode = this.coordinatesMode;
  63440. switch (this.coordinatesMode) {
  63441. case Texture.PLANAR_MODE:
  63442. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  63443. this._cachedTextureMatrix[0] = this.uScale;
  63444. this._cachedTextureMatrix[5] = this.vScale;
  63445. this._cachedTextureMatrix[12] = this.uOffset;
  63446. this._cachedTextureMatrix[13] = this.vOffset;
  63447. break;
  63448. case Texture.PROJECTION_MODE:
  63449. _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);
  63450. var projectionMatrix = scene.getProjectionMatrix();
  63451. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  63452. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  63453. break;
  63454. default:
  63455. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  63456. break;
  63457. }
  63458. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  63459. return (mat.getActiveTextures().indexOf(_this) !== -1);
  63460. });
  63461. return this._cachedTextureMatrix;
  63462. };
  63463. /**
  63464. * Clones the texture.
  63465. * @returns the cloned texture
  63466. */
  63467. Texture.prototype.clone = function () {
  63468. var _this = this;
  63469. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  63470. 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);
  63471. }, this);
  63472. };
  63473. /**
  63474. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  63475. * @returns The JSON representation of the texture
  63476. */
  63477. Texture.prototype.serialize = function () {
  63478. var serializationObject = _super.prototype.serialize.call(this);
  63479. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  63480. serializationObject.base64String = this._buffer;
  63481. serializationObject.name = serializationObject.name.replace("data:", "");
  63482. }
  63483. serializationObject.invertY = this._invertY;
  63484. serializationObject.samplingMode = this.samplingMode;
  63485. return serializationObject;
  63486. };
  63487. /**
  63488. * Get the current class name of the texture useful for serialization or dynamic coding.
  63489. * @returns "Texture"
  63490. */
  63491. Texture.prototype.getClassName = function () {
  63492. return "Texture";
  63493. };
  63494. /**
  63495. * Dispose the texture and release its associated resources.
  63496. */
  63497. Texture.prototype.dispose = function () {
  63498. _super.prototype.dispose.call(this);
  63499. this.onLoadObservable.clear();
  63500. this._delayedOnLoad = null;
  63501. this._delayedOnError = null;
  63502. };
  63503. /**
  63504. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  63505. * @param parsedTexture Define the JSON representation of the texture
  63506. * @param scene Define the scene the parsed texture should be instantiated in
  63507. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  63508. * @returns The parsed texture if successful
  63509. */
  63510. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  63511. if (parsedTexture.customType) {
  63512. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  63513. // Update Sampling Mode
  63514. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  63515. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  63516. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  63517. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  63518. }
  63519. }
  63520. return parsedCustomTexture;
  63521. }
  63522. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  63523. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  63524. }
  63525. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  63526. return null;
  63527. }
  63528. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  63529. var generateMipMaps = true;
  63530. if (parsedTexture.noMipmap) {
  63531. generateMipMaps = false;
  63532. }
  63533. if (parsedTexture.mirrorPlane) {
  63534. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  63535. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  63536. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  63537. return mirrorTexture;
  63538. }
  63539. else if (parsedTexture.isRenderTarget) {
  63540. var renderTargetTexture = null;
  63541. if (parsedTexture.isCube) {
  63542. // Search for an existing reflection probe (which contains a cube render target texture)
  63543. if (scene.reflectionProbes) {
  63544. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  63545. var probe = scene.reflectionProbes[index];
  63546. if (probe.name === parsedTexture.name) {
  63547. return probe.cubeTexture;
  63548. }
  63549. }
  63550. }
  63551. }
  63552. else {
  63553. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  63554. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  63555. }
  63556. return renderTargetTexture;
  63557. }
  63558. else {
  63559. var texture;
  63560. if (parsedTexture.base64String) {
  63561. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  63562. }
  63563. else {
  63564. var url = rootUrl + parsedTexture.name;
  63565. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  63566. url = parsedTexture.url;
  63567. }
  63568. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  63569. }
  63570. return texture;
  63571. }
  63572. }, parsedTexture, scene);
  63573. // Update Sampling Mode
  63574. if (parsedTexture.samplingMode) {
  63575. var sampling = parsedTexture.samplingMode;
  63576. if (texture && texture.samplingMode !== sampling) {
  63577. texture.updateSamplingMode(sampling);
  63578. }
  63579. }
  63580. // Animations
  63581. if (texture && parsedTexture.animations) {
  63582. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  63583. var parsedAnimation = parsedTexture.animations[animationIndex];
  63584. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  63585. if (internalClass) {
  63586. texture.animations.push(internalClass.Parse(parsedAnimation));
  63587. }
  63588. }
  63589. }
  63590. return texture;
  63591. };
  63592. /**
  63593. * Creates a texture from its base 64 representation.
  63594. * @param data Define the base64 payload without the data: prefix
  63595. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  63596. * @param scene Define the scene the texture should belong to
  63597. * @param noMipmap Forces the texture to not create mip map information if true
  63598. * @param invertY define if the texture needs to be inverted on the y axis during loading
  63599. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  63600. * @param onLoad define a callback triggered when the texture has been loaded
  63601. * @param onError define a callback triggered when an error occurred during the loading session
  63602. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  63603. * @returns the created texture
  63604. */
  63605. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  63606. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  63607. if (onLoad === void 0) { onLoad = null; }
  63608. if (onError === void 0) { onError = null; }
  63609. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  63610. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  63611. };
  63612. /**
  63613. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  63614. * @param data Define the base64 payload without the data: prefix
  63615. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  63616. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  63617. * @param scene Define the scene the texture should belong to
  63618. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  63619. * @param noMipmap Forces the texture to not create mip map information if true
  63620. * @param invertY define if the texture needs to be inverted on the y axis during loading
  63621. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  63622. * @param onLoad define a callback triggered when the texture has been loaded
  63623. * @param onError define a callback triggered when an error occurred during the loading session
  63624. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  63625. * @returns the created texture
  63626. */
  63627. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  63628. if (deleteBuffer === void 0) { deleteBuffer = false; }
  63629. if (noMipmap === void 0) { noMipmap = false; }
  63630. if (invertY === void 0) { invertY = true; }
  63631. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  63632. if (onLoad === void 0) { onLoad = null; }
  63633. if (onError === void 0) { onError = null; }
  63634. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  63635. if (name.substr(0, 5) !== "data:") {
  63636. name = "data:" + name;
  63637. }
  63638. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  63639. };
  63640. /** @hidden */
  63641. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  63642. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("CubeTexture");
  63643. };
  63644. /** @hidden */
  63645. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  63646. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("MirrorTexture");
  63647. };
  63648. /** @hidden */
  63649. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  63650. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("RenderTargetTexture");
  63651. };
  63652. /** nearest is mag = nearest and min = nearest and mip = linear */
  63653. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  63654. /** nearest is mag = nearest and min = nearest and mip = linear */
  63655. 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
  63656. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63657. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  63658. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63659. 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
  63660. /** Trilinear is mag = linear and min = linear and mip = linear */
  63661. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  63662. /** Trilinear is mag = linear and min = linear and mip = linear */
  63663. 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
  63664. /** mag = nearest and min = nearest and mip = nearest */
  63665. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  63666. /** mag = nearest and min = linear and mip = nearest */
  63667. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  63668. /** mag = nearest and min = linear and mip = linear */
  63669. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  63670. /** mag = nearest and min = linear and mip = none */
  63671. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  63672. /** mag = nearest and min = nearest and mip = none */
  63673. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  63674. /** mag = linear and min = nearest and mip = nearest */
  63675. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  63676. /** mag = linear and min = nearest and mip = linear */
  63677. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  63678. /** mag = linear and min = linear and mip = none */
  63679. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  63680. /** mag = linear and min = nearest and mip = none */
  63681. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  63682. /** Explicit coordinates mode */
  63683. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  63684. /** Spherical coordinates mode */
  63685. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  63686. /** Planar coordinates mode */
  63687. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  63688. /** Cubic coordinates mode */
  63689. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  63690. /** Projection coordinates mode */
  63691. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  63692. /** Inverse Cubic coordinates mode */
  63693. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  63694. /** Inverse Cubic coordinates mode */
  63695. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  63696. /** Equirectangular coordinates mode */
  63697. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  63698. /** Equirectangular Fixed coordinates mode */
  63699. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  63700. /** Equirectangular Fixed Mirrored coordinates mode */
  63701. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  63702. /** Texture is not repeating outside of 0..1 UVs */
  63703. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  63704. /** Texture is repeating outside of 0..1 UVs */
  63705. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  63706. /** Texture is repeating and mirrored */
  63707. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  63708. /**
  63709. * 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
  63710. */
  63711. Texture.UseSerializedUrlIfAny = false;
  63712. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63713. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63714. ], Texture.prototype, "url", void 0);
  63715. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63716. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63717. ], Texture.prototype, "uOffset", void 0);
  63718. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63719. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63720. ], Texture.prototype, "vOffset", void 0);
  63721. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63722. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63723. ], Texture.prototype, "uScale", void 0);
  63724. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63725. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63726. ], Texture.prototype, "vScale", void 0);
  63727. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63728. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63729. ], Texture.prototype, "uAng", void 0);
  63730. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63731. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63732. ], Texture.prototype, "vAng", void 0);
  63733. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63734. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63735. ], Texture.prototype, "wAng", void 0);
  63736. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63737. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63738. ], Texture.prototype, "uRotationCenter", void 0);
  63739. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63740. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63741. ], Texture.prototype, "vRotationCenter", void 0);
  63742. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63743. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63744. ], Texture.prototype, "wRotationCenter", void 0);
  63745. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63746. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63747. ], Texture.prototype, "isBlocking", null);
  63748. return Texture;
  63749. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  63750. // References the dependencies.
  63751. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  63752. /***/ }),
  63753. /***/ "./Materials/Textures/videoTexture.ts":
  63754. /*!********************************************!*\
  63755. !*** ./Materials/Textures/videoTexture.ts ***!
  63756. \********************************************/
  63757. /*! exports provided: VideoTexture */
  63758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63759. "use strict";
  63760. __webpack_require__.r(__webpack_exports__);
  63761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  63762. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63763. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  63764. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  63765. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  63766. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  63767. /**
  63768. * If you want to display a video in your scene, this is the special texture for that.
  63769. * This special texture works similar to other textures, with the exception of a few parameters.
  63770. * @see https://doc.babylonjs.com/how_to/video_texture
  63771. */
  63772. var VideoTexture = /** @class */ (function (_super) {
  63773. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  63774. /**
  63775. * Creates a video texture.
  63776. * If you want to display a video in your scene, this is the special texture for that.
  63777. * This special texture works similar to other textures, with the exception of a few parameters.
  63778. * @see https://doc.babylonjs.com/how_to/video_texture
  63779. * @param name optional name, will detect from video source, if not defined
  63780. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  63781. * @param scene is obviously the current scene.
  63782. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  63783. * @param invertY is false by default but can be used to invert video on Y axis
  63784. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  63785. * @param settings allows finer control over video usage
  63786. */
  63787. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  63788. if (generateMipMaps === void 0) { generateMipMaps = false; }
  63789. if (invertY === void 0) { invertY = false; }
  63790. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  63791. if (settings === void 0) { settings = {
  63792. autoPlay: true,
  63793. loop: true,
  63794. autoUpdateTexture: true,
  63795. }; }
  63796. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  63797. _this._onUserActionRequestedObservable = null;
  63798. _this._stillImageCaptured = false;
  63799. _this._displayingPosterTexture = false;
  63800. _this._createInternalTexture = function () {
  63801. if (_this._texture != null) {
  63802. if (_this._displayingPosterTexture) {
  63803. _this._texture.dispose();
  63804. _this._displayingPosterTexture = false;
  63805. }
  63806. else {
  63807. return;
  63808. }
  63809. }
  63810. if (!_this._engine.needPOTTextures ||
  63811. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  63812. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  63813. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  63814. }
  63815. else {
  63816. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  63817. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  63818. _this._generateMipMaps = false;
  63819. }
  63820. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  63821. if (!_this.video.autoplay && !_this._settings.poster) {
  63822. var oldHandler_1 = _this.video.onplaying;
  63823. var error_1 = false;
  63824. var oldMuted_1 = _this.video.muted;
  63825. _this.video.muted = true;
  63826. _this.video.onplaying = function () {
  63827. _this.video.muted = oldMuted_1;
  63828. _this.video.onplaying = oldHandler_1;
  63829. _this._texture.isReady = true;
  63830. _this._updateInternalTexture();
  63831. if (!error_1) {
  63832. _this.video.pause();
  63833. }
  63834. if (_this.onLoadObservable.hasObservers()) {
  63835. _this.onLoadObservable.notifyObservers(_this);
  63836. }
  63837. };
  63838. var playing = _this.video.play();
  63839. if (playing) {
  63840. playing.then(function () {
  63841. // Everything is good.
  63842. })
  63843. .catch(function () {
  63844. error_1 = true;
  63845. // On Chrome for instance, new policies might prevent playing without user interaction.
  63846. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  63847. _this._onUserActionRequestedObservable.notifyObservers(_this);
  63848. }
  63849. });
  63850. }
  63851. else {
  63852. _this.video.onplaying = oldHandler_1;
  63853. _this._texture.isReady = true;
  63854. _this._updateInternalTexture();
  63855. if (_this.onLoadObservable.hasObservers()) {
  63856. _this.onLoadObservable.notifyObservers(_this);
  63857. }
  63858. }
  63859. }
  63860. else {
  63861. _this._texture.isReady = true;
  63862. _this._updateInternalTexture();
  63863. if (_this.onLoadObservable.hasObservers()) {
  63864. _this.onLoadObservable.notifyObservers(_this);
  63865. }
  63866. }
  63867. };
  63868. _this.reset = function () {
  63869. if (_this._texture == null) {
  63870. return;
  63871. }
  63872. if (!_this._displayingPosterTexture) {
  63873. _this._texture.dispose();
  63874. _this._texture = null;
  63875. }
  63876. };
  63877. _this._updateInternalTexture = function () {
  63878. if (_this._texture == null || !_this._texture.isReady) {
  63879. return;
  63880. }
  63881. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  63882. return;
  63883. }
  63884. if (_this._displayingPosterTexture) {
  63885. return;
  63886. }
  63887. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  63888. };
  63889. _this._engine = _this.getScene().getEngine();
  63890. _this._generateMipMaps = generateMipMaps;
  63891. _this._initialSamplingMode = samplingMode;
  63892. _this.autoUpdateTexture = settings.autoUpdateTexture;
  63893. _this.name = name || _this._getName(src);
  63894. _this.video = _this._getVideo(src);
  63895. _this._settings = settings;
  63896. if (settings.poster) {
  63897. _this.video.poster = settings.poster;
  63898. }
  63899. if (settings.autoPlay !== undefined) {
  63900. _this.video.autoplay = settings.autoPlay;
  63901. }
  63902. if (settings.loop !== undefined) {
  63903. _this.video.loop = settings.loop;
  63904. }
  63905. _this.video.setAttribute("playsinline", "");
  63906. _this.video.addEventListener("paused", _this._updateInternalTexture);
  63907. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  63908. _this.video.addEventListener("emptied", _this.reset);
  63909. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  63910. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  63911. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  63912. if (settings.poster &&
  63913. (!settings.autoPlay || !videoHasEnoughData)) {
  63914. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  63915. _this._displayingPosterTexture = true;
  63916. }
  63917. else if (videoHasEnoughData) {
  63918. _this._createInternalTexture();
  63919. }
  63920. return _this;
  63921. }
  63922. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  63923. /**
  63924. * Event triggerd when a dom action is required by the user to play the video.
  63925. * This happens due to recent changes in browser policies preventing video to auto start.
  63926. */
  63927. get: function () {
  63928. if (!this._onUserActionRequestedObservable) {
  63929. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  63930. }
  63931. return this._onUserActionRequestedObservable;
  63932. },
  63933. enumerable: true,
  63934. configurable: true
  63935. });
  63936. VideoTexture.prototype._getName = function (src) {
  63937. if (src instanceof HTMLVideoElement) {
  63938. return src.currentSrc;
  63939. }
  63940. if (typeof src === "object") {
  63941. return src.toString();
  63942. }
  63943. return src;
  63944. };
  63945. VideoTexture.prototype._getVideo = function (src) {
  63946. if (src instanceof HTMLVideoElement) {
  63947. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  63948. return src;
  63949. }
  63950. var video = document.createElement("video");
  63951. if (typeof src === "string") {
  63952. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  63953. video.src = src;
  63954. }
  63955. else {
  63956. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  63957. src.forEach(function (url) {
  63958. var source = document.createElement("source");
  63959. source.src = url;
  63960. video.appendChild(source);
  63961. });
  63962. }
  63963. return video;
  63964. };
  63965. /**
  63966. * @hidden Internal method to initiate `update`.
  63967. */
  63968. VideoTexture.prototype._rebuild = function () {
  63969. this.update();
  63970. };
  63971. /**
  63972. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  63973. */
  63974. VideoTexture.prototype.update = function () {
  63975. if (!this.autoUpdateTexture) {
  63976. // Expecting user to call `updateTexture` manually
  63977. return;
  63978. }
  63979. this.updateTexture(true);
  63980. };
  63981. /**
  63982. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  63983. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  63984. */
  63985. VideoTexture.prototype.updateTexture = function (isVisible) {
  63986. if (!isVisible) {
  63987. return;
  63988. }
  63989. if (this.video.paused && this._stillImageCaptured) {
  63990. return;
  63991. }
  63992. this._stillImageCaptured = true;
  63993. this._updateInternalTexture();
  63994. };
  63995. /**
  63996. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  63997. * @param url New url.
  63998. */
  63999. VideoTexture.prototype.updateURL = function (url) {
  64000. this.video.src = url;
  64001. };
  64002. /**
  64003. * Dispose the texture and release its associated resources.
  64004. */
  64005. VideoTexture.prototype.dispose = function () {
  64006. _super.prototype.dispose.call(this);
  64007. if (this._onUserActionRequestedObservable) {
  64008. this._onUserActionRequestedObservable.clear();
  64009. this._onUserActionRequestedObservable = null;
  64010. }
  64011. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  64012. this.video.removeEventListener("paused", this._updateInternalTexture);
  64013. this.video.removeEventListener("seeked", this._updateInternalTexture);
  64014. this.video.removeEventListener("emptied", this.reset);
  64015. this.video.pause();
  64016. };
  64017. /**
  64018. * Creates a video texture straight from a stream.
  64019. * @param scene Define the scene the texture should be created in
  64020. * @param stream Define the stream the texture should be created from
  64021. * @returns The created video texture as a promise
  64022. */
  64023. VideoTexture.CreateFromStreamAsync = function (scene, stream) {
  64024. var video = document.createElement("video");
  64025. video.setAttribute('autoplay', '');
  64026. video.setAttribute('muted', 'true');
  64027. video.setAttribute('playsinline', '');
  64028. video.muted = true;
  64029. if (video.mozSrcObject !== undefined) {
  64030. // hack for Firefox < 19
  64031. video.mozSrcObject = stream;
  64032. }
  64033. else {
  64034. if (typeof video.srcObject == "object") {
  64035. video.srcObject = stream;
  64036. }
  64037. else {
  64038. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  64039. video.src = (window.URL && window.URL.createObjectURL(stream));
  64040. }
  64041. }
  64042. return new Promise(function (resolve) {
  64043. var onPlaying = function () {
  64044. resolve(new VideoTexture("video", video, scene, true, true));
  64045. video.removeEventListener("playing", onPlaying);
  64046. };
  64047. video.addEventListener("playing", onPlaying);
  64048. video.play();
  64049. });
  64050. };
  64051. /**
  64052. * Creates a video texture straight from your WebCam video feed.
  64053. * @param scene Define the scene the texture should be created in
  64054. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  64055. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  64056. * @returns The created video texture as a promise
  64057. */
  64058. VideoTexture.CreateFromWebCamAsync = function (scene, constraints, audioConstaints) {
  64059. var _this = this;
  64060. if (audioConstaints === void 0) { audioConstaints = false; }
  64061. var constraintsDeviceId;
  64062. if (constraints && constraints.deviceId) {
  64063. constraintsDeviceId = {
  64064. exact: constraints.deviceId,
  64065. };
  64066. }
  64067. if (navigator.mediaDevices) {
  64068. return navigator.mediaDevices.getUserMedia({
  64069. video: constraints,
  64070. audio: audioConstaints
  64071. })
  64072. .then(function (stream) {
  64073. return _this.CreateFromStreamAsync(scene, stream);
  64074. });
  64075. }
  64076. else {
  64077. navigator.getUserMedia =
  64078. navigator.getUserMedia ||
  64079. navigator.webkitGetUserMedia ||
  64080. navigator.mozGetUserMedia ||
  64081. navigator.msGetUserMedia;
  64082. if (navigator.getUserMedia) {
  64083. navigator.getUserMedia({
  64084. video: {
  64085. deviceId: constraintsDeviceId,
  64086. width: {
  64087. min: (constraints && constraints.minWidth) || 256,
  64088. max: (constraints && constraints.maxWidth) || 640,
  64089. },
  64090. height: {
  64091. min: (constraints && constraints.minHeight) || 256,
  64092. max: (constraints && constraints.maxHeight) || 480,
  64093. },
  64094. },
  64095. audio: audioConstaints
  64096. }, function (stream) {
  64097. return _this.CreateFromStreamAsync(scene, stream);
  64098. }, function (e) {
  64099. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  64100. });
  64101. }
  64102. }
  64103. return Promise.reject("No support for userMedia on this device");
  64104. };
  64105. /**
  64106. * Creates a video texture straight from your WebCam video feed.
  64107. * @param scene Define the scene the texture should be created in
  64108. * @param onReady Define a callback to triggered once the texture will be ready
  64109. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  64110. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  64111. */
  64112. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints, audioConstaints) {
  64113. if (audioConstaints === void 0) { audioConstaints = false; }
  64114. this.CreateFromWebCamAsync(scene, constraints, audioConstaints)
  64115. .then(function (videoTexture) {
  64116. if (onReady) {
  64117. onReady(videoTexture);
  64118. }
  64119. })
  64120. .catch(function (err) {
  64121. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  64122. });
  64123. };
  64124. return VideoTexture;
  64125. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  64126. /***/ }),
  64127. /***/ "./Materials/colorCurves.ts":
  64128. /*!**********************************!*\
  64129. !*** ./Materials/colorCurves.ts ***!
  64130. \**********************************/
  64131. /*! exports provided: ColorCurves */
  64132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64133. "use strict";
  64134. __webpack_require__.r(__webpack_exports__);
  64135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  64136. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64137. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64138. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64139. /**
  64140. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  64141. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  64142. * 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;
  64143. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  64144. */
  64145. var ColorCurves = /** @class */ (function () {
  64146. function ColorCurves() {
  64147. this._dirty = true;
  64148. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  64149. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  64150. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  64151. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  64152. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  64153. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  64154. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  64155. this._globalHue = 30;
  64156. this._globalDensity = 0;
  64157. this._globalSaturation = 0;
  64158. this._globalExposure = 0;
  64159. this._highlightsHue = 30;
  64160. this._highlightsDensity = 0;
  64161. this._highlightsSaturation = 0;
  64162. this._highlightsExposure = 0;
  64163. this._midtonesHue = 30;
  64164. this._midtonesDensity = 0;
  64165. this._midtonesSaturation = 0;
  64166. this._midtonesExposure = 0;
  64167. this._shadowsHue = 30;
  64168. this._shadowsDensity = 0;
  64169. this._shadowsSaturation = 0;
  64170. this._shadowsExposure = 0;
  64171. }
  64172. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  64173. /**
  64174. * Gets the global Hue value.
  64175. * 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).
  64176. */
  64177. get: function () {
  64178. return this._globalHue;
  64179. },
  64180. /**
  64181. * Sets the global Hue value.
  64182. * 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).
  64183. */
  64184. set: function (value) {
  64185. this._globalHue = value;
  64186. this._dirty = true;
  64187. },
  64188. enumerable: true,
  64189. configurable: true
  64190. });
  64191. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  64192. /**
  64193. * Gets the global Density value.
  64194. * 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.
  64195. * Values less than zero provide a filter of opposite hue.
  64196. */
  64197. get: function () {
  64198. return this._globalDensity;
  64199. },
  64200. /**
  64201. * Sets the global Density value.
  64202. * 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.
  64203. * Values less than zero provide a filter of opposite hue.
  64204. */
  64205. set: function (value) {
  64206. this._globalDensity = value;
  64207. this._dirty = true;
  64208. },
  64209. enumerable: true,
  64210. configurable: true
  64211. });
  64212. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  64213. /**
  64214. * Gets the global Saturation value.
  64215. * 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.
  64216. */
  64217. get: function () {
  64218. return this._globalSaturation;
  64219. },
  64220. /**
  64221. * Sets the global Saturation value.
  64222. * 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.
  64223. */
  64224. set: function (value) {
  64225. this._globalSaturation = value;
  64226. this._dirty = true;
  64227. },
  64228. enumerable: true,
  64229. configurable: true
  64230. });
  64231. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  64232. /**
  64233. * Gets the global Exposure value.
  64234. * 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.
  64235. */
  64236. get: function () {
  64237. return this._globalExposure;
  64238. },
  64239. /**
  64240. * Sets the global Exposure value.
  64241. * 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.
  64242. */
  64243. set: function (value) {
  64244. this._globalExposure = value;
  64245. this._dirty = true;
  64246. },
  64247. enumerable: true,
  64248. configurable: true
  64249. });
  64250. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  64251. /**
  64252. * Gets the highlights Hue value.
  64253. * 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).
  64254. */
  64255. get: function () {
  64256. return this._highlightsHue;
  64257. },
  64258. /**
  64259. * Sets the highlights Hue value.
  64260. * 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).
  64261. */
  64262. set: function (value) {
  64263. this._highlightsHue = value;
  64264. this._dirty = true;
  64265. },
  64266. enumerable: true,
  64267. configurable: true
  64268. });
  64269. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  64270. /**
  64271. * Gets the highlights Density value.
  64272. * 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.
  64273. * Values less than zero provide a filter of opposite hue.
  64274. */
  64275. get: function () {
  64276. return this._highlightsDensity;
  64277. },
  64278. /**
  64279. * Sets the highlights Density value.
  64280. * 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.
  64281. * Values less than zero provide a filter of opposite hue.
  64282. */
  64283. set: function (value) {
  64284. this._highlightsDensity = value;
  64285. this._dirty = true;
  64286. },
  64287. enumerable: true,
  64288. configurable: true
  64289. });
  64290. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  64291. /**
  64292. * Gets the highlights Saturation value.
  64293. * 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.
  64294. */
  64295. get: function () {
  64296. return this._highlightsSaturation;
  64297. },
  64298. /**
  64299. * Sets the highlights Saturation value.
  64300. * 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.
  64301. */
  64302. set: function (value) {
  64303. this._highlightsSaturation = value;
  64304. this._dirty = true;
  64305. },
  64306. enumerable: true,
  64307. configurable: true
  64308. });
  64309. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  64310. /**
  64311. * Gets the highlights Exposure value.
  64312. * 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.
  64313. */
  64314. get: function () {
  64315. return this._highlightsExposure;
  64316. },
  64317. /**
  64318. * Sets the highlights Exposure value.
  64319. * 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.
  64320. */
  64321. set: function (value) {
  64322. this._highlightsExposure = value;
  64323. this._dirty = true;
  64324. },
  64325. enumerable: true,
  64326. configurable: true
  64327. });
  64328. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  64329. /**
  64330. * Gets the midtones Hue value.
  64331. * 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).
  64332. */
  64333. get: function () {
  64334. return this._midtonesHue;
  64335. },
  64336. /**
  64337. * Sets the midtones Hue value.
  64338. * 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).
  64339. */
  64340. set: function (value) {
  64341. this._midtonesHue = value;
  64342. this._dirty = true;
  64343. },
  64344. enumerable: true,
  64345. configurable: true
  64346. });
  64347. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  64348. /**
  64349. * Gets the midtones Density value.
  64350. * 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.
  64351. * Values less than zero provide a filter of opposite hue.
  64352. */
  64353. get: function () {
  64354. return this._midtonesDensity;
  64355. },
  64356. /**
  64357. * Sets the midtones Density value.
  64358. * 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.
  64359. * Values less than zero provide a filter of opposite hue.
  64360. */
  64361. set: function (value) {
  64362. this._midtonesDensity = value;
  64363. this._dirty = true;
  64364. },
  64365. enumerable: true,
  64366. configurable: true
  64367. });
  64368. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  64369. /**
  64370. * Gets the midtones Saturation value.
  64371. * 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.
  64372. */
  64373. get: function () {
  64374. return this._midtonesSaturation;
  64375. },
  64376. /**
  64377. * Sets the midtones Saturation value.
  64378. * 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.
  64379. */
  64380. set: function (value) {
  64381. this._midtonesSaturation = value;
  64382. this._dirty = true;
  64383. },
  64384. enumerable: true,
  64385. configurable: true
  64386. });
  64387. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  64388. /**
  64389. * Gets the midtones Exposure value.
  64390. * 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.
  64391. */
  64392. get: function () {
  64393. return this._midtonesExposure;
  64394. },
  64395. /**
  64396. * Sets the midtones Exposure value.
  64397. * 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.
  64398. */
  64399. set: function (value) {
  64400. this._midtonesExposure = value;
  64401. this._dirty = true;
  64402. },
  64403. enumerable: true,
  64404. configurable: true
  64405. });
  64406. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  64407. /**
  64408. * Gets the shadows Hue value.
  64409. * 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).
  64410. */
  64411. get: function () {
  64412. return this._shadowsHue;
  64413. },
  64414. /**
  64415. * Sets the shadows Hue value.
  64416. * 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).
  64417. */
  64418. set: function (value) {
  64419. this._shadowsHue = value;
  64420. this._dirty = true;
  64421. },
  64422. enumerable: true,
  64423. configurable: true
  64424. });
  64425. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  64426. /**
  64427. * Gets the shadows Density value.
  64428. * 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.
  64429. * Values less than zero provide a filter of opposite hue.
  64430. */
  64431. get: function () {
  64432. return this._shadowsDensity;
  64433. },
  64434. /**
  64435. * Sets the shadows Density value.
  64436. * 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.
  64437. * Values less than zero provide a filter of opposite hue.
  64438. */
  64439. set: function (value) {
  64440. this._shadowsDensity = value;
  64441. this._dirty = true;
  64442. },
  64443. enumerable: true,
  64444. configurable: true
  64445. });
  64446. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  64447. /**
  64448. * Gets the shadows Saturation value.
  64449. * 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.
  64450. */
  64451. get: function () {
  64452. return this._shadowsSaturation;
  64453. },
  64454. /**
  64455. * Sets the shadows Saturation value.
  64456. * 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.
  64457. */
  64458. set: function (value) {
  64459. this._shadowsSaturation = value;
  64460. this._dirty = true;
  64461. },
  64462. enumerable: true,
  64463. configurable: true
  64464. });
  64465. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  64466. /**
  64467. * Gets the shadows Exposure value.
  64468. * 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.
  64469. */
  64470. get: function () {
  64471. return this._shadowsExposure;
  64472. },
  64473. /**
  64474. * Sets the shadows Exposure value.
  64475. * 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.
  64476. */
  64477. set: function (value) {
  64478. this._shadowsExposure = value;
  64479. this._dirty = true;
  64480. },
  64481. enumerable: true,
  64482. configurable: true
  64483. });
  64484. /**
  64485. * Returns the class name
  64486. * @returns The class name
  64487. */
  64488. ColorCurves.prototype.getClassName = function () {
  64489. return "ColorCurves";
  64490. };
  64491. /**
  64492. * Binds the color curves to the shader.
  64493. * @param colorCurves The color curve to bind
  64494. * @param effect The effect to bind to
  64495. * @param positiveUniform The positive uniform shader parameter
  64496. * @param neutralUniform The neutral uniform shader parameter
  64497. * @param negativeUniform The negative uniform shader parameter
  64498. */
  64499. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  64500. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  64501. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  64502. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  64503. if (colorCurves._dirty) {
  64504. colorCurves._dirty = false;
  64505. // Fill in global info.
  64506. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  64507. // Compute highlights info.
  64508. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  64509. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  64510. // Compute midtones info.
  64511. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  64512. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  64513. // Compute shadows info.
  64514. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  64515. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  64516. // Compute deltas (neutral is midtones).
  64517. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  64518. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  64519. }
  64520. if (effect) {
  64521. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  64522. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  64523. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  64524. }
  64525. };
  64526. /**
  64527. * Prepare the list of uniforms associated with the ColorCurves effects.
  64528. * @param uniformsList The list of uniforms used in the effect
  64529. */
  64530. ColorCurves.PrepareUniforms = function (uniformsList) {
  64531. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  64532. };
  64533. /**
  64534. * Returns color grading data based on a hue, density, saturation and exposure value.
  64535. * @param filterHue The hue of the color filter.
  64536. * @param filterDensity The density of the color filter.
  64537. * @param saturation The saturation.
  64538. * @param exposure The exposure.
  64539. * @param result The result data container.
  64540. */
  64541. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  64542. if (hue == null) {
  64543. return;
  64544. }
  64545. hue = ColorCurves.clamp(hue, 0, 360);
  64546. density = ColorCurves.clamp(density, -100, 100);
  64547. saturation = ColorCurves.clamp(saturation, -100, 100);
  64548. exposure = ColorCurves.clamp(exposure, -100, 100);
  64549. // Remap the slider/config filter density with non-linear mapping and also scale by half
  64550. // so that the maximum filter density is only 50% control. This provides fine control
  64551. // for small values and reasonable range.
  64552. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  64553. density *= 0.5;
  64554. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  64555. if (density < 0) {
  64556. density *= -1;
  64557. hue = (hue + 180) % 360;
  64558. }
  64559. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  64560. result.scaleToRef(2, result);
  64561. result.a = 1 + 0.01 * saturation;
  64562. };
  64563. /**
  64564. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  64565. * @param value The input slider value in range [-100,100].
  64566. * @returns Adjusted value.
  64567. */
  64568. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  64569. value /= 100;
  64570. var x = Math.abs(value);
  64571. x = Math.pow(x, 2);
  64572. if (value < 0) {
  64573. x *= -1;
  64574. }
  64575. x *= 100;
  64576. return x;
  64577. };
  64578. /**
  64579. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  64580. * @param hue The hue (H) input.
  64581. * @param saturation The saturation (S) input.
  64582. * @param brightness The brightness (B) input.
  64583. * @result An RGBA color represented as Vector4.
  64584. */
  64585. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  64586. var h = ColorCurves.clamp(hue, 0, 360);
  64587. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  64588. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  64589. if (s === 0) {
  64590. result.r = v;
  64591. result.g = v;
  64592. result.b = v;
  64593. }
  64594. else {
  64595. // sector 0 to 5
  64596. h /= 60;
  64597. var i = Math.floor(h);
  64598. // fractional part of h
  64599. var f = h - i;
  64600. var p = v * (1 - s);
  64601. var q = v * (1 - s * f);
  64602. var t = v * (1 - s * (1 - f));
  64603. switch (i) {
  64604. case 0:
  64605. result.r = v;
  64606. result.g = t;
  64607. result.b = p;
  64608. break;
  64609. case 1:
  64610. result.r = q;
  64611. result.g = v;
  64612. result.b = p;
  64613. break;
  64614. case 2:
  64615. result.r = p;
  64616. result.g = v;
  64617. result.b = t;
  64618. break;
  64619. case 3:
  64620. result.r = p;
  64621. result.g = q;
  64622. result.b = v;
  64623. break;
  64624. case 4:
  64625. result.r = t;
  64626. result.g = p;
  64627. result.b = v;
  64628. break;
  64629. default: // case 5:
  64630. result.r = v;
  64631. result.g = p;
  64632. result.b = q;
  64633. break;
  64634. }
  64635. }
  64636. result.a = 1;
  64637. };
  64638. /**
  64639. * Returns a value clamped between min and max
  64640. * @param value The value to clamp
  64641. * @param min The minimum of value
  64642. * @param max The maximum of value
  64643. * @returns The clamped value.
  64644. */
  64645. ColorCurves.clamp = function (value, min, max) {
  64646. return Math.min(Math.max(value, min), max);
  64647. };
  64648. /**
  64649. * Clones the current color curve instance.
  64650. * @return The cloned curves
  64651. */
  64652. ColorCurves.prototype.clone = function () {
  64653. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  64654. };
  64655. /**
  64656. * Serializes the current color curve instance to a json representation.
  64657. * @return a JSON representation
  64658. */
  64659. ColorCurves.prototype.serialize = function () {
  64660. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  64661. };
  64662. /**
  64663. * Parses the color curve from a json representation.
  64664. * @param source the JSON source to parse
  64665. * @return The parsed curves
  64666. */
  64667. ColorCurves.Parse = function (source) {
  64668. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  64669. };
  64670. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64671. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64672. ], ColorCurves.prototype, "_globalHue", void 0);
  64673. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64674. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64675. ], ColorCurves.prototype, "_globalDensity", void 0);
  64676. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64677. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64678. ], ColorCurves.prototype, "_globalSaturation", void 0);
  64679. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64681. ], ColorCurves.prototype, "_globalExposure", void 0);
  64682. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64683. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64684. ], ColorCurves.prototype, "_highlightsHue", void 0);
  64685. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64686. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64687. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  64688. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64689. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64690. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  64691. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64692. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64693. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  64694. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64695. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64696. ], ColorCurves.prototype, "_midtonesHue", void 0);
  64697. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64698. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64699. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  64700. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64702. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  64703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64705. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  64706. return ColorCurves;
  64707. }());
  64708. // References the dependencies.
  64709. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  64710. /***/ }),
  64711. /***/ "./Materials/effect.ts":
  64712. /*!*****************************!*\
  64713. !*** ./Materials/effect.ts ***!
  64714. \*****************************/
  64715. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  64716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64717. "use strict";
  64718. __webpack_require__.r(__webpack_exports__);
  64719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  64720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  64721. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  64722. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  64723. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  64724. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  64725. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  64726. /**
  64727. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  64728. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  64729. */
  64730. var EffectFallbacks = /** @class */ (function () {
  64731. function EffectFallbacks() {
  64732. this._defines = {};
  64733. this._currentRank = 32;
  64734. this._maxRank = -1;
  64735. this._mesh = null;
  64736. }
  64737. /**
  64738. * Removes the fallback from the bound mesh.
  64739. */
  64740. EffectFallbacks.prototype.unBindMesh = function () {
  64741. this._mesh = null;
  64742. };
  64743. /**
  64744. * Adds a fallback on the specified property.
  64745. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  64746. * @param define The name of the define in the shader
  64747. */
  64748. EffectFallbacks.prototype.addFallback = function (rank, define) {
  64749. if (!this._defines[rank]) {
  64750. if (rank < this._currentRank) {
  64751. this._currentRank = rank;
  64752. }
  64753. if (rank > this._maxRank) {
  64754. this._maxRank = rank;
  64755. }
  64756. this._defines[rank] = new Array();
  64757. }
  64758. this._defines[rank].push(define);
  64759. };
  64760. /**
  64761. * Sets the mesh to use CPU skinning when needing to fallback.
  64762. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  64763. * @param mesh The mesh to use the fallbacks.
  64764. */
  64765. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  64766. this._mesh = mesh;
  64767. if (rank < this._currentRank) {
  64768. this._currentRank = rank;
  64769. }
  64770. if (rank > this._maxRank) {
  64771. this._maxRank = rank;
  64772. }
  64773. };
  64774. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  64775. /**
  64776. * Checks to see if more fallbacks are still availible.
  64777. */
  64778. get: function () {
  64779. return this._currentRank <= this._maxRank;
  64780. },
  64781. enumerable: true,
  64782. configurable: true
  64783. });
  64784. /**
  64785. * Removes the defines that shoould be removed when falling back.
  64786. * @param currentDefines defines the current define statements for the shader.
  64787. * @param effect defines the current effect we try to compile
  64788. * @returns The resulting defines with defines of the current rank removed.
  64789. */
  64790. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  64791. // First we try to switch to CPU skinning
  64792. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  64793. this._mesh.computeBonesUsingShaders = false;
  64794. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  64795. effect._bonesComputationForcedToCPU = true;
  64796. var scene = this._mesh.getScene();
  64797. for (var index = 0; index < scene.meshes.length; index++) {
  64798. var otherMesh = scene.meshes[index];
  64799. if (!otherMesh.material) {
  64800. continue;
  64801. }
  64802. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  64803. continue;
  64804. }
  64805. if (otherMesh.material.getEffect() === effect) {
  64806. otherMesh.computeBonesUsingShaders = false;
  64807. }
  64808. else if (otherMesh.subMeshes) {
  64809. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  64810. var subMesh = _a[_i];
  64811. var subMeshEffect = subMesh.effect;
  64812. if (subMeshEffect === effect) {
  64813. otherMesh.computeBonesUsingShaders = false;
  64814. break;
  64815. }
  64816. }
  64817. }
  64818. }
  64819. }
  64820. else {
  64821. var currentFallbacks = this._defines[this._currentRank];
  64822. if (currentFallbacks) {
  64823. for (var index = 0; index < currentFallbacks.length; index++) {
  64824. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  64825. }
  64826. }
  64827. this._currentRank++;
  64828. }
  64829. return currentDefines;
  64830. };
  64831. return EffectFallbacks;
  64832. }());
  64833. /**
  64834. * Options to be used when creating an effect.
  64835. */
  64836. var EffectCreationOptions = /** @class */ (function () {
  64837. function EffectCreationOptions() {
  64838. }
  64839. return EffectCreationOptions;
  64840. }());
  64841. /**
  64842. * Effect containing vertex and fragment shader that can be executed on an object.
  64843. */
  64844. var Effect = /** @class */ (function () {
  64845. /**
  64846. * Instantiates an effect.
  64847. * An effect can be used to create/manage/execute vertex and fragment shaders.
  64848. * @param baseName Name of the effect.
  64849. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  64850. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  64851. * @param samplers List of sampler variables that will be passed to the shader.
  64852. * @param engine Engine to be used to render the effect
  64853. * @param defines Define statements to be added to the shader.
  64854. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  64855. * @param onCompiled Callback that will be called when the shader is compiled.
  64856. * @param onError Callback that will be called if an error occurs during shader compilation.
  64857. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  64858. */
  64859. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  64860. var _this = this;
  64861. if (samplers === void 0) { samplers = null; }
  64862. if (defines === void 0) { defines = null; }
  64863. if (fallbacks === void 0) { fallbacks = null; }
  64864. if (onCompiled === void 0) { onCompiled = null; }
  64865. if (onError === void 0) { onError = null; }
  64866. /**
  64867. * Name of the effect.
  64868. */
  64869. this.name = null;
  64870. /**
  64871. * String container all the define statements that should be set on the shader.
  64872. */
  64873. this.defines = "";
  64874. /**
  64875. * Callback that will be called when the shader is compiled.
  64876. */
  64877. this.onCompiled = null;
  64878. /**
  64879. * Callback that will be called if an error occurs during shader compilation.
  64880. */
  64881. this.onError = null;
  64882. /**
  64883. * Callback that will be called when effect is bound.
  64884. */
  64885. this.onBind = null;
  64886. /**
  64887. * Unique ID of the effect.
  64888. */
  64889. this.uniqueId = 0;
  64890. /**
  64891. * Observable that will be called when the shader is compiled.
  64892. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  64893. */
  64894. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  64895. /**
  64896. * Observable that will be called if an error occurs during shader compilation.
  64897. */
  64898. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  64899. /** @hidden */
  64900. this._onBindObservable = null;
  64901. /** @hidden */
  64902. this._bonesComputationForcedToCPU = false;
  64903. this._uniformBuffersNames = {};
  64904. this._samplers = {};
  64905. this._isReady = false;
  64906. this._compilationError = "";
  64907. this._uniforms = {};
  64908. /**
  64909. * Key for the effect.
  64910. * @hidden
  64911. */
  64912. this._key = "";
  64913. this._fallbacks = null;
  64914. this._vertexSourceCode = "";
  64915. this._fragmentSourceCode = "";
  64916. this._vertexSourceCodeOverride = "";
  64917. this._fragmentSourceCodeOverride = "";
  64918. this._transformFeedbackVaryings = null;
  64919. /**
  64920. * Compiled shader to webGL program.
  64921. * @hidden
  64922. */
  64923. this._pipelineContext = null;
  64924. this._valueCache = {};
  64925. this.name = baseName;
  64926. if (attributesNamesOrOptions.attributes) {
  64927. var options = attributesNamesOrOptions;
  64928. this._engine = uniformsNamesOrEngine;
  64929. this._attributesNames = options.attributes;
  64930. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  64931. this._samplerList = options.samplers.slice();
  64932. this.defines = options.defines;
  64933. this.onError = options.onError;
  64934. this.onCompiled = options.onCompiled;
  64935. this._fallbacks = options.fallbacks;
  64936. this._indexParameters = options.indexParameters;
  64937. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  64938. if (options.uniformBuffersNames) {
  64939. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  64940. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  64941. }
  64942. }
  64943. }
  64944. else {
  64945. this._engine = engine;
  64946. this.defines = (defines == null ? "" : defines);
  64947. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  64948. this._samplerList = samplers ? samplers.slice() : [];
  64949. this._attributesNames = attributesNamesOrOptions;
  64950. this.onError = onError;
  64951. this.onCompiled = onCompiled;
  64952. this._indexParameters = indexParameters;
  64953. this._fallbacks = fallbacks;
  64954. }
  64955. this.uniqueId = Effect._uniqueIdSeed++;
  64956. var vertexSource;
  64957. var fragmentSource;
  64958. if (baseName.vertexElement) {
  64959. vertexSource = document.getElementById(baseName.vertexElement);
  64960. if (!vertexSource) {
  64961. vertexSource = baseName.vertexElement;
  64962. }
  64963. }
  64964. else {
  64965. vertexSource = baseName.vertex || baseName;
  64966. }
  64967. if (baseName.fragmentElement) {
  64968. fragmentSource = document.getElementById(baseName.fragmentElement);
  64969. if (!fragmentSource) {
  64970. fragmentSource = baseName.fragmentElement;
  64971. }
  64972. }
  64973. else {
  64974. fragmentSource = baseName.fragment || baseName;
  64975. }
  64976. this._loadVertexShader(vertexSource, function (vertexCode) {
  64977. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  64978. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  64979. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  64980. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  64981. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  64982. if (baseName) {
  64983. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  64984. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  64985. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  64986. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  64987. }
  64988. else {
  64989. _this._vertexSourceCode = migratedVertexCode;
  64990. _this._fragmentSourceCode = migratedFragmentCode;
  64991. }
  64992. _this._prepareEffect();
  64993. });
  64994. });
  64995. });
  64996. });
  64997. });
  64998. });
  64999. }
  65000. Object.defineProperty(Effect.prototype, "onBindObservable", {
  65001. /**
  65002. * Observable that will be called when effect is bound.
  65003. */
  65004. get: function () {
  65005. if (!this._onBindObservable) {
  65006. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  65007. }
  65008. return this._onBindObservable;
  65009. },
  65010. enumerable: true,
  65011. configurable: true
  65012. });
  65013. Object.defineProperty(Effect.prototype, "key", {
  65014. /**
  65015. * Unique key for this effect
  65016. */
  65017. get: function () {
  65018. return this._key;
  65019. },
  65020. enumerable: true,
  65021. configurable: true
  65022. });
  65023. /**
  65024. * If the effect has been compiled and prepared.
  65025. * @returns if the effect is compiled and prepared.
  65026. */
  65027. Effect.prototype.isReady = function () {
  65028. if (this._isReady) {
  65029. return true;
  65030. }
  65031. if (this._pipelineContext) {
  65032. return this._pipelineContext.isReady;
  65033. }
  65034. return false;
  65035. };
  65036. /**
  65037. * The engine the effect was initialized with.
  65038. * @returns the engine.
  65039. */
  65040. Effect.prototype.getEngine = function () {
  65041. return this._engine;
  65042. };
  65043. /**
  65044. * The pipeline context for this effect
  65045. * @returns the associated pipeline context
  65046. */
  65047. Effect.prototype.getPipelineContext = function () {
  65048. return this._pipelineContext;
  65049. };
  65050. /**
  65051. * The set of names of attribute variables for the shader.
  65052. * @returns An array of attribute names.
  65053. */
  65054. Effect.prototype.getAttributesNames = function () {
  65055. return this._attributesNames;
  65056. };
  65057. /**
  65058. * Returns the attribute at the given index.
  65059. * @param index The index of the attribute.
  65060. * @returns The location of the attribute.
  65061. */
  65062. Effect.prototype.getAttributeLocation = function (index) {
  65063. return this._attributes[index];
  65064. };
  65065. /**
  65066. * Returns the attribute based on the name of the variable.
  65067. * @param name of the attribute to look up.
  65068. * @returns the attribute location.
  65069. */
  65070. Effect.prototype.getAttributeLocationByName = function (name) {
  65071. var index = this._attributesNames.indexOf(name);
  65072. return this._attributes[index];
  65073. };
  65074. /**
  65075. * The number of attributes.
  65076. * @returns the numnber of attributes.
  65077. */
  65078. Effect.prototype.getAttributesCount = function () {
  65079. return this._attributes.length;
  65080. };
  65081. /**
  65082. * Gets the index of a uniform variable.
  65083. * @param uniformName of the uniform to look up.
  65084. * @returns the index.
  65085. */
  65086. Effect.prototype.getUniformIndex = function (uniformName) {
  65087. return this._uniformsNames.indexOf(uniformName);
  65088. };
  65089. /**
  65090. * Returns the attribute based on the name of the variable.
  65091. * @param uniformName of the uniform to look up.
  65092. * @returns the location of the uniform.
  65093. */
  65094. Effect.prototype.getUniform = function (uniformName) {
  65095. return this._uniforms[uniformName];
  65096. };
  65097. /**
  65098. * Returns an array of sampler variable names
  65099. * @returns The array of sampler variable neames.
  65100. */
  65101. Effect.prototype.getSamplers = function () {
  65102. return this._samplerList;
  65103. };
  65104. /**
  65105. * The error from the last compilation.
  65106. * @returns the error string.
  65107. */
  65108. Effect.prototype.getCompilationError = function () {
  65109. return this._compilationError;
  65110. };
  65111. /**
  65112. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  65113. * @param func The callback to be used.
  65114. */
  65115. Effect.prototype.executeWhenCompiled = function (func) {
  65116. var _this = this;
  65117. if (this.isReady()) {
  65118. func(this);
  65119. return;
  65120. }
  65121. this.onCompileObservable.add(function (effect) {
  65122. func(effect);
  65123. });
  65124. if (!this._pipelineContext || this._pipelineContext.isAsync) {
  65125. setTimeout(function () {
  65126. _this._checkIsReady();
  65127. }, 16);
  65128. }
  65129. };
  65130. Effect.prototype._checkIsReady = function () {
  65131. var _this = this;
  65132. if (this.isReady()) {
  65133. return;
  65134. }
  65135. setTimeout(function () {
  65136. _this._checkIsReady();
  65137. }, 16);
  65138. };
  65139. /** @hidden */
  65140. Effect.prototype._loadVertexShader = function (vertex, callback) {
  65141. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  65142. // DOM element ?
  65143. if (vertex instanceof HTMLElement) {
  65144. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  65145. callback(vertexCode);
  65146. return;
  65147. }
  65148. }
  65149. // Base64 encoded ?
  65150. if (vertex.substr(0, 7) === "base64:") {
  65151. var vertexBinary = window.atob(vertex.substr(7));
  65152. callback(vertexBinary);
  65153. return;
  65154. }
  65155. // Is in local store ?
  65156. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  65157. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  65158. return;
  65159. }
  65160. var vertexShaderUrl;
  65161. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  65162. vertexShaderUrl = vertex;
  65163. }
  65164. else {
  65165. vertexShaderUrl = Effect.ShadersRepository + vertex;
  65166. }
  65167. // Vertex shader
  65168. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  65169. };
  65170. /** @hidden */
  65171. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  65172. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  65173. // DOM element ?
  65174. if (fragment instanceof HTMLElement) {
  65175. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  65176. callback(fragmentCode);
  65177. return;
  65178. }
  65179. }
  65180. // Base64 encoded ?
  65181. if (fragment.substr(0, 7) === "base64:") {
  65182. var fragmentBinary = window.atob(fragment.substr(7));
  65183. callback(fragmentBinary);
  65184. return;
  65185. }
  65186. // Is in local store ?
  65187. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  65188. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  65189. return;
  65190. }
  65191. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  65192. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  65193. return;
  65194. }
  65195. var fragmentShaderUrl;
  65196. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  65197. fragmentShaderUrl = fragment;
  65198. }
  65199. else {
  65200. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  65201. }
  65202. // Fragment shader
  65203. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  65204. };
  65205. /** @hidden */
  65206. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  65207. // Rebuild shaders source code
  65208. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  65209. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  65210. vertexCode = prefix + vertexCode;
  65211. fragmentCode = prefix + fragmentCode;
  65212. // Number lines of shaders source code
  65213. var i = 2;
  65214. var regex = /\n/gm;
  65215. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  65216. i = 2;
  65217. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  65218. // Dump shaders name and formatted source code
  65219. if (this.name.vertexElement) {
  65220. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  65221. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  65222. }
  65223. else if (this.name.vertex) {
  65224. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  65225. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  65226. }
  65227. else {
  65228. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  65229. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  65230. }
  65231. };
  65232. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  65233. var preparedSourceCode = this._processPrecision(sourceCode);
  65234. if (this._engine.webGLVersion == 1) {
  65235. callback(preparedSourceCode);
  65236. return;
  65237. }
  65238. // Already converted
  65239. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  65240. callback(preparedSourceCode.replace("#version 300 es", ""));
  65241. return;
  65242. }
  65243. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  65244. // Remove extensions
  65245. // #extension GL_OES_standard_derivatives : enable
  65246. // #extension GL_EXT_shader_texture_lod : enable
  65247. // #extension GL_EXT_frag_depth : enable
  65248. // #extension GL_EXT_draw_buffers : require
  65249. var regex = /#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  65250. var result = preparedSourceCode.replace(regex, "");
  65251. // Migrate to GLSL v300
  65252. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  65253. result = result.replace(/attribute[ \t]/g, "in ");
  65254. result = result.replace(/[ \t]attribute/g, " in");
  65255. result = result.replace(/texture2D\s*\(/g, "texture(");
  65256. if (isFragment) {
  65257. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  65258. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  65259. result = result.replace(/textureCube\s*\(/g, "texture(");
  65260. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  65261. result = result.replace(/gl_FragColor/g, "glFragColor");
  65262. result = result.replace(/gl_FragData/g, "glFragData");
  65263. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  65264. }
  65265. // Add multiview setup to top of file when defined
  65266. var hasMultiviewExtension = this.defines.indexOf("#define MULTIVIEW\n") !== -1;
  65267. if (hasMultiviewExtension && !isFragment) {
  65268. result = "#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n" + result;
  65269. }
  65270. callback(result);
  65271. };
  65272. Effect.prototype._processIncludes = function (sourceCode, callback) {
  65273. var _this = this;
  65274. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  65275. var match = regex.exec(sourceCode);
  65276. var returnValue = new String(sourceCode);
  65277. while (match != null) {
  65278. var includeFile = match[1];
  65279. // Uniform declaration
  65280. if (includeFile.indexOf("__decl__") !== -1) {
  65281. includeFile = includeFile.replace(/__decl__/, "");
  65282. if (this._engine.supportsUniformBuffers) {
  65283. includeFile = includeFile.replace(/Vertex/, "Ubo");
  65284. includeFile = includeFile.replace(/Fragment/, "Ubo");
  65285. }
  65286. includeFile = includeFile + "Declaration";
  65287. }
  65288. if (Effect.IncludesShadersStore[includeFile]) {
  65289. // Substitution
  65290. var includeContent = Effect.IncludesShadersStore[includeFile];
  65291. if (match[2]) {
  65292. var splits = match[3].split(",");
  65293. for (var index = 0; index < splits.length; index += 2) {
  65294. var source = new RegExp(splits[index], "g");
  65295. var dest = splits[index + 1];
  65296. includeContent = includeContent.replace(source, dest);
  65297. }
  65298. }
  65299. if (match[4]) {
  65300. var indexString = match[5];
  65301. if (indexString.indexOf("..") !== -1) {
  65302. var indexSplits = indexString.split("..");
  65303. var minIndex = parseInt(indexSplits[0]);
  65304. var maxIndex = parseInt(indexSplits[1]);
  65305. var sourceIncludeContent = includeContent.slice(0);
  65306. includeContent = "";
  65307. if (isNaN(maxIndex)) {
  65308. maxIndex = this._indexParameters[indexSplits[1]];
  65309. }
  65310. for (var i = minIndex; i < maxIndex; i++) {
  65311. if (!this._engine.supportsUniformBuffers) {
  65312. // Ubo replacement
  65313. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  65314. return p1 + "{X}";
  65315. });
  65316. }
  65317. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  65318. }
  65319. }
  65320. else {
  65321. if (!this._engine.supportsUniformBuffers) {
  65322. // Ubo replacement
  65323. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  65324. return p1 + "{X}";
  65325. });
  65326. }
  65327. includeContent = includeContent.replace(/\{X\}/g, indexString);
  65328. }
  65329. }
  65330. // Replace
  65331. returnValue = returnValue.replace(match[0], includeContent);
  65332. }
  65333. else {
  65334. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  65335. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  65336. Effect.IncludesShadersStore[includeFile] = fileContent;
  65337. _this._processIncludes(returnValue, callback);
  65338. });
  65339. return;
  65340. }
  65341. match = regex.exec(sourceCode);
  65342. }
  65343. callback(returnValue);
  65344. };
  65345. Effect.prototype._processPrecision = function (source) {
  65346. var shouldUseHighPrecisionShader = this._engine._shouldUseHighPrecisionShader;
  65347. if (source.indexOf("precision highp float") === -1) {
  65348. if (!shouldUseHighPrecisionShader) {
  65349. source = "precision mediump float;\n" + source;
  65350. }
  65351. else {
  65352. source = "precision highp float;\n" + source;
  65353. }
  65354. }
  65355. else {
  65356. if (!shouldUseHighPrecisionShader) { // Moving highp to mediump
  65357. source = source.replace("precision highp float", "precision mediump float");
  65358. }
  65359. }
  65360. return source;
  65361. };
  65362. /**
  65363. * Recompiles the webGL program
  65364. * @param vertexSourceCode The source code for the vertex shader.
  65365. * @param fragmentSourceCode The source code for the fragment shader.
  65366. * @param onCompiled Callback called when completed.
  65367. * @param onError Callback called on error.
  65368. * @hidden
  65369. */
  65370. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  65371. var _this = this;
  65372. this._isReady = false;
  65373. this._vertexSourceCodeOverride = vertexSourceCode;
  65374. this._fragmentSourceCodeOverride = fragmentSourceCode;
  65375. this.onError = function (effect, error) {
  65376. if (onError) {
  65377. onError(error);
  65378. }
  65379. };
  65380. this.onCompiled = function () {
  65381. var scenes = _this.getEngine().scenes;
  65382. for (var i = 0; i < scenes.length; i++) {
  65383. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_AllDirtyFlag);
  65384. }
  65385. _this._pipelineContext._handlesSpectorRebuildCallback(onCompiled);
  65386. };
  65387. this._fallbacks = null;
  65388. this._prepareEffect();
  65389. };
  65390. /**
  65391. * Prepares the effect
  65392. * @hidden
  65393. */
  65394. Effect.prototype._prepareEffect = function () {
  65395. var _this = this;
  65396. var attributesNames = this._attributesNames;
  65397. var defines = this.defines;
  65398. var fallbacks = this._fallbacks;
  65399. this._valueCache = {};
  65400. var previousPipelineContext = this._pipelineContext;
  65401. try {
  65402. var engine_1 = this._engine;
  65403. this._pipelineContext = engine_1.createPipelineContext();
  65404. var rebuildRebind = this._rebuildProgram.bind(this);
  65405. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  65406. engine_1._preparePipelineContext(this._pipelineContext, this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, true, rebuildRebind, null, this._transformFeedbackVaryings);
  65407. }
  65408. else {
  65409. engine_1._preparePipelineContext(this._pipelineContext, this._vertexSourceCode, this._fragmentSourceCode, false, rebuildRebind, defines, this._transformFeedbackVaryings);
  65410. }
  65411. engine_1._executeWhenRenderingStateIsCompiled(this._pipelineContext, function () {
  65412. if (engine_1.supportsUniformBuffers) {
  65413. for (var name in _this._uniformBuffersNames) {
  65414. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  65415. }
  65416. }
  65417. var uniforms = engine_1.getUniforms(_this._pipelineContext, _this._uniformsNames);
  65418. uniforms.forEach(function (uniform, index) {
  65419. _this._uniforms[_this._uniformsNames[index]] = uniform;
  65420. });
  65421. _this._attributes = engine_1.getAttributes(_this._pipelineContext, attributesNames);
  65422. var index;
  65423. for (index = 0; index < _this._samplerList.length; index++) {
  65424. var sampler = _this.getUniform(_this._samplerList[index]);
  65425. if (sampler == null) {
  65426. _this._samplerList.splice(index, 1);
  65427. index--;
  65428. }
  65429. }
  65430. _this._samplerList.forEach(function (name, index) {
  65431. _this._samplers[name] = index;
  65432. });
  65433. engine_1.bindSamplers(_this);
  65434. _this._compilationError = "";
  65435. _this._isReady = true;
  65436. if (_this.onCompiled) {
  65437. _this.onCompiled(_this);
  65438. }
  65439. _this.onCompileObservable.notifyObservers(_this);
  65440. _this.onCompileObservable.clear();
  65441. // Unbind mesh reference in fallbacks
  65442. if (_this._fallbacks) {
  65443. _this._fallbacks.unBindMesh();
  65444. }
  65445. if (previousPipelineContext) {
  65446. _this.getEngine()._deletePipelineContext(previousPipelineContext);
  65447. }
  65448. });
  65449. if (this._pipelineContext.isAsync) {
  65450. this._checkIsReady();
  65451. }
  65452. }
  65453. catch (e) {
  65454. this._compilationError = e.message;
  65455. // Let's go through fallbacks then
  65456. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  65457. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  65458. return " " + uniform;
  65459. }));
  65460. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  65461. return " " + attribute;
  65462. }));
  65463. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  65464. if (previousPipelineContext) {
  65465. this._pipelineContext = previousPipelineContext;
  65466. this._isReady = true;
  65467. if (this.onError) {
  65468. this.onError(this, this._compilationError);
  65469. }
  65470. this.onErrorObservable.notifyObservers(this);
  65471. }
  65472. if (fallbacks && fallbacks.isMoreFallbacks) {
  65473. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  65474. this.defines = fallbacks.reduce(this.defines, this);
  65475. this._prepareEffect();
  65476. }
  65477. else { // Sorry we did everything we can
  65478. if (this.onError) {
  65479. this.onError(this, this._compilationError);
  65480. }
  65481. this.onErrorObservable.notifyObservers(this);
  65482. this.onErrorObservable.clear();
  65483. // Unbind mesh reference in fallbacks
  65484. if (this._fallbacks) {
  65485. this._fallbacks.unBindMesh();
  65486. }
  65487. }
  65488. }
  65489. };
  65490. Object.defineProperty(Effect.prototype, "isSupported", {
  65491. /**
  65492. * Checks if the effect is supported. (Must be called after compilation)
  65493. */
  65494. get: function () {
  65495. return this._compilationError === "";
  65496. },
  65497. enumerable: true,
  65498. configurable: true
  65499. });
  65500. /**
  65501. * Binds a texture to the engine to be used as output of the shader.
  65502. * @param channel Name of the output variable.
  65503. * @param texture Texture to bind.
  65504. * @hidden
  65505. */
  65506. Effect.prototype._bindTexture = function (channel, texture) {
  65507. this._engine._bindTexture(this._samplers[channel], texture);
  65508. };
  65509. /**
  65510. * Sets a texture on the engine to be used in the shader.
  65511. * @param channel Name of the sampler variable.
  65512. * @param texture Texture to set.
  65513. */
  65514. Effect.prototype.setTexture = function (channel, texture) {
  65515. this._engine.setTexture(this._samplers[channel], this._uniforms[channel], texture);
  65516. };
  65517. /**
  65518. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  65519. * @param channel Name of the sampler variable.
  65520. * @param texture Texture to set.
  65521. */
  65522. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  65523. this._engine.setDepthStencilTexture(this._samplers[channel], this._uniforms[channel], texture);
  65524. };
  65525. /**
  65526. * Sets an array of textures on the engine to be used in the shader.
  65527. * @param channel Name of the variable.
  65528. * @param textures Textures to set.
  65529. */
  65530. Effect.prototype.setTextureArray = function (channel, textures) {
  65531. var exName = channel + "Ex";
  65532. if (this._samplerList.indexOf(exName) === -1) {
  65533. var initialPos = this._samplers[channel];
  65534. for (var index = 1; index < textures.length; index++) {
  65535. this._samplerList.splice(initialPos + index, 0, exName);
  65536. this._samplers[exName] = initialPos + index;
  65537. }
  65538. }
  65539. this._engine.setTextureArray(this._samplers[channel], this._uniforms[channel], textures);
  65540. };
  65541. /**
  65542. * 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)
  65543. * @param channel Name of the sampler variable.
  65544. * @param postProcess Post process to get the input texture from.
  65545. */
  65546. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  65547. this._engine.setTextureFromPostProcess(this._samplers[channel], postProcess);
  65548. };
  65549. /**
  65550. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  65551. * 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)
  65552. * @param channel Name of the sampler variable.
  65553. * @param postProcess Post process to get the output texture from.
  65554. */
  65555. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  65556. this._engine.setTextureFromPostProcessOutput(this._samplers[channel], postProcess);
  65557. };
  65558. /** @hidden */
  65559. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  65560. var cache = this._valueCache[uniformName];
  65561. var flag = matrix.updateFlag;
  65562. if (cache !== undefined && cache === flag) {
  65563. return false;
  65564. }
  65565. this._valueCache[uniformName] = flag;
  65566. return true;
  65567. };
  65568. /** @hidden */
  65569. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  65570. var cache = this._valueCache[uniformName];
  65571. if (!cache) {
  65572. cache = [x, y];
  65573. this._valueCache[uniformName] = cache;
  65574. return true;
  65575. }
  65576. var changed = false;
  65577. if (cache[0] !== x) {
  65578. cache[0] = x;
  65579. changed = true;
  65580. }
  65581. if (cache[1] !== y) {
  65582. cache[1] = y;
  65583. changed = true;
  65584. }
  65585. return changed;
  65586. };
  65587. /** @hidden */
  65588. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  65589. var cache = this._valueCache[uniformName];
  65590. if (!cache) {
  65591. cache = [x, y, z];
  65592. this._valueCache[uniformName] = cache;
  65593. return true;
  65594. }
  65595. var changed = false;
  65596. if (cache[0] !== x) {
  65597. cache[0] = x;
  65598. changed = true;
  65599. }
  65600. if (cache[1] !== y) {
  65601. cache[1] = y;
  65602. changed = true;
  65603. }
  65604. if (cache[2] !== z) {
  65605. cache[2] = z;
  65606. changed = true;
  65607. }
  65608. return changed;
  65609. };
  65610. /** @hidden */
  65611. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  65612. var cache = this._valueCache[uniformName];
  65613. if (!cache) {
  65614. cache = [x, y, z, w];
  65615. this._valueCache[uniformName] = cache;
  65616. return true;
  65617. }
  65618. var changed = false;
  65619. if (cache[0] !== x) {
  65620. cache[0] = x;
  65621. changed = true;
  65622. }
  65623. if (cache[1] !== y) {
  65624. cache[1] = y;
  65625. changed = true;
  65626. }
  65627. if (cache[2] !== z) {
  65628. cache[2] = z;
  65629. changed = true;
  65630. }
  65631. if (cache[3] !== w) {
  65632. cache[3] = w;
  65633. changed = true;
  65634. }
  65635. return changed;
  65636. };
  65637. /**
  65638. * Binds a buffer to a uniform.
  65639. * @param buffer Buffer to bind.
  65640. * @param name Name of the uniform variable to bind to.
  65641. */
  65642. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  65643. var bufferName = this._uniformBuffersNames[name];
  65644. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  65645. return;
  65646. }
  65647. Effect._baseCache[bufferName] = buffer;
  65648. this._engine.bindUniformBufferBase(buffer, bufferName);
  65649. };
  65650. /**
  65651. * Binds block to a uniform.
  65652. * @param blockName Name of the block to bind.
  65653. * @param index Index to bind.
  65654. */
  65655. Effect.prototype.bindUniformBlock = function (blockName, index) {
  65656. this._engine.bindUniformBlock(this._pipelineContext, blockName, index);
  65657. };
  65658. /**
  65659. * Sets an interger value on a uniform variable.
  65660. * @param uniformName Name of the variable.
  65661. * @param value Value to be set.
  65662. * @returns this effect.
  65663. */
  65664. Effect.prototype.setInt = function (uniformName, value) {
  65665. var cache = this._valueCache[uniformName];
  65666. if (cache !== undefined && cache === value) {
  65667. return this;
  65668. }
  65669. this._valueCache[uniformName] = value;
  65670. this._engine.setInt(this._uniforms[uniformName], value);
  65671. return this;
  65672. };
  65673. /**
  65674. * Sets an int array on a uniform variable.
  65675. * @param uniformName Name of the variable.
  65676. * @param array array to be set.
  65677. * @returns this effect.
  65678. */
  65679. Effect.prototype.setIntArray = function (uniformName, array) {
  65680. this._valueCache[uniformName] = null;
  65681. this._engine.setIntArray(this._uniforms[uniformName], array);
  65682. return this;
  65683. };
  65684. /**
  65685. * 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)
  65686. * @param uniformName Name of the variable.
  65687. * @param array array to be set.
  65688. * @returns this effect.
  65689. */
  65690. Effect.prototype.setIntArray2 = function (uniformName, array) {
  65691. this._valueCache[uniformName] = null;
  65692. this._engine.setIntArray2(this._uniforms[uniformName], array);
  65693. return this;
  65694. };
  65695. /**
  65696. * 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)
  65697. * @param uniformName Name of the variable.
  65698. * @param array array to be set.
  65699. * @returns this effect.
  65700. */
  65701. Effect.prototype.setIntArray3 = function (uniformName, array) {
  65702. this._valueCache[uniformName] = null;
  65703. this._engine.setIntArray3(this._uniforms[uniformName], array);
  65704. return this;
  65705. };
  65706. /**
  65707. * 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)
  65708. * @param uniformName Name of the variable.
  65709. * @param array array to be set.
  65710. * @returns this effect.
  65711. */
  65712. Effect.prototype.setIntArray4 = function (uniformName, array) {
  65713. this._valueCache[uniformName] = null;
  65714. this._engine.setIntArray4(this._uniforms[uniformName], array);
  65715. return this;
  65716. };
  65717. /**
  65718. * Sets an float array on a uniform variable.
  65719. * @param uniformName Name of the variable.
  65720. * @param array array to be set.
  65721. * @returns this effect.
  65722. */
  65723. Effect.prototype.setFloatArray = function (uniformName, array) {
  65724. this._valueCache[uniformName] = null;
  65725. this._engine.setFloatArray(this._uniforms[uniformName], array);
  65726. return this;
  65727. };
  65728. /**
  65729. * 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)
  65730. * @param uniformName Name of the variable.
  65731. * @param array array to be set.
  65732. * @returns this effect.
  65733. */
  65734. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  65735. this._valueCache[uniformName] = null;
  65736. this._engine.setFloatArray2(this._uniforms[uniformName], array);
  65737. return this;
  65738. };
  65739. /**
  65740. * 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)
  65741. * @param uniformName Name of the variable.
  65742. * @param array array to be set.
  65743. * @returns this effect.
  65744. */
  65745. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  65746. this._valueCache[uniformName] = null;
  65747. this._engine.setFloatArray3(this._uniforms[uniformName], array);
  65748. return this;
  65749. };
  65750. /**
  65751. * 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)
  65752. * @param uniformName Name of the variable.
  65753. * @param array array to be set.
  65754. * @returns this effect.
  65755. */
  65756. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  65757. this._valueCache[uniformName] = null;
  65758. this._engine.setFloatArray4(this._uniforms[uniformName], array);
  65759. return this;
  65760. };
  65761. /**
  65762. * Sets an array on a uniform variable.
  65763. * @param uniformName Name of the variable.
  65764. * @param array array to be set.
  65765. * @returns this effect.
  65766. */
  65767. Effect.prototype.setArray = function (uniformName, array) {
  65768. this._valueCache[uniformName] = null;
  65769. this._engine.setArray(this._uniforms[uniformName], array);
  65770. return this;
  65771. };
  65772. /**
  65773. * 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)
  65774. * @param uniformName Name of the variable.
  65775. * @param array array to be set.
  65776. * @returns this effect.
  65777. */
  65778. Effect.prototype.setArray2 = function (uniformName, array) {
  65779. this._valueCache[uniformName] = null;
  65780. this._engine.setArray2(this._uniforms[uniformName], array);
  65781. return this;
  65782. };
  65783. /**
  65784. * 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)
  65785. * @param uniformName Name of the variable.
  65786. * @param array array to be set.
  65787. * @returns this effect.
  65788. */
  65789. Effect.prototype.setArray3 = function (uniformName, array) {
  65790. this._valueCache[uniformName] = null;
  65791. this._engine.setArray3(this._uniforms[uniformName], array);
  65792. return this;
  65793. };
  65794. /**
  65795. * 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)
  65796. * @param uniformName Name of the variable.
  65797. * @param array array to be set.
  65798. * @returns this effect.
  65799. */
  65800. Effect.prototype.setArray4 = function (uniformName, array) {
  65801. this._valueCache[uniformName] = null;
  65802. this._engine.setArray4(this._uniforms[uniformName], array);
  65803. return this;
  65804. };
  65805. /**
  65806. * Sets matrices on a uniform variable.
  65807. * @param uniformName Name of the variable.
  65808. * @param matrices matrices to be set.
  65809. * @returns this effect.
  65810. */
  65811. Effect.prototype.setMatrices = function (uniformName, matrices) {
  65812. if (!matrices) {
  65813. return this;
  65814. }
  65815. this._valueCache[uniformName] = null;
  65816. this._engine.setMatrices(this._uniforms[uniformName], matrices);
  65817. return this;
  65818. };
  65819. /**
  65820. * Sets matrix on a uniform variable.
  65821. * @param uniformName Name of the variable.
  65822. * @param matrix matrix to be set.
  65823. * @returns this effect.
  65824. */
  65825. Effect.prototype.setMatrix = function (uniformName, matrix) {
  65826. if (this._cacheMatrix(uniformName, matrix)) {
  65827. this._engine.setMatrix(this._uniforms[uniformName], matrix);
  65828. }
  65829. return this;
  65830. };
  65831. /**
  65832. * 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)
  65833. * @param uniformName Name of the variable.
  65834. * @param matrix matrix to be set.
  65835. * @returns this effect.
  65836. */
  65837. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  65838. this._valueCache[uniformName] = null;
  65839. this._engine.setMatrix3x3(this._uniforms[uniformName], matrix);
  65840. return this;
  65841. };
  65842. /**
  65843. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  65844. * @param uniformName Name of the variable.
  65845. * @param matrix matrix to be set.
  65846. * @returns this effect.
  65847. */
  65848. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  65849. this._valueCache[uniformName] = null;
  65850. this._engine.setMatrix2x2(this._uniforms[uniformName], matrix);
  65851. return this;
  65852. };
  65853. /**
  65854. * Sets a float on a uniform variable.
  65855. * @param uniformName Name of the variable.
  65856. * @param value value to be set.
  65857. * @returns this effect.
  65858. */
  65859. Effect.prototype.setFloat = function (uniformName, value) {
  65860. var cache = this._valueCache[uniformName];
  65861. if (cache !== undefined && cache === value) {
  65862. return this;
  65863. }
  65864. this._valueCache[uniformName] = value;
  65865. this._engine.setFloat(this._uniforms[uniformName], value);
  65866. return this;
  65867. };
  65868. /**
  65869. * Sets a boolean on a uniform variable.
  65870. * @param uniformName Name of the variable.
  65871. * @param bool value to be set.
  65872. * @returns this effect.
  65873. */
  65874. Effect.prototype.setBool = function (uniformName, bool) {
  65875. var cache = this._valueCache[uniformName];
  65876. if (cache !== undefined && cache === bool) {
  65877. return this;
  65878. }
  65879. this._valueCache[uniformName] = bool;
  65880. this._engine.setBool(this._uniforms[uniformName], bool ? 1 : 0);
  65881. return this;
  65882. };
  65883. /**
  65884. * Sets a Vector2 on a uniform variable.
  65885. * @param uniformName Name of the variable.
  65886. * @param vector2 vector2 to be set.
  65887. * @returns this effect.
  65888. */
  65889. Effect.prototype.setVector2 = function (uniformName, vector2) {
  65890. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  65891. this._engine.setFloat2(this._uniforms[uniformName], vector2.x, vector2.y);
  65892. }
  65893. return this;
  65894. };
  65895. /**
  65896. * Sets a float2 on a uniform variable.
  65897. * @param uniformName Name of the variable.
  65898. * @param x First float in float2.
  65899. * @param y Second float in float2.
  65900. * @returns this effect.
  65901. */
  65902. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  65903. if (this._cacheFloat2(uniformName, x, y)) {
  65904. this._engine.setFloat2(this._uniforms[uniformName], x, y);
  65905. }
  65906. return this;
  65907. };
  65908. /**
  65909. * Sets a Vector3 on a uniform variable.
  65910. * @param uniformName Name of the variable.
  65911. * @param vector3 Value to be set.
  65912. * @returns this effect.
  65913. */
  65914. Effect.prototype.setVector3 = function (uniformName, vector3) {
  65915. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  65916. this._engine.setFloat3(this._uniforms[uniformName], vector3.x, vector3.y, vector3.z);
  65917. }
  65918. return this;
  65919. };
  65920. /**
  65921. * Sets a float3 on a uniform variable.
  65922. * @param uniformName Name of the variable.
  65923. * @param x First float in float3.
  65924. * @param y Second float in float3.
  65925. * @param z Third float in float3.
  65926. * @returns this effect.
  65927. */
  65928. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  65929. if (this._cacheFloat3(uniformName, x, y, z)) {
  65930. this._engine.setFloat3(this._uniforms[uniformName], x, y, z);
  65931. }
  65932. return this;
  65933. };
  65934. /**
  65935. * Sets a Vector4 on a uniform variable.
  65936. * @param uniformName Name of the variable.
  65937. * @param vector4 Value to be set.
  65938. * @returns this effect.
  65939. */
  65940. Effect.prototype.setVector4 = function (uniformName, vector4) {
  65941. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  65942. this._engine.setFloat4(this._uniforms[uniformName], vector4.x, vector4.y, vector4.z, vector4.w);
  65943. }
  65944. return this;
  65945. };
  65946. /**
  65947. * Sets a float4 on a uniform variable.
  65948. * @param uniformName Name of the variable.
  65949. * @param x First float in float4.
  65950. * @param y Second float in float4.
  65951. * @param z Third float in float4.
  65952. * @param w Fourth float in float4.
  65953. * @returns this effect.
  65954. */
  65955. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  65956. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  65957. this._engine.setFloat4(this._uniforms[uniformName], x, y, z, w);
  65958. }
  65959. return this;
  65960. };
  65961. /**
  65962. * Sets a Color3 on a uniform variable.
  65963. * @param uniformName Name of the variable.
  65964. * @param color3 Value to be set.
  65965. * @returns this effect.
  65966. */
  65967. Effect.prototype.setColor3 = function (uniformName, color3) {
  65968. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  65969. this._engine.setColor3(this._uniforms[uniformName], color3);
  65970. }
  65971. return this;
  65972. };
  65973. /**
  65974. * Sets a Color4 on a uniform variable.
  65975. * @param uniformName Name of the variable.
  65976. * @param color3 Value to be set.
  65977. * @param alpha Alpha value to be set.
  65978. * @returns this effect.
  65979. */
  65980. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  65981. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  65982. this._engine.setColor4(this._uniforms[uniformName], color3, alpha);
  65983. }
  65984. return this;
  65985. };
  65986. /**
  65987. * Sets a Color4 on a uniform variable
  65988. * @param uniformName defines the name of the variable
  65989. * @param color4 defines the value to be set
  65990. * @returns this effect.
  65991. */
  65992. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  65993. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  65994. this._engine.setDirectColor4(this._uniforms[uniformName], color4);
  65995. }
  65996. return this;
  65997. };
  65998. /** Release all associated resources */
  65999. Effect.prototype.dispose = function () {
  66000. this._engine._releaseEffect(this);
  66001. };
  66002. /**
  66003. * This function will add a new shader to the shader store
  66004. * @param name the name of the shader
  66005. * @param pixelShader optional pixel shader content
  66006. * @param vertexShader optional vertex shader content
  66007. */
  66008. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  66009. if (pixelShader) {
  66010. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  66011. }
  66012. if (vertexShader) {
  66013. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  66014. }
  66015. };
  66016. /**
  66017. * Resets the cache of effects.
  66018. */
  66019. Effect.ResetCache = function () {
  66020. Effect._baseCache = {};
  66021. };
  66022. /**
  66023. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  66024. */
  66025. Effect.ShadersRepository = "src/Shaders/";
  66026. Effect._uniqueIdSeed = 0;
  66027. Effect._baseCache = {};
  66028. /**
  66029. * Store of each shader (The can be looked up using effect.key)
  66030. */
  66031. Effect.ShadersStore = {};
  66032. /**
  66033. * Store of each included file for a shader (The can be looked up using effect.key)
  66034. */
  66035. Effect.IncludesShadersStore = {};
  66036. return Effect;
  66037. }());
  66038. /***/ }),
  66039. /***/ "./Materials/fresnelParameters.ts":
  66040. /*!****************************************!*\
  66041. !*** ./Materials/fresnelParameters.ts ***!
  66042. \****************************************/
  66043. /*! exports provided: FresnelParameters */
  66044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66045. "use strict";
  66046. __webpack_require__.r(__webpack_exports__);
  66047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  66048. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  66049. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  66050. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  66051. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  66052. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  66053. /**
  66054. * This represents all the required information to add a fresnel effect on a material:
  66055. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  66056. */
  66057. var FresnelParameters = /** @class */ (function () {
  66058. function FresnelParameters() {
  66059. this._isEnabled = true;
  66060. /**
  66061. * Define the color used on edges (grazing angle)
  66062. */
  66063. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  66064. /**
  66065. * Define the color used on center
  66066. */
  66067. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  66068. /**
  66069. * Define bias applied to computed fresnel term
  66070. */
  66071. this.bias = 0;
  66072. /**
  66073. * Defined the power exponent applied to fresnel term
  66074. */
  66075. this.power = 1;
  66076. }
  66077. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  66078. /**
  66079. * Define if the fresnel effect is enable or not.
  66080. */
  66081. get: function () {
  66082. return this._isEnabled;
  66083. },
  66084. set: function (value) {
  66085. if (this._isEnabled === value) {
  66086. return;
  66087. }
  66088. this._isEnabled = value;
  66089. _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);
  66090. },
  66091. enumerable: true,
  66092. configurable: true
  66093. });
  66094. /**
  66095. * Clones the current fresnel and its valuues
  66096. * @returns a clone fresnel configuration
  66097. */
  66098. FresnelParameters.prototype.clone = function () {
  66099. var newFresnelParameters = new FresnelParameters();
  66100. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  66101. return newFresnelParameters;
  66102. };
  66103. /**
  66104. * Serializes the current fresnel parameters to a JSON representation.
  66105. * @return the JSON serialization
  66106. */
  66107. FresnelParameters.prototype.serialize = function () {
  66108. var serializationObject = {};
  66109. serializationObject.isEnabled = this.isEnabled;
  66110. serializationObject.leftColor = this.leftColor.asArray();
  66111. serializationObject.rightColor = this.rightColor.asArray();
  66112. serializationObject.bias = this.bias;
  66113. serializationObject.power = this.power;
  66114. return serializationObject;
  66115. };
  66116. /**
  66117. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  66118. * @param parsedFresnelParameters Define the JSON representation
  66119. * @returns the parsed parameters
  66120. */
  66121. FresnelParameters.Parse = function (parsedFresnelParameters) {
  66122. var fresnelParameters = new FresnelParameters();
  66123. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  66124. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  66125. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  66126. fresnelParameters.bias = parsedFresnelParameters.bias;
  66127. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  66128. return fresnelParameters;
  66129. };
  66130. return FresnelParameters;
  66131. }());
  66132. // References the dependencies.
  66133. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  66134. /***/ }),
  66135. /***/ "./Materials/imageProcessingConfiguration.ts":
  66136. /*!***************************************************!*\
  66137. !*** ./Materials/imageProcessingConfiguration.ts ***!
  66138. \***************************************************/
  66139. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  66140. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66141. "use strict";
  66142. __webpack_require__.r(__webpack_exports__);
  66143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  66144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  66145. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66146. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  66147. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  66148. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  66149. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  66150. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  66151. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  66152. /**
  66153. * @hidden
  66154. */
  66155. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  66156. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  66157. function ImageProcessingConfigurationDefines() {
  66158. var _this = _super.call(this) || this;
  66159. _this.IMAGEPROCESSING = false;
  66160. _this.VIGNETTE = false;
  66161. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  66162. _this.VIGNETTEBLENDMODEOPAQUE = false;
  66163. _this.TONEMAPPING = false;
  66164. _this.TONEMAPPING_ACES = false;
  66165. _this.CONTRAST = false;
  66166. _this.COLORCURVES = false;
  66167. _this.COLORGRADING = false;
  66168. _this.COLORGRADING3D = false;
  66169. _this.SAMPLER3DGREENDEPTH = false;
  66170. _this.SAMPLER3DBGRMAP = false;
  66171. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  66172. _this.EXPOSURE = false;
  66173. _this.rebuild();
  66174. return _this;
  66175. }
  66176. return ImageProcessingConfigurationDefines;
  66177. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  66178. /**
  66179. * This groups together the common properties used for image processing either in direct forward pass
  66180. * or through post processing effect depending on the use of the image processing pipeline in your scene
  66181. * or not.
  66182. */
  66183. var ImageProcessingConfiguration = /** @class */ (function () {
  66184. function ImageProcessingConfiguration() {
  66185. /**
  66186. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  66187. */
  66188. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  66189. this._colorCurvesEnabled = false;
  66190. this._colorGradingEnabled = false;
  66191. this._colorGradingWithGreenDepth = true;
  66192. this._colorGradingBGR = true;
  66193. /** @hidden */
  66194. this._exposure = 1.0;
  66195. this._toneMappingEnabled = false;
  66196. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  66197. this._contrast = 1.0;
  66198. /**
  66199. * Vignette stretch size.
  66200. */
  66201. this.vignetteStretch = 0;
  66202. /**
  66203. * Vignette centre X Offset.
  66204. */
  66205. this.vignetteCentreX = 0;
  66206. /**
  66207. * Vignette centre Y Offset.
  66208. */
  66209. this.vignetteCentreY = 0;
  66210. /**
  66211. * Vignette weight or intensity of the vignette effect.
  66212. */
  66213. this.vignetteWeight = 1.5;
  66214. /**
  66215. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  66216. * if vignetteEnabled is set to true.
  66217. */
  66218. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  66219. /**
  66220. * Camera field of view used by the Vignette effect.
  66221. */
  66222. this.vignetteCameraFov = 0.5;
  66223. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  66224. this._vignetteEnabled = false;
  66225. this._applyByPostProcess = false;
  66226. this._isEnabled = true;
  66227. /**
  66228. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  66229. */
  66230. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  66231. }
  66232. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  66233. /**
  66234. * Gets wether the color curves effect is enabled.
  66235. */
  66236. get: function () {
  66237. return this._colorCurvesEnabled;
  66238. },
  66239. /**
  66240. * Sets wether the color curves effect is enabled.
  66241. */
  66242. set: function (value) {
  66243. if (this._colorCurvesEnabled === value) {
  66244. return;
  66245. }
  66246. this._colorCurvesEnabled = value;
  66247. this._updateParameters();
  66248. },
  66249. enumerable: true,
  66250. configurable: true
  66251. });
  66252. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  66253. /**
  66254. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  66255. */
  66256. get: function () {
  66257. return this._colorGradingTexture;
  66258. },
  66259. /**
  66260. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  66261. */
  66262. set: function (value) {
  66263. if (this._colorGradingTexture === value) {
  66264. return;
  66265. }
  66266. this._colorGradingTexture = value;
  66267. this._updateParameters();
  66268. },
  66269. enumerable: true,
  66270. configurable: true
  66271. });
  66272. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  66273. /**
  66274. * Gets wether the color grading effect is enabled.
  66275. */
  66276. get: function () {
  66277. return this._colorGradingEnabled;
  66278. },
  66279. /**
  66280. * Sets wether the color grading effect is enabled.
  66281. */
  66282. set: function (value) {
  66283. if (this._colorGradingEnabled === value) {
  66284. return;
  66285. }
  66286. this._colorGradingEnabled = value;
  66287. this._updateParameters();
  66288. },
  66289. enumerable: true,
  66290. configurable: true
  66291. });
  66292. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  66293. /**
  66294. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  66295. */
  66296. get: function () {
  66297. return this._colorGradingWithGreenDepth;
  66298. },
  66299. /**
  66300. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  66301. */
  66302. set: function (value) {
  66303. if (this._colorGradingWithGreenDepth === value) {
  66304. return;
  66305. }
  66306. this._colorGradingWithGreenDepth = value;
  66307. this._updateParameters();
  66308. },
  66309. enumerable: true,
  66310. configurable: true
  66311. });
  66312. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  66313. /**
  66314. * Gets wether the color grading texture contains BGR values.
  66315. */
  66316. get: function () {
  66317. return this._colorGradingBGR;
  66318. },
  66319. /**
  66320. * Sets wether the color grading texture contains BGR values.
  66321. */
  66322. set: function (value) {
  66323. if (this._colorGradingBGR === value) {
  66324. return;
  66325. }
  66326. this._colorGradingBGR = value;
  66327. this._updateParameters();
  66328. },
  66329. enumerable: true,
  66330. configurable: true
  66331. });
  66332. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  66333. /**
  66334. * Gets the Exposure used in the effect.
  66335. */
  66336. get: function () {
  66337. return this._exposure;
  66338. },
  66339. /**
  66340. * Sets the Exposure used in the effect.
  66341. */
  66342. set: function (value) {
  66343. if (this._exposure === value) {
  66344. return;
  66345. }
  66346. this._exposure = value;
  66347. this._updateParameters();
  66348. },
  66349. enumerable: true,
  66350. configurable: true
  66351. });
  66352. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  66353. /**
  66354. * Gets wether the tone mapping effect is enabled.
  66355. */
  66356. get: function () {
  66357. return this._toneMappingEnabled;
  66358. },
  66359. /**
  66360. * Sets wether the tone mapping effect is enabled.
  66361. */
  66362. set: function (value) {
  66363. if (this._toneMappingEnabled === value) {
  66364. return;
  66365. }
  66366. this._toneMappingEnabled = value;
  66367. this._updateParameters();
  66368. },
  66369. enumerable: true,
  66370. configurable: true
  66371. });
  66372. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  66373. /**
  66374. * Gets the type of tone mapping effect.
  66375. */
  66376. get: function () {
  66377. return this._toneMappingType;
  66378. },
  66379. /**
  66380. * Sets the type of tone mapping effect used in BabylonJS.
  66381. */
  66382. set: function (value) {
  66383. if (this._toneMappingType === value) {
  66384. return;
  66385. }
  66386. this._toneMappingType = value;
  66387. this._updateParameters();
  66388. },
  66389. enumerable: true,
  66390. configurable: true
  66391. });
  66392. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  66393. /**
  66394. * Gets the contrast used in the effect.
  66395. */
  66396. get: function () {
  66397. return this._contrast;
  66398. },
  66399. /**
  66400. * Sets the contrast used in the effect.
  66401. */
  66402. set: function (value) {
  66403. if (this._contrast === value) {
  66404. return;
  66405. }
  66406. this._contrast = value;
  66407. this._updateParameters();
  66408. },
  66409. enumerable: true,
  66410. configurable: true
  66411. });
  66412. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  66413. /**
  66414. * Gets the vignette blend mode allowing different kind of effect.
  66415. */
  66416. get: function () {
  66417. return this._vignetteBlendMode;
  66418. },
  66419. /**
  66420. * Sets the vignette blend mode allowing different kind of effect.
  66421. */
  66422. set: function (value) {
  66423. if (this._vignetteBlendMode === value) {
  66424. return;
  66425. }
  66426. this._vignetteBlendMode = value;
  66427. this._updateParameters();
  66428. },
  66429. enumerable: true,
  66430. configurable: true
  66431. });
  66432. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  66433. /**
  66434. * Gets wether the vignette effect is enabled.
  66435. */
  66436. get: function () {
  66437. return this._vignetteEnabled;
  66438. },
  66439. /**
  66440. * Sets wether the vignette effect is enabled.
  66441. */
  66442. set: function (value) {
  66443. if (this._vignetteEnabled === value) {
  66444. return;
  66445. }
  66446. this._vignetteEnabled = value;
  66447. this._updateParameters();
  66448. },
  66449. enumerable: true,
  66450. configurable: true
  66451. });
  66452. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  66453. /**
  66454. * Gets wether the image processing is applied through a post process or not.
  66455. */
  66456. get: function () {
  66457. return this._applyByPostProcess;
  66458. },
  66459. /**
  66460. * Sets wether the image processing is applied through a post process or not.
  66461. */
  66462. set: function (value) {
  66463. if (this._applyByPostProcess === value) {
  66464. return;
  66465. }
  66466. this._applyByPostProcess = value;
  66467. this._updateParameters();
  66468. },
  66469. enumerable: true,
  66470. configurable: true
  66471. });
  66472. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  66473. /**
  66474. * Gets wether the image processing is enabled or not.
  66475. */
  66476. get: function () {
  66477. return this._isEnabled;
  66478. },
  66479. /**
  66480. * Sets wether the image processing is enabled or not.
  66481. */
  66482. set: function (value) {
  66483. if (this._isEnabled === value) {
  66484. return;
  66485. }
  66486. this._isEnabled = value;
  66487. this._updateParameters();
  66488. },
  66489. enumerable: true,
  66490. configurable: true
  66491. });
  66492. /**
  66493. * Method called each time the image processing information changes requires to recompile the effect.
  66494. */
  66495. ImageProcessingConfiguration.prototype._updateParameters = function () {
  66496. this.onUpdateParameters.notifyObservers(this);
  66497. };
  66498. /**
  66499. * Gets the current class name.
  66500. * @return "ImageProcessingConfiguration"
  66501. */
  66502. ImageProcessingConfiguration.prototype.getClassName = function () {
  66503. return "ImageProcessingConfiguration";
  66504. };
  66505. /**
  66506. * Prepare the list of uniforms associated with the Image Processing effects.
  66507. * @param uniforms The list of uniforms used in the effect
  66508. * @param defines the list of defines currently in use
  66509. */
  66510. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  66511. if (defines.EXPOSURE) {
  66512. uniforms.push("exposureLinear");
  66513. }
  66514. if (defines.CONTRAST) {
  66515. uniforms.push("contrast");
  66516. }
  66517. if (defines.COLORGRADING) {
  66518. uniforms.push("colorTransformSettings");
  66519. }
  66520. if (defines.VIGNETTE) {
  66521. uniforms.push("vInverseScreenSize");
  66522. uniforms.push("vignetteSettings1");
  66523. uniforms.push("vignetteSettings2");
  66524. }
  66525. if (defines.COLORCURVES) {
  66526. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  66527. }
  66528. };
  66529. /**
  66530. * Prepare the list of samplers associated with the Image Processing effects.
  66531. * @param samplersList The list of uniforms used in the effect
  66532. * @param defines the list of defines currently in use
  66533. */
  66534. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  66535. if (defines.COLORGRADING) {
  66536. samplersList.push("txColorTransform");
  66537. }
  66538. };
  66539. /**
  66540. * Prepare the list of defines associated to the shader.
  66541. * @param defines the list of defines to complete
  66542. * @param forPostProcess Define if we are currently in post process mode or not
  66543. */
  66544. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  66545. if (forPostProcess === void 0) { forPostProcess = false; }
  66546. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  66547. defines.VIGNETTE = false;
  66548. defines.TONEMAPPING = false;
  66549. defines.TONEMAPPING_ACES = false;
  66550. defines.CONTRAST = false;
  66551. defines.EXPOSURE = false;
  66552. defines.COLORCURVES = false;
  66553. defines.COLORGRADING = false;
  66554. defines.COLORGRADING3D = false;
  66555. defines.IMAGEPROCESSING = false;
  66556. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  66557. return;
  66558. }
  66559. defines.VIGNETTE = this.vignetteEnabled;
  66560. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  66561. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  66562. defines.TONEMAPPING = this.toneMappingEnabled;
  66563. switch (this._toneMappingType) {
  66564. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  66565. defines.TONEMAPPING_ACES = true;
  66566. break;
  66567. default:
  66568. defines.TONEMAPPING_ACES = false;
  66569. break;
  66570. }
  66571. defines.CONTRAST = (this.contrast !== 1.0);
  66572. defines.EXPOSURE = (this.exposure !== 1.0);
  66573. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  66574. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  66575. if (defines.COLORGRADING) {
  66576. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  66577. }
  66578. else {
  66579. defines.COLORGRADING3D = false;
  66580. }
  66581. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  66582. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  66583. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  66584. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  66585. };
  66586. /**
  66587. * Returns true if all the image processing information are ready.
  66588. * @returns True if ready, otherwise, false
  66589. */
  66590. ImageProcessingConfiguration.prototype.isReady = function () {
  66591. // Color Grading texure can not be none blocking.
  66592. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  66593. };
  66594. /**
  66595. * Binds the image processing to the shader.
  66596. * @param effect The effect to bind to
  66597. * @param aspectRatio Define the current aspect ratio of the effect
  66598. */
  66599. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  66600. if (aspectRatio === void 0) { aspectRatio = 1; }
  66601. // Color Curves
  66602. if (this._colorCurvesEnabled && this.colorCurves) {
  66603. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  66604. }
  66605. // Vignette
  66606. if (this._vignetteEnabled) {
  66607. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  66608. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  66609. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  66610. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  66611. var vignetteScaleX = vignetteScaleY * aspectRatio;
  66612. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  66613. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  66614. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  66615. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  66616. var vignettePower = -2.0 * this.vignetteWeight;
  66617. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  66618. }
  66619. // Exposure
  66620. effect.setFloat("exposureLinear", this.exposure);
  66621. // Contrast
  66622. effect.setFloat("contrast", this.contrast);
  66623. // Color transform settings
  66624. if (this.colorGradingTexture) {
  66625. effect.setTexture("txColorTransform", this.colorGradingTexture);
  66626. var textureSize = this.colorGradingTexture.getSize().height;
  66627. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  66628. 0.5 / textureSize, // textureOffset
  66629. textureSize, // textureSize
  66630. this.colorGradingTexture.level // weight
  66631. );
  66632. }
  66633. };
  66634. /**
  66635. * Clones the current image processing instance.
  66636. * @return The cloned image processing
  66637. */
  66638. ImageProcessingConfiguration.prototype.clone = function () {
  66639. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  66640. };
  66641. /**
  66642. * Serializes the current image processing instance to a json representation.
  66643. * @return a JSON representation
  66644. */
  66645. ImageProcessingConfiguration.prototype.serialize = function () {
  66646. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  66647. };
  66648. /**
  66649. * Parses the image processing from a json representation.
  66650. * @param source the JSON source to parse
  66651. * @return The parsed image processing
  66652. */
  66653. ImageProcessingConfiguration.Parse = function (source) {
  66654. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  66655. };
  66656. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  66657. /**
  66658. * Used to apply the vignette as a mix with the pixel color.
  66659. */
  66660. get: function () {
  66661. return this._VIGNETTEMODE_MULTIPLY;
  66662. },
  66663. enumerable: true,
  66664. configurable: true
  66665. });
  66666. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  66667. /**
  66668. * Used to apply the vignette as a replacement of the pixel color.
  66669. */
  66670. get: function () {
  66671. return this._VIGNETTEMODE_OPAQUE;
  66672. },
  66673. enumerable: true,
  66674. configurable: true
  66675. });
  66676. /**
  66677. * Default tone mapping applied in BabylonJS.
  66678. */
  66679. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  66680. /**
  66681. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  66682. * to other engines rendering to increase portability.
  66683. */
  66684. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  66685. // Static constants associated to the image processing.
  66686. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  66687. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  66688. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66689. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  66690. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  66691. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66692. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66693. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  66694. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66695. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  66696. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  66697. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66698. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66699. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  66700. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66702. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  66703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66705. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  66706. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66707. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66708. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  66709. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66710. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66711. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  66712. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66713. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66714. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  66715. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66716. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66717. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  66718. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66719. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66720. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  66721. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66722. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66723. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  66724. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66725. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66726. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  66727. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66728. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66729. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  66730. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66731. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  66732. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  66733. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66734. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66735. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  66736. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66737. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66738. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  66739. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66740. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66741. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  66742. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66743. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66744. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  66745. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66746. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66747. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  66748. return ImageProcessingConfiguration;
  66749. }());
  66750. // References the dependencies.
  66751. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  66752. /***/ }),
  66753. /***/ "./Materials/index.ts":
  66754. /*!****************************!*\
  66755. !*** ./Materials/index.ts ***!
  66756. \****************************/
  66757. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, MultiRenderTarget, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, HtmlElementTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  66758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66759. "use strict";
  66760. __webpack_require__.r(__webpack_exports__);
  66761. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  66762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  66763. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  66764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  66765. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  66766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  66767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  66768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  66769. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  66770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  66771. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  66772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  66773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  66774. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  66775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  66776. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  66777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  66778. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  66779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  66780. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  66781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  66782. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  66783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterialDefines"]; });
  66784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  66785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  66786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  66787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  66788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  66789. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  66790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  66791. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  66792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  66793. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  66794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  66795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  66796. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  66797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  66798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  66799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["EquiRectangularCubeTexture"]; });
  66800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  66801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  66802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  66803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  66804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  66805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  66806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  66807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  66808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  66809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  66810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  66811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  66812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  66813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  66814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HtmlElementTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HtmlElementTexture"]; });
  66815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  66816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  66817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  66818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  66819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  66820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  66821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  66822. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  66823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  66824. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  66825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  66826. /***/ }),
  66827. /***/ "./Materials/material.ts":
  66828. /*!*******************************!*\
  66829. !*** ./Materials/material.ts ***!
  66830. \*******************************/
  66831. /*! exports provided: Material */
  66832. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66833. "use strict";
  66834. __webpack_require__.r(__webpack_exports__);
  66835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  66836. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66837. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  66838. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  66839. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  66840. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  66841. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  66842. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  66843. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  66844. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  66845. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  66846. /**
  66847. * Base class for the main features of a material in Babylon.js
  66848. */
  66849. var Material = /** @class */ (function () {
  66850. /**
  66851. * Creates a material instance
  66852. * @param name defines the name of the material
  66853. * @param scene defines the scene to reference
  66854. * @param doNotAdd specifies if the material should be added to the scene
  66855. */
  66856. function Material(name, scene, doNotAdd) {
  66857. /**
  66858. * Gets or sets user defined metadata
  66859. */
  66860. this.metadata = null;
  66861. /**
  66862. * For internal use only. Please do not use.
  66863. */
  66864. this.reservedDataStore = null;
  66865. /**
  66866. * Specifies if the ready state should be checked on each call
  66867. */
  66868. this.checkReadyOnEveryCall = false;
  66869. /**
  66870. * Specifies if the ready state should be checked once
  66871. */
  66872. this.checkReadyOnlyOnce = false;
  66873. /**
  66874. * The state of the material
  66875. */
  66876. this.state = "";
  66877. /**
  66878. * The alpha value of the material
  66879. */
  66880. this._alpha = 1.0;
  66881. /**
  66882. * Specifies if back face culling is enabled
  66883. */
  66884. this._backFaceCulling = true;
  66885. /**
  66886. * Callback triggered when the material is compiled
  66887. */
  66888. this.onCompiled = null;
  66889. /**
  66890. * Callback triggered when an error occurs
  66891. */
  66892. this.onError = null;
  66893. /**
  66894. * Callback triggered to get the render target textures
  66895. */
  66896. this.getRenderTargetTextures = null;
  66897. /**
  66898. * Specifies if the material should be serialized
  66899. */
  66900. this.doNotSerialize = false;
  66901. /**
  66902. * @hidden
  66903. */
  66904. this._storeEffectOnSubMeshes = false;
  66905. /**
  66906. * Stores the animations for the material
  66907. */
  66908. this.animations = null;
  66909. /**
  66910. * An event triggered when the material is disposed
  66911. */
  66912. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  66913. /**
  66914. * An observer which watches for dispose events
  66915. */
  66916. this._onDisposeObserver = null;
  66917. this._onUnBindObservable = null;
  66918. /**
  66919. * An observer which watches for bind events
  66920. */
  66921. this._onBindObserver = null;
  66922. /**
  66923. * Stores the value of the alpha mode
  66924. */
  66925. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  66926. /**
  66927. * Stores the state of the need depth pre-pass value
  66928. */
  66929. this._needDepthPrePass = false;
  66930. /**
  66931. * Specifies if depth writing should be disabled
  66932. */
  66933. this.disableDepthWrite = false;
  66934. /**
  66935. * Specifies if depth writing should be forced
  66936. */
  66937. this.forceDepthWrite = false;
  66938. /**
  66939. * Specifies if there should be a separate pass for culling
  66940. */
  66941. this.separateCullingPass = false;
  66942. /**
  66943. * Stores the state specifing if fog should be enabled
  66944. */
  66945. this._fogEnabled = true;
  66946. /**
  66947. * Stores the size of points
  66948. */
  66949. this.pointSize = 1.0;
  66950. /**
  66951. * Stores the z offset value
  66952. */
  66953. this.zOffset = 0;
  66954. /**
  66955. * @hidden
  66956. * Stores the effects for the material
  66957. */
  66958. this._effect = null;
  66959. /**
  66960. * @hidden
  66961. * Specifies if the material was previously ready
  66962. */
  66963. this._wasPreviouslyReady = false;
  66964. /**
  66965. * Specifies if uniform buffers should be used
  66966. */
  66967. this._useUBO = false;
  66968. /**
  66969. * Stores the fill mode state
  66970. */
  66971. this._fillMode = Material.TriangleFillMode;
  66972. /**
  66973. * Specifies if the depth write state should be cached
  66974. */
  66975. this._cachedDepthWriteState = false;
  66976. /** @hidden */
  66977. this._indexInSceneMaterialArray = -1;
  66978. /** @hidden */
  66979. this.meshMap = null;
  66980. this.name = name;
  66981. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  66982. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  66983. this.uniqueId = this._scene.getUniqueId();
  66984. if (this._scene.useRightHandedSystem) {
  66985. this.sideOrientation = Material.ClockWiseSideOrientation;
  66986. }
  66987. else {
  66988. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  66989. }
  66990. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  66991. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  66992. if (!doNotAdd) {
  66993. this._scene.addMaterial(this);
  66994. }
  66995. if (this._scene.useMaterialMeshMap) {
  66996. this.meshMap = {};
  66997. }
  66998. }
  66999. Object.defineProperty(Material.prototype, "alpha", {
  67000. /**
  67001. * Gets the alpha value of the material
  67002. */
  67003. get: function () {
  67004. return this._alpha;
  67005. },
  67006. /**
  67007. * Sets the alpha value of the material
  67008. */
  67009. set: function (value) {
  67010. if (this._alpha === value) {
  67011. return;
  67012. }
  67013. this._alpha = value;
  67014. this.markAsDirty(Material.MiscDirtyFlag);
  67015. },
  67016. enumerable: true,
  67017. configurable: true
  67018. });
  67019. Object.defineProperty(Material.prototype, "backFaceCulling", {
  67020. /**
  67021. * Gets the back-face culling state
  67022. */
  67023. get: function () {
  67024. return this._backFaceCulling;
  67025. },
  67026. /**
  67027. * Sets the back-face culling state
  67028. */
  67029. set: function (value) {
  67030. if (this._backFaceCulling === value) {
  67031. return;
  67032. }
  67033. this._backFaceCulling = value;
  67034. this.markAsDirty(Material.TextureDirtyFlag);
  67035. },
  67036. enumerable: true,
  67037. configurable: true
  67038. });
  67039. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  67040. /**
  67041. * Gets a boolean indicating that current material needs to register RTT
  67042. */
  67043. get: function () {
  67044. return false;
  67045. },
  67046. enumerable: true,
  67047. configurable: true
  67048. });
  67049. Object.defineProperty(Material.prototype, "onDispose", {
  67050. /**
  67051. * Called during a dispose event
  67052. */
  67053. set: function (callback) {
  67054. if (this._onDisposeObserver) {
  67055. this.onDisposeObservable.remove(this._onDisposeObserver);
  67056. }
  67057. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  67058. },
  67059. enumerable: true,
  67060. configurable: true
  67061. });
  67062. Object.defineProperty(Material.prototype, "onBindObservable", {
  67063. /**
  67064. * An event triggered when the material is bound
  67065. */
  67066. get: function () {
  67067. if (!this._onBindObservable) {
  67068. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  67069. }
  67070. return this._onBindObservable;
  67071. },
  67072. enumerable: true,
  67073. configurable: true
  67074. });
  67075. Object.defineProperty(Material.prototype, "onBind", {
  67076. /**
  67077. * Called during a bind event
  67078. */
  67079. set: function (callback) {
  67080. if (this._onBindObserver) {
  67081. this.onBindObservable.remove(this._onBindObserver);
  67082. }
  67083. this._onBindObserver = this.onBindObservable.add(callback);
  67084. },
  67085. enumerable: true,
  67086. configurable: true
  67087. });
  67088. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  67089. /**
  67090. * An event triggered when the material is unbound
  67091. */
  67092. get: function () {
  67093. if (!this._onUnBindObservable) {
  67094. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  67095. }
  67096. return this._onUnBindObservable;
  67097. },
  67098. enumerable: true,
  67099. configurable: true
  67100. });
  67101. Object.defineProperty(Material.prototype, "alphaMode", {
  67102. /**
  67103. * Gets the value of the alpha mode
  67104. */
  67105. get: function () {
  67106. return this._alphaMode;
  67107. },
  67108. /**
  67109. * Sets the value of the alpha mode.
  67110. *
  67111. * | Value | Type | Description |
  67112. * | --- | --- | --- |
  67113. * | 0 | ALPHA_DISABLE | |
  67114. * | 1 | ALPHA_ADD | |
  67115. * | 2 | ALPHA_COMBINE | |
  67116. * | 3 | ALPHA_SUBTRACT | |
  67117. * | 4 | ALPHA_MULTIPLY | |
  67118. * | 5 | ALPHA_MAXIMIZED | |
  67119. * | 6 | ALPHA_ONEONE | |
  67120. * | 7 | ALPHA_PREMULTIPLIED | |
  67121. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  67122. * | 9 | ALPHA_INTERPOLATE | |
  67123. * | 10 | ALPHA_SCREENMODE | |
  67124. *
  67125. */
  67126. set: function (value) {
  67127. if (this._alphaMode === value) {
  67128. return;
  67129. }
  67130. this._alphaMode = value;
  67131. this.markAsDirty(Material.TextureDirtyFlag);
  67132. },
  67133. enumerable: true,
  67134. configurable: true
  67135. });
  67136. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  67137. /**
  67138. * Gets the depth pre-pass value
  67139. */
  67140. get: function () {
  67141. return this._needDepthPrePass;
  67142. },
  67143. /**
  67144. * Sets the need depth pre-pass value
  67145. */
  67146. set: function (value) {
  67147. if (this._needDepthPrePass === value) {
  67148. return;
  67149. }
  67150. this._needDepthPrePass = value;
  67151. if (this._needDepthPrePass) {
  67152. this.checkReadyOnEveryCall = true;
  67153. }
  67154. },
  67155. enumerable: true,
  67156. configurable: true
  67157. });
  67158. Object.defineProperty(Material.prototype, "fogEnabled", {
  67159. /**
  67160. * Gets the value of the fog enabled state
  67161. */
  67162. get: function () {
  67163. return this._fogEnabled;
  67164. },
  67165. /**
  67166. * Sets the state for enabling fog
  67167. */
  67168. set: function (value) {
  67169. if (this._fogEnabled === value) {
  67170. return;
  67171. }
  67172. this._fogEnabled = value;
  67173. this.markAsDirty(Material.MiscDirtyFlag);
  67174. },
  67175. enumerable: true,
  67176. configurable: true
  67177. });
  67178. Object.defineProperty(Material.prototype, "wireframe", {
  67179. /**
  67180. * Gets a value specifying if wireframe mode is enabled
  67181. */
  67182. get: function () {
  67183. switch (this._fillMode) {
  67184. case Material.WireFrameFillMode:
  67185. case Material.LineListDrawMode:
  67186. case Material.LineLoopDrawMode:
  67187. case Material.LineStripDrawMode:
  67188. return true;
  67189. }
  67190. return this._scene.forceWireframe;
  67191. },
  67192. /**
  67193. * Sets the state of wireframe mode
  67194. */
  67195. set: function (value) {
  67196. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  67197. },
  67198. enumerable: true,
  67199. configurable: true
  67200. });
  67201. Object.defineProperty(Material.prototype, "pointsCloud", {
  67202. /**
  67203. * Gets the value specifying if point clouds are enabled
  67204. */
  67205. get: function () {
  67206. switch (this._fillMode) {
  67207. case Material.PointFillMode:
  67208. case Material.PointListDrawMode:
  67209. return true;
  67210. }
  67211. return this._scene.forcePointsCloud;
  67212. },
  67213. /**
  67214. * Sets the state of point cloud mode
  67215. */
  67216. set: function (value) {
  67217. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  67218. },
  67219. enumerable: true,
  67220. configurable: true
  67221. });
  67222. Object.defineProperty(Material.prototype, "fillMode", {
  67223. /**
  67224. * Gets the material fill mode
  67225. */
  67226. get: function () {
  67227. return this._fillMode;
  67228. },
  67229. /**
  67230. * Sets the material fill mode
  67231. */
  67232. set: function (value) {
  67233. if (this._fillMode === value) {
  67234. return;
  67235. }
  67236. this._fillMode = value;
  67237. this.markAsDirty(Material.MiscDirtyFlag);
  67238. },
  67239. enumerable: true,
  67240. configurable: true
  67241. });
  67242. /**
  67243. * Returns a string representation of the current material
  67244. * @param fullDetails defines a boolean indicating which levels of logging is desired
  67245. * @returns a string with material information
  67246. */
  67247. Material.prototype.toString = function (fullDetails) {
  67248. var ret = "Name: " + this.name;
  67249. if (fullDetails) {
  67250. }
  67251. return ret;
  67252. };
  67253. /**
  67254. * Gets the class name of the material
  67255. * @returns a string with the class name of the material
  67256. */
  67257. Material.prototype.getClassName = function () {
  67258. return "Material";
  67259. };
  67260. Object.defineProperty(Material.prototype, "isFrozen", {
  67261. /**
  67262. * Specifies if updates for the material been locked
  67263. */
  67264. get: function () {
  67265. return this.checkReadyOnlyOnce;
  67266. },
  67267. enumerable: true,
  67268. configurable: true
  67269. });
  67270. /**
  67271. * Locks updates for the material
  67272. */
  67273. Material.prototype.freeze = function () {
  67274. this.checkReadyOnlyOnce = true;
  67275. };
  67276. /**
  67277. * Unlocks updates for the material
  67278. */
  67279. Material.prototype.unfreeze = function () {
  67280. this.checkReadyOnlyOnce = false;
  67281. };
  67282. /**
  67283. * Specifies if the material is ready to be used
  67284. * @param mesh defines the mesh to check
  67285. * @param useInstances specifies if instances should be used
  67286. * @returns a boolean indicating if the material is ready to be used
  67287. */
  67288. Material.prototype.isReady = function (mesh, useInstances) {
  67289. return true;
  67290. };
  67291. /**
  67292. * Specifies that the submesh is ready to be used
  67293. * @param mesh defines the mesh to check
  67294. * @param subMesh defines which submesh to check
  67295. * @param useInstances specifies that instances should be used
  67296. * @returns a boolean indicating that the submesh is ready or not
  67297. */
  67298. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  67299. return false;
  67300. };
  67301. /**
  67302. * Returns the material effect
  67303. * @returns the effect associated with the material
  67304. */
  67305. Material.prototype.getEffect = function () {
  67306. return this._effect;
  67307. };
  67308. /**
  67309. * Returns the current scene
  67310. * @returns a Scene
  67311. */
  67312. Material.prototype.getScene = function () {
  67313. return this._scene;
  67314. };
  67315. /**
  67316. * Specifies if the material will require alpha blending
  67317. * @returns a boolean specifying if alpha blending is needed
  67318. */
  67319. Material.prototype.needAlphaBlending = function () {
  67320. return (this.alpha < 1.0);
  67321. };
  67322. /**
  67323. * Specifies if the mesh will require alpha blending
  67324. * @param mesh defines the mesh to check
  67325. * @returns a boolean specifying if alpha blending is needed for the mesh
  67326. */
  67327. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  67328. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  67329. };
  67330. /**
  67331. * Specifies if this material should be rendered in alpha test mode
  67332. * @returns a boolean specifying if an alpha test is needed.
  67333. */
  67334. Material.prototype.needAlphaTesting = function () {
  67335. return false;
  67336. };
  67337. /**
  67338. * Gets the texture used for the alpha test
  67339. * @returns the texture to use for alpha testing
  67340. */
  67341. Material.prototype.getAlphaTestTexture = function () {
  67342. return null;
  67343. };
  67344. /**
  67345. * Marks the material to indicate that it needs to be re-calculated
  67346. */
  67347. Material.prototype.markDirty = function () {
  67348. this._wasPreviouslyReady = false;
  67349. };
  67350. /** @hidden */
  67351. Material.prototype._preBind = function (effect, overrideOrientation) {
  67352. if (overrideOrientation === void 0) { overrideOrientation = null; }
  67353. var engine = this._scene.getEngine();
  67354. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  67355. var reverse = orientation === Material.ClockWiseSideOrientation;
  67356. engine.enableEffect(effect ? effect : this._effect);
  67357. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  67358. return reverse;
  67359. };
  67360. /**
  67361. * Binds the material to the mesh
  67362. * @param world defines the world transformation matrix
  67363. * @param mesh defines the mesh to bind the material to
  67364. */
  67365. Material.prototype.bind = function (world, mesh) {
  67366. };
  67367. /**
  67368. * Binds the submesh to the material
  67369. * @param world defines the world transformation matrix
  67370. * @param mesh defines the mesh containing the submesh
  67371. * @param subMesh defines the submesh to bind the material to
  67372. */
  67373. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  67374. };
  67375. /**
  67376. * Binds the world matrix to the material
  67377. * @param world defines the world transformation matrix
  67378. */
  67379. Material.prototype.bindOnlyWorldMatrix = function (world) {
  67380. };
  67381. /**
  67382. * Binds the scene's uniform buffer to the effect.
  67383. * @param effect defines the effect to bind to the scene uniform buffer
  67384. * @param sceneUbo defines the uniform buffer storing scene data
  67385. */
  67386. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  67387. sceneUbo.bindToEffect(effect, "Scene");
  67388. };
  67389. /**
  67390. * Binds the view matrix to the effect
  67391. * @param effect defines the effect to bind the view matrix to
  67392. */
  67393. Material.prototype.bindView = function (effect) {
  67394. if (!this._useUBO) {
  67395. effect.setMatrix("view", this.getScene().getViewMatrix());
  67396. }
  67397. else {
  67398. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  67399. }
  67400. };
  67401. /**
  67402. * Binds the view projection matrix to the effect
  67403. * @param effect defines the effect to bind the view projection matrix to
  67404. */
  67405. Material.prototype.bindViewProjection = function (effect) {
  67406. if (!this._useUBO) {
  67407. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  67408. }
  67409. else {
  67410. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  67411. }
  67412. };
  67413. /**
  67414. * Specifies if material alpha testing should be turned on for the mesh
  67415. * @param mesh defines the mesh to check
  67416. */
  67417. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  67418. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  67419. };
  67420. /**
  67421. * Processes to execute after binding the material to a mesh
  67422. * @param mesh defines the rendered mesh
  67423. */
  67424. Material.prototype._afterBind = function (mesh) {
  67425. this._scene._cachedMaterial = this;
  67426. if (mesh) {
  67427. this._scene._cachedVisibility = mesh.visibility;
  67428. }
  67429. else {
  67430. this._scene._cachedVisibility = 1;
  67431. }
  67432. if (this._onBindObservable && mesh) {
  67433. this._onBindObservable.notifyObservers(mesh);
  67434. }
  67435. if (this.disableDepthWrite) {
  67436. var engine = this._scene.getEngine();
  67437. this._cachedDepthWriteState = engine.getDepthWrite();
  67438. engine.setDepthWrite(false);
  67439. }
  67440. };
  67441. /**
  67442. * Unbinds the material from the mesh
  67443. */
  67444. Material.prototype.unbind = function () {
  67445. if (this._onUnBindObservable) {
  67446. this._onUnBindObservable.notifyObservers(this);
  67447. }
  67448. if (this.disableDepthWrite) {
  67449. var engine = this._scene.getEngine();
  67450. engine.setDepthWrite(this._cachedDepthWriteState);
  67451. }
  67452. };
  67453. /**
  67454. * Gets the active textures from the material
  67455. * @returns an array of textures
  67456. */
  67457. Material.prototype.getActiveTextures = function () {
  67458. return [];
  67459. };
  67460. /**
  67461. * Specifies if the material uses a texture
  67462. * @param texture defines the texture to check against the material
  67463. * @returns a boolean specifying if the material uses the texture
  67464. */
  67465. Material.prototype.hasTexture = function (texture) {
  67466. return false;
  67467. };
  67468. /**
  67469. * Makes a duplicate of the material, and gives it a new name
  67470. * @param name defines the new name for the duplicated material
  67471. * @returns the cloned material
  67472. */
  67473. Material.prototype.clone = function (name) {
  67474. return null;
  67475. };
  67476. /**
  67477. * Gets the meshes bound to the material
  67478. * @returns an array of meshes bound to the material
  67479. */
  67480. Material.prototype.getBindedMeshes = function () {
  67481. var _this = this;
  67482. if (this.meshMap) {
  67483. var result = new Array();
  67484. for (var meshId in this.meshMap) {
  67485. var mesh = this.meshMap[meshId];
  67486. if (mesh) {
  67487. result.push(mesh);
  67488. }
  67489. }
  67490. return result;
  67491. }
  67492. else {
  67493. var meshes = this._scene.meshes;
  67494. return meshes.filter(function (mesh) { return mesh.material === _this; });
  67495. }
  67496. };
  67497. /**
  67498. * Force shader compilation
  67499. * @param mesh defines the mesh associated with this material
  67500. * @param onCompiled defines a function to execute once the material is compiled
  67501. * @param options defines the options to configure the compilation
  67502. */
  67503. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  67504. var _this = this;
  67505. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  67506. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  67507. var scene = this.getScene();
  67508. var checkReady = function () {
  67509. if (!_this._scene || !_this._scene.getEngine()) {
  67510. return;
  67511. }
  67512. if (subMesh._materialDefines) {
  67513. subMesh._materialDefines._renderId = -1;
  67514. }
  67515. var clipPlaneState = scene.clipPlane;
  67516. if (localOptions.clipPlane) {
  67517. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  67518. }
  67519. if (_this._storeEffectOnSubMeshes) {
  67520. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  67521. if (onCompiled) {
  67522. onCompiled(_this);
  67523. }
  67524. }
  67525. else {
  67526. setTimeout(checkReady, 16);
  67527. }
  67528. }
  67529. else {
  67530. if (_this.isReady()) {
  67531. if (onCompiled) {
  67532. onCompiled(_this);
  67533. }
  67534. }
  67535. else {
  67536. setTimeout(checkReady, 16);
  67537. }
  67538. }
  67539. if (localOptions.clipPlane) {
  67540. scene.clipPlane = clipPlaneState;
  67541. }
  67542. };
  67543. checkReady();
  67544. };
  67545. /**
  67546. * Force shader compilation
  67547. * @param mesh defines the mesh that will use this material
  67548. * @param options defines additional options for compiling the shaders
  67549. * @returns a promise that resolves when the compilation completes
  67550. */
  67551. Material.prototype.forceCompilationAsync = function (mesh, options) {
  67552. var _this = this;
  67553. return new Promise(function (resolve) {
  67554. _this.forceCompilation(mesh, function () {
  67555. resolve();
  67556. }, options);
  67557. });
  67558. };
  67559. /**
  67560. * Marks a define in the material to indicate that it needs to be re-computed
  67561. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  67562. */
  67563. Material.prototype.markAsDirty = function (flag) {
  67564. if (this.getScene().blockMaterialDirtyMechanism) {
  67565. return;
  67566. }
  67567. Material._DirtyCallbackArray.length = 0;
  67568. if (flag & Material.TextureDirtyFlag) {
  67569. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  67570. }
  67571. if (flag & Material.LightDirtyFlag) {
  67572. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  67573. }
  67574. if (flag & Material.FresnelDirtyFlag) {
  67575. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  67576. }
  67577. if (flag & Material.AttributesDirtyFlag) {
  67578. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  67579. }
  67580. if (flag & Material.MiscDirtyFlag) {
  67581. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  67582. }
  67583. if (Material._DirtyCallbackArray.length) {
  67584. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  67585. }
  67586. this.getScene().resetCachedMaterial();
  67587. };
  67588. /**
  67589. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  67590. * @param func defines a function which checks material defines against the submeshes
  67591. */
  67592. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  67593. if (this.getScene().blockMaterialDirtyMechanism) {
  67594. return;
  67595. }
  67596. var meshes = this.getScene().meshes;
  67597. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  67598. var mesh = meshes_1[_i];
  67599. if (!mesh.subMeshes) {
  67600. continue;
  67601. }
  67602. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  67603. var subMesh = _b[_a];
  67604. if (subMesh.getMaterial() !== this) {
  67605. continue;
  67606. }
  67607. if (!subMesh._materialDefines) {
  67608. continue;
  67609. }
  67610. func(subMesh._materialDefines);
  67611. }
  67612. }
  67613. };
  67614. /**
  67615. * Indicates that image processing needs to be re-calculated for all submeshes
  67616. */
  67617. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  67618. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  67619. };
  67620. /**
  67621. * Indicates that textures need to be re-calculated for all submeshes
  67622. */
  67623. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  67624. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  67625. };
  67626. /**
  67627. * Indicates that fresnel needs to be re-calculated for all submeshes
  67628. */
  67629. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  67630. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  67631. };
  67632. /**
  67633. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  67634. */
  67635. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  67636. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  67637. };
  67638. /**
  67639. * Indicates that lights need to be re-calculated for all submeshes
  67640. */
  67641. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  67642. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  67643. };
  67644. /**
  67645. * Indicates that attributes need to be re-calculated for all submeshes
  67646. */
  67647. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  67648. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  67649. };
  67650. /**
  67651. * Indicates that misc needs to be re-calculated for all submeshes
  67652. */
  67653. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  67654. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  67655. };
  67656. /**
  67657. * Indicates that textures and misc need to be re-calculated for all submeshes
  67658. */
  67659. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  67660. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  67661. };
  67662. /**
  67663. * Disposes the material
  67664. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  67665. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  67666. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  67667. */
  67668. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  67669. var scene = this.getScene();
  67670. // Animations
  67671. scene.stopAnimation(this);
  67672. scene.freeProcessedMaterials();
  67673. // Remove from scene
  67674. scene.removeMaterial(this);
  67675. if (notBoundToMesh !== true) {
  67676. // Remove from meshes
  67677. if (this.meshMap) {
  67678. for (var meshId in this.meshMap) {
  67679. var mesh = this.meshMap[meshId];
  67680. if (mesh) {
  67681. mesh.material = null; // will set the entry in the map to undefined
  67682. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  67683. }
  67684. }
  67685. }
  67686. else {
  67687. var meshes = scene.meshes;
  67688. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  67689. var mesh = meshes_2[_i];
  67690. if (mesh.material === this && !mesh.sourceMesh) {
  67691. mesh.material = null;
  67692. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  67693. }
  67694. }
  67695. }
  67696. }
  67697. this._uniformBuffer.dispose();
  67698. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  67699. if (forceDisposeEffect && this._effect) {
  67700. if (!this._storeEffectOnSubMeshes) {
  67701. this._effect.dispose();
  67702. }
  67703. this._effect = null;
  67704. }
  67705. // Callback
  67706. this.onDisposeObservable.notifyObservers(this);
  67707. this.onDisposeObservable.clear();
  67708. if (this._onBindObservable) {
  67709. this._onBindObservable.clear();
  67710. }
  67711. if (this._onUnBindObservable) {
  67712. this._onUnBindObservable.clear();
  67713. }
  67714. };
  67715. /** @hidden */
  67716. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  67717. if (mesh.geometry) {
  67718. var geometry = (mesh.geometry);
  67719. if (this._storeEffectOnSubMeshes) {
  67720. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  67721. var subMesh = _a[_i];
  67722. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  67723. if (forceDisposeEffect && subMesh._materialEffect) {
  67724. subMesh._materialEffect.dispose();
  67725. }
  67726. }
  67727. }
  67728. else {
  67729. geometry._releaseVertexArrayObject(this._effect);
  67730. }
  67731. }
  67732. };
  67733. /**
  67734. * Serializes this material
  67735. * @returns the serialized material object
  67736. */
  67737. Material.prototype.serialize = function () {
  67738. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  67739. };
  67740. /**
  67741. * Creates a material from parsed material data
  67742. * @param parsedMaterial defines parsed material data
  67743. * @param scene defines the hosting scene
  67744. * @param rootUrl defines the root URL to use to load textures
  67745. * @returns a new material
  67746. */
  67747. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  67748. if (!parsedMaterial.customType) {
  67749. parsedMaterial.customType = "BABYLON.StandardMaterial";
  67750. }
  67751. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  67752. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  67753. if (!BABYLON.LegacyPBRMaterial) {
  67754. _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.");
  67755. return null;
  67756. }
  67757. }
  67758. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  67759. return materialType.Parse(parsedMaterial, scene, rootUrl);
  67760. };
  67761. /**
  67762. * Returns the triangle fill mode
  67763. */
  67764. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  67765. /**
  67766. * Returns the wireframe mode
  67767. */
  67768. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  67769. /**
  67770. * Returns the point fill mode
  67771. */
  67772. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  67773. /**
  67774. * Returns the point list draw mode
  67775. */
  67776. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  67777. /**
  67778. * Returns the line list draw mode
  67779. */
  67780. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  67781. /**
  67782. * Returns the line loop draw mode
  67783. */
  67784. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  67785. /**
  67786. * Returns the line strip draw mode
  67787. */
  67788. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  67789. /**
  67790. * Returns the triangle strip draw mode
  67791. */
  67792. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  67793. /**
  67794. * Returns the triangle fan draw mode
  67795. */
  67796. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  67797. /**
  67798. * Stores the clock-wise side orientation
  67799. */
  67800. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  67801. /**
  67802. * Stores the counter clock-wise side orientation
  67803. */
  67804. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  67805. /**
  67806. * The dirty texture flag value
  67807. */
  67808. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  67809. /**
  67810. * The dirty light flag value
  67811. */
  67812. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  67813. /**
  67814. * The dirty fresnel flag value
  67815. */
  67816. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  67817. /**
  67818. * The dirty attribute flag value
  67819. */
  67820. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  67821. /**
  67822. * The dirty misc flag value
  67823. */
  67824. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  67825. /**
  67826. * The all dirty flag value
  67827. */
  67828. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  67829. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  67830. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  67831. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  67832. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  67833. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  67834. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  67835. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  67836. Material._FresnelDirtyCallBack(defines);
  67837. Material._MiscDirtyCallBack(defines);
  67838. };
  67839. Material._TextureAndMiscDirtyCallBack = function (defines) {
  67840. Material._TextureDirtyCallBack(defines);
  67841. Material._MiscDirtyCallBack(defines);
  67842. };
  67843. Material._DirtyCallbackArray = [];
  67844. Material._RunDirtyCallBacks = function (defines) {
  67845. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  67846. var cb = _a[_i];
  67847. cb(defines);
  67848. }
  67849. };
  67850. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67851. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67852. ], Material.prototype, "id", void 0);
  67853. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67854. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67855. ], Material.prototype, "uniqueId", void 0);
  67856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67858. ], Material.prototype, "name", void 0);
  67859. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67860. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67861. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  67862. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67863. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67864. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  67865. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67867. ], Material.prototype, "state", void 0);
  67868. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  67870. ], Material.prototype, "_alpha", void 0);
  67871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  67873. ], Material.prototype, "_backFaceCulling", void 0);
  67874. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67875. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67876. ], Material.prototype, "sideOrientation", void 0);
  67877. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67878. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  67879. ], Material.prototype, "_alphaMode", void 0);
  67880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67882. ], Material.prototype, "_needDepthPrePass", void 0);
  67883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67885. ], Material.prototype, "disableDepthWrite", void 0);
  67886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67888. ], Material.prototype, "forceDepthWrite", void 0);
  67889. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67890. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67891. ], Material.prototype, "separateCullingPass", void 0);
  67892. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67893. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  67894. ], Material.prototype, "_fogEnabled", void 0);
  67895. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67896. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67897. ], Material.prototype, "pointSize", void 0);
  67898. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67899. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67900. ], Material.prototype, "zOffset", void 0);
  67901. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67902. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67903. ], Material.prototype, "wireframe", null);
  67904. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67905. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67906. ], Material.prototype, "pointsCloud", null);
  67907. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67908. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67909. ], Material.prototype, "fillMode", null);
  67910. return Material;
  67911. }());
  67912. /***/ }),
  67913. /***/ "./Materials/materialDefines.ts":
  67914. /*!**************************************!*\
  67915. !*** ./Materials/materialDefines.ts ***!
  67916. \**************************************/
  67917. /*! exports provided: MaterialDefines */
  67918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67919. "use strict";
  67920. __webpack_require__.r(__webpack_exports__);
  67921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  67922. /**
  67923. * Manages the defines for the Material
  67924. */
  67925. var MaterialDefines = /** @class */ (function () {
  67926. function MaterialDefines() {
  67927. this._isDirty = true;
  67928. /** @hidden */
  67929. this._areLightsDirty = true;
  67930. /** @hidden */
  67931. this._areAttributesDirty = true;
  67932. /** @hidden */
  67933. this._areTexturesDirty = true;
  67934. /** @hidden */
  67935. this._areFresnelDirty = true;
  67936. /** @hidden */
  67937. this._areMiscDirty = true;
  67938. /** @hidden */
  67939. this._areImageProcessingDirty = true;
  67940. /** @hidden */
  67941. this._normals = false;
  67942. /** @hidden */
  67943. this._uvs = false;
  67944. /** @hidden */
  67945. this._needNormals = false;
  67946. /** @hidden */
  67947. this._needUVs = false;
  67948. }
  67949. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  67950. /**
  67951. * Specifies if the material needs to be re-calculated
  67952. */
  67953. get: function () {
  67954. return this._isDirty;
  67955. },
  67956. enumerable: true,
  67957. configurable: true
  67958. });
  67959. /**
  67960. * Marks the material to indicate that it has been re-calculated
  67961. */
  67962. MaterialDefines.prototype.markAsProcessed = function () {
  67963. this._isDirty = false;
  67964. this._areAttributesDirty = false;
  67965. this._areTexturesDirty = false;
  67966. this._areFresnelDirty = false;
  67967. this._areLightsDirty = false;
  67968. this._areMiscDirty = false;
  67969. this._areImageProcessingDirty = false;
  67970. };
  67971. /**
  67972. * Marks the material to indicate that it needs to be re-calculated
  67973. */
  67974. MaterialDefines.prototype.markAsUnprocessed = function () {
  67975. this._isDirty = true;
  67976. };
  67977. /**
  67978. * Marks the material to indicate all of its defines need to be re-calculated
  67979. */
  67980. MaterialDefines.prototype.markAllAsDirty = function () {
  67981. this._areTexturesDirty = true;
  67982. this._areAttributesDirty = true;
  67983. this._areLightsDirty = true;
  67984. this._areFresnelDirty = true;
  67985. this._areMiscDirty = true;
  67986. this._areImageProcessingDirty = true;
  67987. this._isDirty = true;
  67988. };
  67989. /**
  67990. * Marks the material to indicate that image processing needs to be re-calculated
  67991. */
  67992. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  67993. this._areImageProcessingDirty = true;
  67994. this._isDirty = true;
  67995. };
  67996. /**
  67997. * Marks the material to indicate the lights need to be re-calculated
  67998. */
  67999. MaterialDefines.prototype.markAsLightDirty = function () {
  68000. this._areLightsDirty = true;
  68001. this._isDirty = true;
  68002. };
  68003. /**
  68004. * Marks the attribute state as changed
  68005. */
  68006. MaterialDefines.prototype.markAsAttributesDirty = function () {
  68007. this._areAttributesDirty = true;
  68008. this._isDirty = true;
  68009. };
  68010. /**
  68011. * Marks the texture state as changed
  68012. */
  68013. MaterialDefines.prototype.markAsTexturesDirty = function () {
  68014. this._areTexturesDirty = true;
  68015. this._isDirty = true;
  68016. };
  68017. /**
  68018. * Marks the fresnel state as changed
  68019. */
  68020. MaterialDefines.prototype.markAsFresnelDirty = function () {
  68021. this._areFresnelDirty = true;
  68022. this._isDirty = true;
  68023. };
  68024. /**
  68025. * Marks the misc state as changed
  68026. */
  68027. MaterialDefines.prototype.markAsMiscDirty = function () {
  68028. this._areMiscDirty = true;
  68029. this._isDirty = true;
  68030. };
  68031. /**
  68032. * Rebuilds the material defines
  68033. */
  68034. MaterialDefines.prototype.rebuild = function () {
  68035. if (this._keys) {
  68036. delete this._keys;
  68037. }
  68038. this._keys = [];
  68039. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  68040. var key = _a[_i];
  68041. if (key[0] === "_") {
  68042. continue;
  68043. }
  68044. this._keys.push(key);
  68045. }
  68046. };
  68047. /**
  68048. * Specifies if two material defines are equal
  68049. * @param other - A material define instance to compare to
  68050. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  68051. */
  68052. MaterialDefines.prototype.isEqual = function (other) {
  68053. if (this._keys.length !== other._keys.length) {
  68054. return false;
  68055. }
  68056. for (var index = 0; index < this._keys.length; index++) {
  68057. var prop = this._keys[index];
  68058. if (this[prop] !== other[prop]) {
  68059. return false;
  68060. }
  68061. }
  68062. return true;
  68063. };
  68064. /**
  68065. * Clones this instance's defines to another instance
  68066. * @param other - material defines to clone values to
  68067. */
  68068. MaterialDefines.prototype.cloneTo = function (other) {
  68069. if (this._keys.length !== other._keys.length) {
  68070. other._keys = this._keys.slice(0);
  68071. }
  68072. for (var index = 0; index < this._keys.length; index++) {
  68073. var prop = this._keys[index];
  68074. other[prop] = this[prop];
  68075. }
  68076. };
  68077. /**
  68078. * Resets the material define values
  68079. */
  68080. MaterialDefines.prototype.reset = function () {
  68081. for (var index = 0; index < this._keys.length; index++) {
  68082. var prop = this._keys[index];
  68083. var type = typeof this[prop];
  68084. switch (type) {
  68085. case "number":
  68086. this[prop] = 0;
  68087. break;
  68088. case "string":
  68089. this[prop] = "";
  68090. break;
  68091. default:
  68092. this[prop] = false;
  68093. break;
  68094. }
  68095. }
  68096. };
  68097. /**
  68098. * Converts the material define values to a string
  68099. * @returns - String of material define information
  68100. */
  68101. MaterialDefines.prototype.toString = function () {
  68102. var result = "";
  68103. for (var index = 0; index < this._keys.length; index++) {
  68104. var prop = this._keys[index];
  68105. var value = this[prop];
  68106. var type = typeof value;
  68107. switch (type) {
  68108. case "number":
  68109. case "string":
  68110. result += "#define " + prop + " " + value + "\n";
  68111. break;
  68112. default:
  68113. if (value) {
  68114. result += "#define " + prop + "\n";
  68115. }
  68116. break;
  68117. }
  68118. }
  68119. return result;
  68120. };
  68121. return MaterialDefines;
  68122. }());
  68123. /***/ }),
  68124. /***/ "./Materials/materialFlags.ts":
  68125. /*!************************************!*\
  68126. !*** ./Materials/materialFlags.ts ***!
  68127. \************************************/
  68128. /*! exports provided: MaterialFlags */
  68129. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68130. "use strict";
  68131. __webpack_require__.r(__webpack_exports__);
  68132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  68133. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  68134. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  68135. /**
  68136. * This groups all the flags used to control the materials channel.
  68137. */
  68138. var MaterialFlags = /** @class */ (function () {
  68139. function MaterialFlags() {
  68140. }
  68141. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  68142. /**
  68143. * Are diffuse textures enabled in the application.
  68144. */
  68145. get: function () {
  68146. return this._DiffuseTextureEnabled;
  68147. },
  68148. set: function (value) {
  68149. if (this._DiffuseTextureEnabled === value) {
  68150. return;
  68151. }
  68152. this._DiffuseTextureEnabled = value;
  68153. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68154. },
  68155. enumerable: true,
  68156. configurable: true
  68157. });
  68158. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  68159. /**
  68160. * Are ambient textures enabled in the application.
  68161. */
  68162. get: function () {
  68163. return this._AmbientTextureEnabled;
  68164. },
  68165. set: function (value) {
  68166. if (this._AmbientTextureEnabled === value) {
  68167. return;
  68168. }
  68169. this._AmbientTextureEnabled = value;
  68170. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68171. },
  68172. enumerable: true,
  68173. configurable: true
  68174. });
  68175. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  68176. /**
  68177. * Are opacity textures enabled in the application.
  68178. */
  68179. get: function () {
  68180. return this._OpacityTextureEnabled;
  68181. },
  68182. set: function (value) {
  68183. if (this._OpacityTextureEnabled === value) {
  68184. return;
  68185. }
  68186. this._OpacityTextureEnabled = value;
  68187. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68188. },
  68189. enumerable: true,
  68190. configurable: true
  68191. });
  68192. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  68193. /**
  68194. * Are reflection textures enabled in the application.
  68195. */
  68196. get: function () {
  68197. return this._ReflectionTextureEnabled;
  68198. },
  68199. set: function (value) {
  68200. if (this._ReflectionTextureEnabled === value) {
  68201. return;
  68202. }
  68203. this._ReflectionTextureEnabled = value;
  68204. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68205. },
  68206. enumerable: true,
  68207. configurable: true
  68208. });
  68209. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  68210. /**
  68211. * Are emissive textures enabled in the application.
  68212. */
  68213. get: function () {
  68214. return this._EmissiveTextureEnabled;
  68215. },
  68216. set: function (value) {
  68217. if (this._EmissiveTextureEnabled === value) {
  68218. return;
  68219. }
  68220. this._EmissiveTextureEnabled = value;
  68221. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68222. },
  68223. enumerable: true,
  68224. configurable: true
  68225. });
  68226. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  68227. /**
  68228. * Are specular textures enabled in the application.
  68229. */
  68230. get: function () {
  68231. return this._SpecularTextureEnabled;
  68232. },
  68233. set: function (value) {
  68234. if (this._SpecularTextureEnabled === value) {
  68235. return;
  68236. }
  68237. this._SpecularTextureEnabled = value;
  68238. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68239. },
  68240. enumerable: true,
  68241. configurable: true
  68242. });
  68243. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  68244. /**
  68245. * Are bump textures enabled in the application.
  68246. */
  68247. get: function () {
  68248. return this._BumpTextureEnabled;
  68249. },
  68250. set: function (value) {
  68251. if (this._BumpTextureEnabled === value) {
  68252. return;
  68253. }
  68254. this._BumpTextureEnabled = value;
  68255. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68256. },
  68257. enumerable: true,
  68258. configurable: true
  68259. });
  68260. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  68261. /**
  68262. * Are lightmap textures enabled in the application.
  68263. */
  68264. get: function () {
  68265. return this._LightmapTextureEnabled;
  68266. },
  68267. set: function (value) {
  68268. if (this._LightmapTextureEnabled === value) {
  68269. return;
  68270. }
  68271. this._LightmapTextureEnabled = value;
  68272. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68273. },
  68274. enumerable: true,
  68275. configurable: true
  68276. });
  68277. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  68278. /**
  68279. * Are refraction textures enabled in the application.
  68280. */
  68281. get: function () {
  68282. return this._RefractionTextureEnabled;
  68283. },
  68284. set: function (value) {
  68285. if (this._RefractionTextureEnabled === value) {
  68286. return;
  68287. }
  68288. this._RefractionTextureEnabled = value;
  68289. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68290. },
  68291. enumerable: true,
  68292. configurable: true
  68293. });
  68294. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  68295. /**
  68296. * Are color grading textures enabled in the application.
  68297. */
  68298. get: function () {
  68299. return this._ColorGradingTextureEnabled;
  68300. },
  68301. set: function (value) {
  68302. if (this._ColorGradingTextureEnabled === value) {
  68303. return;
  68304. }
  68305. this._ColorGradingTextureEnabled = value;
  68306. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68307. },
  68308. enumerable: true,
  68309. configurable: true
  68310. });
  68311. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  68312. /**
  68313. * Are fresnels enabled in the application.
  68314. */
  68315. get: function () {
  68316. return this._FresnelEnabled;
  68317. },
  68318. set: function (value) {
  68319. if (this._FresnelEnabled === value) {
  68320. return;
  68321. }
  68322. this._FresnelEnabled = value;
  68323. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  68324. },
  68325. enumerable: true,
  68326. configurable: true
  68327. });
  68328. Object.defineProperty(MaterialFlags, "ClearCoatTextureEnabled", {
  68329. /**
  68330. * Are clear coat textures enabled in the application.
  68331. */
  68332. get: function () {
  68333. return this._ClearCoatTextureEnabled;
  68334. },
  68335. set: function (value) {
  68336. if (this._ClearCoatTextureEnabled === value) {
  68337. return;
  68338. }
  68339. this._ClearCoatTextureEnabled = value;
  68340. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68341. },
  68342. enumerable: true,
  68343. configurable: true
  68344. });
  68345. Object.defineProperty(MaterialFlags, "ClearCoatBumpTextureEnabled", {
  68346. /**
  68347. * Are clear coat bump textures enabled in the application.
  68348. */
  68349. get: function () {
  68350. return this._ClearCoatBumpTextureEnabled;
  68351. },
  68352. set: function (value) {
  68353. if (this._ClearCoatBumpTextureEnabled === value) {
  68354. return;
  68355. }
  68356. this._ClearCoatBumpTextureEnabled = value;
  68357. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68358. },
  68359. enumerable: true,
  68360. configurable: true
  68361. });
  68362. Object.defineProperty(MaterialFlags, "ClearCoatTintTextureEnabled", {
  68363. /**
  68364. * Are clear coat tint textures enabled in the application.
  68365. */
  68366. get: function () {
  68367. return this._ClearCoatTintTextureEnabled;
  68368. },
  68369. set: function (value) {
  68370. if (this._ClearCoatTintTextureEnabled === value) {
  68371. return;
  68372. }
  68373. this._ClearCoatTintTextureEnabled = value;
  68374. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68375. },
  68376. enumerable: true,
  68377. configurable: true
  68378. });
  68379. Object.defineProperty(MaterialFlags, "SheenTextureEnabled", {
  68380. /**
  68381. * Are sheen textures enabled in the application.
  68382. */
  68383. get: function () {
  68384. return this._SheenTextureEnabled;
  68385. },
  68386. set: function (value) {
  68387. if (this._SheenTextureEnabled === value) {
  68388. return;
  68389. }
  68390. this._SheenTextureEnabled = value;
  68391. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68392. },
  68393. enumerable: true,
  68394. configurable: true
  68395. });
  68396. Object.defineProperty(MaterialFlags, "AnisotropicTextureEnabled", {
  68397. /**
  68398. * Are anisotropic textures enabled in the application.
  68399. */
  68400. get: function () {
  68401. return this._AnisotropicTextureEnabled;
  68402. },
  68403. set: function (value) {
  68404. if (this._AnisotropicTextureEnabled === value) {
  68405. return;
  68406. }
  68407. this._AnisotropicTextureEnabled = value;
  68408. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68409. },
  68410. enumerable: true,
  68411. configurable: true
  68412. });
  68413. Object.defineProperty(MaterialFlags, "ThicknessTextureEnabled", {
  68414. /**
  68415. * Are thickness textures enabled in the application.
  68416. */
  68417. get: function () {
  68418. return this._ThicknessTextureEnabled;
  68419. },
  68420. set: function (value) {
  68421. if (this._ThicknessTextureEnabled === value) {
  68422. return;
  68423. }
  68424. this._ThicknessTextureEnabled = value;
  68425. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  68426. },
  68427. enumerable: true,
  68428. configurable: true
  68429. });
  68430. // Flags used to enable or disable a type of texture for all Standard Materials
  68431. MaterialFlags._DiffuseTextureEnabled = true;
  68432. MaterialFlags._AmbientTextureEnabled = true;
  68433. MaterialFlags._OpacityTextureEnabled = true;
  68434. MaterialFlags._ReflectionTextureEnabled = true;
  68435. MaterialFlags._EmissiveTextureEnabled = true;
  68436. MaterialFlags._SpecularTextureEnabled = true;
  68437. MaterialFlags._BumpTextureEnabled = true;
  68438. MaterialFlags._LightmapTextureEnabled = true;
  68439. MaterialFlags._RefractionTextureEnabled = true;
  68440. MaterialFlags._ColorGradingTextureEnabled = true;
  68441. MaterialFlags._FresnelEnabled = true;
  68442. MaterialFlags._ClearCoatTextureEnabled = true;
  68443. MaterialFlags._ClearCoatBumpTextureEnabled = true;
  68444. MaterialFlags._ClearCoatTintTextureEnabled = true;
  68445. MaterialFlags._SheenTextureEnabled = true;
  68446. MaterialFlags._AnisotropicTextureEnabled = true;
  68447. MaterialFlags._ThicknessTextureEnabled = true;
  68448. return MaterialFlags;
  68449. }());
  68450. /***/ }),
  68451. /***/ "./Materials/materialHelper.ts":
  68452. /*!*************************************!*\
  68453. !*** ./Materials/materialHelper.ts ***!
  68454. \*************************************/
  68455. /*! exports provided: MaterialHelper */
  68456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68457. "use strict";
  68458. __webpack_require__.r(__webpack_exports__);
  68459. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  68460. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  68461. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  68462. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  68463. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  68464. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  68465. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  68466. /**
  68467. * "Static Class" containing the most commonly used helper while dealing with material for
  68468. * rendering purpose.
  68469. *
  68470. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  68471. *
  68472. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  68473. */
  68474. var MaterialHelper = /** @class */ (function () {
  68475. function MaterialHelper() {
  68476. }
  68477. /**
  68478. * Bind the current view position to an effect.
  68479. * @param effect The effect to be bound
  68480. * @param scene The scene the eyes position is used from
  68481. */
  68482. MaterialHelper.BindEyePosition = function (effect, scene) {
  68483. if (scene._forcedViewPosition) {
  68484. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  68485. return;
  68486. }
  68487. var globalPosition = scene.activeCamera.globalPosition;
  68488. if (!globalPosition) {
  68489. // Use WebVRFreecamera's device position as global position is not it's actual position in babylon space
  68490. globalPosition = scene.activeCamera.devicePosition;
  68491. }
  68492. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : globalPosition);
  68493. };
  68494. /**
  68495. * Helps preparing the defines values about the UVs in used in the effect.
  68496. * UVs are shared as much as we can accross channels in the shaders.
  68497. * @param texture The texture we are preparing the UVs for
  68498. * @param defines The defines to update
  68499. * @param key The channel key "diffuse", "specular"... used in the shader
  68500. */
  68501. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  68502. defines._needUVs = true;
  68503. defines[key] = true;
  68504. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  68505. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  68506. if (texture.coordinatesIndex === 0) {
  68507. defines["MAINUV1"] = true;
  68508. }
  68509. else {
  68510. defines["MAINUV2"] = true;
  68511. }
  68512. }
  68513. else {
  68514. defines[key + "DIRECTUV"] = 0;
  68515. }
  68516. };
  68517. /**
  68518. * Binds a texture matrix value to its corrsponding uniform
  68519. * @param texture The texture to bind the matrix for
  68520. * @param uniformBuffer The uniform buffer receivin the data
  68521. * @param key The channel key "diffuse", "specular"... used in the shader
  68522. */
  68523. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  68524. var matrix = texture.getTextureMatrix();
  68525. if (!matrix.isIdentityAs3x2()) {
  68526. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  68527. }
  68528. };
  68529. /**
  68530. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  68531. * @param mesh defines the current mesh
  68532. * @param scene defines the current scene
  68533. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  68534. * @param pointsCloud defines if point cloud rendering has to be turned on
  68535. * @param fogEnabled defines if fog has to be turned on
  68536. * @param alphaTest defines if alpha testing has to be turned on
  68537. * @param defines defines the current list of defines
  68538. */
  68539. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  68540. if (defines._areMiscDirty) {
  68541. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  68542. defines["POINTSIZE"] = pointsCloud;
  68543. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  68544. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  68545. defines["ALPHATEST"] = alphaTest;
  68546. }
  68547. };
  68548. /**
  68549. * Helper used to prepare the list of defines associated with frame values for shader compilation
  68550. * @param scene defines the current scene
  68551. * @param engine defines the current engine
  68552. * @param defines specifies the list of active defines
  68553. * @param useInstances defines if instances have to be turned on
  68554. * @param useClipPlane defines if clip plane have to be turned on
  68555. */
  68556. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  68557. if (useClipPlane === void 0) { useClipPlane = null; }
  68558. var changed = false;
  68559. var useClipPlane1 = false;
  68560. var useClipPlane2 = false;
  68561. var useClipPlane3 = false;
  68562. var useClipPlane4 = false;
  68563. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  68564. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  68565. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  68566. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  68567. if (defines["CLIPPLANE"] !== useClipPlane1) {
  68568. defines["CLIPPLANE"] = useClipPlane1;
  68569. changed = true;
  68570. }
  68571. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  68572. defines["CLIPPLANE2"] = useClipPlane2;
  68573. changed = true;
  68574. }
  68575. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  68576. defines["CLIPPLANE3"] = useClipPlane3;
  68577. changed = true;
  68578. }
  68579. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  68580. defines["CLIPPLANE4"] = useClipPlane4;
  68581. changed = true;
  68582. }
  68583. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  68584. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  68585. changed = true;
  68586. }
  68587. if (defines["INSTANCES"] !== useInstances) {
  68588. defines["INSTANCES"] = useInstances;
  68589. changed = true;
  68590. }
  68591. if (changed) {
  68592. defines.markAsUnprocessed();
  68593. }
  68594. };
  68595. /**
  68596. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  68597. * @param mesh The mesh containing the geometry data we will draw
  68598. * @param defines The defines to update
  68599. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  68600. * @param useBones Precise whether bones should be used or not (override mesh info)
  68601. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  68602. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  68603. * @returns false if defines are considered not dirty and have not been checked
  68604. */
  68605. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  68606. if (useMorphTargets === void 0) { useMorphTargets = false; }
  68607. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  68608. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  68609. return false;
  68610. }
  68611. defines._normals = defines._needNormals;
  68612. defines._uvs = defines._needUVs;
  68613. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  68614. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  68615. defines["TANGENT"] = true;
  68616. }
  68617. if (defines._needUVs) {
  68618. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  68619. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  68620. }
  68621. else {
  68622. defines["UV1"] = false;
  68623. defines["UV2"] = false;
  68624. }
  68625. if (useVertexColor) {
  68626. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  68627. defines["VERTEXCOLOR"] = hasVertexColors;
  68628. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  68629. }
  68630. if (useBones) {
  68631. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  68632. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  68633. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  68634. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  68635. defines["BONETEXTURE"] = true;
  68636. }
  68637. else {
  68638. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  68639. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  68640. }
  68641. }
  68642. else {
  68643. defines["NUM_BONE_INFLUENCERS"] = 0;
  68644. defines["BonesPerMesh"] = 0;
  68645. }
  68646. }
  68647. if (useMorphTargets) {
  68648. var manager = mesh.morphTargetManager;
  68649. if (manager) {
  68650. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  68651. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  68652. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  68653. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  68654. }
  68655. else {
  68656. defines["MORPHTARGETS_TANGENT"] = false;
  68657. defines["MORPHTARGETS_NORMAL"] = false;
  68658. defines["MORPHTARGETS"] = false;
  68659. defines["NUM_MORPH_INFLUENCERS"] = 0;
  68660. }
  68661. }
  68662. return true;
  68663. };
  68664. /**
  68665. * Prepares the defines related to multiview
  68666. * @param scene The scene we are intending to draw
  68667. * @param defines The defines to update
  68668. */
  68669. MaterialHelper.PrepareDefinesForMultiview = function (scene, defines) {
  68670. if (scene.activeCamera) {
  68671. var previousMultiview = defines.MULTIVIEW;
  68672. defines.MULTIVIEW = (scene.activeCamera.outputRenderTarget !== null && scene.activeCamera.outputRenderTarget.getViewCount() > 1);
  68673. if (defines.MULTIVIEW != previousMultiview) {
  68674. defines.markAsUnprocessed();
  68675. }
  68676. }
  68677. };
  68678. /**
  68679. * Prepares the defines related to the light information passed in parameter
  68680. * @param scene The scene we are intending to draw
  68681. * @param mesh The mesh the effect is compiling for
  68682. * @param defines The defines to update
  68683. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  68684. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  68685. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  68686. * @returns true if normals will be required for the rest of the effect
  68687. */
  68688. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  68689. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  68690. if (disableLighting === void 0) { disableLighting = false; }
  68691. if (!defines._areLightsDirty) {
  68692. return defines._needNormals;
  68693. }
  68694. var lightIndex = 0;
  68695. var needNormals = false;
  68696. var needRebuild = false;
  68697. var lightmapMode = false;
  68698. var shadowEnabled = false;
  68699. var specularEnabled = false;
  68700. if (scene.lightsEnabled && !disableLighting) {
  68701. for (var _i = 0, _a = mesh.lightSources; _i < _a.length; _i++) {
  68702. var light = _a[_i];
  68703. needNormals = true;
  68704. if (defines["LIGHT" + lightIndex] === undefined) {
  68705. needRebuild = true;
  68706. }
  68707. defines["LIGHT" + lightIndex] = true;
  68708. defines["SPOTLIGHT" + lightIndex] = false;
  68709. defines["HEMILIGHT" + lightIndex] = false;
  68710. defines["POINTLIGHT" + lightIndex] = false;
  68711. defines["DIRLIGHT" + lightIndex] = false;
  68712. light.prepareLightSpecificDefines(defines, lightIndex);
  68713. // FallOff.
  68714. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  68715. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  68716. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  68717. switch (light.falloffType) {
  68718. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  68719. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  68720. break;
  68721. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  68722. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  68723. break;
  68724. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  68725. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  68726. break;
  68727. }
  68728. // Specular
  68729. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  68730. specularEnabled = true;
  68731. }
  68732. // Shadows
  68733. defines["SHADOW" + lightIndex] = false;
  68734. defines["SHADOWPCF" + lightIndex] = false;
  68735. defines["SHADOWPCSS" + lightIndex] = false;
  68736. defines["SHADOWPOISSON" + lightIndex] = false;
  68737. defines["SHADOWESM" + lightIndex] = false;
  68738. defines["SHADOWCUBE" + lightIndex] = false;
  68739. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  68740. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  68741. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  68742. var shadowGenerator = light.getShadowGenerator();
  68743. if (shadowGenerator) {
  68744. var shadowMap = shadowGenerator.getShadowMap();
  68745. if (shadowMap) {
  68746. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  68747. shadowEnabled = true;
  68748. shadowGenerator.prepareDefines(defines, lightIndex);
  68749. }
  68750. }
  68751. }
  68752. }
  68753. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  68754. lightmapMode = true;
  68755. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  68756. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  68757. }
  68758. else {
  68759. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  68760. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  68761. }
  68762. lightIndex++;
  68763. if (lightIndex === maxSimultaneousLights) {
  68764. break;
  68765. }
  68766. }
  68767. }
  68768. defines["SPECULARTERM"] = specularEnabled;
  68769. defines["SHADOWS"] = shadowEnabled;
  68770. // Resetting all other lights if any
  68771. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  68772. if (defines["LIGHT" + index] !== undefined) {
  68773. defines["LIGHT" + index] = false;
  68774. defines["HEMILIGHT" + index] = false;
  68775. defines["POINTLIGHT" + index] = false;
  68776. defines["DIRLIGHT" + index] = false;
  68777. defines["SPOTLIGHT" + index] = false;
  68778. defines["SHADOW" + index] = false;
  68779. defines["SHADOWPCF" + index] = false;
  68780. defines["SHADOWPCSS" + index] = false;
  68781. defines["SHADOWPOISSON" + index] = false;
  68782. defines["SHADOWESM" + index] = false;
  68783. defines["SHADOWCUBE" + index] = false;
  68784. defines["SHADOWLOWQUALITY" + index] = false;
  68785. defines["SHADOWMEDIUMQUALITY" + index] = false;
  68786. }
  68787. }
  68788. var caps = scene.getEngine().getCaps();
  68789. if (defines["SHADOWFLOAT"] === undefined) {
  68790. needRebuild = true;
  68791. }
  68792. defines["SHADOWFLOAT"] = shadowEnabled &&
  68793. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  68794. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  68795. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  68796. if (needRebuild) {
  68797. defines.rebuild();
  68798. }
  68799. return needNormals;
  68800. };
  68801. /**
  68802. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  68803. * that won t be acctive due to defines being turned off.
  68804. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  68805. * @param samplersList The samplers list
  68806. * @param defines The defines helping in the list generation
  68807. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  68808. */
  68809. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  68810. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  68811. var uniformsList;
  68812. var uniformBuffersList = null;
  68813. if (uniformsListOrOptions.uniformsNames) {
  68814. var options = uniformsListOrOptions;
  68815. uniformsList = options.uniformsNames;
  68816. uniformBuffersList = options.uniformBuffersNames;
  68817. samplersList = options.samplers;
  68818. defines = options.defines;
  68819. maxSimultaneousLights = options.maxSimultaneousLights;
  68820. }
  68821. else {
  68822. uniformsList = uniformsListOrOptions;
  68823. if (!samplersList) {
  68824. samplersList = [];
  68825. }
  68826. }
  68827. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  68828. if (!defines["LIGHT" + lightIndex]) {
  68829. break;
  68830. }
  68831. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  68832. if (uniformBuffersList) {
  68833. uniformBuffersList.push("Light" + lightIndex);
  68834. }
  68835. samplersList.push("shadowSampler" + lightIndex);
  68836. samplersList.push("depthSampler" + lightIndex);
  68837. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  68838. samplersList.push("projectionLightSampler" + lightIndex);
  68839. uniformsList.push("textureProjectionMatrix" + lightIndex);
  68840. }
  68841. }
  68842. if (defines["NUM_MORPH_INFLUENCERS"]) {
  68843. uniformsList.push("morphTargetInfluences");
  68844. }
  68845. };
  68846. /**
  68847. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  68848. * @param defines The defines to update while falling back
  68849. * @param fallbacks The authorized effect fallbacks
  68850. * @param maxSimultaneousLights The maximum number of lights allowed
  68851. * @param rank the current rank of the Effect
  68852. * @returns The newly affected rank
  68853. */
  68854. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  68855. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  68856. if (rank === void 0) { rank = 0; }
  68857. var lightFallbackRank = 0;
  68858. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  68859. if (!defines["LIGHT" + lightIndex]) {
  68860. break;
  68861. }
  68862. if (lightIndex > 0) {
  68863. lightFallbackRank = rank + lightIndex;
  68864. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  68865. }
  68866. if (!defines["SHADOWS"]) {
  68867. if (defines["SHADOW" + lightIndex]) {
  68868. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  68869. }
  68870. if (defines["SHADOWPCF" + lightIndex]) {
  68871. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  68872. }
  68873. if (defines["SHADOWPCSS" + lightIndex]) {
  68874. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  68875. }
  68876. if (defines["SHADOWPOISSON" + lightIndex]) {
  68877. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  68878. }
  68879. if (defines["SHADOWESM" + lightIndex]) {
  68880. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  68881. }
  68882. }
  68883. }
  68884. return lightFallbackRank++;
  68885. };
  68886. /**
  68887. * Prepares the list of attributes required for morph targets according to the effect defines.
  68888. * @param attribs The current list of supported attribs
  68889. * @param mesh The mesh to prepare the morph targets attributes for
  68890. * @param defines The current Defines of the effect
  68891. */
  68892. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  68893. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  68894. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  68895. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  68896. var manager = mesh.morphTargetManager;
  68897. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  68898. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  68899. for (var index = 0; index < influencers; index++) {
  68900. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  68901. if (normal) {
  68902. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  68903. }
  68904. if (tangent) {
  68905. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  68906. }
  68907. if (attribs.length > maxAttributesCount) {
  68908. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  68909. }
  68910. }
  68911. }
  68912. };
  68913. /**
  68914. * Prepares the list of attributes required for bones according to the effect defines.
  68915. * @param attribs The current list of supported attribs
  68916. * @param mesh The mesh to prepare the bones attributes for
  68917. * @param defines The current Defines of the effect
  68918. * @param fallbacks The current efffect fallback strategy
  68919. */
  68920. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  68921. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  68922. fallbacks.addCPUSkinningFallback(0, mesh);
  68923. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  68924. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  68925. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  68926. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  68927. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  68928. }
  68929. }
  68930. };
  68931. /**
  68932. * Prepares the list of attributes required for instances according to the effect defines.
  68933. * @param attribs The current list of supported attribs
  68934. * @param defines The current Defines of the effect
  68935. */
  68936. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  68937. if (defines["INSTANCES"]) {
  68938. attribs.push("world0");
  68939. attribs.push("world1");
  68940. attribs.push("world2");
  68941. attribs.push("world3");
  68942. }
  68943. };
  68944. /**
  68945. * Binds the light shadow information to the effect for the given mesh.
  68946. * @param light The light containing the generator
  68947. * @param scene The scene the lights belongs to
  68948. * @param mesh The mesh we are binding the information to render
  68949. * @param lightIndex The light index in the effect used to render the mesh
  68950. * @param effect The effect we are binding the data to
  68951. */
  68952. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  68953. if (light.shadowEnabled && mesh.receiveShadows) {
  68954. var shadowGenerator = light.getShadowGenerator();
  68955. if (shadowGenerator) {
  68956. shadowGenerator.bindShadowLight(lightIndex, effect);
  68957. }
  68958. }
  68959. };
  68960. /**
  68961. * Binds the light information to the effect.
  68962. * @param light The light containing the generator
  68963. * @param effect The effect we are binding the data to
  68964. * @param lightIndex The light index in the effect used to render
  68965. */
  68966. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  68967. light.transferToEffect(effect, lightIndex + "");
  68968. };
  68969. /**
  68970. * Binds the lights information from the scene to the effect for the given mesh.
  68971. * @param scene The scene the lights belongs to
  68972. * @param mesh The mesh we are binding the information to render
  68973. * @param effect The effect we are binding the data to
  68974. * @param defines The generated defines for the effect
  68975. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  68976. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  68977. */
  68978. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  68979. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  68980. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  68981. var len = Math.min(mesh.lightSources.length, maxSimultaneousLights);
  68982. for (var i = 0; i < len; i++) {
  68983. var light = mesh.lightSources[i];
  68984. var iAsString = i.toString();
  68985. var scaledIntensity = light.getScaledIntensity();
  68986. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  68987. MaterialHelper.BindLightProperties(light, effect, i);
  68988. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  68989. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  68990. if (defines["SPECULARTERM"]) {
  68991. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  68992. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  68993. }
  68994. // Shadows
  68995. if (scene.shadowsEnabled) {
  68996. this.BindLightShadow(light, mesh, iAsString, effect);
  68997. }
  68998. light._uniformBuffer.update();
  68999. }
  69000. };
  69001. /**
  69002. * Binds the fog information from the scene to the effect for the given mesh.
  69003. * @param scene The scene the lights belongs to
  69004. * @param mesh The mesh we are binding the information to render
  69005. * @param effect The effect we are binding the data to
  69006. * @param linearSpace Defines if the fog effect is applied in linear space
  69007. */
  69008. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  69009. if (linearSpace === void 0) { linearSpace = false; }
  69010. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  69011. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  69012. // Convert fog color to linear space if used in a linear space computed shader.
  69013. if (linearSpace) {
  69014. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  69015. effect.setColor3("vFogColor", this._tempFogColor);
  69016. }
  69017. else {
  69018. effect.setColor3("vFogColor", scene.fogColor);
  69019. }
  69020. }
  69021. };
  69022. /**
  69023. * Binds the bones information from the mesh to the effect.
  69024. * @param mesh The mesh we are binding the information to render
  69025. * @param effect The effect we are binding the data to
  69026. */
  69027. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  69028. if (!effect || !mesh) {
  69029. return;
  69030. }
  69031. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  69032. mesh.computeBonesUsingShaders = false;
  69033. }
  69034. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  69035. var skeleton = mesh.skeleton;
  69036. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  69037. var boneTexture = skeleton.getTransformMatrixTexture();
  69038. effect.setTexture("boneSampler", boneTexture);
  69039. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  69040. }
  69041. else {
  69042. var matrices = skeleton.getTransformMatrices(mesh);
  69043. if (matrices) {
  69044. effect.setMatrices("mBones", matrices);
  69045. }
  69046. }
  69047. }
  69048. };
  69049. /**
  69050. * Binds the morph targets information from the mesh to the effect.
  69051. * @param abstractMesh The mesh we are binding the information to render
  69052. * @param effect The effect we are binding the data to
  69053. */
  69054. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  69055. var manager = abstractMesh.morphTargetManager;
  69056. if (!abstractMesh || !manager) {
  69057. return;
  69058. }
  69059. effect.setFloatArray("morphTargetInfluences", manager.influences);
  69060. };
  69061. /**
  69062. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69063. * @param defines The generated defines used in the effect
  69064. * @param effect The effect we are binding the data to
  69065. * @param scene The scene we are willing to render with logarithmic scale for
  69066. */
  69067. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  69068. if (defines["LOGARITHMICDEPTH"]) {
  69069. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  69070. }
  69071. };
  69072. /**
  69073. * Binds the clip plane information from the scene to the effect.
  69074. * @param scene The scene the clip plane information are extracted from
  69075. * @param effect The effect we are binding the data to
  69076. */
  69077. MaterialHelper.BindClipPlane = function (effect, scene) {
  69078. if (scene.clipPlane) {
  69079. var clipPlane = scene.clipPlane;
  69080. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  69081. }
  69082. if (scene.clipPlane2) {
  69083. var clipPlane = scene.clipPlane2;
  69084. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  69085. }
  69086. if (scene.clipPlane3) {
  69087. var clipPlane = scene.clipPlane3;
  69088. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  69089. }
  69090. if (scene.clipPlane4) {
  69091. var clipPlane = scene.clipPlane4;
  69092. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  69093. }
  69094. };
  69095. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  69096. return MaterialHelper;
  69097. }());
  69098. /***/ }),
  69099. /***/ "./Materials/multiMaterial.ts":
  69100. /*!************************************!*\
  69101. !*** ./Materials/multiMaterial.ts ***!
  69102. \************************************/
  69103. /*! exports provided: MultiMaterial */
  69104. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69105. "use strict";
  69106. __webpack_require__.r(__webpack_exports__);
  69107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  69108. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  69109. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  69110. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  69111. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  69112. /**
  69113. * A multi-material is used to apply different materials to different parts of the same object without the need of
  69114. * separate meshes. This can be use to improve performances.
  69115. * @see http://doc.babylonjs.com/how_to/multi_materials
  69116. */
  69117. var MultiMaterial = /** @class */ (function (_super) {
  69118. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  69119. /**
  69120. * Instantiates a new Multi Material
  69121. * A multi-material is used to apply different materials to different parts of the same object without the need of
  69122. * separate meshes. This can be use to improve performances.
  69123. * @see http://doc.babylonjs.com/how_to/multi_materials
  69124. * @param name Define the name in the scene
  69125. * @param scene Define the scene the material belongs to
  69126. */
  69127. function MultiMaterial(name, scene) {
  69128. var _this = _super.call(this, name, scene, true) || this;
  69129. scene.multiMaterials.push(_this);
  69130. _this.subMaterials = new Array();
  69131. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  69132. return _this;
  69133. }
  69134. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  69135. /**
  69136. * Gets or Sets the list of Materials used within the multi material.
  69137. * They need to be ordered according to the submeshes order in the associated mesh
  69138. */
  69139. get: function () {
  69140. return this._subMaterials;
  69141. },
  69142. set: function (value) {
  69143. this._subMaterials = value;
  69144. this._hookArray(value);
  69145. },
  69146. enumerable: true,
  69147. configurable: true
  69148. });
  69149. /**
  69150. * Function used to align with Node.getChildren()
  69151. * @returns the list of Materials used within the multi material
  69152. */
  69153. MultiMaterial.prototype.getChildren = function () {
  69154. return this.subMaterials;
  69155. };
  69156. MultiMaterial.prototype._hookArray = function (array) {
  69157. var _this = this;
  69158. var oldPush = array.push;
  69159. array.push = function () {
  69160. var items = [];
  69161. for (var _i = 0; _i < arguments.length; _i++) {
  69162. items[_i] = arguments[_i];
  69163. }
  69164. var result = oldPush.apply(array, items);
  69165. _this._markAllSubMeshesAsTexturesDirty();
  69166. return result;
  69167. };
  69168. var oldSplice = array.splice;
  69169. array.splice = function (index, deleteCount) {
  69170. var deleted = oldSplice.apply(array, [index, deleteCount]);
  69171. _this._markAllSubMeshesAsTexturesDirty();
  69172. return deleted;
  69173. };
  69174. };
  69175. /**
  69176. * Get one of the submaterial by its index in the submaterials array
  69177. * @param index The index to look the sub material at
  69178. * @returns The Material if the index has been defined
  69179. */
  69180. MultiMaterial.prototype.getSubMaterial = function (index) {
  69181. if (index < 0 || index >= this.subMaterials.length) {
  69182. return this.getScene().defaultMaterial;
  69183. }
  69184. return this.subMaterials[index];
  69185. };
  69186. /**
  69187. * Get the list of active textures for the whole sub materials list.
  69188. * @returns All the textures that will be used during the rendering
  69189. */
  69190. MultiMaterial.prototype.getActiveTextures = function () {
  69191. var _a;
  69192. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  69193. if (subMaterial) {
  69194. return subMaterial.getActiveTextures();
  69195. }
  69196. else {
  69197. return [];
  69198. }
  69199. }));
  69200. };
  69201. /**
  69202. * Gets the current class name of the material e.g. "MultiMaterial"
  69203. * Mainly use in serialization.
  69204. * @returns the class name
  69205. */
  69206. MultiMaterial.prototype.getClassName = function () {
  69207. return "MultiMaterial";
  69208. };
  69209. /**
  69210. * Checks if the material is ready to render the requested sub mesh
  69211. * @param mesh Define the mesh the submesh belongs to
  69212. * @param subMesh Define the sub mesh to look readyness for
  69213. * @param useInstances Define whether or not the material is used with instances
  69214. * @returns true if ready, otherwise false
  69215. */
  69216. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  69217. for (var index = 0; index < this.subMaterials.length; index++) {
  69218. var subMaterial = this.subMaterials[index];
  69219. if (subMaterial) {
  69220. if (subMaterial._storeEffectOnSubMeshes) {
  69221. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  69222. return false;
  69223. }
  69224. continue;
  69225. }
  69226. if (!subMaterial.isReady(mesh)) {
  69227. return false;
  69228. }
  69229. }
  69230. }
  69231. return true;
  69232. };
  69233. /**
  69234. * Clones the current material and its related sub materials
  69235. * @param name Define the name of the newly cloned material
  69236. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  69237. * @returns the cloned material
  69238. */
  69239. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  69240. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  69241. for (var index = 0; index < this.subMaterials.length; index++) {
  69242. var subMaterial = null;
  69243. var current = this.subMaterials[index];
  69244. if (cloneChildren && current) {
  69245. subMaterial = current.clone(name + "-" + current.name);
  69246. }
  69247. else {
  69248. subMaterial = this.subMaterials[index];
  69249. }
  69250. newMultiMaterial.subMaterials.push(subMaterial);
  69251. }
  69252. return newMultiMaterial;
  69253. };
  69254. /**
  69255. * Serializes the materials into a JSON representation.
  69256. * @returns the JSON representation
  69257. */
  69258. MultiMaterial.prototype.serialize = function () {
  69259. var serializationObject = {};
  69260. serializationObject.name = this.name;
  69261. serializationObject.id = this.id;
  69262. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  69263. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  69264. }
  69265. serializationObject.materials = [];
  69266. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  69267. var subMat = this.subMaterials[matIndex];
  69268. if (subMat) {
  69269. serializationObject.materials.push(subMat.id);
  69270. }
  69271. else {
  69272. serializationObject.materials.push(null);
  69273. }
  69274. }
  69275. return serializationObject;
  69276. };
  69277. /**
  69278. * Dispose the material and release its associated resources
  69279. * @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)
  69280. * @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)
  69281. * @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)
  69282. */
  69283. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  69284. var scene = this.getScene();
  69285. if (!scene) {
  69286. return;
  69287. }
  69288. if (forceDisposeChildren) {
  69289. for (var index = 0; index < this.subMaterials.length; index++) {
  69290. var subMaterial = this.subMaterials[index];
  69291. if (subMaterial) {
  69292. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  69293. }
  69294. }
  69295. }
  69296. var index = scene.multiMaterials.indexOf(this);
  69297. if (index >= 0) {
  69298. scene.multiMaterials.splice(index, 1);
  69299. }
  69300. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  69301. };
  69302. /**
  69303. * Creates a MultiMaterial from parsed MultiMaterial data.
  69304. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  69305. * @param scene defines the hosting scene
  69306. * @returns a new MultiMaterial
  69307. */
  69308. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  69309. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  69310. multiMaterial.id = parsedMultiMaterial.id;
  69311. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  69312. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  69313. }
  69314. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  69315. var subMatId = parsedMultiMaterial.materials[matIndex];
  69316. if (subMatId) {
  69317. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  69318. }
  69319. else {
  69320. multiMaterial.subMaterials.push(null);
  69321. }
  69322. }
  69323. return multiMaterial;
  69324. };
  69325. return MultiMaterial;
  69326. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  69327. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  69328. /***/ }),
  69329. /***/ "./Materials/pushMaterial.ts":
  69330. /*!***********************************!*\
  69331. !*** ./Materials/pushMaterial.ts ***!
  69332. \***********************************/
  69333. /*! exports provided: PushMaterial */
  69334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69335. "use strict";
  69336. __webpack_require__.r(__webpack_exports__);
  69337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  69338. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  69339. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  69340. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  69341. /**
  69342. * Base class of materials working in push mode in babylon JS
  69343. * @hidden
  69344. */
  69345. var PushMaterial = /** @class */ (function (_super) {
  69346. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  69347. function PushMaterial(name, scene) {
  69348. var _this = _super.call(this, name, scene) || this;
  69349. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  69350. /**
  69351. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  69352. * This means that the material can keep using a previous shader while a new one is being compiled.
  69353. * This is mostly used when shader parallel compilation is supported (true by default)
  69354. */
  69355. _this.allowShaderHotSwapping = true;
  69356. _this._storeEffectOnSubMeshes = true;
  69357. return _this;
  69358. }
  69359. PushMaterial.prototype.getEffect = function () {
  69360. return this._activeEffect;
  69361. };
  69362. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  69363. if (!mesh) {
  69364. return false;
  69365. }
  69366. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  69367. return true;
  69368. }
  69369. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  69370. };
  69371. /**
  69372. * Binds the given world matrix to the active effect
  69373. *
  69374. * @param world the matrix to bind
  69375. */
  69376. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  69377. this._activeEffect.setMatrix("world", world);
  69378. };
  69379. /**
  69380. * Binds the given normal matrix to the active effect
  69381. *
  69382. * @param normalMatrix the matrix to bind
  69383. */
  69384. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  69385. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  69386. };
  69387. PushMaterial.prototype.bind = function (world, mesh) {
  69388. if (!mesh) {
  69389. return;
  69390. }
  69391. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  69392. };
  69393. PushMaterial.prototype._afterBind = function (mesh, effect) {
  69394. if (effect === void 0) { effect = null; }
  69395. _super.prototype._afterBind.call(this, mesh);
  69396. this.getScene()._cachedEffect = effect;
  69397. };
  69398. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  69399. if (visibility === void 0) { visibility = 1; }
  69400. return scene.isCachedMaterialInvalid(this, effect, visibility);
  69401. };
  69402. return PushMaterial;
  69403. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  69404. /***/ }),
  69405. /***/ "./Materials/shaderMaterial.ts":
  69406. /*!*************************************!*\
  69407. !*** ./Materials/shaderMaterial.ts ***!
  69408. \*************************************/
  69409. /*! exports provided: ShaderMaterial */
  69410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69411. "use strict";
  69412. __webpack_require__.r(__webpack_exports__);
  69413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  69414. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  69415. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  69416. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  69417. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  69418. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  69419. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  69420. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  69421. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  69422. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  69423. /**
  69424. * 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.
  69425. *
  69426. * This returned material effects how the mesh will look based on the code in the shaders.
  69427. *
  69428. * @see http://doc.babylonjs.com/how_to/shader_material
  69429. */
  69430. var ShaderMaterial = /** @class */ (function (_super) {
  69431. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  69432. /**
  69433. * Instantiate a new shader material.
  69434. * 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.
  69435. * This returned material effects how the mesh will look based on the code in the shaders.
  69436. * @see http://doc.babylonjs.com/how_to/shader_material
  69437. * @param name Define the name of the material in the scene
  69438. * @param scene Define the scene the material belongs to
  69439. * @param shaderPath Defines the route to the shader code in one of three ways:
  69440. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  69441. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  69442. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  69443. * @param options Define the options used to create the shader
  69444. */
  69445. function ShaderMaterial(name, scene, shaderPath, options) {
  69446. if (options === void 0) { options = {}; }
  69447. var _this = _super.call(this, name, scene) || this;
  69448. _this._textures = {};
  69449. _this._textureArrays = {};
  69450. _this._floats = {};
  69451. _this._ints = {};
  69452. _this._floatsArrays = {};
  69453. _this._colors3 = {};
  69454. _this._colors3Arrays = {};
  69455. _this._colors4 = {};
  69456. _this._vectors2 = {};
  69457. _this._vectors3 = {};
  69458. _this._vectors4 = {};
  69459. _this._matrices = {};
  69460. _this._matrices3x3 = {};
  69461. _this._matrices2x2 = {};
  69462. _this._vectors2Arrays = {};
  69463. _this._vectors3Arrays = {};
  69464. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  69465. _this._shaderPath = shaderPath;
  69466. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  69467. return _this;
  69468. }
  69469. Object.defineProperty(ShaderMaterial.prototype, "options", {
  69470. /**
  69471. * Gets the options used to compile the shader.
  69472. * They can be modified to trigger a new compilation
  69473. */
  69474. get: function () {
  69475. return this._options;
  69476. },
  69477. enumerable: true,
  69478. configurable: true
  69479. });
  69480. /**
  69481. * Gets the current class name of the material e.g. "ShaderMaterial"
  69482. * Mainly use in serialization.
  69483. * @returns the class name
  69484. */
  69485. ShaderMaterial.prototype.getClassName = function () {
  69486. return "ShaderMaterial";
  69487. };
  69488. /**
  69489. * Specifies if the material will require alpha blending
  69490. * @returns a boolean specifying if alpha blending is needed
  69491. */
  69492. ShaderMaterial.prototype.needAlphaBlending = function () {
  69493. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  69494. };
  69495. /**
  69496. * Specifies if this material should be rendered in alpha test mode
  69497. * @returns a boolean specifying if an alpha test is needed.
  69498. */
  69499. ShaderMaterial.prototype.needAlphaTesting = function () {
  69500. return this._options.needAlphaTesting;
  69501. };
  69502. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  69503. if (this._options.uniforms.indexOf(uniformName) === -1) {
  69504. this._options.uniforms.push(uniformName);
  69505. }
  69506. };
  69507. /**
  69508. * Set a texture in the shader.
  69509. * @param name Define the name of the uniform samplers as defined in the shader
  69510. * @param texture Define the texture to bind to this sampler
  69511. * @return the material itself allowing "fluent" like uniform updates
  69512. */
  69513. ShaderMaterial.prototype.setTexture = function (name, texture) {
  69514. if (this._options.samplers.indexOf(name) === -1) {
  69515. this._options.samplers.push(name);
  69516. }
  69517. this._textures[name] = texture;
  69518. return this;
  69519. };
  69520. /**
  69521. * Set a texture array in the shader.
  69522. * @param name Define the name of the uniform sampler array as defined in the shader
  69523. * @param textures Define the list of textures to bind to this sampler
  69524. * @return the material itself allowing "fluent" like uniform updates
  69525. */
  69526. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  69527. if (this._options.samplers.indexOf(name) === -1) {
  69528. this._options.samplers.push(name);
  69529. }
  69530. this._checkUniform(name);
  69531. this._textureArrays[name] = textures;
  69532. return this;
  69533. };
  69534. /**
  69535. * Set a float in the shader.
  69536. * @param name Define the name of the uniform as defined in the shader
  69537. * @param value Define the value to give to the uniform
  69538. * @return the material itself allowing "fluent" like uniform updates
  69539. */
  69540. ShaderMaterial.prototype.setFloat = function (name, value) {
  69541. this._checkUniform(name);
  69542. this._floats[name] = value;
  69543. return this;
  69544. };
  69545. /**
  69546. * Set a int in the shader.
  69547. * @param name Define the name of the uniform as defined in the shader
  69548. * @param value Define the value to give to the uniform
  69549. * @return the material itself allowing "fluent" like uniform updates
  69550. */
  69551. ShaderMaterial.prototype.setInt = function (name, value) {
  69552. this._checkUniform(name);
  69553. this._ints[name] = value;
  69554. return this;
  69555. };
  69556. /**
  69557. * Set an array of floats in the shader.
  69558. * @param name Define the name of the uniform as defined in the shader
  69559. * @param value Define the value to give to the uniform
  69560. * @return the material itself allowing "fluent" like uniform updates
  69561. */
  69562. ShaderMaterial.prototype.setFloats = function (name, value) {
  69563. this._checkUniform(name);
  69564. this._floatsArrays[name] = value;
  69565. return this;
  69566. };
  69567. /**
  69568. * Set a vec3 in the shader from a Color3.
  69569. * @param name Define the name of the uniform as defined in the shader
  69570. * @param value Define the value to give to the uniform
  69571. * @return the material itself allowing "fluent" like uniform updates
  69572. */
  69573. ShaderMaterial.prototype.setColor3 = function (name, value) {
  69574. this._checkUniform(name);
  69575. this._colors3[name] = value;
  69576. return this;
  69577. };
  69578. /**
  69579. * Set a vec3 array in the shader from a Color3 array.
  69580. * @param name Define the name of the uniform as defined in the shader
  69581. * @param value Define the value to give to the uniform
  69582. * @return the material itself allowing "fluent" like uniform updates
  69583. */
  69584. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  69585. this._checkUniform(name);
  69586. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  69587. color.toArray(arr, arr.length);
  69588. return arr;
  69589. }, []);
  69590. return this;
  69591. };
  69592. /**
  69593. * Set a vec4 in the shader from a Color4.
  69594. * @param name Define the name of the uniform as defined in the shader
  69595. * @param value Define the value to give to the uniform
  69596. * @return the material itself allowing "fluent" like uniform updates
  69597. */
  69598. ShaderMaterial.prototype.setColor4 = function (name, value) {
  69599. this._checkUniform(name);
  69600. this._colors4[name] = value;
  69601. return this;
  69602. };
  69603. /**
  69604. * Set a vec2 in the shader from a Vector2.
  69605. * @param name Define the name of the uniform as defined in the shader
  69606. * @param value Define the value to give to the uniform
  69607. * @return the material itself allowing "fluent" like uniform updates
  69608. */
  69609. ShaderMaterial.prototype.setVector2 = function (name, value) {
  69610. this._checkUniform(name);
  69611. this._vectors2[name] = value;
  69612. return this;
  69613. };
  69614. /**
  69615. * Set a vec3 in the shader from a Vector3.
  69616. * @param name Define the name of the uniform as defined in the shader
  69617. * @param value Define the value to give to the uniform
  69618. * @return the material itself allowing "fluent" like uniform updates
  69619. */
  69620. ShaderMaterial.prototype.setVector3 = function (name, value) {
  69621. this._checkUniform(name);
  69622. this._vectors3[name] = value;
  69623. return this;
  69624. };
  69625. /**
  69626. * Set a vec4 in the shader from a Vector4.
  69627. * @param name Define the name of the uniform as defined in the shader
  69628. * @param value Define the value to give to the uniform
  69629. * @return the material itself allowing "fluent" like uniform updates
  69630. */
  69631. ShaderMaterial.prototype.setVector4 = function (name, value) {
  69632. this._checkUniform(name);
  69633. this._vectors4[name] = value;
  69634. return this;
  69635. };
  69636. /**
  69637. * Set a mat4 in the shader from a Matrix.
  69638. * @param name Define the name of the uniform as defined in the shader
  69639. * @param value Define the value to give to the uniform
  69640. * @return the material itself allowing "fluent" like uniform updates
  69641. */
  69642. ShaderMaterial.prototype.setMatrix = function (name, value) {
  69643. this._checkUniform(name);
  69644. this._matrices[name] = value;
  69645. return this;
  69646. };
  69647. /**
  69648. * Set a mat3 in the shader from a Float32Array.
  69649. * @param name Define the name of the uniform as defined in the shader
  69650. * @param value Define the value to give to the uniform
  69651. * @return the material itself allowing "fluent" like uniform updates
  69652. */
  69653. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  69654. this._checkUniform(name);
  69655. this._matrices3x3[name] = value;
  69656. return this;
  69657. };
  69658. /**
  69659. * Set a mat2 in the shader from a Float32Array.
  69660. * @param name Define the name of the uniform as defined in the shader
  69661. * @param value Define the value to give to the uniform
  69662. * @return the material itself allowing "fluent" like uniform updates
  69663. */
  69664. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  69665. this._checkUniform(name);
  69666. this._matrices2x2[name] = value;
  69667. return this;
  69668. };
  69669. /**
  69670. * Set a vec2 array in the shader from a number array.
  69671. * @param name Define the name of the uniform as defined in the shader
  69672. * @param value Define the value to give to the uniform
  69673. * @return the material itself allowing "fluent" like uniform updates
  69674. */
  69675. ShaderMaterial.prototype.setArray2 = function (name, value) {
  69676. this._checkUniform(name);
  69677. this._vectors2Arrays[name] = value;
  69678. return this;
  69679. };
  69680. /**
  69681. * Set a vec3 array in the shader from a number array.
  69682. * @param name Define the name of the uniform as defined in the shader
  69683. * @param value Define the value to give to the uniform
  69684. * @return the material itself allowing "fluent" like uniform updates
  69685. */
  69686. ShaderMaterial.prototype.setArray3 = function (name, value) {
  69687. this._checkUniform(name);
  69688. this._vectors3Arrays[name] = value;
  69689. return this;
  69690. };
  69691. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  69692. if (!mesh) {
  69693. return true;
  69694. }
  69695. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  69696. return false;
  69697. }
  69698. return false;
  69699. };
  69700. /**
  69701. * Specifies that the submesh is ready to be used
  69702. * @param mesh defines the mesh to check
  69703. * @param subMesh defines which submesh to check
  69704. * @param useInstances specifies that instances should be used
  69705. * @returns a boolean indicating that the submesh is ready or not
  69706. */
  69707. ShaderMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  69708. return this.isReady(mesh, useInstances);
  69709. };
  69710. /**
  69711. * Checks if the material is ready to render the requested mesh
  69712. * @param mesh Define the mesh to render
  69713. * @param useInstances Define whether or not the material is used with instances
  69714. * @returns true if ready, otherwise false
  69715. */
  69716. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  69717. var scene = this.getScene();
  69718. var engine = scene.getEngine();
  69719. if (!this.checkReadyOnEveryCall) {
  69720. if (this._renderId === scene.getRenderId()) {
  69721. if (this._checkCache(mesh, useInstances)) {
  69722. return true;
  69723. }
  69724. }
  69725. }
  69726. // Instances
  69727. var defines = [];
  69728. var attribs = [];
  69729. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  69730. for (var index = 0; index < this._options.defines.length; index++) {
  69731. defines.push(this._options.defines[index]);
  69732. }
  69733. for (var index = 0; index < this._options.attributes.length; index++) {
  69734. attribs.push(this._options.attributes[index]);
  69735. }
  69736. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  69737. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  69738. defines.push("#define VERTEXCOLOR");
  69739. }
  69740. if (useInstances) {
  69741. defines.push("#define INSTANCES");
  69742. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  69743. }
  69744. // Bones
  69745. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  69746. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  69747. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  69748. if (mesh.numBoneInfluencers > 4) {
  69749. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  69750. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  69751. }
  69752. var skeleton = mesh.skeleton;
  69753. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  69754. fallbacks.addCPUSkinningFallback(0, mesh);
  69755. if (skeleton.isUsingTextureForMatrices) {
  69756. defines.push("#define BONETEXTURE");
  69757. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  69758. this._options.uniforms.push("boneTextureWidth");
  69759. }
  69760. if (this._options.samplers.indexOf("boneSampler") === -1) {
  69761. this._options.samplers.push("boneSampler");
  69762. }
  69763. }
  69764. else {
  69765. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  69766. if (this._options.uniforms.indexOf("mBones") === -1) {
  69767. this._options.uniforms.push("mBones");
  69768. }
  69769. }
  69770. }
  69771. else {
  69772. defines.push("#define NUM_BONE_INFLUENCERS 0");
  69773. }
  69774. // Textures
  69775. for (var name in this._textures) {
  69776. if (!this._textures[name].isReady()) {
  69777. return false;
  69778. }
  69779. }
  69780. // Alpha test
  69781. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  69782. defines.push("#define ALPHATEST");
  69783. }
  69784. var previousEffect = this._effect;
  69785. var join = defines.join("\n");
  69786. this._effect = engine.createEffect(this._shaderPath, {
  69787. attributes: attribs,
  69788. uniformsNames: this._options.uniforms,
  69789. uniformBuffersNames: this._options.uniformBuffers,
  69790. samplers: this._options.samplers,
  69791. defines: join,
  69792. fallbacks: fallbacks,
  69793. onCompiled: this.onCompiled,
  69794. onError: this.onError
  69795. }, engine);
  69796. if (!this._effect.isReady()) {
  69797. return false;
  69798. }
  69799. if (previousEffect !== this._effect) {
  69800. scene.resetCachedMaterial();
  69801. }
  69802. this._renderId = scene.getRenderId();
  69803. return true;
  69804. };
  69805. /**
  69806. * Binds the world matrix to the material
  69807. * @param world defines the world transformation matrix
  69808. */
  69809. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  69810. var scene = this.getScene();
  69811. if (!this._effect) {
  69812. return;
  69813. }
  69814. if (this._options.uniforms.indexOf("world") !== -1) {
  69815. this._effect.setMatrix("world", world);
  69816. }
  69817. if (this._options.uniforms.indexOf("worldView") !== -1) {
  69818. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  69819. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  69820. }
  69821. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  69822. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  69823. }
  69824. };
  69825. /**
  69826. * Binds the material to the mesh
  69827. * @param world defines the world transformation matrix
  69828. * @param mesh defines the mesh to bind the material to
  69829. */
  69830. ShaderMaterial.prototype.bind = function (world, mesh) {
  69831. // Std values
  69832. this.bindOnlyWorldMatrix(world);
  69833. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  69834. if (this._options.uniforms.indexOf("view") !== -1) {
  69835. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  69836. }
  69837. if (this._options.uniforms.indexOf("projection") !== -1) {
  69838. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  69839. }
  69840. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  69841. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  69842. }
  69843. // Bones
  69844. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  69845. var name;
  69846. // Texture
  69847. for (name in this._textures) {
  69848. this._effect.setTexture(name, this._textures[name]);
  69849. }
  69850. // Texture arrays
  69851. for (name in this._textureArrays) {
  69852. this._effect.setTextureArray(name, this._textureArrays[name]);
  69853. }
  69854. // Int
  69855. for (name in this._ints) {
  69856. this._effect.setInt(name, this._ints[name]);
  69857. }
  69858. // Float
  69859. for (name in this._floats) {
  69860. this._effect.setFloat(name, this._floats[name]);
  69861. }
  69862. // Floats
  69863. for (name in this._floatsArrays) {
  69864. this._effect.setArray(name, this._floatsArrays[name]);
  69865. }
  69866. // Color3
  69867. for (name in this._colors3) {
  69868. this._effect.setColor3(name, this._colors3[name]);
  69869. }
  69870. for (name in this._colors3Arrays) {
  69871. this._effect.setArray3(name, this._colors3Arrays[name]);
  69872. }
  69873. // Color4
  69874. for (name in this._colors4) {
  69875. var color = this._colors4[name];
  69876. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  69877. }
  69878. // Vector2
  69879. for (name in this._vectors2) {
  69880. this._effect.setVector2(name, this._vectors2[name]);
  69881. }
  69882. // Vector3
  69883. for (name in this._vectors3) {
  69884. this._effect.setVector3(name, this._vectors3[name]);
  69885. }
  69886. // Vector4
  69887. for (name in this._vectors4) {
  69888. this._effect.setVector4(name, this._vectors4[name]);
  69889. }
  69890. // Matrix
  69891. for (name in this._matrices) {
  69892. this._effect.setMatrix(name, this._matrices[name]);
  69893. }
  69894. // Matrix 3x3
  69895. for (name in this._matrices3x3) {
  69896. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  69897. }
  69898. // Matrix 2x2
  69899. for (name in this._matrices2x2) {
  69900. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  69901. }
  69902. // Vector2Array
  69903. for (name in this._vectors2Arrays) {
  69904. this._effect.setArray2(name, this._vectors2Arrays[name]);
  69905. }
  69906. // Vector3Array
  69907. for (name in this._vectors3Arrays) {
  69908. this._effect.setArray3(name, this._vectors3Arrays[name]);
  69909. }
  69910. }
  69911. this._afterBind(mesh);
  69912. };
  69913. /**
  69914. * Gets the active textures from the material
  69915. * @returns an array of textures
  69916. */
  69917. ShaderMaterial.prototype.getActiveTextures = function () {
  69918. var activeTextures = _super.prototype.getActiveTextures.call(this);
  69919. for (var name in this._textures) {
  69920. activeTextures.push(this._textures[name]);
  69921. }
  69922. for (var name in this._textureArrays) {
  69923. var array = this._textureArrays[name];
  69924. for (var index = 0; index < array.length; index++) {
  69925. activeTextures.push(array[index]);
  69926. }
  69927. }
  69928. return activeTextures;
  69929. };
  69930. /**
  69931. * Specifies if the material uses a texture
  69932. * @param texture defines the texture to check against the material
  69933. * @returns a boolean specifying if the material uses the texture
  69934. */
  69935. ShaderMaterial.prototype.hasTexture = function (texture) {
  69936. if (_super.prototype.hasTexture.call(this, texture)) {
  69937. return true;
  69938. }
  69939. for (var name in this._textures) {
  69940. if (this._textures[name] === texture) {
  69941. return true;
  69942. }
  69943. }
  69944. for (var name in this._textureArrays) {
  69945. var array = this._textureArrays[name];
  69946. for (var index = 0; index < array.length; index++) {
  69947. if (array[index] === texture) {
  69948. return true;
  69949. }
  69950. }
  69951. }
  69952. return false;
  69953. };
  69954. /**
  69955. * Makes a duplicate of the material, and gives it a new name
  69956. * @param name defines the new name for the duplicated material
  69957. * @returns the cloned material
  69958. */
  69959. ShaderMaterial.prototype.clone = function (name) {
  69960. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  69961. return newShaderMaterial;
  69962. };
  69963. /**
  69964. * Disposes the material
  69965. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  69966. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  69967. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  69968. */
  69969. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  69970. if (forceDisposeTextures) {
  69971. var name;
  69972. for (name in this._textures) {
  69973. this._textures[name].dispose();
  69974. }
  69975. for (name in this._textureArrays) {
  69976. var array = this._textureArrays[name];
  69977. for (var index = 0; index < array.length; index++) {
  69978. array[index].dispose();
  69979. }
  69980. }
  69981. }
  69982. this._textures = {};
  69983. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  69984. };
  69985. /**
  69986. * Serializes this material in a JSON representation
  69987. * @returns the serialized material object
  69988. */
  69989. ShaderMaterial.prototype.serialize = function () {
  69990. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  69991. serializationObject.customType = "BABYLON.ShaderMaterial";
  69992. serializationObject.options = this._options;
  69993. serializationObject.shaderPath = this._shaderPath;
  69994. var name;
  69995. // Texture
  69996. serializationObject.textures = {};
  69997. for (name in this._textures) {
  69998. serializationObject.textures[name] = this._textures[name].serialize();
  69999. }
  70000. // Texture arrays
  70001. serializationObject.textureArrays = {};
  70002. for (name in this._textureArrays) {
  70003. serializationObject.textureArrays[name] = [];
  70004. var array = this._textureArrays[name];
  70005. for (var index = 0; index < array.length; index++) {
  70006. serializationObject.textureArrays[name].push(array[index].serialize());
  70007. }
  70008. }
  70009. // Float
  70010. serializationObject.floats = {};
  70011. for (name in this._floats) {
  70012. serializationObject.floats[name] = this._floats[name];
  70013. }
  70014. // Float s
  70015. serializationObject.FloatArrays = {};
  70016. for (name in this._floatsArrays) {
  70017. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  70018. }
  70019. // Color3
  70020. serializationObject.colors3 = {};
  70021. for (name in this._colors3) {
  70022. serializationObject.colors3[name] = this._colors3[name].asArray();
  70023. }
  70024. // Color3 array
  70025. serializationObject.colors3Arrays = {};
  70026. for (name in this._colors3Arrays) {
  70027. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  70028. }
  70029. // Color4
  70030. serializationObject.colors4 = {};
  70031. for (name in this._colors4) {
  70032. serializationObject.colors4[name] = this._colors4[name].asArray();
  70033. }
  70034. // Vector2
  70035. serializationObject.vectors2 = {};
  70036. for (name in this._vectors2) {
  70037. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  70038. }
  70039. // Vector3
  70040. serializationObject.vectors3 = {};
  70041. for (name in this._vectors3) {
  70042. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  70043. }
  70044. // Vector4
  70045. serializationObject.vectors4 = {};
  70046. for (name in this._vectors4) {
  70047. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  70048. }
  70049. // Matrix
  70050. serializationObject.matrices = {};
  70051. for (name in this._matrices) {
  70052. serializationObject.matrices[name] = this._matrices[name].asArray();
  70053. }
  70054. // Matrix 3x3
  70055. serializationObject.matrices3x3 = {};
  70056. for (name in this._matrices3x3) {
  70057. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  70058. }
  70059. // Matrix 2x2
  70060. serializationObject.matrices2x2 = {};
  70061. for (name in this._matrices2x2) {
  70062. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  70063. }
  70064. // Vector2Array
  70065. serializationObject.vectors2Arrays = {};
  70066. for (name in this._vectors2Arrays) {
  70067. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  70068. }
  70069. // Vector3Array
  70070. serializationObject.vectors3Arrays = {};
  70071. for (name in this._vectors3Arrays) {
  70072. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  70073. }
  70074. return serializationObject;
  70075. };
  70076. /**
  70077. * Creates a shader material from parsed shader material data
  70078. * @param source defines the JSON represnetation of the material
  70079. * @param scene defines the hosting scene
  70080. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70081. * @returns a new material
  70082. */
  70083. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  70084. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  70085. var name;
  70086. // Texture
  70087. for (name in source.textures) {
  70088. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  70089. }
  70090. // Texture arrays
  70091. for (name in source.textureArrays) {
  70092. var array = source.textureArrays[name];
  70093. var textureArray = new Array();
  70094. for (var index = 0; index < array.length; index++) {
  70095. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  70096. }
  70097. material.setTextureArray(name, textureArray);
  70098. }
  70099. // Float
  70100. for (name in source.floats) {
  70101. material.setFloat(name, source.floats[name]);
  70102. }
  70103. // Float s
  70104. for (name in source.floatsArrays) {
  70105. material.setFloats(name, source.floatsArrays[name]);
  70106. }
  70107. // Color3
  70108. for (name in source.colors3) {
  70109. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  70110. }
  70111. // Color3 arrays
  70112. for (name in source.colors3Arrays) {
  70113. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  70114. if (i % 3 === 0) {
  70115. arr.push([num]);
  70116. }
  70117. else {
  70118. arr[arr.length - 1].push(num);
  70119. }
  70120. return arr;
  70121. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  70122. material.setColor3Array(name, colors);
  70123. }
  70124. // Color4
  70125. for (name in source.colors4) {
  70126. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  70127. }
  70128. // Vector2
  70129. for (name in source.vectors2) {
  70130. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  70131. }
  70132. // Vector3
  70133. for (name in source.vectors3) {
  70134. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  70135. }
  70136. // Vector4
  70137. for (name in source.vectors4) {
  70138. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  70139. }
  70140. // Matrix
  70141. for (name in source.matrices) {
  70142. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  70143. }
  70144. // Matrix 3x3
  70145. for (name in source.matrices3x3) {
  70146. material.setMatrix3x3(name, source.matrices3x3[name]);
  70147. }
  70148. // Matrix 2x2
  70149. for (name in source.matrices2x2) {
  70150. material.setMatrix2x2(name, source.matrices2x2[name]);
  70151. }
  70152. // Vector2Array
  70153. for (name in source.vectors2Arrays) {
  70154. material.setArray2(name, source.vectors2Arrays[name]);
  70155. }
  70156. // Vector3Array
  70157. for (name in source.vectors3Arrays) {
  70158. material.setArray3(name, source.vectors3Arrays[name]);
  70159. }
  70160. return material;
  70161. };
  70162. return ShaderMaterial;
  70163. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  70164. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  70165. /***/ }),
  70166. /***/ "./Materials/standardMaterial.ts":
  70167. /*!***************************************!*\
  70168. !*** ./Materials/standardMaterial.ts ***!
  70169. \***************************************/
  70170. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  70171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  70172. "use strict";
  70173. __webpack_require__.r(__webpack_exports__);
  70174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  70175. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  70176. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  70177. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  70178. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  70179. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  70180. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  70181. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  70182. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  70183. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  70184. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  70185. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  70186. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  70187. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  70188. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  70189. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  70190. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  70191. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  70192. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  70193. /** @hidden */
  70194. var StandardMaterialDefines = /** @class */ (function (_super) {
  70195. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  70196. function StandardMaterialDefines() {
  70197. var _this = _super.call(this) || this;
  70198. _this.MAINUV1 = false;
  70199. _this.MAINUV2 = false;
  70200. _this.DIFFUSE = false;
  70201. _this.DIFFUSEDIRECTUV = 0;
  70202. _this.AMBIENT = false;
  70203. _this.AMBIENTDIRECTUV = 0;
  70204. _this.OPACITY = false;
  70205. _this.OPACITYDIRECTUV = 0;
  70206. _this.OPACITYRGB = false;
  70207. _this.REFLECTION = false;
  70208. _this.EMISSIVE = false;
  70209. _this.EMISSIVEDIRECTUV = 0;
  70210. _this.SPECULAR = false;
  70211. _this.SPECULARDIRECTUV = 0;
  70212. _this.BUMP = false;
  70213. _this.BUMPDIRECTUV = 0;
  70214. _this.PARALLAX = false;
  70215. _this.PARALLAXOCCLUSION = false;
  70216. _this.SPECULAROVERALPHA = false;
  70217. _this.CLIPPLANE = false;
  70218. _this.CLIPPLANE2 = false;
  70219. _this.CLIPPLANE3 = false;
  70220. _this.CLIPPLANE4 = false;
  70221. _this.ALPHATEST = false;
  70222. _this.DEPTHPREPASS = false;
  70223. _this.ALPHAFROMDIFFUSE = false;
  70224. _this.POINTSIZE = false;
  70225. _this.FOG = false;
  70226. _this.SPECULARTERM = false;
  70227. _this.DIFFUSEFRESNEL = false;
  70228. _this.OPACITYFRESNEL = false;
  70229. _this.REFLECTIONFRESNEL = false;
  70230. _this.REFRACTIONFRESNEL = false;
  70231. _this.EMISSIVEFRESNEL = false;
  70232. _this.FRESNEL = false;
  70233. _this.NORMAL = false;
  70234. _this.UV1 = false;
  70235. _this.UV2 = false;
  70236. _this.VERTEXCOLOR = false;
  70237. _this.VERTEXALPHA = false;
  70238. _this.NUM_BONE_INFLUENCERS = 0;
  70239. _this.BonesPerMesh = 0;
  70240. _this.BONETEXTURE = false;
  70241. _this.INSTANCES = false;
  70242. _this.GLOSSINESS = false;
  70243. _this.ROUGHNESS = false;
  70244. _this.EMISSIVEASILLUMINATION = false;
  70245. _this.LINKEMISSIVEWITHDIFFUSE = false;
  70246. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  70247. _this.LIGHTMAP = false;
  70248. _this.LIGHTMAPDIRECTUV = 0;
  70249. _this.OBJECTSPACE_NORMALMAP = false;
  70250. _this.USELIGHTMAPASSHADOWMAP = false;
  70251. _this.REFLECTIONMAP_3D = false;
  70252. _this.REFLECTIONMAP_SPHERICAL = false;
  70253. _this.REFLECTIONMAP_PLANAR = false;
  70254. _this.REFLECTIONMAP_CUBIC = false;
  70255. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  70256. _this.REFLECTIONMAP_PROJECTION = false;
  70257. _this.REFLECTIONMAP_SKYBOX = false;
  70258. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  70259. _this.REFLECTIONMAP_EXPLICIT = false;
  70260. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  70261. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  70262. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  70263. _this.INVERTCUBICMAP = false;
  70264. _this.LOGARITHMICDEPTH = false;
  70265. _this.REFRACTION = false;
  70266. _this.REFRACTIONMAP_3D = false;
  70267. _this.REFLECTIONOVERALPHA = false;
  70268. _this.TWOSIDEDLIGHTING = false;
  70269. _this.SHADOWFLOAT = false;
  70270. _this.MORPHTARGETS = false;
  70271. _this.MORPHTARGETS_NORMAL = false;
  70272. _this.MORPHTARGETS_TANGENT = false;
  70273. _this.NUM_MORPH_INFLUENCERS = 0;
  70274. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  70275. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  70276. _this.IMAGEPROCESSING = false;
  70277. _this.VIGNETTE = false;
  70278. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  70279. _this.VIGNETTEBLENDMODEOPAQUE = false;
  70280. _this.TONEMAPPING = false;
  70281. _this.TONEMAPPING_ACES = false;
  70282. _this.CONTRAST = false;
  70283. _this.COLORCURVES = false;
  70284. _this.COLORGRADING = false;
  70285. _this.COLORGRADING3D = false;
  70286. _this.SAMPLER3DGREENDEPTH = false;
  70287. _this.SAMPLER3DBGRMAP = false;
  70288. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  70289. _this.MULTIVIEW = false;
  70290. /**
  70291. * If the reflection texture on this material is in linear color space
  70292. * @hidden
  70293. */
  70294. _this.IS_REFLECTION_LINEAR = false;
  70295. /**
  70296. * If the refraction texture on this material is in linear color space
  70297. * @hidden
  70298. */
  70299. _this.IS_REFRACTION_LINEAR = false;
  70300. _this.EXPOSURE = false;
  70301. _this.rebuild();
  70302. return _this;
  70303. }
  70304. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  70305. var modes = [
  70306. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  70307. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  70308. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  70309. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  70310. ];
  70311. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  70312. var mode = modes_1[_i];
  70313. this[mode] = (mode === modeToEnable);
  70314. }
  70315. };
  70316. return StandardMaterialDefines;
  70317. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  70318. /**
  70319. * This is the default material used in Babylon. It is the best trade off between quality
  70320. * and performances.
  70321. * @see http://doc.babylonjs.com/babylon101/materials
  70322. */
  70323. var StandardMaterial = /** @class */ (function (_super) {
  70324. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  70325. /**
  70326. * Instantiates a new standard material.
  70327. * This is the default material used in Babylon. It is the best trade off between quality
  70328. * and performances.
  70329. * @see http://doc.babylonjs.com/babylon101/materials
  70330. * @param name Define the name of the material in the scene
  70331. * @param scene Define the scene the material belong to
  70332. */
  70333. function StandardMaterial(name, scene) {
  70334. var _this = _super.call(this, name, scene) || this;
  70335. _this._diffuseTexture = null;
  70336. _this._ambientTexture = null;
  70337. _this._opacityTexture = null;
  70338. _this._reflectionTexture = null;
  70339. _this._emissiveTexture = null;
  70340. _this._specularTexture = null;
  70341. _this._bumpTexture = null;
  70342. _this._lightmapTexture = null;
  70343. _this._refractionTexture = null;
  70344. /**
  70345. * The color of the material lit by the environmental background lighting.
  70346. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  70347. */
  70348. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  70349. /**
  70350. * The basic color of the material as viewed under a light.
  70351. */
  70352. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  70353. /**
  70354. * Define how the color and intensity of the highlight given by the light in the material.
  70355. */
  70356. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  70357. /**
  70358. * Define the color of the material as if self lit.
  70359. * This will be mixed in the final result even in the absence of light.
  70360. */
  70361. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  70362. /**
  70363. * Defines how sharp are the highlights in the material.
  70364. * The bigger the value the sharper giving a more glossy feeling to the result.
  70365. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  70366. */
  70367. _this.specularPower = 64;
  70368. _this._useAlphaFromDiffuseTexture = false;
  70369. _this._useEmissiveAsIllumination = false;
  70370. _this._linkEmissiveWithDiffuse = false;
  70371. _this._useSpecularOverAlpha = false;
  70372. _this._useReflectionOverAlpha = false;
  70373. _this._disableLighting = false;
  70374. _this._useObjectSpaceNormalMap = false;
  70375. _this._useParallax = false;
  70376. _this._useParallaxOcclusion = false;
  70377. /**
  70378. * 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.
  70379. */
  70380. _this.parallaxScaleBias = 0.05;
  70381. _this._roughness = 0;
  70382. /**
  70383. * In case of refraction, define the value of the indice of refraction.
  70384. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  70385. */
  70386. _this.indexOfRefraction = 0.98;
  70387. /**
  70388. * Invert the refraction texture alongside the y axis.
  70389. * It can be useful with procedural textures or probe for instance.
  70390. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  70391. */
  70392. _this.invertRefractionY = true;
  70393. /**
  70394. * Defines the alpha limits in alpha test mode.
  70395. */
  70396. _this.alphaCutOff = 0.4;
  70397. _this._useLightmapAsShadowmap = false;
  70398. _this._useReflectionFresnelFromSpecular = false;
  70399. _this._useGlossinessFromSpecularMapAlpha = false;
  70400. _this._maxSimultaneousLights = 4;
  70401. _this._invertNormalMapX = false;
  70402. _this._invertNormalMapY = false;
  70403. _this._twoSidedLighting = false;
  70404. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  70405. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  70406. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  70407. // Setup the default processing configuration to the scene.
  70408. _this._attachImageProcessingConfiguration(null);
  70409. _this.getRenderTargetTextures = function () {
  70410. _this._renderTargets.reset();
  70411. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  70412. _this._renderTargets.push(_this._reflectionTexture);
  70413. }
  70414. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  70415. _this._renderTargets.push(_this._refractionTexture);
  70416. }
  70417. return _this._renderTargets;
  70418. };
  70419. return _this;
  70420. }
  70421. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  70422. /**
  70423. * Gets the image processing configuration used either in this material.
  70424. */
  70425. get: function () {
  70426. return this._imageProcessingConfiguration;
  70427. },
  70428. /**
  70429. * Sets the Default image processing configuration used either in the this material.
  70430. *
  70431. * If sets to null, the scene one is in use.
  70432. */
  70433. set: function (value) {
  70434. this._attachImageProcessingConfiguration(value);
  70435. // Ensure the effect will be rebuilt.
  70436. this._markAllSubMeshesAsTexturesDirty();
  70437. },
  70438. enumerable: true,
  70439. configurable: true
  70440. });
  70441. /**
  70442. * Attaches a new image processing configuration to the Standard Material.
  70443. * @param configuration
  70444. */
  70445. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  70446. var _this = this;
  70447. if (configuration === this._imageProcessingConfiguration) {
  70448. return;
  70449. }
  70450. // Detaches observer.
  70451. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  70452. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  70453. }
  70454. // Pick the scene configuration if needed.
  70455. if (!configuration) {
  70456. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  70457. }
  70458. else {
  70459. this._imageProcessingConfiguration = configuration;
  70460. }
  70461. // Attaches observer.
  70462. if (this._imageProcessingConfiguration) {
  70463. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  70464. _this._markAllSubMeshesAsImageProcessingDirty();
  70465. });
  70466. }
  70467. };
  70468. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  70469. /**
  70470. * Gets wether the color curves effect is enabled.
  70471. */
  70472. get: function () {
  70473. return this.imageProcessingConfiguration.colorCurvesEnabled;
  70474. },
  70475. /**
  70476. * Sets wether the color curves effect is enabled.
  70477. */
  70478. set: function (value) {
  70479. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  70480. },
  70481. enumerable: true,
  70482. configurable: true
  70483. });
  70484. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  70485. /**
  70486. * Gets wether the color grading effect is enabled.
  70487. */
  70488. get: function () {
  70489. return this.imageProcessingConfiguration.colorGradingEnabled;
  70490. },
  70491. /**
  70492. * Gets wether the color grading effect is enabled.
  70493. */
  70494. set: function (value) {
  70495. this.imageProcessingConfiguration.colorGradingEnabled = value;
  70496. },
  70497. enumerable: true,
  70498. configurable: true
  70499. });
  70500. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  70501. /**
  70502. * Gets wether tonemapping is enabled or not.
  70503. */
  70504. get: function () {
  70505. return this._imageProcessingConfiguration.toneMappingEnabled;
  70506. },
  70507. /**
  70508. * Sets wether tonemapping is enabled or not
  70509. */
  70510. set: function (value) {
  70511. this._imageProcessingConfiguration.toneMappingEnabled = value;
  70512. },
  70513. enumerable: true,
  70514. configurable: true
  70515. });
  70516. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  70517. /**
  70518. * The camera exposure used on this material.
  70519. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  70520. * This corresponds to a photographic exposure.
  70521. */
  70522. get: function () {
  70523. return this._imageProcessingConfiguration.exposure;
  70524. },
  70525. /**
  70526. * The camera exposure used on this material.
  70527. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  70528. * This corresponds to a photographic exposure.
  70529. */
  70530. set: function (value) {
  70531. this._imageProcessingConfiguration.exposure = value;
  70532. },
  70533. enumerable: true,
  70534. configurable: true
  70535. });
  70536. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  70537. /**
  70538. * Gets The camera contrast used on this material.
  70539. */
  70540. get: function () {
  70541. return this._imageProcessingConfiguration.contrast;
  70542. },
  70543. /**
  70544. * Sets The camera contrast used on this material.
  70545. */
  70546. set: function (value) {
  70547. this._imageProcessingConfiguration.contrast = value;
  70548. },
  70549. enumerable: true,
  70550. configurable: true
  70551. });
  70552. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  70553. /**
  70554. * Gets the Color Grading 2D Lookup Texture.
  70555. */
  70556. get: function () {
  70557. return this._imageProcessingConfiguration.colorGradingTexture;
  70558. },
  70559. /**
  70560. * Sets the Color Grading 2D Lookup Texture.
  70561. */
  70562. set: function (value) {
  70563. this._imageProcessingConfiguration.colorGradingTexture = value;
  70564. },
  70565. enumerable: true,
  70566. configurable: true
  70567. });
  70568. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  70569. /**
  70570. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  70571. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  70572. * 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;
  70573. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  70574. */
  70575. get: function () {
  70576. return this._imageProcessingConfiguration.colorCurves;
  70577. },
  70578. /**
  70579. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  70580. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  70581. * 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;
  70582. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  70583. */
  70584. set: function (value) {
  70585. this._imageProcessingConfiguration.colorCurves = value;
  70586. },
  70587. enumerable: true,
  70588. configurable: true
  70589. });
  70590. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  70591. /**
  70592. * Gets a boolean indicating that current material needs to register RTT
  70593. */
  70594. get: function () {
  70595. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  70596. return true;
  70597. }
  70598. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  70599. return true;
  70600. }
  70601. return false;
  70602. },
  70603. enumerable: true,
  70604. configurable: true
  70605. });
  70606. /**
  70607. * Gets the current class name of the material e.g. "StandardMaterial"
  70608. * Mainly use in serialization.
  70609. * @returns the class name
  70610. */
  70611. StandardMaterial.prototype.getClassName = function () {
  70612. return "StandardMaterial";
  70613. };
  70614. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  70615. /**
  70616. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  70617. * You can try switching to logarithmic depth.
  70618. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  70619. */
  70620. get: function () {
  70621. return this._useLogarithmicDepth;
  70622. },
  70623. set: function (value) {
  70624. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  70625. this._markAllSubMeshesAsMiscDirty();
  70626. },
  70627. enumerable: true,
  70628. configurable: true
  70629. });
  70630. /**
  70631. * Specifies if the material will require alpha blending
  70632. * @returns a boolean specifying if alpha blending is needed
  70633. */
  70634. StandardMaterial.prototype.needAlphaBlending = function () {
  70635. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  70636. };
  70637. /**
  70638. * Specifies if this material should be rendered in alpha test mode
  70639. * @returns a boolean specifying if an alpha test is needed.
  70640. */
  70641. StandardMaterial.prototype.needAlphaTesting = function () {
  70642. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  70643. };
  70644. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  70645. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  70646. };
  70647. /**
  70648. * Get the texture used for alpha test purpose.
  70649. * @returns the diffuse texture in case of the standard material.
  70650. */
  70651. StandardMaterial.prototype.getAlphaTestTexture = function () {
  70652. return this._diffuseTexture;
  70653. };
  70654. /**
  70655. * Get if the submesh is ready to be used and all its information available.
  70656. * Child classes can use it to update shaders
  70657. * @param mesh defines the mesh to check
  70658. * @param subMesh defines which submesh to check
  70659. * @param useInstances specifies that instances should be used
  70660. * @returns a boolean indicating that the submesh is ready or not
  70661. */
  70662. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  70663. if (useInstances === void 0) { useInstances = false; }
  70664. if (subMesh.effect && this.isFrozen) {
  70665. if (this._wasPreviouslyReady) {
  70666. return true;
  70667. }
  70668. }
  70669. if (!subMesh._materialDefines) {
  70670. subMesh._materialDefines = new StandardMaterialDefines();
  70671. }
  70672. var scene = this.getScene();
  70673. var defines = subMesh._materialDefines;
  70674. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  70675. if (defines._renderId === scene.getRenderId()) {
  70676. return true;
  70677. }
  70678. }
  70679. var engine = scene.getEngine();
  70680. // Lights
  70681. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  70682. // Multiview
  70683. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  70684. // Textures
  70685. if (defines._areTexturesDirty) {
  70686. defines._needUVs = false;
  70687. defines.MAINUV1 = false;
  70688. defines.MAINUV2 = false;
  70689. if (scene.texturesEnabled) {
  70690. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  70691. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  70692. return false;
  70693. }
  70694. else {
  70695. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  70696. }
  70697. }
  70698. else {
  70699. defines.DIFFUSE = false;
  70700. }
  70701. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  70702. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  70703. return false;
  70704. }
  70705. else {
  70706. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  70707. }
  70708. }
  70709. else {
  70710. defines.AMBIENT = false;
  70711. }
  70712. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  70713. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  70714. return false;
  70715. }
  70716. else {
  70717. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  70718. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  70719. }
  70720. }
  70721. else {
  70722. defines.OPACITY = false;
  70723. }
  70724. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  70725. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  70726. return false;
  70727. }
  70728. else {
  70729. defines._needNormals = true;
  70730. defines.REFLECTION = true;
  70731. defines.ROUGHNESS = (this._roughness > 0);
  70732. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  70733. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  70734. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  70735. switch (this._reflectionTexture.coordinatesMode) {
  70736. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  70737. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  70738. break;
  70739. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  70740. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  70741. break;
  70742. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  70743. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  70744. break;
  70745. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  70746. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  70747. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  70748. break;
  70749. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  70750. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  70751. break;
  70752. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  70753. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  70754. break;
  70755. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  70756. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  70757. break;
  70758. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  70759. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  70760. break;
  70761. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  70762. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  70763. default:
  70764. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  70765. break;
  70766. }
  70767. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  70768. }
  70769. }
  70770. else {
  70771. defines.REFLECTION = false;
  70772. }
  70773. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  70774. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  70775. return false;
  70776. }
  70777. else {
  70778. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  70779. }
  70780. }
  70781. else {
  70782. defines.EMISSIVE = false;
  70783. }
  70784. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  70785. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  70786. return false;
  70787. }
  70788. else {
  70789. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  70790. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  70791. }
  70792. }
  70793. else {
  70794. defines.LIGHTMAP = false;
  70795. }
  70796. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  70797. if (!this._specularTexture.isReadyOrNotBlocking()) {
  70798. return false;
  70799. }
  70800. else {
  70801. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  70802. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  70803. }
  70804. }
  70805. else {
  70806. defines.SPECULAR = false;
  70807. }
  70808. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  70809. // Bump texure can not be not blocking.
  70810. if (!this._bumpTexture.isReady()) {
  70811. return false;
  70812. }
  70813. else {
  70814. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  70815. defines.PARALLAX = this._useParallax;
  70816. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  70817. }
  70818. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  70819. }
  70820. else {
  70821. defines.BUMP = false;
  70822. }
  70823. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  70824. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  70825. return false;
  70826. }
  70827. else {
  70828. defines._needUVs = true;
  70829. defines.REFRACTION = true;
  70830. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  70831. }
  70832. }
  70833. else {
  70834. defines.REFRACTION = false;
  70835. }
  70836. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  70837. }
  70838. else {
  70839. defines.DIFFUSE = false;
  70840. defines.AMBIENT = false;
  70841. defines.OPACITY = false;
  70842. defines.REFLECTION = false;
  70843. defines.EMISSIVE = false;
  70844. defines.LIGHTMAP = false;
  70845. defines.BUMP = false;
  70846. defines.REFRACTION = false;
  70847. }
  70848. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  70849. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  70850. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  70851. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  70852. 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);
  70853. }
  70854. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  70855. if (!this._imageProcessingConfiguration.isReady()) {
  70856. return false;
  70857. }
  70858. this._imageProcessingConfiguration.prepareDefines(defines);
  70859. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  70860. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  70861. }
  70862. if (defines._areFresnelDirty) {
  70863. if (StandardMaterial.FresnelEnabled) {
  70864. // Fresnel
  70865. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  70866. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  70867. this._reflectionFresnelParameters) {
  70868. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  70869. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  70870. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  70871. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  70872. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  70873. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  70874. defines._needNormals = true;
  70875. defines.FRESNEL = true;
  70876. }
  70877. }
  70878. else {
  70879. defines.FRESNEL = false;
  70880. }
  70881. }
  70882. // Misc.
  70883. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  70884. // Attribs
  70885. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  70886. // Values that need to be evaluated on every frame
  70887. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  70888. // Get correct effect
  70889. if (defines.isDirty) {
  70890. defines.markAsProcessed();
  70891. // Fallbacks
  70892. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  70893. if (defines.REFLECTION) {
  70894. fallbacks.addFallback(0, "REFLECTION");
  70895. }
  70896. if (defines.SPECULAR) {
  70897. fallbacks.addFallback(0, "SPECULAR");
  70898. }
  70899. if (defines.BUMP) {
  70900. fallbacks.addFallback(0, "BUMP");
  70901. }
  70902. if (defines.PARALLAX) {
  70903. fallbacks.addFallback(1, "PARALLAX");
  70904. }
  70905. if (defines.PARALLAXOCCLUSION) {
  70906. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  70907. }
  70908. if (defines.SPECULAROVERALPHA) {
  70909. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  70910. }
  70911. if (defines.FOG) {
  70912. fallbacks.addFallback(1, "FOG");
  70913. }
  70914. if (defines.POINTSIZE) {
  70915. fallbacks.addFallback(0, "POINTSIZE");
  70916. }
  70917. if (defines.LOGARITHMICDEPTH) {
  70918. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  70919. }
  70920. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  70921. if (defines.SPECULARTERM) {
  70922. fallbacks.addFallback(0, "SPECULARTERM");
  70923. }
  70924. if (defines.DIFFUSEFRESNEL) {
  70925. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  70926. }
  70927. if (defines.OPACITYFRESNEL) {
  70928. fallbacks.addFallback(2, "OPACITYFRESNEL");
  70929. }
  70930. if (defines.REFLECTIONFRESNEL) {
  70931. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  70932. }
  70933. if (defines.EMISSIVEFRESNEL) {
  70934. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  70935. }
  70936. if (defines.FRESNEL) {
  70937. fallbacks.addFallback(4, "FRESNEL");
  70938. }
  70939. if (defines.MULTIVIEW) {
  70940. fallbacks.addFallback(0, "MULTIVIEW");
  70941. }
  70942. //Attributes
  70943. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  70944. if (defines.NORMAL) {
  70945. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  70946. }
  70947. if (defines.UV1) {
  70948. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  70949. }
  70950. if (defines.UV2) {
  70951. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  70952. }
  70953. if (defines.VERTEXCOLOR) {
  70954. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  70955. }
  70956. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  70957. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  70958. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  70959. var shaderName = "default";
  70960. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor", "visibility",
  70961. "vFogInfos", "vFogColor", "pointSize",
  70962. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  70963. "mBones",
  70964. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  70965. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  70966. "vReflectionPosition", "vReflectionSize",
  70967. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  70968. ];
  70969. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  70970. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  70971. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  70972. var uniformBuffers = ["Material", "Scene"];
  70973. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  70974. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  70975. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  70976. }
  70977. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  70978. uniformsNames: uniforms,
  70979. uniformBuffersNames: uniformBuffers,
  70980. samplers: samplers,
  70981. defines: defines,
  70982. maxSimultaneousLights: this._maxSimultaneousLights
  70983. });
  70984. if (this.customShaderNameResolve) {
  70985. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  70986. }
  70987. var join = defines.toString();
  70988. var previousEffect = subMesh.effect;
  70989. var effect = scene.getEngine().createEffect(shaderName, {
  70990. attributes: attribs,
  70991. uniformsNames: uniforms,
  70992. uniformBuffersNames: uniformBuffers,
  70993. samplers: samplers,
  70994. defines: join,
  70995. fallbacks: fallbacks,
  70996. onCompiled: this.onCompiled,
  70997. onError: this.onError,
  70998. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  70999. }, engine);
  71000. if (effect) {
  71001. // Use previous effect while new one is compiling
  71002. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  71003. effect = previousEffect;
  71004. defines.markAsUnprocessed();
  71005. }
  71006. else {
  71007. scene.resetCachedMaterial();
  71008. subMesh.setEffect(effect, defines);
  71009. this.buildUniformLayout();
  71010. }
  71011. }
  71012. }
  71013. if (!subMesh.effect || !subMesh.effect.isReady()) {
  71014. return false;
  71015. }
  71016. defines._renderId = scene.getRenderId();
  71017. this._wasPreviouslyReady = true;
  71018. return true;
  71019. };
  71020. /**
  71021. * Builds the material UBO layouts.
  71022. * Used internally during the effect preparation.
  71023. */
  71024. StandardMaterial.prototype.buildUniformLayout = function () {
  71025. // Order is important !
  71026. var ubo = this._uniformBuffer;
  71027. ubo.addUniform("diffuseLeftColor", 4);
  71028. ubo.addUniform("diffuseRightColor", 4);
  71029. ubo.addUniform("opacityParts", 4);
  71030. ubo.addUniform("reflectionLeftColor", 4);
  71031. ubo.addUniform("reflectionRightColor", 4);
  71032. ubo.addUniform("refractionLeftColor", 4);
  71033. ubo.addUniform("refractionRightColor", 4);
  71034. ubo.addUniform("emissiveLeftColor", 4);
  71035. ubo.addUniform("emissiveRightColor", 4);
  71036. ubo.addUniform("vDiffuseInfos", 2);
  71037. ubo.addUniform("vAmbientInfos", 2);
  71038. ubo.addUniform("vOpacityInfos", 2);
  71039. ubo.addUniform("vReflectionInfos", 2);
  71040. ubo.addUniform("vReflectionPosition", 3);
  71041. ubo.addUniform("vReflectionSize", 3);
  71042. ubo.addUniform("vEmissiveInfos", 2);
  71043. ubo.addUniform("vLightmapInfos", 2);
  71044. ubo.addUniform("vSpecularInfos", 2);
  71045. ubo.addUniform("vBumpInfos", 3);
  71046. ubo.addUniform("diffuseMatrix", 16);
  71047. ubo.addUniform("ambientMatrix", 16);
  71048. ubo.addUniform("opacityMatrix", 16);
  71049. ubo.addUniform("reflectionMatrix", 16);
  71050. ubo.addUniform("emissiveMatrix", 16);
  71051. ubo.addUniform("lightmapMatrix", 16);
  71052. ubo.addUniform("specularMatrix", 16);
  71053. ubo.addUniform("bumpMatrix", 16);
  71054. ubo.addUniform("vTangentSpaceParams", 2);
  71055. ubo.addUniform("pointSize", 1);
  71056. ubo.addUniform("refractionMatrix", 16);
  71057. ubo.addUniform("vRefractionInfos", 4);
  71058. ubo.addUniform("vSpecularColor", 4);
  71059. ubo.addUniform("vEmissiveColor", 3);
  71060. ubo.addUniform("visibility", 1);
  71061. ubo.addUniform("vDiffuseColor", 4);
  71062. ubo.create();
  71063. };
  71064. /**
  71065. * Unbinds the material from the mesh
  71066. */
  71067. StandardMaterial.prototype.unbind = function () {
  71068. if (this._activeEffect) {
  71069. var needFlag = false;
  71070. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  71071. this._activeEffect.setTexture("reflection2DSampler", null);
  71072. needFlag = true;
  71073. }
  71074. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  71075. this._activeEffect.setTexture("refraction2DSampler", null);
  71076. needFlag = true;
  71077. }
  71078. if (needFlag) {
  71079. this._markAllSubMeshesAsTexturesDirty();
  71080. }
  71081. }
  71082. _super.prototype.unbind.call(this);
  71083. };
  71084. /**
  71085. * Binds the submesh to this material by preparing the effect and shader to draw
  71086. * @param world defines the world transformation matrix
  71087. * @param mesh defines the mesh containing the submesh
  71088. * @param subMesh defines the submesh to bind the material to
  71089. */
  71090. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  71091. var scene = this.getScene();
  71092. var defines = subMesh._materialDefines;
  71093. if (!defines) {
  71094. return;
  71095. }
  71096. var effect = subMesh.effect;
  71097. if (!effect) {
  71098. return;
  71099. }
  71100. this._activeEffect = effect;
  71101. // Matrices
  71102. if (!defines.INSTANCES) {
  71103. this.bindOnlyWorldMatrix(world);
  71104. }
  71105. // Normal Matrix
  71106. if (defines.OBJECTSPACE_NORMALMAP) {
  71107. world.toNormalMatrix(this._normalMatrix);
  71108. this.bindOnlyNormalMatrix(this._normalMatrix);
  71109. }
  71110. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  71111. // Bones
  71112. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  71113. var ubo = this._uniformBuffer;
  71114. if (mustRebind) {
  71115. ubo.bindToEffect(effect, "Material");
  71116. this.bindViewProjection(effect);
  71117. if (!ubo.useUbo || !this.isFrozen || !ubo.isSync) {
  71118. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  71119. // Fresnel
  71120. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  71121. ubo.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  71122. ubo.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  71123. }
  71124. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  71125. 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);
  71126. }
  71127. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  71128. ubo.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  71129. ubo.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  71130. }
  71131. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  71132. ubo.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  71133. ubo.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  71134. }
  71135. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  71136. ubo.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  71137. ubo.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  71138. }
  71139. }
  71140. // Textures
  71141. if (scene.texturesEnabled) {
  71142. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  71143. ubo.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  71144. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, ubo, "diffuse");
  71145. if (this._diffuseTexture.hasAlpha) {
  71146. effect.setFloat("alphaCutOff", this.alphaCutOff);
  71147. }
  71148. }
  71149. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  71150. ubo.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  71151. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, ubo, "ambient");
  71152. }
  71153. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  71154. ubo.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  71155. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, ubo, "opacity");
  71156. }
  71157. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  71158. ubo.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  71159. ubo.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  71160. if (this._reflectionTexture.boundingBoxSize) {
  71161. var cubeTexture = this._reflectionTexture;
  71162. ubo.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  71163. ubo.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  71164. }
  71165. }
  71166. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  71167. ubo.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  71168. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, ubo, "emissive");
  71169. }
  71170. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  71171. ubo.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  71172. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, ubo, "lightmap");
  71173. }
  71174. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  71175. ubo.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  71176. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, ubo, "specular");
  71177. }
  71178. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  71179. ubo.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  71180. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, ubo, "bump");
  71181. if (scene._mirroredCameraPosition) {
  71182. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  71183. }
  71184. else {
  71185. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  71186. }
  71187. }
  71188. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  71189. var depth = 1.0;
  71190. if (!this._refractionTexture.isCube) {
  71191. ubo.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  71192. if (this._refractionTexture.depth) {
  71193. depth = this._refractionTexture.depth;
  71194. }
  71195. }
  71196. ubo.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  71197. }
  71198. }
  71199. // Point size
  71200. if (this.pointsCloud) {
  71201. ubo.updateFloat("pointSize", this.pointSize);
  71202. }
  71203. if (defines.SPECULARTERM) {
  71204. ubo.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  71205. }
  71206. ubo.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  71207. // Visibility
  71208. ubo.updateFloat("visibility", mesh.visibility);
  71209. // Diffuse
  71210. ubo.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha);
  71211. }
  71212. // Textures
  71213. if (scene.texturesEnabled) {
  71214. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  71215. effect.setTexture("diffuseSampler", this._diffuseTexture);
  71216. }
  71217. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  71218. effect.setTexture("ambientSampler", this._ambientTexture);
  71219. }
  71220. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  71221. effect.setTexture("opacitySampler", this._opacityTexture);
  71222. }
  71223. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  71224. if (this._reflectionTexture.isCube) {
  71225. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  71226. }
  71227. else {
  71228. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  71229. }
  71230. }
  71231. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  71232. effect.setTexture("emissiveSampler", this._emissiveTexture);
  71233. }
  71234. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  71235. effect.setTexture("lightmapSampler", this._lightmapTexture);
  71236. }
  71237. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  71238. effect.setTexture("specularSampler", this._specularTexture);
  71239. }
  71240. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  71241. effect.setTexture("bumpSampler", this._bumpTexture);
  71242. }
  71243. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  71244. var depth = 1.0;
  71245. if (this._refractionTexture.isCube) {
  71246. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  71247. }
  71248. else {
  71249. effect.setTexture("refraction2DSampler", this._refractionTexture);
  71250. }
  71251. }
  71252. }
  71253. // Clip plane
  71254. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  71255. // Colors
  71256. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  71257. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  71258. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  71259. }
  71260. if (mustRebind || !this.isFrozen) {
  71261. // Lights
  71262. if (scene.lightsEnabled && !this._disableLighting) {
  71263. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  71264. }
  71265. // View
  71266. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  71267. this.bindView(effect);
  71268. }
  71269. // Fog
  71270. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  71271. // Morph targets
  71272. if (defines.NUM_MORPH_INFLUENCERS) {
  71273. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  71274. }
  71275. // Log. depth
  71276. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  71277. // image processing
  71278. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  71279. this._imageProcessingConfiguration.bind(this._activeEffect);
  71280. }
  71281. }
  71282. ubo.update();
  71283. this._afterBind(mesh, this._activeEffect);
  71284. };
  71285. /**
  71286. * Get the list of animatables in the material.
  71287. * @returns the list of animatables object used in the material
  71288. */
  71289. StandardMaterial.prototype.getAnimatables = function () {
  71290. var results = [];
  71291. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  71292. results.push(this._diffuseTexture);
  71293. }
  71294. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  71295. results.push(this._ambientTexture);
  71296. }
  71297. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  71298. results.push(this._opacityTexture);
  71299. }
  71300. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  71301. results.push(this._reflectionTexture);
  71302. }
  71303. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  71304. results.push(this._emissiveTexture);
  71305. }
  71306. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  71307. results.push(this._specularTexture);
  71308. }
  71309. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  71310. results.push(this._bumpTexture);
  71311. }
  71312. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  71313. results.push(this._lightmapTexture);
  71314. }
  71315. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  71316. results.push(this._refractionTexture);
  71317. }
  71318. return results;
  71319. };
  71320. /**
  71321. * Gets the active textures from the material
  71322. * @returns an array of textures
  71323. */
  71324. StandardMaterial.prototype.getActiveTextures = function () {
  71325. var activeTextures = _super.prototype.getActiveTextures.call(this);
  71326. if (this._diffuseTexture) {
  71327. activeTextures.push(this._diffuseTexture);
  71328. }
  71329. if (this._ambientTexture) {
  71330. activeTextures.push(this._ambientTexture);
  71331. }
  71332. if (this._opacityTexture) {
  71333. activeTextures.push(this._opacityTexture);
  71334. }
  71335. if (this._reflectionTexture) {
  71336. activeTextures.push(this._reflectionTexture);
  71337. }
  71338. if (this._emissiveTexture) {
  71339. activeTextures.push(this._emissiveTexture);
  71340. }
  71341. if (this._specularTexture) {
  71342. activeTextures.push(this._specularTexture);
  71343. }
  71344. if (this._bumpTexture) {
  71345. activeTextures.push(this._bumpTexture);
  71346. }
  71347. if (this._lightmapTexture) {
  71348. activeTextures.push(this._lightmapTexture);
  71349. }
  71350. if (this._refractionTexture) {
  71351. activeTextures.push(this._refractionTexture);
  71352. }
  71353. return activeTextures;
  71354. };
  71355. /**
  71356. * Specifies if the material uses a texture
  71357. * @param texture defines the texture to check against the material
  71358. * @returns a boolean specifying if the material uses the texture
  71359. */
  71360. StandardMaterial.prototype.hasTexture = function (texture) {
  71361. if (_super.prototype.hasTexture.call(this, texture)) {
  71362. return true;
  71363. }
  71364. if (this._diffuseTexture === texture) {
  71365. return true;
  71366. }
  71367. if (this._ambientTexture === texture) {
  71368. return true;
  71369. }
  71370. if (this._opacityTexture === texture) {
  71371. return true;
  71372. }
  71373. if (this._reflectionTexture === texture) {
  71374. return true;
  71375. }
  71376. if (this._emissiveTexture === texture) {
  71377. return true;
  71378. }
  71379. if (this._specularTexture === texture) {
  71380. return true;
  71381. }
  71382. if (this._bumpTexture === texture) {
  71383. return true;
  71384. }
  71385. if (this._lightmapTexture === texture) {
  71386. return true;
  71387. }
  71388. if (this._refractionTexture === texture) {
  71389. return true;
  71390. }
  71391. return false;
  71392. };
  71393. /**
  71394. * Disposes the material
  71395. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  71396. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  71397. */
  71398. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  71399. if (forceDisposeTextures) {
  71400. if (this._diffuseTexture) {
  71401. this._diffuseTexture.dispose();
  71402. }
  71403. if (this._ambientTexture) {
  71404. this._ambientTexture.dispose();
  71405. }
  71406. if (this._opacityTexture) {
  71407. this._opacityTexture.dispose();
  71408. }
  71409. if (this._reflectionTexture) {
  71410. this._reflectionTexture.dispose();
  71411. }
  71412. if (this._emissiveTexture) {
  71413. this._emissiveTexture.dispose();
  71414. }
  71415. if (this._specularTexture) {
  71416. this._specularTexture.dispose();
  71417. }
  71418. if (this._bumpTexture) {
  71419. this._bumpTexture.dispose();
  71420. }
  71421. if (this._lightmapTexture) {
  71422. this._lightmapTexture.dispose();
  71423. }
  71424. if (this._refractionTexture) {
  71425. this._refractionTexture.dispose();
  71426. }
  71427. }
  71428. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  71429. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  71430. }
  71431. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  71432. };
  71433. /**
  71434. * Makes a duplicate of the material, and gives it a new name
  71435. * @param name defines the new name for the duplicated material
  71436. * @returns the cloned material
  71437. */
  71438. StandardMaterial.prototype.clone = function (name) {
  71439. var _this = this;
  71440. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  71441. result.name = name;
  71442. result.id = name;
  71443. return result;
  71444. };
  71445. /**
  71446. * Serializes this material in a JSON representation
  71447. * @returns the serialized material object
  71448. */
  71449. StandardMaterial.prototype.serialize = function () {
  71450. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  71451. };
  71452. /**
  71453. * Creates a standard material from parsed material data
  71454. * @param source defines the JSON representation of the material
  71455. * @param scene defines the hosting scene
  71456. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71457. * @returns a new standard material
  71458. */
  71459. StandardMaterial.Parse = function (source, scene, rootUrl) {
  71460. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  71461. };
  71462. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  71463. // Flags used to enable or disable a type of texture for all Standard Materials
  71464. /**
  71465. * Are diffuse textures enabled in the application.
  71466. */
  71467. get: function () {
  71468. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  71469. },
  71470. set: function (value) {
  71471. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  71472. },
  71473. enumerable: true,
  71474. configurable: true
  71475. });
  71476. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  71477. /**
  71478. * Are ambient textures enabled in the application.
  71479. */
  71480. get: function () {
  71481. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  71482. },
  71483. set: function (value) {
  71484. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  71485. },
  71486. enumerable: true,
  71487. configurable: true
  71488. });
  71489. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  71490. /**
  71491. * Are opacity textures enabled in the application.
  71492. */
  71493. get: function () {
  71494. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  71495. },
  71496. set: function (value) {
  71497. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  71498. },
  71499. enumerable: true,
  71500. configurable: true
  71501. });
  71502. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  71503. /**
  71504. * Are reflection textures enabled in the application.
  71505. */
  71506. get: function () {
  71507. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  71508. },
  71509. set: function (value) {
  71510. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  71511. },
  71512. enumerable: true,
  71513. configurable: true
  71514. });
  71515. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  71516. /**
  71517. * Are emissive textures enabled in the application.
  71518. */
  71519. get: function () {
  71520. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  71521. },
  71522. set: function (value) {
  71523. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  71524. },
  71525. enumerable: true,
  71526. configurable: true
  71527. });
  71528. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  71529. /**
  71530. * Are specular textures enabled in the application.
  71531. */
  71532. get: function () {
  71533. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  71534. },
  71535. set: function (value) {
  71536. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  71537. },
  71538. enumerable: true,
  71539. configurable: true
  71540. });
  71541. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  71542. /**
  71543. * Are bump textures enabled in the application.
  71544. */
  71545. get: function () {
  71546. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  71547. },
  71548. set: function (value) {
  71549. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  71550. },
  71551. enumerable: true,
  71552. configurable: true
  71553. });
  71554. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  71555. /**
  71556. * Are lightmap textures enabled in the application.
  71557. */
  71558. get: function () {
  71559. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  71560. },
  71561. set: function (value) {
  71562. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  71563. },
  71564. enumerable: true,
  71565. configurable: true
  71566. });
  71567. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  71568. /**
  71569. * Are refraction textures enabled in the application.
  71570. */
  71571. get: function () {
  71572. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  71573. },
  71574. set: function (value) {
  71575. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  71576. },
  71577. enumerable: true,
  71578. configurable: true
  71579. });
  71580. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  71581. /**
  71582. * Are color grading textures enabled in the application.
  71583. */
  71584. get: function () {
  71585. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  71586. },
  71587. set: function (value) {
  71588. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  71589. },
  71590. enumerable: true,
  71591. configurable: true
  71592. });
  71593. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  71594. /**
  71595. * Are fresnels enabled in the application.
  71596. */
  71597. get: function () {
  71598. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  71599. },
  71600. set: function (value) {
  71601. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  71602. },
  71603. enumerable: true,
  71604. configurable: true
  71605. });
  71606. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71607. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  71608. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  71609. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71610. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  71611. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  71612. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71613. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  71614. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  71615. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71616. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71617. ], StandardMaterial.prototype, "ambientTexture", void 0);
  71618. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71619. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  71620. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  71621. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71622. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  71623. ], StandardMaterial.prototype, "opacityTexture", void 0);
  71624. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71625. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  71626. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  71627. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71628. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71629. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  71630. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71631. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  71632. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  71633. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71634. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71635. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  71636. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71637. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  71638. ], StandardMaterial.prototype, "_specularTexture", void 0);
  71639. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71641. ], StandardMaterial.prototype, "specularTexture", void 0);
  71642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  71644. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  71645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71647. ], StandardMaterial.prototype, "bumpTexture", void 0);
  71648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  71650. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  71651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71653. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  71654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  71656. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  71657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71659. ], StandardMaterial.prototype, "refractionTexture", void 0);
  71660. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  71662. ], StandardMaterial.prototype, "ambientColor", void 0);
  71663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  71665. ], StandardMaterial.prototype, "diffuseColor", void 0);
  71666. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  71668. ], StandardMaterial.prototype, "specularColor", void 0);
  71669. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71670. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  71671. ], StandardMaterial.prototype, "emissiveColor", void 0);
  71672. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71674. ], StandardMaterial.prototype, "specularPower", void 0);
  71675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  71677. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  71678. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71679. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71680. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  71681. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71682. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  71683. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  71684. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71685. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71686. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  71687. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71688. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  71689. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  71690. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71691. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71692. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  71693. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71694. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  71695. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  71696. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71697. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71698. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  71699. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71700. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  71701. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  71702. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71703. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71704. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  71705. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71706. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  71707. ], StandardMaterial.prototype, "_disableLighting", void 0);
  71708. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  71710. ], StandardMaterial.prototype, "disableLighting", void 0);
  71711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  71713. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  71714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71716. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  71717. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71718. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  71719. ], StandardMaterial.prototype, "_useParallax", void 0);
  71720. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71721. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71722. ], StandardMaterial.prototype, "useParallax", void 0);
  71723. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71724. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  71725. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  71726. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71727. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71728. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  71729. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71730. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71731. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  71732. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71733. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  71734. ], StandardMaterial.prototype, "_roughness", void 0);
  71735. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71736. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71737. ], StandardMaterial.prototype, "roughness", void 0);
  71738. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71739. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71740. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  71741. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71742. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71743. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  71744. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71745. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71746. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  71747. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71748. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  71749. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  71750. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71751. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71752. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  71753. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71754. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  71755. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  71756. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71757. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  71758. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  71759. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71760. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  71761. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  71762. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71763. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  71764. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  71765. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71766. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  71767. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  71768. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71769. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  71770. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  71771. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71772. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  71773. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  71774. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71775. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  71776. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  71777. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71778. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  71779. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  71780. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71781. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  71782. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  71783. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71784. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  71785. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  71786. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71787. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  71788. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  71789. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71790. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  71791. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  71792. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71793. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71794. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  71795. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71796. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  71797. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  71798. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71799. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  71800. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  71801. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71802. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  71803. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  71804. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71806. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  71807. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71808. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  71809. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  71810. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71811. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71812. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  71813. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71814. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  71815. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  71816. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  71818. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  71819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  71820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  71821. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  71822. return StandardMaterial;
  71823. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  71824. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  71825. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  71826. return new StandardMaterial("default material", scene);
  71827. };
  71828. /***/ }),
  71829. /***/ "./Materials/uniformBuffer.ts":
  71830. /*!************************************!*\
  71831. !*** ./Materials/uniformBuffer.ts ***!
  71832. \************************************/
  71833. /*! exports provided: UniformBuffer */
  71834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  71835. "use strict";
  71836. __webpack_require__.r(__webpack_exports__);
  71837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  71838. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  71839. /**
  71840. * Uniform buffer objects.
  71841. *
  71842. * Handles blocks of uniform on the GPU.
  71843. *
  71844. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  71845. *
  71846. * For more information, please refer to :
  71847. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  71848. */
  71849. var UniformBuffer = /** @class */ (function () {
  71850. /**
  71851. * Instantiates a new Uniform buffer objects.
  71852. *
  71853. * Handles blocks of uniform on the GPU.
  71854. *
  71855. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  71856. *
  71857. * For more information, please refer to :
  71858. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  71859. * @param engine Define the engine the buffer is associated with
  71860. * @param data Define the data contained in the buffer
  71861. * @param dynamic Define if the buffer is updatable
  71862. */
  71863. function UniformBuffer(engine, data, dynamic) {
  71864. this._engine = engine;
  71865. this._noUBO = !engine.supportsUniformBuffers;
  71866. this._dynamic = dynamic;
  71867. this._data = data || [];
  71868. this._uniformLocations = {};
  71869. this._uniformSizes = {};
  71870. this._uniformLocationPointer = 0;
  71871. this._needSync = false;
  71872. if (this._noUBO) {
  71873. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  71874. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  71875. this.updateFloat = this._updateFloatForEffect;
  71876. this.updateFloat2 = this._updateFloat2ForEffect;
  71877. this.updateFloat3 = this._updateFloat3ForEffect;
  71878. this.updateFloat4 = this._updateFloat4ForEffect;
  71879. this.updateMatrix = this._updateMatrixForEffect;
  71880. this.updateVector3 = this._updateVector3ForEffect;
  71881. this.updateVector4 = this._updateVector4ForEffect;
  71882. this.updateColor3 = this._updateColor3ForEffect;
  71883. this.updateColor4 = this._updateColor4ForEffect;
  71884. }
  71885. else {
  71886. this._engine._uniformBuffers.push(this);
  71887. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  71888. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  71889. this.updateFloat = this._updateFloatForUniform;
  71890. this.updateFloat2 = this._updateFloat2ForUniform;
  71891. this.updateFloat3 = this._updateFloat3ForUniform;
  71892. this.updateFloat4 = this._updateFloat4ForUniform;
  71893. this.updateMatrix = this._updateMatrixForUniform;
  71894. this.updateVector3 = this._updateVector3ForUniform;
  71895. this.updateVector4 = this._updateVector4ForUniform;
  71896. this.updateColor3 = this._updateColor3ForUniform;
  71897. this.updateColor4 = this._updateColor4ForUniform;
  71898. }
  71899. }
  71900. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  71901. /**
  71902. * Indicates if the buffer is using the WebGL2 UBO implementation,
  71903. * or just falling back on setUniformXXX calls.
  71904. */
  71905. get: function () {
  71906. return !this._noUBO;
  71907. },
  71908. enumerable: true,
  71909. configurable: true
  71910. });
  71911. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  71912. /**
  71913. * Indicates if the WebGL underlying uniform buffer is in sync
  71914. * with the javascript cache data.
  71915. */
  71916. get: function () {
  71917. return !this._needSync;
  71918. },
  71919. enumerable: true,
  71920. configurable: true
  71921. });
  71922. /**
  71923. * Indicates if the WebGL underlying uniform buffer is dynamic.
  71924. * Also, a dynamic UniformBuffer will disable cache verification and always
  71925. * update the underlying WebGL uniform buffer to the GPU.
  71926. * @returns if Dynamic, otherwise false
  71927. */
  71928. UniformBuffer.prototype.isDynamic = function () {
  71929. return this._dynamic !== undefined;
  71930. };
  71931. /**
  71932. * The data cache on JS side.
  71933. * @returns the underlying data as a float array
  71934. */
  71935. UniformBuffer.prototype.getData = function () {
  71936. return this._bufferData;
  71937. };
  71938. /**
  71939. * The underlying WebGL Uniform buffer.
  71940. * @returns the webgl buffer
  71941. */
  71942. UniformBuffer.prototype.getBuffer = function () {
  71943. return this._buffer;
  71944. };
  71945. /**
  71946. * std140 layout specifies how to align data within an UBO structure.
  71947. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  71948. * for specs.
  71949. */
  71950. UniformBuffer.prototype._fillAlignment = function (size) {
  71951. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  71952. // and 4x4 matrices
  71953. // TODO : change if other types are used
  71954. var alignment;
  71955. if (size <= 2) {
  71956. alignment = size;
  71957. }
  71958. else {
  71959. alignment = 4;
  71960. }
  71961. if ((this._uniformLocationPointer % alignment) !== 0) {
  71962. var oldPointer = this._uniformLocationPointer;
  71963. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  71964. var diff = this._uniformLocationPointer - oldPointer;
  71965. for (var i = 0; i < diff; i++) {
  71966. this._data.push(0);
  71967. }
  71968. }
  71969. };
  71970. /**
  71971. * Adds an uniform in the buffer.
  71972. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  71973. * for the layout to be correct !
  71974. * @param name Name of the uniform, as used in the uniform block in the shader.
  71975. * @param size Data size, or data directly.
  71976. */
  71977. UniformBuffer.prototype.addUniform = function (name, size) {
  71978. if (this._noUBO) {
  71979. return;
  71980. }
  71981. if (this._uniformLocations[name] !== undefined) {
  71982. // Already existing uniform
  71983. return;
  71984. }
  71985. // This function must be called in the order of the shader layout !
  71986. // size can be the size of the uniform, or data directly
  71987. var data;
  71988. if (size instanceof Array) {
  71989. data = size;
  71990. size = data.length;
  71991. }
  71992. else {
  71993. size = size;
  71994. data = [];
  71995. // Fill with zeros
  71996. for (var i = 0; i < size; i++) {
  71997. data.push(0);
  71998. }
  71999. }
  72000. this._fillAlignment(size);
  72001. this._uniformSizes[name] = size;
  72002. this._uniformLocations[name] = this._uniformLocationPointer;
  72003. this._uniformLocationPointer += size;
  72004. for (var i = 0; i < size; i++) {
  72005. this._data.push(data[i]);
  72006. }
  72007. this._needSync = true;
  72008. };
  72009. /**
  72010. * Adds a Matrix 4x4 to the uniform buffer.
  72011. * @param name Name of the uniform, as used in the uniform block in the shader.
  72012. * @param mat A 4x4 matrix.
  72013. */
  72014. UniformBuffer.prototype.addMatrix = function (name, mat) {
  72015. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  72016. };
  72017. /**
  72018. * Adds a vec2 to the uniform buffer.
  72019. * @param name Name of the uniform, as used in the uniform block in the shader.
  72020. * @param x Define the x component value of the vec2
  72021. * @param y Define the y component value of the vec2
  72022. */
  72023. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  72024. var temp = [x, y];
  72025. this.addUniform(name, temp);
  72026. };
  72027. /**
  72028. * Adds a vec3 to the uniform buffer.
  72029. * @param name Name of the uniform, as used in the uniform block in the shader.
  72030. * @param x Define the x component value of the vec3
  72031. * @param y Define the y component value of the vec3
  72032. * @param z Define the z component value of the vec3
  72033. */
  72034. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  72035. var temp = [x, y, z];
  72036. this.addUniform(name, temp);
  72037. };
  72038. /**
  72039. * Adds a vec3 to the uniform buffer.
  72040. * @param name Name of the uniform, as used in the uniform block in the shader.
  72041. * @param color Define the vec3 from a Color
  72042. */
  72043. UniformBuffer.prototype.addColor3 = function (name, color) {
  72044. var temp = new Array();
  72045. color.toArray(temp);
  72046. this.addUniform(name, temp);
  72047. };
  72048. /**
  72049. * Adds a vec4 to the uniform buffer.
  72050. * @param name Name of the uniform, as used in the uniform block in the shader.
  72051. * @param color Define the rgb components from a Color
  72052. * @param alpha Define the a component of the vec4
  72053. */
  72054. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  72055. var temp = new Array();
  72056. color.toArray(temp);
  72057. temp.push(alpha);
  72058. this.addUniform(name, temp);
  72059. };
  72060. /**
  72061. * Adds a vec3 to the uniform buffer.
  72062. * @param name Name of the uniform, as used in the uniform block in the shader.
  72063. * @param vector Define the vec3 components from a Vector
  72064. */
  72065. UniformBuffer.prototype.addVector3 = function (name, vector) {
  72066. var temp = new Array();
  72067. vector.toArray(temp);
  72068. this.addUniform(name, temp);
  72069. };
  72070. /**
  72071. * Adds a Matrix 3x3 to the uniform buffer.
  72072. * @param name Name of the uniform, as used in the uniform block in the shader.
  72073. */
  72074. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  72075. this.addUniform(name, 12);
  72076. };
  72077. /**
  72078. * Adds a Matrix 2x2 to the uniform buffer.
  72079. * @param name Name of the uniform, as used in the uniform block in the shader.
  72080. */
  72081. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  72082. this.addUniform(name, 8);
  72083. };
  72084. /**
  72085. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  72086. */
  72087. UniformBuffer.prototype.create = function () {
  72088. if (this._noUBO) {
  72089. return;
  72090. }
  72091. if (this._buffer) {
  72092. return; // nothing to do
  72093. }
  72094. // See spec, alignment must be filled as a vec4
  72095. this._fillAlignment(4);
  72096. this._bufferData = new Float32Array(this._data);
  72097. this._rebuild();
  72098. this._needSync = true;
  72099. };
  72100. /** @hidden */
  72101. UniformBuffer.prototype._rebuild = function () {
  72102. if (this._noUBO || !this._bufferData) {
  72103. return;
  72104. }
  72105. if (this._dynamic) {
  72106. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  72107. }
  72108. else {
  72109. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  72110. }
  72111. };
  72112. /**
  72113. * Updates the WebGL Uniform Buffer on the GPU.
  72114. * If the `dynamic` flag is set to true, no cache comparison is done.
  72115. * Otherwise, the buffer will be updated only if the cache differs.
  72116. */
  72117. UniformBuffer.prototype.update = function () {
  72118. if (!this._buffer) {
  72119. this.create();
  72120. return;
  72121. }
  72122. if (!this._dynamic && !this._needSync) {
  72123. return;
  72124. }
  72125. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  72126. this._needSync = false;
  72127. };
  72128. /**
  72129. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  72130. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  72131. * @param data Define the flattened data
  72132. * @param size Define the size of the data.
  72133. */
  72134. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  72135. var location = this._uniformLocations[uniformName];
  72136. if (location === undefined) {
  72137. if (this._buffer) {
  72138. // Cannot add an uniform if the buffer is already created
  72139. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  72140. return;
  72141. }
  72142. this.addUniform(uniformName, size);
  72143. location = this._uniformLocations[uniformName];
  72144. }
  72145. if (!this._buffer) {
  72146. this.create();
  72147. }
  72148. if (!this._dynamic) {
  72149. // Cache for static uniform buffers
  72150. var changed = false;
  72151. for (var i = 0; i < size; i++) {
  72152. if (this._bufferData[location + i] !== data[i]) {
  72153. changed = true;
  72154. this._bufferData[location + i] = data[i];
  72155. }
  72156. }
  72157. this._needSync = this._needSync || changed;
  72158. }
  72159. else {
  72160. // No cache for dynamic
  72161. for (var i = 0; i < size; i++) {
  72162. this._bufferData[location + i] = data[i];
  72163. }
  72164. }
  72165. };
  72166. // Update methods
  72167. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  72168. // To match std140, matrix must be realigned
  72169. for (var i = 0; i < 3; i++) {
  72170. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  72171. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  72172. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  72173. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  72174. }
  72175. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  72176. };
  72177. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  72178. this._currentEffect.setMatrix3x3(name, matrix);
  72179. };
  72180. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  72181. this._currentEffect.setMatrix2x2(name, matrix);
  72182. };
  72183. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  72184. // To match std140, matrix must be realigned
  72185. for (var i = 0; i < 2; i++) {
  72186. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  72187. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  72188. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  72189. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  72190. }
  72191. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  72192. };
  72193. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  72194. this._currentEffect.setFloat(name, x);
  72195. };
  72196. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  72197. UniformBuffer._tempBuffer[0] = x;
  72198. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  72199. };
  72200. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  72201. if (suffix === void 0) { suffix = ""; }
  72202. this._currentEffect.setFloat2(name + suffix, x, y);
  72203. };
  72204. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  72205. UniformBuffer._tempBuffer[0] = x;
  72206. UniformBuffer._tempBuffer[1] = y;
  72207. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  72208. };
  72209. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  72210. if (suffix === void 0) { suffix = ""; }
  72211. this._currentEffect.setFloat3(name + suffix, x, y, z);
  72212. };
  72213. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  72214. UniformBuffer._tempBuffer[0] = x;
  72215. UniformBuffer._tempBuffer[1] = y;
  72216. UniformBuffer._tempBuffer[2] = z;
  72217. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  72218. };
  72219. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  72220. if (suffix === void 0) { suffix = ""; }
  72221. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  72222. };
  72223. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  72224. UniformBuffer._tempBuffer[0] = x;
  72225. UniformBuffer._tempBuffer[1] = y;
  72226. UniformBuffer._tempBuffer[2] = z;
  72227. UniformBuffer._tempBuffer[3] = w;
  72228. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  72229. };
  72230. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  72231. this._currentEffect.setMatrix(name, mat);
  72232. };
  72233. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  72234. this.updateUniform(name, mat.toArray(), 16);
  72235. };
  72236. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  72237. this._currentEffect.setVector3(name, vector);
  72238. };
  72239. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  72240. vector.toArray(UniformBuffer._tempBuffer);
  72241. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  72242. };
  72243. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  72244. this._currentEffect.setVector4(name, vector);
  72245. };
  72246. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  72247. vector.toArray(UniformBuffer._tempBuffer);
  72248. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  72249. };
  72250. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  72251. if (suffix === void 0) { suffix = ""; }
  72252. this._currentEffect.setColor3(name + suffix, color);
  72253. };
  72254. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  72255. color.toArray(UniformBuffer._tempBuffer);
  72256. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  72257. };
  72258. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  72259. if (suffix === void 0) { suffix = ""; }
  72260. this._currentEffect.setColor4(name + suffix, color, alpha);
  72261. };
  72262. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  72263. color.toArray(UniformBuffer._tempBuffer);
  72264. UniformBuffer._tempBuffer[3] = alpha;
  72265. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  72266. };
  72267. /**
  72268. * Sets a sampler uniform on the effect.
  72269. * @param name Define the name of the sampler.
  72270. * @param texture Define the texture to set in the sampler
  72271. */
  72272. UniformBuffer.prototype.setTexture = function (name, texture) {
  72273. this._currentEffect.setTexture(name, texture);
  72274. };
  72275. /**
  72276. * Directly updates the value of the uniform in the cache AND on the GPU.
  72277. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  72278. * @param data Define the flattened data
  72279. */
  72280. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  72281. this.updateUniform(uniformName, data, data.length);
  72282. this.update();
  72283. };
  72284. /**
  72285. * Binds this uniform buffer to an effect.
  72286. * @param effect Define the effect to bind the buffer to
  72287. * @param name Name of the uniform block in the shader.
  72288. */
  72289. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  72290. this._currentEffect = effect;
  72291. if (this._noUBO || !this._buffer) {
  72292. return;
  72293. }
  72294. effect.bindUniformBuffer(this._buffer, name);
  72295. };
  72296. /**
  72297. * Disposes the uniform buffer.
  72298. */
  72299. UniformBuffer.prototype.dispose = function () {
  72300. if (this._noUBO) {
  72301. return;
  72302. }
  72303. var uniformBuffers = this._engine._uniformBuffers;
  72304. var index = uniformBuffers.indexOf(this);
  72305. if (index !== -1) {
  72306. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  72307. uniformBuffers.pop();
  72308. }
  72309. if (!this._buffer) {
  72310. return;
  72311. }
  72312. if (this._engine._releaseBuffer(this._buffer)) {
  72313. this._buffer = null;
  72314. }
  72315. };
  72316. // Pool for avoiding memory leaks
  72317. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  72318. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  72319. return UniformBuffer;
  72320. }());
  72321. /***/ }),
  72322. /***/ "./Maths/index.ts":
  72323. /*!************************!*\
  72324. !*** ./Maths/index.ts ***!
  72325. \************************/
  72326. /*! 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, SphericalHarmonics, SphericalPolynomial */
  72327. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  72328. "use strict";
  72329. __webpack_require__.r(__webpack_exports__);
  72330. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  72331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  72332. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  72333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  72334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  72335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  72336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  72337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  72338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  72339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  72340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  72341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  72342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  72343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  72344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  72345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  72346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  72347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  72348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  72349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  72350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  72351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  72352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  72353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  72354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  72355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  72356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  72357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  72358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  72359. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  72360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  72361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  72362. /***/ }),
  72363. /***/ "./Maths/math.scalar.ts":
  72364. /*!******************************!*\
  72365. !*** ./Maths/math.scalar.ts ***!
  72366. \******************************/
  72367. /*! exports provided: Scalar */
  72368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  72369. "use strict";
  72370. __webpack_require__.r(__webpack_exports__);
  72371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  72372. /**
  72373. * Scalar computation library
  72374. */
  72375. var Scalar = /** @class */ (function () {
  72376. function Scalar() {
  72377. }
  72378. /**
  72379. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72380. * @param a number
  72381. * @param b number
  72382. * @param epsilon (default = 1.401298E-45)
  72383. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72384. */
  72385. Scalar.WithinEpsilon = function (a, b, epsilon) {
  72386. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  72387. var num = a - b;
  72388. return -epsilon <= num && num <= epsilon;
  72389. };
  72390. /**
  72391. * Returns a string : the upper case translation of the number i to hexadecimal.
  72392. * @param i number
  72393. * @returns the upper case translation of the number i to hexadecimal.
  72394. */
  72395. Scalar.ToHex = function (i) {
  72396. var str = i.toString(16);
  72397. if (i <= 15) {
  72398. return ("0" + str).toUpperCase();
  72399. }
  72400. return str.toUpperCase();
  72401. };
  72402. /**
  72403. * Returns -1 if value is negative and +1 is value is positive.
  72404. * @param value the value
  72405. * @returns the value itself if it's equal to zero.
  72406. */
  72407. Scalar.Sign = function (value) {
  72408. value = +value; // convert to a number
  72409. if (value === 0 || isNaN(value)) {
  72410. return value;
  72411. }
  72412. return value > 0 ? 1 : -1;
  72413. };
  72414. /**
  72415. * Returns the value itself if it's between min and max.
  72416. * Returns min if the value is lower than min.
  72417. * Returns max if the value is greater than max.
  72418. * @param value the value to clmap
  72419. * @param min the min value to clamp to (default: 0)
  72420. * @param max the max value to clamp to (default: 1)
  72421. * @returns the clamped value
  72422. */
  72423. Scalar.Clamp = function (value, min, max) {
  72424. if (min === void 0) { min = 0; }
  72425. if (max === void 0) { max = 1; }
  72426. return Math.min(max, Math.max(min, value));
  72427. };
  72428. /**
  72429. * the log2 of value.
  72430. * @param value the value to compute log2 of
  72431. * @returns the log2 of value.
  72432. */
  72433. Scalar.Log2 = function (value) {
  72434. return Math.log(value) * Math.LOG2E;
  72435. };
  72436. /**
  72437. * Loops the value, so that it is never larger than length and never smaller than 0.
  72438. *
  72439. * This is similar to the modulo operator but it works with floating point numbers.
  72440. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  72441. * With t = 5 and length = 2.5, the result would be 0.0.
  72442. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  72443. * @param value the value
  72444. * @param length the length
  72445. * @returns the looped value
  72446. */
  72447. Scalar.Repeat = function (value, length) {
  72448. return value - Math.floor(value / length) * length;
  72449. };
  72450. /**
  72451. * Normalize the value between 0.0 and 1.0 using min and max values
  72452. * @param value value to normalize
  72453. * @param min max to normalize between
  72454. * @param max min to normalize between
  72455. * @returns the normalized value
  72456. */
  72457. Scalar.Normalize = function (value, min, max) {
  72458. return (value - min) / (max - min);
  72459. };
  72460. /**
  72461. * Denormalize the value from 0.0 and 1.0 using min and max values
  72462. * @param normalized value to denormalize
  72463. * @param min max to denormalize between
  72464. * @param max min to denormalize between
  72465. * @returns the denormalized value
  72466. */
  72467. Scalar.Denormalize = function (normalized, min, max) {
  72468. return (normalized * (max - min) + min);
  72469. };
  72470. /**
  72471. * Calculates the shortest difference between two given angles given in degrees.
  72472. * @param current current angle in degrees
  72473. * @param target target angle in degrees
  72474. * @returns the delta
  72475. */
  72476. Scalar.DeltaAngle = function (current, target) {
  72477. var num = Scalar.Repeat(target - current, 360.0);
  72478. if (num > 180.0) {
  72479. num -= 360.0;
  72480. }
  72481. return num;
  72482. };
  72483. /**
  72484. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  72485. * @param tx value
  72486. * @param length length
  72487. * @returns The returned value will move back and forth between 0 and length
  72488. */
  72489. Scalar.PingPong = function (tx, length) {
  72490. var t = Scalar.Repeat(tx, length * 2.0);
  72491. return length - Math.abs(t - length);
  72492. };
  72493. /**
  72494. * Interpolates between min and max with smoothing at the limits.
  72495. *
  72496. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  72497. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  72498. * @param from from
  72499. * @param to to
  72500. * @param tx value
  72501. * @returns the smooth stepped value
  72502. */
  72503. Scalar.SmoothStep = function (from, to, tx) {
  72504. var t = Scalar.Clamp(tx);
  72505. t = -2.0 * t * t * t + 3.0 * t * t;
  72506. return to * t + from * (1.0 - t);
  72507. };
  72508. /**
  72509. * Moves a value current towards target.
  72510. *
  72511. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  72512. * Negative values of maxDelta pushes the value away from target.
  72513. * @param current current value
  72514. * @param target target value
  72515. * @param maxDelta max distance to move
  72516. * @returns resulting value
  72517. */
  72518. Scalar.MoveTowards = function (current, target, maxDelta) {
  72519. var result = 0;
  72520. if (Math.abs(target - current) <= maxDelta) {
  72521. result = target;
  72522. }
  72523. else {
  72524. result = current + Scalar.Sign(target - current) * maxDelta;
  72525. }
  72526. return result;
  72527. };
  72528. /**
  72529. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72530. *
  72531. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  72532. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  72533. * @param current current value
  72534. * @param target target value
  72535. * @param maxDelta max distance to move
  72536. * @returns resulting angle
  72537. */
  72538. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  72539. var num = Scalar.DeltaAngle(current, target);
  72540. var result = 0;
  72541. if (-maxDelta < num && num < maxDelta) {
  72542. result = target;
  72543. }
  72544. else {
  72545. target = current + num;
  72546. result = Scalar.MoveTowards(current, target, maxDelta);
  72547. }
  72548. return result;
  72549. };
  72550. /**
  72551. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  72552. * @param start start value
  72553. * @param end target value
  72554. * @param amount amount to lerp between
  72555. * @returns the lerped value
  72556. */
  72557. Scalar.Lerp = function (start, end, amount) {
  72558. return start + ((end - start) * amount);
  72559. };
  72560. /**
  72561. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72562. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  72563. * @param start start value
  72564. * @param end target value
  72565. * @param amount amount to lerp between
  72566. * @returns the lerped value
  72567. */
  72568. Scalar.LerpAngle = function (start, end, amount) {
  72569. var num = Scalar.Repeat(end - start, 360.0);
  72570. if (num > 180.0) {
  72571. num -= 360.0;
  72572. }
  72573. return start + num * Scalar.Clamp(amount);
  72574. };
  72575. /**
  72576. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  72577. * @param a start value
  72578. * @param b target value
  72579. * @param value value between a and b
  72580. * @returns the inverseLerp value
  72581. */
  72582. Scalar.InverseLerp = function (a, b, value) {
  72583. var result = 0;
  72584. if (a != b) {
  72585. result = Scalar.Clamp((value - a) / (b - a));
  72586. }
  72587. else {
  72588. result = 0.0;
  72589. }
  72590. return result;
  72591. };
  72592. /**
  72593. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  72594. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  72595. * @param value1 spline value
  72596. * @param tangent1 spline value
  72597. * @param value2 spline value
  72598. * @param tangent2 spline value
  72599. * @param amount input value
  72600. * @returns hermite result
  72601. */
  72602. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  72603. var squared = amount * amount;
  72604. var cubed = amount * squared;
  72605. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  72606. var part2 = (-2.0 * cubed) + (3.0 * squared);
  72607. var part3 = (cubed - (2.0 * squared)) + amount;
  72608. var part4 = cubed - squared;
  72609. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  72610. };
  72611. /**
  72612. * Returns a random float number between and min and max values
  72613. * @param min min value of random
  72614. * @param max max value of random
  72615. * @returns random value
  72616. */
  72617. Scalar.RandomRange = function (min, max) {
  72618. if (min === max) {
  72619. return min;
  72620. }
  72621. return ((Math.random() * (max - min)) + min);
  72622. };
  72623. /**
  72624. * This function returns percentage of a number in a given range.
  72625. *
  72626. * RangeToPercent(40,20,60) will return 0.5 (50%)
  72627. * RangeToPercent(34,0,100) will return 0.34 (34%)
  72628. * @param number to convert to percentage
  72629. * @param min min range
  72630. * @param max max range
  72631. * @returns the percentage
  72632. */
  72633. Scalar.RangeToPercent = function (number, min, max) {
  72634. return ((number - min) / (max - min));
  72635. };
  72636. /**
  72637. * This function returns number that corresponds to the percentage in a given range.
  72638. *
  72639. * PercentToRange(0.34,0,100) will return 34.
  72640. * @param percent to convert to number
  72641. * @param min min range
  72642. * @param max max range
  72643. * @returns the number
  72644. */
  72645. Scalar.PercentToRange = function (percent, min, max) {
  72646. return ((max - min) * percent + min);
  72647. };
  72648. /**
  72649. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  72650. * @param angle The angle to normalize in radian.
  72651. * @return The converted angle.
  72652. */
  72653. Scalar.NormalizeRadians = function (angle) {
  72654. // More precise but slower version kept for reference.
  72655. // angle = angle % Tools.TwoPi;
  72656. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  72657. //if (angle > Math.PI) {
  72658. // angle -= Tools.TwoPi;
  72659. //}
  72660. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  72661. return angle;
  72662. };
  72663. /**
  72664. * Two pi constants convenient for computation.
  72665. */
  72666. Scalar.TwoPi = Math.PI * 2;
  72667. return Scalar;
  72668. }());
  72669. /***/ }),
  72670. /***/ "./Maths/math.ts":
  72671. /*!***********************!*\
  72672. !*** ./Maths/math.ts ***!
  72673. \***********************/
  72674. /*! 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 */
  72675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  72676. "use strict";
  72677. __webpack_require__.r(__webpack_exports__);
  72678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  72679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  72680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  72681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  72682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  72683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  72684. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  72685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  72686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  72687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  72688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  72689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  72690. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  72691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  72692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  72693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  72694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  72695. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  72696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  72697. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  72698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  72699. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  72700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  72701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  72702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  72703. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  72704. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  72705. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  72706. /**
  72707. * Constant used to convert a value to gamma space
  72708. * @ignorenaming
  72709. */
  72710. var ToGammaSpace = 1 / 2.2;
  72711. /**
  72712. * Constant used to convert a value to linear space
  72713. * @ignorenaming
  72714. */
  72715. var ToLinearSpace = 2.2;
  72716. /**
  72717. * Constant used to define the minimal number value in Babylon.js
  72718. * @ignorenaming
  72719. */
  72720. var Epsilon = 0.001;
  72721. /**
  72722. * Class used to hold a RBG color
  72723. */
  72724. var Color3 = /** @class */ (function () {
  72725. /**
  72726. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  72727. * @param r defines the red component (between 0 and 1, default is 0)
  72728. * @param g defines the green component (between 0 and 1, default is 0)
  72729. * @param b defines the blue component (between 0 and 1, default is 0)
  72730. */
  72731. function Color3(
  72732. /**
  72733. * Defines the red component (between 0 and 1, default is 0)
  72734. */
  72735. r,
  72736. /**
  72737. * Defines the green component (between 0 and 1, default is 0)
  72738. */
  72739. g,
  72740. /**
  72741. * Defines the blue component (between 0 and 1, default is 0)
  72742. */
  72743. b) {
  72744. if (r === void 0) { r = 0; }
  72745. if (g === void 0) { g = 0; }
  72746. if (b === void 0) { b = 0; }
  72747. this.r = r;
  72748. this.g = g;
  72749. this.b = b;
  72750. }
  72751. /**
  72752. * Creates a string with the Color3 current values
  72753. * @returns the string representation of the Color3 object
  72754. */
  72755. Color3.prototype.toString = function () {
  72756. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  72757. };
  72758. /**
  72759. * Returns the string "Color3"
  72760. * @returns "Color3"
  72761. */
  72762. Color3.prototype.getClassName = function () {
  72763. return "Color3";
  72764. };
  72765. /**
  72766. * Compute the Color3 hash code
  72767. * @returns an unique number that can be used to hash Color3 objects
  72768. */
  72769. Color3.prototype.getHashCode = function () {
  72770. var hash = this.r || 0;
  72771. hash = (hash * 397) ^ (this.g || 0);
  72772. hash = (hash * 397) ^ (this.b || 0);
  72773. return hash;
  72774. };
  72775. // Operators
  72776. /**
  72777. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  72778. * @param array defines the array where to store the r,g,b components
  72779. * @param index defines an optional index in the target array to define where to start storing values
  72780. * @returns the current Color3 object
  72781. */
  72782. Color3.prototype.toArray = function (array, index) {
  72783. if (index === void 0) { index = 0; }
  72784. array[index] = this.r;
  72785. array[index + 1] = this.g;
  72786. array[index + 2] = this.b;
  72787. return this;
  72788. };
  72789. /**
  72790. * Returns a new Color4 object from the current Color3 and the given alpha
  72791. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  72792. * @returns a new Color4 object
  72793. */
  72794. Color3.prototype.toColor4 = function (alpha) {
  72795. if (alpha === void 0) { alpha = 1; }
  72796. return new Color4(this.r, this.g, this.b, alpha);
  72797. };
  72798. /**
  72799. * Returns a new array populated with 3 numeric elements : red, green and blue values
  72800. * @returns the new array
  72801. */
  72802. Color3.prototype.asArray = function () {
  72803. var result = new Array();
  72804. this.toArray(result, 0);
  72805. return result;
  72806. };
  72807. /**
  72808. * Returns the luminance value
  72809. * @returns a float value
  72810. */
  72811. Color3.prototype.toLuminance = function () {
  72812. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  72813. };
  72814. /**
  72815. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  72816. * @param otherColor defines the second operand
  72817. * @returns the new Color3 object
  72818. */
  72819. Color3.prototype.multiply = function (otherColor) {
  72820. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  72821. };
  72822. /**
  72823. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  72824. * @param otherColor defines the second operand
  72825. * @param result defines the Color3 object where to store the result
  72826. * @returns the current Color3
  72827. */
  72828. Color3.prototype.multiplyToRef = function (otherColor, result) {
  72829. result.r = this.r * otherColor.r;
  72830. result.g = this.g * otherColor.g;
  72831. result.b = this.b * otherColor.b;
  72832. return this;
  72833. };
  72834. /**
  72835. * Determines equality between Color3 objects
  72836. * @param otherColor defines the second operand
  72837. * @returns true if the rgb values are equal to the given ones
  72838. */
  72839. Color3.prototype.equals = function (otherColor) {
  72840. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  72841. };
  72842. /**
  72843. * Determines equality between the current Color3 object and a set of r,b,g values
  72844. * @param r defines the red component to check
  72845. * @param g defines the green component to check
  72846. * @param b defines the blue component to check
  72847. * @returns true if the rgb values are equal to the given ones
  72848. */
  72849. Color3.prototype.equalsFloats = function (r, g, b) {
  72850. return this.r === r && this.g === g && this.b === b;
  72851. };
  72852. /**
  72853. * Multiplies in place each rgb value by scale
  72854. * @param scale defines the scaling factor
  72855. * @returns the updated Color3
  72856. */
  72857. Color3.prototype.scale = function (scale) {
  72858. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  72859. };
  72860. /**
  72861. * Multiplies the rgb values by scale and stores the result into "result"
  72862. * @param scale defines the scaling factor
  72863. * @param result defines the Color3 object where to store the result
  72864. * @returns the unmodified current Color3
  72865. */
  72866. Color3.prototype.scaleToRef = function (scale, result) {
  72867. result.r = this.r * scale;
  72868. result.g = this.g * scale;
  72869. result.b = this.b * scale;
  72870. return this;
  72871. };
  72872. /**
  72873. * Scale the current Color3 values by a factor and add the result to a given Color3
  72874. * @param scale defines the scale factor
  72875. * @param result defines color to store the result into
  72876. * @returns the unmodified current Color3
  72877. */
  72878. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  72879. result.r += this.r * scale;
  72880. result.g += this.g * scale;
  72881. result.b += this.b * scale;
  72882. return this;
  72883. };
  72884. /**
  72885. * Clamps the rgb values by the min and max values and stores the result into "result"
  72886. * @param min defines minimum clamping value (default is 0)
  72887. * @param max defines maximum clamping value (default is 1)
  72888. * @param result defines color to store the result into
  72889. * @returns the original Color3
  72890. */
  72891. Color3.prototype.clampToRef = function (min, max, result) {
  72892. if (min === void 0) { min = 0; }
  72893. if (max === void 0) { max = 1; }
  72894. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  72895. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  72896. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  72897. return this;
  72898. };
  72899. /**
  72900. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72901. * @param otherColor defines the second operand
  72902. * @returns the new Color3
  72903. */
  72904. Color3.prototype.add = function (otherColor) {
  72905. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  72906. };
  72907. /**
  72908. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72909. * @param otherColor defines the second operand
  72910. * @param result defines Color3 object to store the result into
  72911. * @returns the unmodified current Color3
  72912. */
  72913. Color3.prototype.addToRef = function (otherColor, result) {
  72914. result.r = this.r + otherColor.r;
  72915. result.g = this.g + otherColor.g;
  72916. result.b = this.b + otherColor.b;
  72917. return this;
  72918. };
  72919. /**
  72920. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72921. * @param otherColor defines the second operand
  72922. * @returns the new Color3
  72923. */
  72924. Color3.prototype.subtract = function (otherColor) {
  72925. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  72926. };
  72927. /**
  72928. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72929. * @param otherColor defines the second operand
  72930. * @param result defines Color3 object to store the result into
  72931. * @returns the unmodified current Color3
  72932. */
  72933. Color3.prototype.subtractToRef = function (otherColor, result) {
  72934. result.r = this.r - otherColor.r;
  72935. result.g = this.g - otherColor.g;
  72936. result.b = this.b - otherColor.b;
  72937. return this;
  72938. };
  72939. /**
  72940. * Copy the current object
  72941. * @returns a new Color3 copied the current one
  72942. */
  72943. Color3.prototype.clone = function () {
  72944. return new Color3(this.r, this.g, this.b);
  72945. };
  72946. /**
  72947. * Copies the rgb values from the source in the current Color3
  72948. * @param source defines the source Color3 object
  72949. * @returns the updated Color3 object
  72950. */
  72951. Color3.prototype.copyFrom = function (source) {
  72952. this.r = source.r;
  72953. this.g = source.g;
  72954. this.b = source.b;
  72955. return this;
  72956. };
  72957. /**
  72958. * Updates the Color3 rgb values from the given floats
  72959. * @param r defines the red component to read from
  72960. * @param g defines the green component to read from
  72961. * @param b defines the blue component to read from
  72962. * @returns the current Color3 object
  72963. */
  72964. Color3.prototype.copyFromFloats = function (r, g, b) {
  72965. this.r = r;
  72966. this.g = g;
  72967. this.b = b;
  72968. return this;
  72969. };
  72970. /**
  72971. * Updates the Color3 rgb values from the given floats
  72972. * @param r defines the red component to read from
  72973. * @param g defines the green component to read from
  72974. * @param b defines the blue component to read from
  72975. * @returns the current Color3 object
  72976. */
  72977. Color3.prototype.set = function (r, g, b) {
  72978. return this.copyFromFloats(r, g, b);
  72979. };
  72980. /**
  72981. * Compute the Color3 hexadecimal code as a string
  72982. * @returns a string containing the hexadecimal representation of the Color3 object
  72983. */
  72984. Color3.prototype.toHexString = function () {
  72985. var intR = (this.r * 255) | 0;
  72986. var intG = (this.g * 255) | 0;
  72987. var intB = (this.b * 255) | 0;
  72988. 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);
  72989. };
  72990. /**
  72991. * Computes a new Color3 converted from the current one to linear space
  72992. * @returns a new Color3 object
  72993. */
  72994. Color3.prototype.toLinearSpace = function () {
  72995. var convertedColor = new Color3();
  72996. this.toLinearSpaceToRef(convertedColor);
  72997. return convertedColor;
  72998. };
  72999. /**
  73000. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  73001. * @param convertedColor defines the Color3 object where to store the linear space version
  73002. * @returns the unmodified Color3
  73003. */
  73004. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  73005. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  73006. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  73007. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  73008. return this;
  73009. };
  73010. /**
  73011. * Computes a new Color3 converted from the current one to gamma space
  73012. * @returns a new Color3 object
  73013. */
  73014. Color3.prototype.toGammaSpace = function () {
  73015. var convertedColor = new Color3();
  73016. this.toGammaSpaceToRef(convertedColor);
  73017. return convertedColor;
  73018. };
  73019. /**
  73020. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73021. * @param convertedColor defines the Color3 object where to store the gamma space version
  73022. * @returns the unmodified Color3
  73023. */
  73024. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  73025. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  73026. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  73027. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  73028. return this;
  73029. };
  73030. /**
  73031. * Creates a new Color3 from the string containing valid hexadecimal values
  73032. * @param hex defines a string containing valid hexadecimal values
  73033. * @returns a new Color3 object
  73034. */
  73035. Color3.FromHexString = function (hex) {
  73036. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  73037. return new Color3(0, 0, 0);
  73038. }
  73039. var r = parseInt(hex.substring(1, 3), 16);
  73040. var g = parseInt(hex.substring(3, 5), 16);
  73041. var b = parseInt(hex.substring(5, 7), 16);
  73042. return Color3.FromInts(r, g, b);
  73043. };
  73044. /**
  73045. * Creates a new Color3 from the starting index of the given array
  73046. * @param array defines the source array
  73047. * @param offset defines an offset in the source array
  73048. * @returns a new Color3 object
  73049. */
  73050. Color3.FromArray = function (array, offset) {
  73051. if (offset === void 0) { offset = 0; }
  73052. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  73053. };
  73054. /**
  73055. * Creates a new Color3 from integer values (< 256)
  73056. * @param r defines the red component to read from (value between 0 and 255)
  73057. * @param g defines the green component to read from (value between 0 and 255)
  73058. * @param b defines the blue component to read from (value between 0 and 255)
  73059. * @returns a new Color3 object
  73060. */
  73061. Color3.FromInts = function (r, g, b) {
  73062. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  73063. };
  73064. /**
  73065. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73066. * @param start defines the start Color3 value
  73067. * @param end defines the end Color3 value
  73068. * @param amount defines the gradient value between start and end
  73069. * @returns a new Color3 object
  73070. */
  73071. Color3.Lerp = function (start, end, amount) {
  73072. var result = new Color3(0.0, 0.0, 0.0);
  73073. Color3.LerpToRef(start, end, amount, result);
  73074. return result;
  73075. };
  73076. /**
  73077. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73078. * @param left defines the start value
  73079. * @param right defines the end value
  73080. * @param amount defines the gradient factor
  73081. * @param result defines the Color3 object where to store the result
  73082. */
  73083. Color3.LerpToRef = function (left, right, amount, result) {
  73084. result.r = left.r + ((right.r - left.r) * amount);
  73085. result.g = left.g + ((right.g - left.g) * amount);
  73086. result.b = left.b + ((right.b - left.b) * amount);
  73087. };
  73088. /**
  73089. * Returns a Color3 value containing a red color
  73090. * @returns a new Color3 object
  73091. */
  73092. Color3.Red = function () { return new Color3(1, 0, 0); };
  73093. /**
  73094. * Returns a Color3 value containing a green color
  73095. * @returns a new Color3 object
  73096. */
  73097. Color3.Green = function () { return new Color3(0, 1, 0); };
  73098. /**
  73099. * Returns a Color3 value containing a blue color
  73100. * @returns a new Color3 object
  73101. */
  73102. Color3.Blue = function () { return new Color3(0, 0, 1); };
  73103. /**
  73104. * Returns a Color3 value containing a black color
  73105. * @returns a new Color3 object
  73106. */
  73107. Color3.Black = function () { return new Color3(0, 0, 0); };
  73108. Object.defineProperty(Color3, "BlackReadOnly", {
  73109. /**
  73110. * Gets a Color3 value containing a black color that must not be updated
  73111. */
  73112. get: function () {
  73113. return Color3._BlackReadOnly;
  73114. },
  73115. enumerable: true,
  73116. configurable: true
  73117. });
  73118. /**
  73119. * Returns a Color3 value containing a white color
  73120. * @returns a new Color3 object
  73121. */
  73122. Color3.White = function () { return new Color3(1, 1, 1); };
  73123. /**
  73124. * Returns a Color3 value containing a purple color
  73125. * @returns a new Color3 object
  73126. */
  73127. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  73128. /**
  73129. * Returns a Color3 value containing a magenta color
  73130. * @returns a new Color3 object
  73131. */
  73132. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  73133. /**
  73134. * Returns a Color3 value containing a yellow color
  73135. * @returns a new Color3 object
  73136. */
  73137. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  73138. /**
  73139. * Returns a Color3 value containing a gray color
  73140. * @returns a new Color3 object
  73141. */
  73142. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  73143. /**
  73144. * Returns a Color3 value containing a teal color
  73145. * @returns a new Color3 object
  73146. */
  73147. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  73148. /**
  73149. * Returns a Color3 value containing a random color
  73150. * @returns a new Color3 object
  73151. */
  73152. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  73153. // Statics
  73154. Color3._BlackReadOnly = Color3.Black();
  73155. return Color3;
  73156. }());
  73157. /**
  73158. * Class used to hold a RBGA color
  73159. */
  73160. var Color4 = /** @class */ (function () {
  73161. /**
  73162. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  73163. * @param r defines the red component (between 0 and 1, default is 0)
  73164. * @param g defines the green component (between 0 and 1, default is 0)
  73165. * @param b defines the blue component (between 0 and 1, default is 0)
  73166. * @param a defines the alpha component (between 0 and 1, default is 1)
  73167. */
  73168. function Color4(
  73169. /**
  73170. * Defines the red component (between 0 and 1, default is 0)
  73171. */
  73172. r,
  73173. /**
  73174. * Defines the green component (between 0 and 1, default is 0)
  73175. */
  73176. g,
  73177. /**
  73178. * Defines the blue component (between 0 and 1, default is 0)
  73179. */
  73180. b,
  73181. /**
  73182. * Defines the alpha component (between 0 and 1, default is 1)
  73183. */
  73184. a) {
  73185. if (r === void 0) { r = 0; }
  73186. if (g === void 0) { g = 0; }
  73187. if (b === void 0) { b = 0; }
  73188. if (a === void 0) { a = 1; }
  73189. this.r = r;
  73190. this.g = g;
  73191. this.b = b;
  73192. this.a = a;
  73193. }
  73194. // Operators
  73195. /**
  73196. * Adds in place the given Color4 values to the current Color4 object
  73197. * @param right defines the second operand
  73198. * @returns the current updated Color4 object
  73199. */
  73200. Color4.prototype.addInPlace = function (right) {
  73201. this.r += right.r;
  73202. this.g += right.g;
  73203. this.b += right.b;
  73204. this.a += right.a;
  73205. return this;
  73206. };
  73207. /**
  73208. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  73209. * @returns the new array
  73210. */
  73211. Color4.prototype.asArray = function () {
  73212. var result = new Array();
  73213. this.toArray(result, 0);
  73214. return result;
  73215. };
  73216. /**
  73217. * Stores from the starting index in the given array the Color4 successive values
  73218. * @param array defines the array where to store the r,g,b components
  73219. * @param index defines an optional index in the target array to define where to start storing values
  73220. * @returns the current Color4 object
  73221. */
  73222. Color4.prototype.toArray = function (array, index) {
  73223. if (index === void 0) { index = 0; }
  73224. array[index] = this.r;
  73225. array[index + 1] = this.g;
  73226. array[index + 2] = this.b;
  73227. array[index + 3] = this.a;
  73228. return this;
  73229. };
  73230. /**
  73231. * Determines equality between Color4 objects
  73232. * @param otherColor defines the second operand
  73233. * @returns true if the rgba values are equal to the given ones
  73234. */
  73235. Color4.prototype.equals = function (otherColor) {
  73236. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  73237. };
  73238. /**
  73239. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  73240. * @param right defines the second operand
  73241. * @returns a new Color4 object
  73242. */
  73243. Color4.prototype.add = function (right) {
  73244. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  73245. };
  73246. /**
  73247. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  73248. * @param right defines the second operand
  73249. * @returns a new Color4 object
  73250. */
  73251. Color4.prototype.subtract = function (right) {
  73252. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  73253. };
  73254. /**
  73255. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  73256. * @param right defines the second operand
  73257. * @param result defines the Color4 object where to store the result
  73258. * @returns the current Color4 object
  73259. */
  73260. Color4.prototype.subtractToRef = function (right, result) {
  73261. result.r = this.r - right.r;
  73262. result.g = this.g - right.g;
  73263. result.b = this.b - right.b;
  73264. result.a = this.a - right.a;
  73265. return this;
  73266. };
  73267. /**
  73268. * Creates a new Color4 with the current Color4 values multiplied by scale
  73269. * @param scale defines the scaling factor to apply
  73270. * @returns a new Color4 object
  73271. */
  73272. Color4.prototype.scale = function (scale) {
  73273. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  73274. };
  73275. /**
  73276. * Multiplies the current Color4 values by scale and stores the result in "result"
  73277. * @param scale defines the scaling factor to apply
  73278. * @param result defines the Color4 object where to store the result
  73279. * @returns the current unmodified Color4
  73280. */
  73281. Color4.prototype.scaleToRef = function (scale, result) {
  73282. result.r = this.r * scale;
  73283. result.g = this.g * scale;
  73284. result.b = this.b * scale;
  73285. result.a = this.a * scale;
  73286. return this;
  73287. };
  73288. /**
  73289. * Scale the current Color4 values by a factor and add the result to a given Color4
  73290. * @param scale defines the scale factor
  73291. * @param result defines the Color4 object where to store the result
  73292. * @returns the unmodified current Color4
  73293. */
  73294. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  73295. result.r += this.r * scale;
  73296. result.g += this.g * scale;
  73297. result.b += this.b * scale;
  73298. result.a += this.a * scale;
  73299. return this;
  73300. };
  73301. /**
  73302. * Clamps the rgb values by the min and max values and stores the result into "result"
  73303. * @param min defines minimum clamping value (default is 0)
  73304. * @param max defines maximum clamping value (default is 1)
  73305. * @param result defines color to store the result into.
  73306. * @returns the cuurent Color4
  73307. */
  73308. Color4.prototype.clampToRef = function (min, max, result) {
  73309. if (min === void 0) { min = 0; }
  73310. if (max === void 0) { max = 1; }
  73311. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  73312. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  73313. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  73314. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  73315. return this;
  73316. };
  73317. /**
  73318. * Multipy an Color4 value by another and return a new Color4 object
  73319. * @param color defines the Color4 value to multiply by
  73320. * @returns a new Color4 object
  73321. */
  73322. Color4.prototype.multiply = function (color) {
  73323. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  73324. };
  73325. /**
  73326. * Multipy a Color4 value by another and push the result in a reference value
  73327. * @param color defines the Color4 value to multiply by
  73328. * @param result defines the Color4 to fill the result in
  73329. * @returns the result Color4
  73330. */
  73331. Color4.prototype.multiplyToRef = function (color, result) {
  73332. result.r = this.r * color.r;
  73333. result.g = this.g * color.g;
  73334. result.b = this.b * color.b;
  73335. result.a = this.a * color.a;
  73336. return result;
  73337. };
  73338. /**
  73339. * Creates a string with the Color4 current values
  73340. * @returns the string representation of the Color4 object
  73341. */
  73342. Color4.prototype.toString = function () {
  73343. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  73344. };
  73345. /**
  73346. * Returns the string "Color4"
  73347. * @returns "Color4"
  73348. */
  73349. Color4.prototype.getClassName = function () {
  73350. return "Color4";
  73351. };
  73352. /**
  73353. * Compute the Color4 hash code
  73354. * @returns an unique number that can be used to hash Color4 objects
  73355. */
  73356. Color4.prototype.getHashCode = function () {
  73357. var hash = this.r || 0;
  73358. hash = (hash * 397) ^ (this.g || 0);
  73359. hash = (hash * 397) ^ (this.b || 0);
  73360. hash = (hash * 397) ^ (this.a || 0);
  73361. return hash;
  73362. };
  73363. /**
  73364. * Creates a new Color4 copied from the current one
  73365. * @returns a new Color4 object
  73366. */
  73367. Color4.prototype.clone = function () {
  73368. return new Color4(this.r, this.g, this.b, this.a);
  73369. };
  73370. /**
  73371. * Copies the given Color4 values into the current one
  73372. * @param source defines the source Color4 object
  73373. * @returns the current updated Color4 object
  73374. */
  73375. Color4.prototype.copyFrom = function (source) {
  73376. this.r = source.r;
  73377. this.g = source.g;
  73378. this.b = source.b;
  73379. this.a = source.a;
  73380. return this;
  73381. };
  73382. /**
  73383. * Copies the given float values into the current one
  73384. * @param r defines the red component to read from
  73385. * @param g defines the green component to read from
  73386. * @param b defines the blue component to read from
  73387. * @param a defines the alpha component to read from
  73388. * @returns the current updated Color4 object
  73389. */
  73390. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  73391. this.r = r;
  73392. this.g = g;
  73393. this.b = b;
  73394. this.a = a;
  73395. return this;
  73396. };
  73397. /**
  73398. * Copies the given float values into the current one
  73399. * @param r defines the red component to read from
  73400. * @param g defines the green component to read from
  73401. * @param b defines the blue component to read from
  73402. * @param a defines the alpha component to read from
  73403. * @returns the current updated Color4 object
  73404. */
  73405. Color4.prototype.set = function (r, g, b, a) {
  73406. return this.copyFromFloats(r, g, b, a);
  73407. };
  73408. /**
  73409. * Compute the Color4 hexadecimal code as a string
  73410. * @returns a string containing the hexadecimal representation of the Color4 object
  73411. */
  73412. Color4.prototype.toHexString = function () {
  73413. var intR = (this.r * 255) | 0;
  73414. var intG = (this.g * 255) | 0;
  73415. var intB = (this.b * 255) | 0;
  73416. var intA = (this.a * 255) | 0;
  73417. 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);
  73418. };
  73419. /**
  73420. * Computes a new Color4 converted from the current one to linear space
  73421. * @returns a new Color4 object
  73422. */
  73423. Color4.prototype.toLinearSpace = function () {
  73424. var convertedColor = new Color4();
  73425. this.toLinearSpaceToRef(convertedColor);
  73426. return convertedColor;
  73427. };
  73428. /**
  73429. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73430. * @param convertedColor defines the Color4 object where to store the linear space version
  73431. * @returns the unmodified Color4
  73432. */
  73433. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  73434. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  73435. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  73436. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  73437. convertedColor.a = this.a;
  73438. return this;
  73439. };
  73440. /**
  73441. * Computes a new Color4 converted from the current one to gamma space
  73442. * @returns a new Color4 object
  73443. */
  73444. Color4.prototype.toGammaSpace = function () {
  73445. var convertedColor = new Color4();
  73446. this.toGammaSpaceToRef(convertedColor);
  73447. return convertedColor;
  73448. };
  73449. /**
  73450. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73451. * @param convertedColor defines the Color4 object where to store the gamma space version
  73452. * @returns the unmodified Color4
  73453. */
  73454. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  73455. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  73456. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  73457. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  73458. convertedColor.a = this.a;
  73459. return this;
  73460. };
  73461. // Statics
  73462. /**
  73463. * Creates a new Color4 from the string containing valid hexadecimal values
  73464. * @param hex defines a string containing valid hexadecimal values
  73465. * @returns a new Color4 object
  73466. */
  73467. Color4.FromHexString = function (hex) {
  73468. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  73469. return new Color4(0.0, 0.0, 0.0, 0.0);
  73470. }
  73471. var r = parseInt(hex.substring(1, 3), 16);
  73472. var g = parseInt(hex.substring(3, 5), 16);
  73473. var b = parseInt(hex.substring(5, 7), 16);
  73474. var a = parseInt(hex.substring(7, 9), 16);
  73475. return Color4.FromInts(r, g, b, a);
  73476. };
  73477. /**
  73478. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73479. * @param left defines the start value
  73480. * @param right defines the end value
  73481. * @param amount defines the gradient factor
  73482. * @returns a new Color4 object
  73483. */
  73484. Color4.Lerp = function (left, right, amount) {
  73485. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  73486. Color4.LerpToRef(left, right, amount, result);
  73487. return result;
  73488. };
  73489. /**
  73490. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73491. * @param left defines the start value
  73492. * @param right defines the end value
  73493. * @param amount defines the gradient factor
  73494. * @param result defines the Color4 object where to store data
  73495. */
  73496. Color4.LerpToRef = function (left, right, amount, result) {
  73497. result.r = left.r + (right.r - left.r) * amount;
  73498. result.g = left.g + (right.g - left.g) * amount;
  73499. result.b = left.b + (right.b - left.b) * amount;
  73500. result.a = left.a + (right.a - left.a) * amount;
  73501. };
  73502. /**
  73503. * Creates a new Color4 from a Color3 and an alpha value
  73504. * @param color3 defines the source Color3 to read from
  73505. * @param alpha defines the alpha component (1.0 by default)
  73506. * @returns a new Color4 object
  73507. */
  73508. Color4.FromColor3 = function (color3, alpha) {
  73509. if (alpha === void 0) { alpha = 1.0; }
  73510. return new Color4(color3.r, color3.g, color3.b, alpha);
  73511. };
  73512. /**
  73513. * Creates a new Color4 from the starting index element of the given array
  73514. * @param array defines the source array to read from
  73515. * @param offset defines the offset in the source array
  73516. * @returns a new Color4 object
  73517. */
  73518. Color4.FromArray = function (array, offset) {
  73519. if (offset === void 0) { offset = 0; }
  73520. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  73521. };
  73522. /**
  73523. * Creates a new Color3 from integer values (< 256)
  73524. * @param r defines the red component to read from (value between 0 and 255)
  73525. * @param g defines the green component to read from (value between 0 and 255)
  73526. * @param b defines the blue component to read from (value between 0 and 255)
  73527. * @param a defines the alpha component to read from (value between 0 and 255)
  73528. * @returns a new Color3 object
  73529. */
  73530. Color4.FromInts = function (r, g, b, a) {
  73531. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  73532. };
  73533. /**
  73534. * Check the content of a given array and convert it to an array containing RGBA data
  73535. * If the original array was already containing count * 4 values then it is returned directly
  73536. * @param colors defines the array to check
  73537. * @param count defines the number of RGBA data to expect
  73538. * @returns an array containing count * 4 values (RGBA)
  73539. */
  73540. Color4.CheckColors4 = function (colors, count) {
  73541. // Check if color3 was used
  73542. if (colors.length === count * 3) {
  73543. var colors4 = [];
  73544. for (var index = 0; index < colors.length; index += 3) {
  73545. var newIndex = (index / 3) * 4;
  73546. colors4[newIndex] = colors[index];
  73547. colors4[newIndex + 1] = colors[index + 1];
  73548. colors4[newIndex + 2] = colors[index + 2];
  73549. colors4[newIndex + 3] = 1.0;
  73550. }
  73551. return colors4;
  73552. }
  73553. return colors;
  73554. };
  73555. return Color4;
  73556. }());
  73557. /**
  73558. * Class representing a vector containing 2 coordinates
  73559. */
  73560. var Vector2 = /** @class */ (function () {
  73561. /**
  73562. * Creates a new Vector2 from the given x and y coordinates
  73563. * @param x defines the first coordinate
  73564. * @param y defines the second coordinate
  73565. */
  73566. function Vector2(
  73567. /** defines the first coordinate */
  73568. x,
  73569. /** defines the second coordinate */
  73570. y) {
  73571. if (x === void 0) { x = 0; }
  73572. if (y === void 0) { y = 0; }
  73573. this.x = x;
  73574. this.y = y;
  73575. }
  73576. /**
  73577. * Gets a string with the Vector2 coordinates
  73578. * @returns a string with the Vector2 coordinates
  73579. */
  73580. Vector2.prototype.toString = function () {
  73581. return "{X: " + this.x + " Y:" + this.y + "}";
  73582. };
  73583. /**
  73584. * Gets class name
  73585. * @returns the string "Vector2"
  73586. */
  73587. Vector2.prototype.getClassName = function () {
  73588. return "Vector2";
  73589. };
  73590. /**
  73591. * Gets current vector hash code
  73592. * @returns the Vector2 hash code as a number
  73593. */
  73594. Vector2.prototype.getHashCode = function () {
  73595. var hash = this.x || 0;
  73596. hash = (hash * 397) ^ (this.y || 0);
  73597. return hash;
  73598. };
  73599. // Operators
  73600. /**
  73601. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  73602. * @param array defines the source array
  73603. * @param index defines the offset in source array
  73604. * @returns the current Vector2
  73605. */
  73606. Vector2.prototype.toArray = function (array, index) {
  73607. if (index === void 0) { index = 0; }
  73608. array[index] = this.x;
  73609. array[index + 1] = this.y;
  73610. return this;
  73611. };
  73612. /**
  73613. * Copy the current vector to an array
  73614. * @returns a new array with 2 elements: the Vector2 coordinates.
  73615. */
  73616. Vector2.prototype.asArray = function () {
  73617. var result = new Array();
  73618. this.toArray(result, 0);
  73619. return result;
  73620. };
  73621. /**
  73622. * Sets the Vector2 coordinates with the given Vector2 coordinates
  73623. * @param source defines the source Vector2
  73624. * @returns the current updated Vector2
  73625. */
  73626. Vector2.prototype.copyFrom = function (source) {
  73627. this.x = source.x;
  73628. this.y = source.y;
  73629. return this;
  73630. };
  73631. /**
  73632. * Sets the Vector2 coordinates with the given floats
  73633. * @param x defines the first coordinate
  73634. * @param y defines the second coordinate
  73635. * @returns the current updated Vector2
  73636. */
  73637. Vector2.prototype.copyFromFloats = function (x, y) {
  73638. this.x = x;
  73639. this.y = y;
  73640. return this;
  73641. };
  73642. /**
  73643. * Sets the Vector2 coordinates with the given floats
  73644. * @param x defines the first coordinate
  73645. * @param y defines the second coordinate
  73646. * @returns the current updated Vector2
  73647. */
  73648. Vector2.prototype.set = function (x, y) {
  73649. return this.copyFromFloats(x, y);
  73650. };
  73651. /**
  73652. * Add another vector with the current one
  73653. * @param otherVector defines the other vector
  73654. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  73655. */
  73656. Vector2.prototype.add = function (otherVector) {
  73657. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  73658. };
  73659. /**
  73660. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  73661. * @param otherVector defines the other vector
  73662. * @param result defines the target vector
  73663. * @returns the unmodified current Vector2
  73664. */
  73665. Vector2.prototype.addToRef = function (otherVector, result) {
  73666. result.x = this.x + otherVector.x;
  73667. result.y = this.y + otherVector.y;
  73668. return this;
  73669. };
  73670. /**
  73671. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  73672. * @param otherVector defines the other vector
  73673. * @returns the current updated Vector2
  73674. */
  73675. Vector2.prototype.addInPlace = function (otherVector) {
  73676. this.x += otherVector.x;
  73677. this.y += otherVector.y;
  73678. return this;
  73679. };
  73680. /**
  73681. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  73682. * @param otherVector defines the other vector
  73683. * @returns a new Vector2
  73684. */
  73685. Vector2.prototype.addVector3 = function (otherVector) {
  73686. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  73687. };
  73688. /**
  73689. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  73690. * @param otherVector defines the other vector
  73691. * @returns a new Vector2
  73692. */
  73693. Vector2.prototype.subtract = function (otherVector) {
  73694. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  73695. };
  73696. /**
  73697. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  73698. * @param otherVector defines the other vector
  73699. * @param result defines the target vector
  73700. * @returns the unmodified current Vector2
  73701. */
  73702. Vector2.prototype.subtractToRef = function (otherVector, result) {
  73703. result.x = this.x - otherVector.x;
  73704. result.y = this.y - otherVector.y;
  73705. return this;
  73706. };
  73707. /**
  73708. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  73709. * @param otherVector defines the other vector
  73710. * @returns the current updated Vector2
  73711. */
  73712. Vector2.prototype.subtractInPlace = function (otherVector) {
  73713. this.x -= otherVector.x;
  73714. this.y -= otherVector.y;
  73715. return this;
  73716. };
  73717. /**
  73718. * Multiplies in place the current Vector2 coordinates by the given ones
  73719. * @param otherVector defines the other vector
  73720. * @returns the current updated Vector2
  73721. */
  73722. Vector2.prototype.multiplyInPlace = function (otherVector) {
  73723. this.x *= otherVector.x;
  73724. this.y *= otherVector.y;
  73725. return this;
  73726. };
  73727. /**
  73728. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  73729. * @param otherVector defines the other vector
  73730. * @returns a new Vector2
  73731. */
  73732. Vector2.prototype.multiply = function (otherVector) {
  73733. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  73734. };
  73735. /**
  73736. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  73737. * @param otherVector defines the other vector
  73738. * @param result defines the target vector
  73739. * @returns the unmodified current Vector2
  73740. */
  73741. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  73742. result.x = this.x * otherVector.x;
  73743. result.y = this.y * otherVector.y;
  73744. return this;
  73745. };
  73746. /**
  73747. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  73748. * @param x defines the first coordinate
  73749. * @param y defines the second coordinate
  73750. * @returns a new Vector2
  73751. */
  73752. Vector2.prototype.multiplyByFloats = function (x, y) {
  73753. return new Vector2(this.x * x, this.y * y);
  73754. };
  73755. /**
  73756. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  73757. * @param otherVector defines the other vector
  73758. * @returns a new Vector2
  73759. */
  73760. Vector2.prototype.divide = function (otherVector) {
  73761. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  73762. };
  73763. /**
  73764. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  73765. * @param otherVector defines the other vector
  73766. * @param result defines the target vector
  73767. * @returns the unmodified current Vector2
  73768. */
  73769. Vector2.prototype.divideToRef = function (otherVector, result) {
  73770. result.x = this.x / otherVector.x;
  73771. result.y = this.y / otherVector.y;
  73772. return this;
  73773. };
  73774. /**
  73775. * Divides the current Vector2 coordinates by the given ones
  73776. * @param otherVector defines the other vector
  73777. * @returns the current updated Vector2
  73778. */
  73779. Vector2.prototype.divideInPlace = function (otherVector) {
  73780. return this.divideToRef(otherVector, this);
  73781. };
  73782. /**
  73783. * Gets a new Vector2 with current Vector2 negated coordinates
  73784. * @returns a new Vector2
  73785. */
  73786. Vector2.prototype.negate = function () {
  73787. return new Vector2(-this.x, -this.y);
  73788. };
  73789. /**
  73790. * Multiply the Vector2 coordinates by scale
  73791. * @param scale defines the scaling factor
  73792. * @returns the current updated Vector2
  73793. */
  73794. Vector2.prototype.scaleInPlace = function (scale) {
  73795. this.x *= scale;
  73796. this.y *= scale;
  73797. return this;
  73798. };
  73799. /**
  73800. * Returns a new Vector2 scaled by "scale" from the current Vector2
  73801. * @param scale defines the scaling factor
  73802. * @returns a new Vector2
  73803. */
  73804. Vector2.prototype.scale = function (scale) {
  73805. var result = new Vector2(0, 0);
  73806. this.scaleToRef(scale, result);
  73807. return result;
  73808. };
  73809. /**
  73810. * Scale the current Vector2 values by a factor to a given Vector2
  73811. * @param scale defines the scale factor
  73812. * @param result defines the Vector2 object where to store the result
  73813. * @returns the unmodified current Vector2
  73814. */
  73815. Vector2.prototype.scaleToRef = function (scale, result) {
  73816. result.x = this.x * scale;
  73817. result.y = this.y * scale;
  73818. return this;
  73819. };
  73820. /**
  73821. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  73822. * @param scale defines the scale factor
  73823. * @param result defines the Vector2 object where to store the result
  73824. * @returns the unmodified current Vector2
  73825. */
  73826. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  73827. result.x += this.x * scale;
  73828. result.y += this.y * scale;
  73829. return this;
  73830. };
  73831. /**
  73832. * Gets a boolean if two vectors are equals
  73833. * @param otherVector defines the other vector
  73834. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  73835. */
  73836. Vector2.prototype.equals = function (otherVector) {
  73837. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  73838. };
  73839. /**
  73840. * Gets a boolean if two vectors are equals (using an epsilon value)
  73841. * @param otherVector defines the other vector
  73842. * @param epsilon defines the minimal distance to consider equality
  73843. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  73844. */
  73845. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  73846. if (epsilon === void 0) { epsilon = Epsilon; }
  73847. 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);
  73848. };
  73849. /**
  73850. * Gets a new Vector2 from current Vector2 floored values
  73851. * @returns a new Vector2
  73852. */
  73853. Vector2.prototype.floor = function () {
  73854. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  73855. };
  73856. /**
  73857. * Gets a new Vector2 from current Vector2 floored values
  73858. * @returns a new Vector2
  73859. */
  73860. Vector2.prototype.fract = function () {
  73861. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  73862. };
  73863. // Properties
  73864. /**
  73865. * Gets the length of the vector
  73866. * @returns the vector length (float)
  73867. */
  73868. Vector2.prototype.length = function () {
  73869. return Math.sqrt(this.x * this.x + this.y * this.y);
  73870. };
  73871. /**
  73872. * Gets the vector squared length
  73873. * @returns the vector squared length (float)
  73874. */
  73875. Vector2.prototype.lengthSquared = function () {
  73876. return (this.x * this.x + this.y * this.y);
  73877. };
  73878. // Methods
  73879. /**
  73880. * Normalize the vector
  73881. * @returns the current updated Vector2
  73882. */
  73883. Vector2.prototype.normalize = function () {
  73884. var len = this.length();
  73885. if (len === 0) {
  73886. return this;
  73887. }
  73888. var num = 1.0 / len;
  73889. this.x *= num;
  73890. this.y *= num;
  73891. return this;
  73892. };
  73893. /**
  73894. * Gets a new Vector2 copied from the Vector2
  73895. * @returns a new Vector2
  73896. */
  73897. Vector2.prototype.clone = function () {
  73898. return new Vector2(this.x, this.y);
  73899. };
  73900. // Statics
  73901. /**
  73902. * Gets a new Vector2(0, 0)
  73903. * @returns a new Vector2
  73904. */
  73905. Vector2.Zero = function () {
  73906. return new Vector2(0, 0);
  73907. };
  73908. /**
  73909. * Gets a new Vector2(1, 1)
  73910. * @returns a new Vector2
  73911. */
  73912. Vector2.One = function () {
  73913. return new Vector2(1, 1);
  73914. };
  73915. /**
  73916. * Gets a new Vector2 set from the given index element of the given array
  73917. * @param array defines the data source
  73918. * @param offset defines the offset in the data source
  73919. * @returns a new Vector2
  73920. */
  73921. Vector2.FromArray = function (array, offset) {
  73922. if (offset === void 0) { offset = 0; }
  73923. return new Vector2(array[offset], array[offset + 1]);
  73924. };
  73925. /**
  73926. * Sets "result" from the given index element of the given array
  73927. * @param array defines the data source
  73928. * @param offset defines the offset in the data source
  73929. * @param result defines the target vector
  73930. */
  73931. Vector2.FromArrayToRef = function (array, offset, result) {
  73932. result.x = array[offset];
  73933. result.y = array[offset + 1];
  73934. };
  73935. /**
  73936. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  73937. * @param value1 defines 1st point of control
  73938. * @param value2 defines 2nd point of control
  73939. * @param value3 defines 3rd point of control
  73940. * @param value4 defines 4th point of control
  73941. * @param amount defines the interpolation factor
  73942. * @returns a new Vector2
  73943. */
  73944. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  73945. var squared = amount * amount;
  73946. var cubed = amount * squared;
  73947. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  73948. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  73949. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  73950. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  73951. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  73952. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  73953. return new Vector2(x, y);
  73954. };
  73955. /**
  73956. * 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".
  73957. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  73958. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  73959. * @param value defines the value to clamp
  73960. * @param min defines the lower limit
  73961. * @param max defines the upper limit
  73962. * @returns a new Vector2
  73963. */
  73964. Vector2.Clamp = function (value, min, max) {
  73965. var x = value.x;
  73966. x = (x > max.x) ? max.x : x;
  73967. x = (x < min.x) ? min.x : x;
  73968. var y = value.y;
  73969. y = (y > max.y) ? max.y : y;
  73970. y = (y < min.y) ? min.y : y;
  73971. return new Vector2(x, y);
  73972. };
  73973. /**
  73974. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  73975. * @param value1 defines the 1st control point
  73976. * @param tangent1 defines the outgoing tangent
  73977. * @param value2 defines the 2nd control point
  73978. * @param tangent2 defines the incoming tangent
  73979. * @param amount defines the interpolation factor
  73980. * @returns a new Vector2
  73981. */
  73982. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  73983. var squared = amount * amount;
  73984. var cubed = amount * squared;
  73985. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  73986. var part2 = (-2.0 * cubed) + (3.0 * squared);
  73987. var part3 = (cubed - (2.0 * squared)) + amount;
  73988. var part4 = cubed - squared;
  73989. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  73990. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  73991. return new Vector2(x, y);
  73992. };
  73993. /**
  73994. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  73995. * @param start defines the start vector
  73996. * @param end defines the end vector
  73997. * @param amount defines the interpolation factor
  73998. * @returns a new Vector2
  73999. */
  74000. Vector2.Lerp = function (start, end, amount) {
  74001. var x = start.x + ((end.x - start.x) * amount);
  74002. var y = start.y + ((end.y - start.y) * amount);
  74003. return new Vector2(x, y);
  74004. };
  74005. /**
  74006. * Gets the dot product of the vector "left" and the vector "right"
  74007. * @param left defines first vector
  74008. * @param right defines second vector
  74009. * @returns the dot product (float)
  74010. */
  74011. Vector2.Dot = function (left, right) {
  74012. return left.x * right.x + left.y * right.y;
  74013. };
  74014. /**
  74015. * Returns a new Vector2 equal to the normalized given vector
  74016. * @param vector defines the vector to normalize
  74017. * @returns a new Vector2
  74018. */
  74019. Vector2.Normalize = function (vector) {
  74020. var newVector = vector.clone();
  74021. newVector.normalize();
  74022. return newVector;
  74023. };
  74024. /**
  74025. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  74026. * @param left defines 1st vector
  74027. * @param right defines 2nd vector
  74028. * @returns a new Vector2
  74029. */
  74030. Vector2.Minimize = function (left, right) {
  74031. var x = (left.x < right.x) ? left.x : right.x;
  74032. var y = (left.y < right.y) ? left.y : right.y;
  74033. return new Vector2(x, y);
  74034. };
  74035. /**
  74036. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  74037. * @param left defines 1st vector
  74038. * @param right defines 2nd vector
  74039. * @returns a new Vector2
  74040. */
  74041. Vector2.Maximize = function (left, right) {
  74042. var x = (left.x > right.x) ? left.x : right.x;
  74043. var y = (left.y > right.y) ? left.y : right.y;
  74044. return new Vector2(x, y);
  74045. };
  74046. /**
  74047. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  74048. * @param vector defines the vector to transform
  74049. * @param transformation defines the matrix to apply
  74050. * @returns a new Vector2
  74051. */
  74052. Vector2.Transform = function (vector, transformation) {
  74053. var r = Vector2.Zero();
  74054. Vector2.TransformToRef(vector, transformation, r);
  74055. return r;
  74056. };
  74057. /**
  74058. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  74059. * @param vector defines the vector to transform
  74060. * @param transformation defines the matrix to apply
  74061. * @param result defines the target vector
  74062. */
  74063. Vector2.TransformToRef = function (vector, transformation, result) {
  74064. var m = transformation.m;
  74065. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  74066. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  74067. result.x = x;
  74068. result.y = y;
  74069. };
  74070. /**
  74071. * Determines if a given vector is included in a triangle
  74072. * @param p defines the vector to test
  74073. * @param p0 defines 1st triangle point
  74074. * @param p1 defines 2nd triangle point
  74075. * @param p2 defines 3rd triangle point
  74076. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  74077. */
  74078. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  74079. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  74080. var sign = a < 0 ? -1 : 1;
  74081. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  74082. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  74083. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  74084. };
  74085. /**
  74086. * Gets the distance between the vectors "value1" and "value2"
  74087. * @param value1 defines first vector
  74088. * @param value2 defines second vector
  74089. * @returns the distance between vectors
  74090. */
  74091. Vector2.Distance = function (value1, value2) {
  74092. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  74093. };
  74094. /**
  74095. * Returns the squared distance between the vectors "value1" and "value2"
  74096. * @param value1 defines first vector
  74097. * @param value2 defines second vector
  74098. * @returns the squared distance between vectors
  74099. */
  74100. Vector2.DistanceSquared = function (value1, value2) {
  74101. var x = value1.x - value2.x;
  74102. var y = value1.y - value2.y;
  74103. return (x * x) + (y * y);
  74104. };
  74105. /**
  74106. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  74107. * @param value1 defines first vector
  74108. * @param value2 defines second vector
  74109. * @returns a new Vector2
  74110. */
  74111. Vector2.Center = function (value1, value2) {
  74112. var center = value1.add(value2);
  74113. center.scaleInPlace(0.5);
  74114. return center;
  74115. };
  74116. /**
  74117. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  74118. * @param p defines the middle point
  74119. * @param segA defines one point of the segment
  74120. * @param segB defines the other point of the segment
  74121. * @returns the shortest distance
  74122. */
  74123. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  74124. var l2 = Vector2.DistanceSquared(segA, segB);
  74125. if (l2 === 0.0) {
  74126. return Vector2.Distance(p, segA);
  74127. }
  74128. var v = segB.subtract(segA);
  74129. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  74130. var proj = segA.add(v.multiplyByFloats(t, t));
  74131. return Vector2.Distance(p, proj);
  74132. };
  74133. return Vector2;
  74134. }());
  74135. /**
  74136. * Classed used to store (x,y,z) vector representation
  74137. * A Vector3 is the main object used in 3D geometry
  74138. * It can represent etiher the coordinates of a point the space, either a direction
  74139. * Reminder: js uses a left handed forward facing system
  74140. */
  74141. var Vector3 = /** @class */ (function () {
  74142. /**
  74143. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  74144. * @param x defines the first coordinates (on X axis)
  74145. * @param y defines the second coordinates (on Y axis)
  74146. * @param z defines the third coordinates (on Z axis)
  74147. */
  74148. function Vector3(
  74149. /**
  74150. * Defines the first coordinates (on X axis)
  74151. */
  74152. x,
  74153. /**
  74154. * Defines the second coordinates (on Y axis)
  74155. */
  74156. y,
  74157. /**
  74158. * Defines the third coordinates (on Z axis)
  74159. */
  74160. z) {
  74161. if (x === void 0) { x = 0; }
  74162. if (y === void 0) { y = 0; }
  74163. if (z === void 0) { z = 0; }
  74164. this.x = x;
  74165. this.y = y;
  74166. this.z = z;
  74167. }
  74168. /**
  74169. * Creates a string representation of the Vector3
  74170. * @returns a string with the Vector3 coordinates.
  74171. */
  74172. Vector3.prototype.toString = function () {
  74173. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  74174. };
  74175. /**
  74176. * Gets the class name
  74177. * @returns the string "Vector3"
  74178. */
  74179. Vector3.prototype.getClassName = function () {
  74180. return "Vector3";
  74181. };
  74182. /**
  74183. * Creates the Vector3 hash code
  74184. * @returns a number which tends to be unique between Vector3 instances
  74185. */
  74186. Vector3.prototype.getHashCode = function () {
  74187. var hash = this.x || 0;
  74188. hash = (hash * 397) ^ (this.y || 0);
  74189. hash = (hash * 397) ^ (this.z || 0);
  74190. return hash;
  74191. };
  74192. // Operators
  74193. /**
  74194. * Creates an array containing three elements : the coordinates of the Vector3
  74195. * @returns a new array of numbers
  74196. */
  74197. Vector3.prototype.asArray = function () {
  74198. var result = [];
  74199. this.toArray(result, 0);
  74200. return result;
  74201. };
  74202. /**
  74203. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  74204. * @param array defines the destination array
  74205. * @param index defines the offset in the destination array
  74206. * @returns the current Vector3
  74207. */
  74208. Vector3.prototype.toArray = function (array, index) {
  74209. if (index === void 0) { index = 0; }
  74210. array[index] = this.x;
  74211. array[index + 1] = this.y;
  74212. array[index + 2] = this.z;
  74213. return this;
  74214. };
  74215. /**
  74216. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  74217. * @returns a new Quaternion object, computed from the Vector3 coordinates
  74218. */
  74219. Vector3.prototype.toQuaternion = function () {
  74220. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  74221. };
  74222. /**
  74223. * Adds the given vector to the current Vector3
  74224. * @param otherVector defines the second operand
  74225. * @returns the current updated Vector3
  74226. */
  74227. Vector3.prototype.addInPlace = function (otherVector) {
  74228. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  74229. };
  74230. /**
  74231. * Adds the given coordinates to the current Vector3
  74232. * @param x defines the x coordinate of the operand
  74233. * @param y defines the y coordinate of the operand
  74234. * @param z defines the z coordinate of the operand
  74235. * @returns the current updated Vector3
  74236. */
  74237. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  74238. this.x += x;
  74239. this.y += y;
  74240. this.z += z;
  74241. return this;
  74242. };
  74243. /**
  74244. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  74245. * @param otherVector defines the second operand
  74246. * @returns the resulting Vector3
  74247. */
  74248. Vector3.prototype.add = function (otherVector) {
  74249. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  74250. };
  74251. /**
  74252. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  74253. * @param otherVector defines the second operand
  74254. * @param result defines the Vector3 object where to store the result
  74255. * @returns the current Vector3
  74256. */
  74257. Vector3.prototype.addToRef = function (otherVector, result) {
  74258. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  74259. };
  74260. /**
  74261. * Subtract the given vector from the current Vector3
  74262. * @param otherVector defines the second operand
  74263. * @returns the current updated Vector3
  74264. */
  74265. Vector3.prototype.subtractInPlace = function (otherVector) {
  74266. this.x -= otherVector.x;
  74267. this.y -= otherVector.y;
  74268. this.z -= otherVector.z;
  74269. return this;
  74270. };
  74271. /**
  74272. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  74273. * @param otherVector defines the second operand
  74274. * @returns the resulting Vector3
  74275. */
  74276. Vector3.prototype.subtract = function (otherVector) {
  74277. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  74278. };
  74279. /**
  74280. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  74281. * @param otherVector defines the second operand
  74282. * @param result defines the Vector3 object where to store the result
  74283. * @returns the current Vector3
  74284. */
  74285. Vector3.prototype.subtractToRef = function (otherVector, result) {
  74286. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  74287. };
  74288. /**
  74289. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  74290. * @param x defines the x coordinate of the operand
  74291. * @param y defines the y coordinate of the operand
  74292. * @param z defines the z coordinate of the operand
  74293. * @returns the resulting Vector3
  74294. */
  74295. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  74296. return new Vector3(this.x - x, this.y - y, this.z - z);
  74297. };
  74298. /**
  74299. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  74300. * @param x defines the x coordinate of the operand
  74301. * @param y defines the y coordinate of the operand
  74302. * @param z defines the z coordinate of the operand
  74303. * @param result defines the Vector3 object where to store the result
  74304. * @returns the current Vector3
  74305. */
  74306. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  74307. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  74308. };
  74309. /**
  74310. * Gets a new Vector3 set with the current Vector3 negated coordinates
  74311. * @returns a new Vector3
  74312. */
  74313. Vector3.prototype.negate = function () {
  74314. return new Vector3(-this.x, -this.y, -this.z);
  74315. };
  74316. /**
  74317. * Multiplies the Vector3 coordinates by the float "scale"
  74318. * @param scale defines the multiplier factor
  74319. * @returns the current updated Vector3
  74320. */
  74321. Vector3.prototype.scaleInPlace = function (scale) {
  74322. this.x *= scale;
  74323. this.y *= scale;
  74324. this.z *= scale;
  74325. return this;
  74326. };
  74327. /**
  74328. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  74329. * @param scale defines the multiplier factor
  74330. * @returns a new Vector3
  74331. */
  74332. Vector3.prototype.scale = function (scale) {
  74333. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  74334. };
  74335. /**
  74336. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  74337. * @param scale defines the multiplier factor
  74338. * @param result defines the Vector3 object where to store the result
  74339. * @returns the current Vector3
  74340. */
  74341. Vector3.prototype.scaleToRef = function (scale, result) {
  74342. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  74343. };
  74344. /**
  74345. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  74346. * @param scale defines the scale factor
  74347. * @param result defines the Vector3 object where to store the result
  74348. * @returns the unmodified current Vector3
  74349. */
  74350. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  74351. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  74352. };
  74353. /**
  74354. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  74355. * @param otherVector defines the second operand
  74356. * @returns true if both vectors are equals
  74357. */
  74358. Vector3.prototype.equals = function (otherVector) {
  74359. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  74360. };
  74361. /**
  74362. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  74363. * @param otherVector defines the second operand
  74364. * @param epsilon defines the minimal distance to define values as equals
  74365. * @returns true if both vectors are distant less than epsilon
  74366. */
  74367. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  74368. if (epsilon === void 0) { epsilon = Epsilon; }
  74369. 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);
  74370. };
  74371. /**
  74372. * Returns true if the current Vector3 coordinates equals the given floats
  74373. * @param x defines the x coordinate of the operand
  74374. * @param y defines the y coordinate of the operand
  74375. * @param z defines the z coordinate of the operand
  74376. * @returns true if both vectors are equals
  74377. */
  74378. Vector3.prototype.equalsToFloats = function (x, y, z) {
  74379. return this.x === x && this.y === y && this.z === z;
  74380. };
  74381. /**
  74382. * Multiplies the current Vector3 coordinates by the given ones
  74383. * @param otherVector defines the second operand
  74384. * @returns the current updated Vector3
  74385. */
  74386. Vector3.prototype.multiplyInPlace = function (otherVector) {
  74387. this.x *= otherVector.x;
  74388. this.y *= otherVector.y;
  74389. this.z *= otherVector.z;
  74390. return this;
  74391. };
  74392. /**
  74393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  74394. * @param otherVector defines the second operand
  74395. * @returns the new Vector3
  74396. */
  74397. Vector3.prototype.multiply = function (otherVector) {
  74398. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  74399. };
  74400. /**
  74401. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  74402. * @param otherVector defines the second operand
  74403. * @param result defines the Vector3 object where to store the result
  74404. * @returns the current Vector3
  74405. */
  74406. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  74407. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  74408. };
  74409. /**
  74410. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  74411. * @param x defines the x coordinate of the operand
  74412. * @param y defines the y coordinate of the operand
  74413. * @param z defines the z coordinate of the operand
  74414. * @returns the new Vector3
  74415. */
  74416. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  74417. return new Vector3(this.x * x, this.y * y, this.z * z);
  74418. };
  74419. /**
  74420. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  74421. * @param otherVector defines the second operand
  74422. * @returns the new Vector3
  74423. */
  74424. Vector3.prototype.divide = function (otherVector) {
  74425. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  74426. };
  74427. /**
  74428. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  74429. * @param otherVector defines the second operand
  74430. * @param result defines the Vector3 object where to store the result
  74431. * @returns the current Vector3
  74432. */
  74433. Vector3.prototype.divideToRef = function (otherVector, result) {
  74434. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  74435. };
  74436. /**
  74437. * Divides the current Vector3 coordinates by the given ones.
  74438. * @param otherVector defines the second operand
  74439. * @returns the current updated Vector3
  74440. */
  74441. Vector3.prototype.divideInPlace = function (otherVector) {
  74442. return this.divideToRef(otherVector, this);
  74443. };
  74444. /**
  74445. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  74446. * @param other defines the second operand
  74447. * @returns the current updated Vector3
  74448. */
  74449. Vector3.prototype.minimizeInPlace = function (other) {
  74450. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  74451. };
  74452. /**
  74453. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  74454. * @param other defines the second operand
  74455. * @returns the current updated Vector3
  74456. */
  74457. Vector3.prototype.maximizeInPlace = function (other) {
  74458. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  74459. };
  74460. /**
  74461. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  74462. * @param x defines the x coordinate of the operand
  74463. * @param y defines the y coordinate of the operand
  74464. * @param z defines the z coordinate of the operand
  74465. * @returns the current updated Vector3
  74466. */
  74467. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  74468. if (x < this.x) {
  74469. this.x = x;
  74470. }
  74471. if (y < this.y) {
  74472. this.y = y;
  74473. }
  74474. if (z < this.z) {
  74475. this.z = z;
  74476. }
  74477. return this;
  74478. };
  74479. /**
  74480. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  74481. * @param x defines the x coordinate of the operand
  74482. * @param y defines the y coordinate of the operand
  74483. * @param z defines the z coordinate of the operand
  74484. * @returns the current updated Vector3
  74485. */
  74486. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  74487. if (x > this.x) {
  74488. this.x = x;
  74489. }
  74490. if (y > this.y) {
  74491. this.y = y;
  74492. }
  74493. if (z > this.z) {
  74494. this.z = z;
  74495. }
  74496. return this;
  74497. };
  74498. /**
  74499. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  74500. * Check if is non uniform within a certain amount of decimal places to account for this
  74501. * @param epsilon the amount the values can differ
  74502. * @returns if the the vector is non uniform to a certain number of decimal places
  74503. */
  74504. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  74505. var absX = Math.abs(this.x);
  74506. var absY = Math.abs(this.y);
  74507. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  74508. return true;
  74509. }
  74510. var absZ = Math.abs(this.z);
  74511. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  74512. return true;
  74513. }
  74514. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  74515. return true;
  74516. }
  74517. return false;
  74518. };
  74519. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  74520. /**
  74521. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  74522. */
  74523. get: function () {
  74524. var absX = Math.abs(this.x);
  74525. var absY = Math.abs(this.y);
  74526. if (absX !== absY) {
  74527. return true;
  74528. }
  74529. var absZ = Math.abs(this.z);
  74530. if (absX !== absZ) {
  74531. return true;
  74532. }
  74533. if (absY !== absZ) {
  74534. return true;
  74535. }
  74536. return false;
  74537. },
  74538. enumerable: true,
  74539. configurable: true
  74540. });
  74541. /**
  74542. * Gets a new Vector3 from current Vector3 floored values
  74543. * @returns a new Vector3
  74544. */
  74545. Vector3.prototype.floor = function () {
  74546. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  74547. };
  74548. /**
  74549. * Gets a new Vector3 from current Vector3 floored values
  74550. * @returns a new Vector3
  74551. */
  74552. Vector3.prototype.fract = function () {
  74553. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  74554. };
  74555. // Properties
  74556. /**
  74557. * Gets the length of the Vector3
  74558. * @returns the length of the Vecto3
  74559. */
  74560. Vector3.prototype.length = function () {
  74561. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  74562. };
  74563. /**
  74564. * Gets the squared length of the Vector3
  74565. * @returns squared length of the Vector3
  74566. */
  74567. Vector3.prototype.lengthSquared = function () {
  74568. return (this.x * this.x + this.y * this.y + this.z * this.z);
  74569. };
  74570. /**
  74571. * Normalize the current Vector3.
  74572. * Please note that this is an in place operation.
  74573. * @returns the current updated Vector3
  74574. */
  74575. Vector3.prototype.normalize = function () {
  74576. return this.normalizeFromLength(this.length());
  74577. };
  74578. /**
  74579. * Reorders the x y z properties of the vector in place
  74580. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  74581. * @returns the current updated vector
  74582. */
  74583. Vector3.prototype.reorderInPlace = function (order) {
  74584. var _this = this;
  74585. order = order.toLowerCase();
  74586. if (order === "xyz") {
  74587. return this;
  74588. }
  74589. MathTmp.Vector3[0].copyFrom(this);
  74590. ["x", "y", "z"].forEach(function (val, i) {
  74591. _this[val] = MathTmp.Vector3[0][order[i]];
  74592. });
  74593. return this;
  74594. };
  74595. /**
  74596. * Rotates the vector around 0,0,0 by a quaternion
  74597. * @param quaternion the rotation quaternion
  74598. * @param result vector to store the result
  74599. * @returns the resulting vector
  74600. */
  74601. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  74602. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  74603. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  74604. return result;
  74605. };
  74606. /**
  74607. * Rotates a vector around a given point
  74608. * @param quaternion the rotation quaternion
  74609. * @param point the point to rotate around
  74610. * @param result vector to store the result
  74611. * @returns the resulting vector
  74612. */
  74613. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  74614. this.subtractToRef(point, MathTmp.Vector3[0]);
  74615. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  74616. point.addToRef(MathTmp.Vector3[0], result);
  74617. return result;
  74618. };
  74619. /**
  74620. * Normalize the current Vector3 with the given input length.
  74621. * Please note that this is an in place operation.
  74622. * @param len the length of the vector
  74623. * @returns the current updated Vector3
  74624. */
  74625. Vector3.prototype.normalizeFromLength = function (len) {
  74626. if (len === 0 || len === 1.0) {
  74627. return this;
  74628. }
  74629. return this.scaleInPlace(1.0 / len);
  74630. };
  74631. /**
  74632. * Normalize the current Vector3 to a new vector
  74633. * @returns the new Vector3
  74634. */
  74635. Vector3.prototype.normalizeToNew = function () {
  74636. var normalized = new Vector3(0, 0, 0);
  74637. this.normalizeToRef(normalized);
  74638. return normalized;
  74639. };
  74640. /**
  74641. * Normalize the current Vector3 to the reference
  74642. * @param reference define the Vector3 to update
  74643. * @returns the updated Vector3
  74644. */
  74645. Vector3.prototype.normalizeToRef = function (reference) {
  74646. var len = this.length();
  74647. if (len === 0 || len === 1.0) {
  74648. return reference.copyFromFloats(this.x, this.y, this.z);
  74649. }
  74650. return this.scaleToRef(1.0 / len, reference);
  74651. };
  74652. /**
  74653. * Creates a new Vector3 copied from the current Vector3
  74654. * @returns the new Vector3
  74655. */
  74656. Vector3.prototype.clone = function () {
  74657. return new Vector3(this.x, this.y, this.z);
  74658. };
  74659. /**
  74660. * Copies the given vector coordinates to the current Vector3 ones
  74661. * @param source defines the source Vector3
  74662. * @returns the current updated Vector3
  74663. */
  74664. Vector3.prototype.copyFrom = function (source) {
  74665. return this.copyFromFloats(source.x, source.y, source.z);
  74666. };
  74667. /**
  74668. * Copies the given floats to the current Vector3 coordinates
  74669. * @param x defines the x coordinate of the operand
  74670. * @param y defines the y coordinate of the operand
  74671. * @param z defines the z coordinate of the operand
  74672. * @returns the current updated Vector3
  74673. */
  74674. Vector3.prototype.copyFromFloats = function (x, y, z) {
  74675. this.x = x;
  74676. this.y = y;
  74677. this.z = z;
  74678. return this;
  74679. };
  74680. /**
  74681. * Copies the given floats to the current Vector3 coordinates
  74682. * @param x defines the x coordinate of the operand
  74683. * @param y defines the y coordinate of the operand
  74684. * @param z defines the z coordinate of the operand
  74685. * @returns the current updated Vector3
  74686. */
  74687. Vector3.prototype.set = function (x, y, z) {
  74688. return this.copyFromFloats(x, y, z);
  74689. };
  74690. /**
  74691. * Copies the given float to the current Vector3 coordinates
  74692. * @param v defines the x, y and z coordinates of the operand
  74693. * @returns the current updated Vector3
  74694. */
  74695. Vector3.prototype.setAll = function (v) {
  74696. this.x = this.y = this.z = v;
  74697. return this;
  74698. };
  74699. // Statics
  74700. /**
  74701. * Get the clip factor between two vectors
  74702. * @param vector0 defines the first operand
  74703. * @param vector1 defines the second operand
  74704. * @param axis defines the axis to use
  74705. * @param size defines the size along the axis
  74706. * @returns the clip factor
  74707. */
  74708. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  74709. var d0 = Vector3.Dot(vector0, axis) - size;
  74710. var d1 = Vector3.Dot(vector1, axis) - size;
  74711. var s = d0 / (d0 - d1);
  74712. return s;
  74713. };
  74714. /**
  74715. * Get angle between two vectors
  74716. * @param vector0 angle between vector0 and vector1
  74717. * @param vector1 angle between vector0 and vector1
  74718. * @param normal direction of the normal
  74719. * @return the angle between vector0 and vector1
  74720. */
  74721. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  74722. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  74723. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  74724. var dot = Vector3.Dot(v0, v1);
  74725. var n = MathTmp.Vector3[3];
  74726. Vector3.CrossToRef(v0, v1, n);
  74727. if (Vector3.Dot(n, normal) > 0) {
  74728. return Math.acos(dot);
  74729. }
  74730. return -Math.acos(dot);
  74731. };
  74732. /**
  74733. * Returns a new Vector3 set from the index "offset" of the given array
  74734. * @param array defines the source array
  74735. * @param offset defines the offset in the source array
  74736. * @returns the new Vector3
  74737. */
  74738. Vector3.FromArray = function (array, offset) {
  74739. if (offset === void 0) { offset = 0; }
  74740. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  74741. };
  74742. /**
  74743. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  74744. * This function is deprecated. Use FromArray instead
  74745. * @param array defines the source array
  74746. * @param offset defines the offset in the source array
  74747. * @returns the new Vector3
  74748. */
  74749. Vector3.FromFloatArray = function (array, offset) {
  74750. return Vector3.FromArray(array, offset);
  74751. };
  74752. /**
  74753. * Sets the given vector "result" with the element values from the index "offset" of the given array
  74754. * @param array defines the source array
  74755. * @param offset defines the offset in the source array
  74756. * @param result defines the Vector3 where to store the result
  74757. */
  74758. Vector3.FromArrayToRef = function (array, offset, result) {
  74759. result.x = array[offset];
  74760. result.y = array[offset + 1];
  74761. result.z = array[offset + 2];
  74762. };
  74763. /**
  74764. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  74765. * This function is deprecated. Use FromArrayToRef instead.
  74766. * @param array defines the source array
  74767. * @param offset defines the offset in the source array
  74768. * @param result defines the Vector3 where to store the result
  74769. */
  74770. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  74771. return Vector3.FromArrayToRef(array, offset, result);
  74772. };
  74773. /**
  74774. * Sets the given vector "result" with the given floats.
  74775. * @param x defines the x coordinate of the source
  74776. * @param y defines the y coordinate of the source
  74777. * @param z defines the z coordinate of the source
  74778. * @param result defines the Vector3 where to store the result
  74779. */
  74780. Vector3.FromFloatsToRef = function (x, y, z, result) {
  74781. result.copyFromFloats(x, y, z);
  74782. };
  74783. /**
  74784. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  74785. * @returns a new empty Vector3
  74786. */
  74787. Vector3.Zero = function () {
  74788. return new Vector3(0.0, 0.0, 0.0);
  74789. };
  74790. /**
  74791. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  74792. * @returns a new unit Vector3
  74793. */
  74794. Vector3.One = function () {
  74795. return new Vector3(1.0, 1.0, 1.0);
  74796. };
  74797. /**
  74798. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  74799. * @returns a new up Vector3
  74800. */
  74801. Vector3.Up = function () {
  74802. return new Vector3(0.0, 1.0, 0.0);
  74803. };
  74804. Object.defineProperty(Vector3, "UpReadOnly", {
  74805. /**
  74806. * Gets a up Vector3 that must not be updated
  74807. */
  74808. get: function () {
  74809. return Vector3._UpReadOnly;
  74810. },
  74811. enumerable: true,
  74812. configurable: true
  74813. });
  74814. /**
  74815. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  74816. * @returns a new down Vector3
  74817. */
  74818. Vector3.Down = function () {
  74819. return new Vector3(0.0, -1.0, 0.0);
  74820. };
  74821. /**
  74822. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  74823. * @returns a new forward Vector3
  74824. */
  74825. Vector3.Forward = function () {
  74826. return new Vector3(0.0, 0.0, 1.0);
  74827. };
  74828. /**
  74829. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  74830. * @returns a new forward Vector3
  74831. */
  74832. Vector3.Backward = function () {
  74833. return new Vector3(0.0, 0.0, -1.0);
  74834. };
  74835. /**
  74836. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  74837. * @returns a new right Vector3
  74838. */
  74839. Vector3.Right = function () {
  74840. return new Vector3(1.0, 0.0, 0.0);
  74841. };
  74842. /**
  74843. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  74844. * @returns a new left Vector3
  74845. */
  74846. Vector3.Left = function () {
  74847. return new Vector3(-1.0, 0.0, 0.0);
  74848. };
  74849. /**
  74850. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  74851. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  74852. * @param vector defines the Vector3 to transform
  74853. * @param transformation defines the transformation matrix
  74854. * @returns the transformed Vector3
  74855. */
  74856. Vector3.TransformCoordinates = function (vector, transformation) {
  74857. var result = Vector3.Zero();
  74858. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  74859. return result;
  74860. };
  74861. /**
  74862. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  74863. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  74864. * @param vector defines the Vector3 to transform
  74865. * @param transformation defines the transformation matrix
  74866. * @param result defines the Vector3 where to store the result
  74867. */
  74868. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  74869. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  74870. };
  74871. /**
  74872. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  74873. * This method computes tranformed coordinates only, not transformed direction vectors
  74874. * @param x define the x coordinate of the source vector
  74875. * @param y define the y coordinate of the source vector
  74876. * @param z define the z coordinate of the source vector
  74877. * @param transformation defines the transformation matrix
  74878. * @param result defines the Vector3 where to store the result
  74879. */
  74880. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  74881. var m = transformation.m;
  74882. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  74883. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  74884. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  74885. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  74886. result.x = rx * rw;
  74887. result.y = ry * rw;
  74888. result.z = rz * rw;
  74889. };
  74890. /**
  74891. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  74892. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  74893. * @param vector defines the Vector3 to transform
  74894. * @param transformation defines the transformation matrix
  74895. * @returns the new Vector3
  74896. */
  74897. Vector3.TransformNormal = function (vector, transformation) {
  74898. var result = Vector3.Zero();
  74899. Vector3.TransformNormalToRef(vector, transformation, result);
  74900. return result;
  74901. };
  74902. /**
  74903. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  74904. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  74905. * @param vector defines the Vector3 to transform
  74906. * @param transformation defines the transformation matrix
  74907. * @param result defines the Vector3 where to store the result
  74908. */
  74909. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  74910. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  74911. };
  74912. /**
  74913. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  74914. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  74915. * @param x define the x coordinate of the source vector
  74916. * @param y define the y coordinate of the source vector
  74917. * @param z define the z coordinate of the source vector
  74918. * @param transformation defines the transformation matrix
  74919. * @param result defines the Vector3 where to store the result
  74920. */
  74921. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  74922. var m = transformation.m;
  74923. result.x = x * m[0] + y * m[4] + z * m[8];
  74924. result.y = x * m[1] + y * m[5] + z * m[9];
  74925. result.z = x * m[2] + y * m[6] + z * m[10];
  74926. };
  74927. /**
  74928. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  74929. * @param value1 defines the first control point
  74930. * @param value2 defines the second control point
  74931. * @param value3 defines the third control point
  74932. * @param value4 defines the fourth control point
  74933. * @param amount defines the amount on the spline to use
  74934. * @returns the new Vector3
  74935. */
  74936. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  74937. var squared = amount * amount;
  74938. var cubed = amount * squared;
  74939. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  74940. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  74941. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  74942. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  74943. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  74944. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  74945. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  74946. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  74947. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  74948. return new Vector3(x, y, z);
  74949. };
  74950. /**
  74951. * 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"
  74952. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  74953. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  74954. * @param value defines the current value
  74955. * @param min defines the lower range value
  74956. * @param max defines the upper range value
  74957. * @returns the new Vector3
  74958. */
  74959. Vector3.Clamp = function (value, min, max) {
  74960. var v = new Vector3();
  74961. Vector3.ClampToRef(value, min, max, v);
  74962. return v;
  74963. };
  74964. /**
  74965. * 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"
  74966. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  74967. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  74968. * @param value defines the current value
  74969. * @param min defines the lower range value
  74970. * @param max defines the upper range value
  74971. * @param result defines the Vector3 where to store the result
  74972. */
  74973. Vector3.ClampToRef = function (value, min, max, result) {
  74974. var x = value.x;
  74975. x = (x > max.x) ? max.x : x;
  74976. x = (x < min.x) ? min.x : x;
  74977. var y = value.y;
  74978. y = (y > max.y) ? max.y : y;
  74979. y = (y < min.y) ? min.y : y;
  74980. var z = value.z;
  74981. z = (z > max.z) ? max.z : z;
  74982. z = (z < min.z) ? min.z : z;
  74983. result.copyFromFloats(x, y, z);
  74984. };
  74985. /**
  74986. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  74987. * @param value1 defines the first control point
  74988. * @param tangent1 defines the first tangent vector
  74989. * @param value2 defines the second control point
  74990. * @param tangent2 defines the second tangent vector
  74991. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  74992. * @returns the new Vector3
  74993. */
  74994. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  74995. var squared = amount * amount;
  74996. var cubed = amount * squared;
  74997. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  74998. var part2 = (-2.0 * cubed) + (3.0 * squared);
  74999. var part3 = (cubed - (2.0 * squared)) + amount;
  75000. var part4 = cubed - squared;
  75001. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  75002. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  75003. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  75004. return new Vector3(x, y, z);
  75005. };
  75006. /**
  75007. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  75008. * @param start defines the start value
  75009. * @param end defines the end value
  75010. * @param amount max defines amount between both (between 0 and 1)
  75011. * @returns the new Vector3
  75012. */
  75013. Vector3.Lerp = function (start, end, amount) {
  75014. var result = new Vector3(0, 0, 0);
  75015. Vector3.LerpToRef(start, end, amount, result);
  75016. return result;
  75017. };
  75018. /**
  75019. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  75020. * @param start defines the start value
  75021. * @param end defines the end value
  75022. * @param amount max defines amount between both (between 0 and 1)
  75023. * @param result defines the Vector3 where to store the result
  75024. */
  75025. Vector3.LerpToRef = function (start, end, amount, result) {
  75026. result.x = start.x + ((end.x - start.x) * amount);
  75027. result.y = start.y + ((end.y - start.y) * amount);
  75028. result.z = start.z + ((end.z - start.z) * amount);
  75029. };
  75030. /**
  75031. * Returns the dot product (float) between the vectors "left" and "right"
  75032. * @param left defines the left operand
  75033. * @param right defines the right operand
  75034. * @returns the dot product
  75035. */
  75036. Vector3.Dot = function (left, right) {
  75037. return (left.x * right.x + left.y * right.y + left.z * right.z);
  75038. };
  75039. /**
  75040. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  75041. * The cross product is then orthogonal to both "left" and "right"
  75042. * @param left defines the left operand
  75043. * @param right defines the right operand
  75044. * @returns the cross product
  75045. */
  75046. Vector3.Cross = function (left, right) {
  75047. var result = Vector3.Zero();
  75048. Vector3.CrossToRef(left, right, result);
  75049. return result;
  75050. };
  75051. /**
  75052. * Sets the given vector "result" with the cross product of "left" and "right"
  75053. * The cross product is then orthogonal to both "left" and "right"
  75054. * @param left defines the left operand
  75055. * @param right defines the right operand
  75056. * @param result defines the Vector3 where to store the result
  75057. */
  75058. Vector3.CrossToRef = function (left, right, result) {
  75059. var x = left.y * right.z - left.z * right.y;
  75060. var y = left.z * right.x - left.x * right.z;
  75061. var z = left.x * right.y - left.y * right.x;
  75062. result.copyFromFloats(x, y, z);
  75063. };
  75064. /**
  75065. * Returns a new Vector3 as the normalization of the given vector
  75066. * @param vector defines the Vector3 to normalize
  75067. * @returns the new Vector3
  75068. */
  75069. Vector3.Normalize = function (vector) {
  75070. var result = Vector3.Zero();
  75071. Vector3.NormalizeToRef(vector, result);
  75072. return result;
  75073. };
  75074. /**
  75075. * Sets the given vector "result" with the normalization of the given first vector
  75076. * @param vector defines the Vector3 to normalize
  75077. * @param result defines the Vector3 where to store the result
  75078. */
  75079. Vector3.NormalizeToRef = function (vector, result) {
  75080. vector.normalizeToRef(result);
  75081. };
  75082. /**
  75083. * Project a Vector3 onto screen space
  75084. * @param vector defines the Vector3 to project
  75085. * @param world defines the world matrix to use
  75086. * @param transform defines the transform (view x projection) matrix to use
  75087. * @param viewport defines the screen viewport to use
  75088. * @returns the new Vector3
  75089. */
  75090. Vector3.Project = function (vector, world, transform, viewport) {
  75091. var cw = viewport.width;
  75092. var ch = viewport.height;
  75093. var cx = viewport.x;
  75094. var cy = viewport.y;
  75095. var viewportMatrix = MathTmp.Matrix[1];
  75096. 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);
  75097. var matrix = MathTmp.Matrix[0];
  75098. world.multiplyToRef(transform, matrix);
  75099. matrix.multiplyToRef(viewportMatrix, matrix);
  75100. return Vector3.TransformCoordinates(vector, matrix);
  75101. };
  75102. /** @hidden */
  75103. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  75104. Vector3.TransformCoordinatesToRef(source, matrix, result);
  75105. var m = matrix.m;
  75106. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  75107. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  75108. result.scaleInPlace(1.0 / num);
  75109. }
  75110. };
  75111. /**
  75112. * Unproject from screen space to object space
  75113. * @param source defines the screen space Vector3 to use
  75114. * @param viewportWidth defines the current width of the viewport
  75115. * @param viewportHeight defines the current height of the viewport
  75116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75117. * @param transform defines the transform (view x projection) matrix to use
  75118. * @returns the new Vector3
  75119. */
  75120. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  75121. var matrix = MathTmp.Matrix[0];
  75122. world.multiplyToRef(transform, matrix);
  75123. matrix.invert();
  75124. source.x = source.x / viewportWidth * 2 - 1;
  75125. source.y = -(source.y / viewportHeight * 2 - 1);
  75126. var vector = new Vector3();
  75127. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  75128. return vector;
  75129. };
  75130. /**
  75131. * Unproject from screen space to object space
  75132. * @param source defines the screen space Vector3 to use
  75133. * @param viewportWidth defines the current width of the viewport
  75134. * @param viewportHeight defines the current height of the viewport
  75135. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75136. * @param view defines the view matrix to use
  75137. * @param projection defines the projection matrix to use
  75138. * @returns the new Vector3
  75139. */
  75140. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  75141. var result = Vector3.Zero();
  75142. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  75143. return result;
  75144. };
  75145. /**
  75146. * Unproject from screen space to object space
  75147. * @param source defines the screen space Vector3 to use
  75148. * @param viewportWidth defines the current width of the viewport
  75149. * @param viewportHeight defines the current height of the viewport
  75150. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75151. * @param view defines the view matrix to use
  75152. * @param projection defines the projection matrix to use
  75153. * @param result defines the Vector3 where to store the result
  75154. */
  75155. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  75156. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  75157. };
  75158. /**
  75159. * Unproject from screen space to object space
  75160. * @param sourceX defines the screen space x coordinate to use
  75161. * @param sourceY defines the screen space y coordinate to use
  75162. * @param sourceZ defines the screen space z coordinate to use
  75163. * @param viewportWidth defines the current width of the viewport
  75164. * @param viewportHeight defines the current height of the viewport
  75165. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75166. * @param view defines the view matrix to use
  75167. * @param projection defines the projection matrix to use
  75168. * @param result defines the Vector3 where to store the result
  75169. */
  75170. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  75171. var matrix = MathTmp.Matrix[0];
  75172. world.multiplyToRef(view, matrix);
  75173. matrix.multiplyToRef(projection, matrix);
  75174. matrix.invert();
  75175. var screenSource = MathTmp.Vector3[0];
  75176. screenSource.x = sourceX / viewportWidth * 2 - 1;
  75177. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  75178. screenSource.z = 2 * sourceZ - 1.0;
  75179. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  75180. };
  75181. /**
  75182. * Gets the minimal coordinate values between two Vector3
  75183. * @param left defines the first operand
  75184. * @param right defines the second operand
  75185. * @returns the new Vector3
  75186. */
  75187. Vector3.Minimize = function (left, right) {
  75188. var min = left.clone();
  75189. min.minimizeInPlace(right);
  75190. return min;
  75191. };
  75192. /**
  75193. * Gets the maximal coordinate values between two Vector3
  75194. * @param left defines the first operand
  75195. * @param right defines the second operand
  75196. * @returns the new Vector3
  75197. */
  75198. Vector3.Maximize = function (left, right) {
  75199. var max = left.clone();
  75200. max.maximizeInPlace(right);
  75201. return max;
  75202. };
  75203. /**
  75204. * Returns the distance between the vectors "value1" and "value2"
  75205. * @param value1 defines the first operand
  75206. * @param value2 defines the second operand
  75207. * @returns the distance
  75208. */
  75209. Vector3.Distance = function (value1, value2) {
  75210. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  75211. };
  75212. /**
  75213. * Returns the squared distance between the vectors "value1" and "value2"
  75214. * @param value1 defines the first operand
  75215. * @param value2 defines the second operand
  75216. * @returns the squared distance
  75217. */
  75218. Vector3.DistanceSquared = function (value1, value2) {
  75219. var x = value1.x - value2.x;
  75220. var y = value1.y - value2.y;
  75221. var z = value1.z - value2.z;
  75222. return (x * x) + (y * y) + (z * z);
  75223. };
  75224. /**
  75225. * Returns a new Vector3 located at the center between "value1" and "value2"
  75226. * @param value1 defines the first operand
  75227. * @param value2 defines the second operand
  75228. * @returns the new Vector3
  75229. */
  75230. Vector3.Center = function (value1, value2) {
  75231. var center = value1.add(value2);
  75232. center.scaleInPlace(0.5);
  75233. return center;
  75234. };
  75235. /**
  75236. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  75237. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  75238. * to something in order to rotate it from its local system to the given target system
  75239. * Note: axis1, axis2 and axis3 are normalized during this operation
  75240. * @param axis1 defines the first axis
  75241. * @param axis2 defines the second axis
  75242. * @param axis3 defines the third axis
  75243. * @returns a new Vector3
  75244. */
  75245. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  75246. var rotation = Vector3.Zero();
  75247. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  75248. return rotation;
  75249. };
  75250. /**
  75251. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  75252. * @param axis1 defines the first axis
  75253. * @param axis2 defines the second axis
  75254. * @param axis3 defines the third axis
  75255. * @param ref defines the Vector3 where to store the result
  75256. */
  75257. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  75258. var quat = MathTmp.Quaternion[0];
  75259. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  75260. quat.toEulerAnglesToRef(ref);
  75261. };
  75262. Vector3._UpReadOnly = Vector3.Up();
  75263. return Vector3;
  75264. }());
  75265. /**
  75266. * Vector4 class created for EulerAngle class conversion to Quaternion
  75267. */
  75268. var Vector4 = /** @class */ (function () {
  75269. /**
  75270. * Creates a Vector4 object from the given floats.
  75271. * @param x x value of the vector
  75272. * @param y y value of the vector
  75273. * @param z z value of the vector
  75274. * @param w w value of the vector
  75275. */
  75276. function Vector4(
  75277. /** x value of the vector */
  75278. x,
  75279. /** y value of the vector */
  75280. y,
  75281. /** z value of the vector */
  75282. z,
  75283. /** w value of the vector */
  75284. w) {
  75285. this.x = x;
  75286. this.y = y;
  75287. this.z = z;
  75288. this.w = w;
  75289. }
  75290. /**
  75291. * Returns the string with the Vector4 coordinates.
  75292. * @returns a string containing all the vector values
  75293. */
  75294. Vector4.prototype.toString = function () {
  75295. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  75296. };
  75297. /**
  75298. * Returns the string "Vector4".
  75299. * @returns "Vector4"
  75300. */
  75301. Vector4.prototype.getClassName = function () {
  75302. return "Vector4";
  75303. };
  75304. /**
  75305. * Returns the Vector4 hash code.
  75306. * @returns a unique hash code
  75307. */
  75308. Vector4.prototype.getHashCode = function () {
  75309. var hash = this.x || 0;
  75310. hash = (hash * 397) ^ (this.y || 0);
  75311. hash = (hash * 397) ^ (this.z || 0);
  75312. hash = (hash * 397) ^ (this.w || 0);
  75313. return hash;
  75314. };
  75315. // Operators
  75316. /**
  75317. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  75318. * @returns the resulting array
  75319. */
  75320. Vector4.prototype.asArray = function () {
  75321. var result = new Array();
  75322. this.toArray(result, 0);
  75323. return result;
  75324. };
  75325. /**
  75326. * Populates the given array from the given index with the Vector4 coordinates.
  75327. * @param array array to populate
  75328. * @param index index of the array to start at (default: 0)
  75329. * @returns the Vector4.
  75330. */
  75331. Vector4.prototype.toArray = function (array, index) {
  75332. if (index === undefined) {
  75333. index = 0;
  75334. }
  75335. array[index] = this.x;
  75336. array[index + 1] = this.y;
  75337. array[index + 2] = this.z;
  75338. array[index + 3] = this.w;
  75339. return this;
  75340. };
  75341. /**
  75342. * Adds the given vector to the current Vector4.
  75343. * @param otherVector the vector to add
  75344. * @returns the updated Vector4.
  75345. */
  75346. Vector4.prototype.addInPlace = function (otherVector) {
  75347. this.x += otherVector.x;
  75348. this.y += otherVector.y;
  75349. this.z += otherVector.z;
  75350. this.w += otherVector.w;
  75351. return this;
  75352. };
  75353. /**
  75354. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  75355. * @param otherVector the vector to add
  75356. * @returns the resulting vector
  75357. */
  75358. Vector4.prototype.add = function (otherVector) {
  75359. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  75360. };
  75361. /**
  75362. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  75363. * @param otherVector the vector to add
  75364. * @param result the vector to store the result
  75365. * @returns the current Vector4.
  75366. */
  75367. Vector4.prototype.addToRef = function (otherVector, result) {
  75368. result.x = this.x + otherVector.x;
  75369. result.y = this.y + otherVector.y;
  75370. result.z = this.z + otherVector.z;
  75371. result.w = this.w + otherVector.w;
  75372. return this;
  75373. };
  75374. /**
  75375. * Subtract in place the given vector from the current Vector4.
  75376. * @param otherVector the vector to subtract
  75377. * @returns the updated Vector4.
  75378. */
  75379. Vector4.prototype.subtractInPlace = function (otherVector) {
  75380. this.x -= otherVector.x;
  75381. this.y -= otherVector.y;
  75382. this.z -= otherVector.z;
  75383. this.w -= otherVector.w;
  75384. return this;
  75385. };
  75386. /**
  75387. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  75388. * @param otherVector the vector to add
  75389. * @returns the new vector with the result
  75390. */
  75391. Vector4.prototype.subtract = function (otherVector) {
  75392. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  75393. };
  75394. /**
  75395. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  75396. * @param otherVector the vector to subtract
  75397. * @param result the vector to store the result
  75398. * @returns the current Vector4.
  75399. */
  75400. Vector4.prototype.subtractToRef = function (otherVector, result) {
  75401. result.x = this.x - otherVector.x;
  75402. result.y = this.y - otherVector.y;
  75403. result.z = this.z - otherVector.z;
  75404. result.w = this.w - otherVector.w;
  75405. return this;
  75406. };
  75407. /**
  75408. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75409. */
  75410. /**
  75411. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75412. * @param x value to subtract
  75413. * @param y value to subtract
  75414. * @param z value to subtract
  75415. * @param w value to subtract
  75416. * @returns new vector containing the result
  75417. */
  75418. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  75419. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  75420. };
  75421. /**
  75422. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75423. * @param x value to subtract
  75424. * @param y value to subtract
  75425. * @param z value to subtract
  75426. * @param w value to subtract
  75427. * @param result the vector to store the result in
  75428. * @returns the current Vector4.
  75429. */
  75430. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  75431. result.x = this.x - x;
  75432. result.y = this.y - y;
  75433. result.z = this.z - z;
  75434. result.w = this.w - w;
  75435. return this;
  75436. };
  75437. /**
  75438. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  75439. * @returns a new vector with the negated values
  75440. */
  75441. Vector4.prototype.negate = function () {
  75442. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  75443. };
  75444. /**
  75445. * Multiplies the current Vector4 coordinates by scale (float).
  75446. * @param scale the number to scale with
  75447. * @returns the updated Vector4.
  75448. */
  75449. Vector4.prototype.scaleInPlace = function (scale) {
  75450. this.x *= scale;
  75451. this.y *= scale;
  75452. this.z *= scale;
  75453. this.w *= scale;
  75454. return this;
  75455. };
  75456. /**
  75457. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  75458. * @param scale the number to scale with
  75459. * @returns a new vector with the result
  75460. */
  75461. Vector4.prototype.scale = function (scale) {
  75462. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  75463. };
  75464. /**
  75465. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  75466. * @param scale the number to scale with
  75467. * @param result a vector to store the result in
  75468. * @returns the current Vector4.
  75469. */
  75470. Vector4.prototype.scaleToRef = function (scale, result) {
  75471. result.x = this.x * scale;
  75472. result.y = this.y * scale;
  75473. result.z = this.z * scale;
  75474. result.w = this.w * scale;
  75475. return this;
  75476. };
  75477. /**
  75478. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  75479. * @param scale defines the scale factor
  75480. * @param result defines the Vector4 object where to store the result
  75481. * @returns the unmodified current Vector4
  75482. */
  75483. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  75484. result.x += this.x * scale;
  75485. result.y += this.y * scale;
  75486. result.z += this.z * scale;
  75487. result.w += this.w * scale;
  75488. return this;
  75489. };
  75490. /**
  75491. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  75492. * @param otherVector the vector to compare against
  75493. * @returns true if they are equal
  75494. */
  75495. Vector4.prototype.equals = function (otherVector) {
  75496. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  75497. };
  75498. /**
  75499. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  75500. * @param otherVector vector to compare against
  75501. * @param epsilon (Default: very small number)
  75502. * @returns true if they are equal
  75503. */
  75504. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  75505. if (epsilon === void 0) { epsilon = Epsilon; }
  75506. return otherVector
  75507. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  75508. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  75509. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  75510. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  75511. };
  75512. /**
  75513. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  75514. * @param x x value to compare against
  75515. * @param y y value to compare against
  75516. * @param z z value to compare against
  75517. * @param w w value to compare against
  75518. * @returns true if equal
  75519. */
  75520. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  75521. return this.x === x && this.y === y && this.z === z && this.w === w;
  75522. };
  75523. /**
  75524. * Multiplies in place the current Vector4 by the given one.
  75525. * @param otherVector vector to multiple with
  75526. * @returns the updated Vector4.
  75527. */
  75528. Vector4.prototype.multiplyInPlace = function (otherVector) {
  75529. this.x *= otherVector.x;
  75530. this.y *= otherVector.y;
  75531. this.z *= otherVector.z;
  75532. this.w *= otherVector.w;
  75533. return this;
  75534. };
  75535. /**
  75536. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  75537. * @param otherVector vector to multiple with
  75538. * @returns resulting new vector
  75539. */
  75540. Vector4.prototype.multiply = function (otherVector) {
  75541. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  75542. };
  75543. /**
  75544. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  75545. * @param otherVector vector to multiple with
  75546. * @param result vector to store the result
  75547. * @returns the current Vector4.
  75548. */
  75549. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  75550. result.x = this.x * otherVector.x;
  75551. result.y = this.y * otherVector.y;
  75552. result.z = this.z * otherVector.z;
  75553. result.w = this.w * otherVector.w;
  75554. return this;
  75555. };
  75556. /**
  75557. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  75558. * @param x x value multiply with
  75559. * @param y y value multiply with
  75560. * @param z z value multiply with
  75561. * @param w w value multiply with
  75562. * @returns resulting new vector
  75563. */
  75564. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  75565. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  75566. };
  75567. /**
  75568. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  75569. * @param otherVector vector to devide with
  75570. * @returns resulting new vector
  75571. */
  75572. Vector4.prototype.divide = function (otherVector) {
  75573. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  75574. };
  75575. /**
  75576. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  75577. * @param otherVector vector to devide with
  75578. * @param result vector to store the result
  75579. * @returns the current Vector4.
  75580. */
  75581. Vector4.prototype.divideToRef = function (otherVector, result) {
  75582. result.x = this.x / otherVector.x;
  75583. result.y = this.y / otherVector.y;
  75584. result.z = this.z / otherVector.z;
  75585. result.w = this.w / otherVector.w;
  75586. return this;
  75587. };
  75588. /**
  75589. * Divides the current Vector3 coordinates by the given ones.
  75590. * @param otherVector vector to devide with
  75591. * @returns the updated Vector3.
  75592. */
  75593. Vector4.prototype.divideInPlace = function (otherVector) {
  75594. return this.divideToRef(otherVector, this);
  75595. };
  75596. /**
  75597. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  75598. * @param other defines the second operand
  75599. * @returns the current updated Vector4
  75600. */
  75601. Vector4.prototype.minimizeInPlace = function (other) {
  75602. if (other.x < this.x) {
  75603. this.x = other.x;
  75604. }
  75605. if (other.y < this.y) {
  75606. this.y = other.y;
  75607. }
  75608. if (other.z < this.z) {
  75609. this.z = other.z;
  75610. }
  75611. if (other.w < this.w) {
  75612. this.w = other.w;
  75613. }
  75614. return this;
  75615. };
  75616. /**
  75617. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  75618. * @param other defines the second operand
  75619. * @returns the current updated Vector4
  75620. */
  75621. Vector4.prototype.maximizeInPlace = function (other) {
  75622. if (other.x > this.x) {
  75623. this.x = other.x;
  75624. }
  75625. if (other.y > this.y) {
  75626. this.y = other.y;
  75627. }
  75628. if (other.z > this.z) {
  75629. this.z = other.z;
  75630. }
  75631. if (other.w > this.w) {
  75632. this.w = other.w;
  75633. }
  75634. return this;
  75635. };
  75636. /**
  75637. * Gets a new Vector4 from current Vector4 floored values
  75638. * @returns a new Vector4
  75639. */
  75640. Vector4.prototype.floor = function () {
  75641. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  75642. };
  75643. /**
  75644. * Gets a new Vector4 from current Vector3 floored values
  75645. * @returns a new Vector4
  75646. */
  75647. Vector4.prototype.fract = function () {
  75648. 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));
  75649. };
  75650. // Properties
  75651. /**
  75652. * Returns the Vector4 length (float).
  75653. * @returns the length
  75654. */
  75655. Vector4.prototype.length = function () {
  75656. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  75657. };
  75658. /**
  75659. * Returns the Vector4 squared length (float).
  75660. * @returns the length squared
  75661. */
  75662. Vector4.prototype.lengthSquared = function () {
  75663. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  75664. };
  75665. // Methods
  75666. /**
  75667. * Normalizes in place the Vector4.
  75668. * @returns the updated Vector4.
  75669. */
  75670. Vector4.prototype.normalize = function () {
  75671. var len = this.length();
  75672. if (len === 0) {
  75673. return this;
  75674. }
  75675. return this.scaleInPlace(1.0 / len);
  75676. };
  75677. /**
  75678. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  75679. * @returns this converted to a new vector3
  75680. */
  75681. Vector4.prototype.toVector3 = function () {
  75682. return new Vector3(this.x, this.y, this.z);
  75683. };
  75684. /**
  75685. * Returns a new Vector4 copied from the current one.
  75686. * @returns the new cloned vector
  75687. */
  75688. Vector4.prototype.clone = function () {
  75689. return new Vector4(this.x, this.y, this.z, this.w);
  75690. };
  75691. /**
  75692. * Updates the current Vector4 with the given one coordinates.
  75693. * @param source the source vector to copy from
  75694. * @returns the updated Vector4.
  75695. */
  75696. Vector4.prototype.copyFrom = function (source) {
  75697. this.x = source.x;
  75698. this.y = source.y;
  75699. this.z = source.z;
  75700. this.w = source.w;
  75701. return this;
  75702. };
  75703. /**
  75704. * Updates the current Vector4 coordinates with the given floats.
  75705. * @param x float to copy from
  75706. * @param y float to copy from
  75707. * @param z float to copy from
  75708. * @param w float to copy from
  75709. * @returns the updated Vector4.
  75710. */
  75711. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  75712. this.x = x;
  75713. this.y = y;
  75714. this.z = z;
  75715. this.w = w;
  75716. return this;
  75717. };
  75718. /**
  75719. * Updates the current Vector4 coordinates with the given floats.
  75720. * @param x float to set from
  75721. * @param y float to set from
  75722. * @param z float to set from
  75723. * @param w float to set from
  75724. * @returns the updated Vector4.
  75725. */
  75726. Vector4.prototype.set = function (x, y, z, w) {
  75727. return this.copyFromFloats(x, y, z, w);
  75728. };
  75729. /**
  75730. * Copies the given float to the current Vector3 coordinates
  75731. * @param v defines the x, y, z and w coordinates of the operand
  75732. * @returns the current updated Vector3
  75733. */
  75734. Vector4.prototype.setAll = function (v) {
  75735. this.x = this.y = this.z = this.w = v;
  75736. return this;
  75737. };
  75738. // Statics
  75739. /**
  75740. * Returns a new Vector4 set from the starting index of the given array.
  75741. * @param array the array to pull values from
  75742. * @param offset the offset into the array to start at
  75743. * @returns the new vector
  75744. */
  75745. Vector4.FromArray = function (array, offset) {
  75746. if (!offset) {
  75747. offset = 0;
  75748. }
  75749. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  75750. };
  75751. /**
  75752. * Updates the given vector "result" from the starting index of the given array.
  75753. * @param array the array to pull values from
  75754. * @param offset the offset into the array to start at
  75755. * @param result the vector to store the result in
  75756. */
  75757. Vector4.FromArrayToRef = function (array, offset, result) {
  75758. result.x = array[offset];
  75759. result.y = array[offset + 1];
  75760. result.z = array[offset + 2];
  75761. result.w = array[offset + 3];
  75762. };
  75763. /**
  75764. * Updates the given vector "result" from the starting index of the given Float32Array.
  75765. * @param array the array to pull values from
  75766. * @param offset the offset into the array to start at
  75767. * @param result the vector to store the result in
  75768. */
  75769. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  75770. Vector4.FromArrayToRef(array, offset, result);
  75771. };
  75772. /**
  75773. * Updates the given vector "result" coordinates from the given floats.
  75774. * @param x float to set from
  75775. * @param y float to set from
  75776. * @param z float to set from
  75777. * @param w float to set from
  75778. * @param result the vector to the floats in
  75779. */
  75780. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  75781. result.x = x;
  75782. result.y = y;
  75783. result.z = z;
  75784. result.w = w;
  75785. };
  75786. /**
  75787. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  75788. * @returns the new vector
  75789. */
  75790. Vector4.Zero = function () {
  75791. return new Vector4(0.0, 0.0, 0.0, 0.0);
  75792. };
  75793. /**
  75794. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  75795. * @returns the new vector
  75796. */
  75797. Vector4.One = function () {
  75798. return new Vector4(1.0, 1.0, 1.0, 1.0);
  75799. };
  75800. /**
  75801. * Returns a new normalized Vector4 from the given one.
  75802. * @param vector the vector to normalize
  75803. * @returns the vector
  75804. */
  75805. Vector4.Normalize = function (vector) {
  75806. var result = Vector4.Zero();
  75807. Vector4.NormalizeToRef(vector, result);
  75808. return result;
  75809. };
  75810. /**
  75811. * Updates the given vector "result" from the normalization of the given one.
  75812. * @param vector the vector to normalize
  75813. * @param result the vector to store the result in
  75814. */
  75815. Vector4.NormalizeToRef = function (vector, result) {
  75816. result.copyFrom(vector);
  75817. result.normalize();
  75818. };
  75819. /**
  75820. * Returns a vector with the minimum values from the left and right vectors
  75821. * @param left left vector to minimize
  75822. * @param right right vector to minimize
  75823. * @returns a new vector with the minimum of the left and right vector values
  75824. */
  75825. Vector4.Minimize = function (left, right) {
  75826. var min = left.clone();
  75827. min.minimizeInPlace(right);
  75828. return min;
  75829. };
  75830. /**
  75831. * Returns a vector with the maximum values from the left and right vectors
  75832. * @param left left vector to maximize
  75833. * @param right right vector to maximize
  75834. * @returns a new vector with the maximum of the left and right vector values
  75835. */
  75836. Vector4.Maximize = function (left, right) {
  75837. var max = left.clone();
  75838. max.maximizeInPlace(right);
  75839. return max;
  75840. };
  75841. /**
  75842. * Returns the distance (float) between the vectors "value1" and "value2".
  75843. * @param value1 value to calulate the distance between
  75844. * @param value2 value to calulate the distance between
  75845. * @return the distance between the two vectors
  75846. */
  75847. Vector4.Distance = function (value1, value2) {
  75848. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  75849. };
  75850. /**
  75851. * Returns the squared distance (float) between the vectors "value1" and "value2".
  75852. * @param value1 value to calulate the distance between
  75853. * @param value2 value to calulate the distance between
  75854. * @return the distance between the two vectors squared
  75855. */
  75856. Vector4.DistanceSquared = function (value1, value2) {
  75857. var x = value1.x - value2.x;
  75858. var y = value1.y - value2.y;
  75859. var z = value1.z - value2.z;
  75860. var w = value1.w - value2.w;
  75861. return (x * x) + (y * y) + (z * z) + (w * w);
  75862. };
  75863. /**
  75864. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  75865. * @param value1 value to calulate the center between
  75866. * @param value2 value to calulate the center between
  75867. * @return the center between the two vectors
  75868. */
  75869. Vector4.Center = function (value1, value2) {
  75870. var center = value1.add(value2);
  75871. center.scaleInPlace(0.5);
  75872. return center;
  75873. };
  75874. /**
  75875. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  75876. * This methods computes transformed normalized direction vectors only.
  75877. * @param vector the vector to transform
  75878. * @param transformation the transformation matrix to apply
  75879. * @returns the new vector
  75880. */
  75881. Vector4.TransformNormal = function (vector, transformation) {
  75882. var result = Vector4.Zero();
  75883. Vector4.TransformNormalToRef(vector, transformation, result);
  75884. return result;
  75885. };
  75886. /**
  75887. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  75888. * This methods computes transformed normalized direction vectors only.
  75889. * @param vector the vector to transform
  75890. * @param transformation the transformation matrix to apply
  75891. * @param result the vector to store the result in
  75892. */
  75893. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  75894. var m = transformation.m;
  75895. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  75896. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  75897. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  75898. result.x = x;
  75899. result.y = y;
  75900. result.z = z;
  75901. result.w = vector.w;
  75902. };
  75903. /**
  75904. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  75905. * This methods computes transformed normalized direction vectors only.
  75906. * @param x value to transform
  75907. * @param y value to transform
  75908. * @param z value to transform
  75909. * @param w value to transform
  75910. * @param transformation the transformation matrix to apply
  75911. * @param result the vector to store the results in
  75912. */
  75913. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  75914. var m = transformation.m;
  75915. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  75916. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  75917. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  75918. result.w = w;
  75919. };
  75920. /**
  75921. * Creates a new Vector4 from a Vector3
  75922. * @param source defines the source data
  75923. * @param w defines the 4th component (default is 0)
  75924. * @returns a new Vector4
  75925. */
  75926. Vector4.FromVector3 = function (source, w) {
  75927. if (w === void 0) { w = 0; }
  75928. return new Vector4(source.x, source.y, source.z, w);
  75929. };
  75930. return Vector4;
  75931. }());
  75932. /**
  75933. * Size containing widht and height
  75934. */
  75935. var Size = /** @class */ (function () {
  75936. /**
  75937. * Creates a Size object from the given width and height (floats).
  75938. * @param width width of the new size
  75939. * @param height height of the new size
  75940. */
  75941. function Size(width, height) {
  75942. this.width = width;
  75943. this.height = height;
  75944. }
  75945. /**
  75946. * Returns a string with the Size width and height
  75947. * @returns a string with the Size width and height
  75948. */
  75949. Size.prototype.toString = function () {
  75950. return "{W: " + this.width + ", H: " + this.height + "}";
  75951. };
  75952. /**
  75953. * "Size"
  75954. * @returns the string "Size"
  75955. */
  75956. Size.prototype.getClassName = function () {
  75957. return "Size";
  75958. };
  75959. /**
  75960. * Returns the Size hash code.
  75961. * @returns a hash code for a unique width and height
  75962. */
  75963. Size.prototype.getHashCode = function () {
  75964. var hash = this.width || 0;
  75965. hash = (hash * 397) ^ (this.height || 0);
  75966. return hash;
  75967. };
  75968. /**
  75969. * Updates the current size from the given one.
  75970. * @param src the given size
  75971. */
  75972. Size.prototype.copyFrom = function (src) {
  75973. this.width = src.width;
  75974. this.height = src.height;
  75975. };
  75976. /**
  75977. * Updates in place the current Size from the given floats.
  75978. * @param width width of the new size
  75979. * @param height height of the new size
  75980. * @returns the updated Size.
  75981. */
  75982. Size.prototype.copyFromFloats = function (width, height) {
  75983. this.width = width;
  75984. this.height = height;
  75985. return this;
  75986. };
  75987. /**
  75988. * Updates in place the current Size from the given floats.
  75989. * @param width width to set
  75990. * @param height height to set
  75991. * @returns the updated Size.
  75992. */
  75993. Size.prototype.set = function (width, height) {
  75994. return this.copyFromFloats(width, height);
  75995. };
  75996. /**
  75997. * Multiplies the width and height by numbers
  75998. * @param w factor to multiple the width by
  75999. * @param h factor to multiple the height by
  76000. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  76001. */
  76002. Size.prototype.multiplyByFloats = function (w, h) {
  76003. return new Size(this.width * w, this.height * h);
  76004. };
  76005. /**
  76006. * Clones the size
  76007. * @returns a new Size copied from the given one.
  76008. */
  76009. Size.prototype.clone = function () {
  76010. return new Size(this.width, this.height);
  76011. };
  76012. /**
  76013. * True if the current Size and the given one width and height are strictly equal.
  76014. * @param other the other size to compare against
  76015. * @returns True if the current Size and the given one width and height are strictly equal.
  76016. */
  76017. Size.prototype.equals = function (other) {
  76018. if (!other) {
  76019. return false;
  76020. }
  76021. return (this.width === other.width) && (this.height === other.height);
  76022. };
  76023. Object.defineProperty(Size.prototype, "surface", {
  76024. /**
  76025. * The surface of the Size : width * height (float).
  76026. */
  76027. get: function () {
  76028. return this.width * this.height;
  76029. },
  76030. enumerable: true,
  76031. configurable: true
  76032. });
  76033. /**
  76034. * Create a new size of zero
  76035. * @returns a new Size set to (0.0, 0.0)
  76036. */
  76037. Size.Zero = function () {
  76038. return new Size(0.0, 0.0);
  76039. };
  76040. /**
  76041. * Sums the width and height of two sizes
  76042. * @param otherSize size to add to this size
  76043. * @returns a new Size set as the addition result of the current Size and the given one.
  76044. */
  76045. Size.prototype.add = function (otherSize) {
  76046. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  76047. return r;
  76048. };
  76049. /**
  76050. * Subtracts the width and height of two
  76051. * @param otherSize size to subtract to this size
  76052. * @returns a new Size set as the subtraction result of the given one from the current Size.
  76053. */
  76054. Size.prototype.subtract = function (otherSize) {
  76055. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  76056. return r;
  76057. };
  76058. /**
  76059. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  76060. * @param start starting size to lerp between
  76061. * @param end end size to lerp between
  76062. * @param amount amount to lerp between the start and end values
  76063. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  76064. */
  76065. Size.Lerp = function (start, end, amount) {
  76066. var w = start.width + ((end.width - start.width) * amount);
  76067. var h = start.height + ((end.height - start.height) * amount);
  76068. return new Size(w, h);
  76069. };
  76070. return Size;
  76071. }());
  76072. /**
  76073. * Class used to store quaternion data
  76074. * @see https://en.wikipedia.org/wiki/Quaternion
  76075. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76076. */
  76077. var Quaternion = /** @class */ (function () {
  76078. /**
  76079. * Creates a new Quaternion from the given floats
  76080. * @param x defines the first component (0 by default)
  76081. * @param y defines the second component (0 by default)
  76082. * @param z defines the third component (0 by default)
  76083. * @param w defines the fourth component (1.0 by default)
  76084. */
  76085. function Quaternion(
  76086. /** defines the first component (0 by default) */
  76087. x,
  76088. /** defines the second component (0 by default) */
  76089. y,
  76090. /** defines the third component (0 by default) */
  76091. z,
  76092. /** defines the fourth component (1.0 by default) */
  76093. w) {
  76094. if (x === void 0) { x = 0.0; }
  76095. if (y === void 0) { y = 0.0; }
  76096. if (z === void 0) { z = 0.0; }
  76097. if (w === void 0) { w = 1.0; }
  76098. this.x = x;
  76099. this.y = y;
  76100. this.z = z;
  76101. this.w = w;
  76102. }
  76103. /**
  76104. * Gets a string representation for the current quaternion
  76105. * @returns a string with the Quaternion coordinates
  76106. */
  76107. Quaternion.prototype.toString = function () {
  76108. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  76109. };
  76110. /**
  76111. * Gets the class name of the quaternion
  76112. * @returns the string "Quaternion"
  76113. */
  76114. Quaternion.prototype.getClassName = function () {
  76115. return "Quaternion";
  76116. };
  76117. /**
  76118. * Gets a hash code for this quaternion
  76119. * @returns the quaternion hash code
  76120. */
  76121. Quaternion.prototype.getHashCode = function () {
  76122. var hash = this.x || 0;
  76123. hash = (hash * 397) ^ (this.y || 0);
  76124. hash = (hash * 397) ^ (this.z || 0);
  76125. hash = (hash * 397) ^ (this.w || 0);
  76126. return hash;
  76127. };
  76128. /**
  76129. * Copy the quaternion to an array
  76130. * @returns a new array populated with 4 elements from the quaternion coordinates
  76131. */
  76132. Quaternion.prototype.asArray = function () {
  76133. return [this.x, this.y, this.z, this.w];
  76134. };
  76135. /**
  76136. * Check if two quaternions are equals
  76137. * @param otherQuaternion defines the second operand
  76138. * @return true if the current quaternion and the given one coordinates are strictly equals
  76139. */
  76140. Quaternion.prototype.equals = function (otherQuaternion) {
  76141. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  76142. };
  76143. /**
  76144. * Clone the current quaternion
  76145. * @returns a new quaternion copied from the current one
  76146. */
  76147. Quaternion.prototype.clone = function () {
  76148. return new Quaternion(this.x, this.y, this.z, this.w);
  76149. };
  76150. /**
  76151. * Copy a quaternion to the current one
  76152. * @param other defines the other quaternion
  76153. * @returns the updated current quaternion
  76154. */
  76155. Quaternion.prototype.copyFrom = function (other) {
  76156. this.x = other.x;
  76157. this.y = other.y;
  76158. this.z = other.z;
  76159. this.w = other.w;
  76160. return this;
  76161. };
  76162. /**
  76163. * Updates the current quaternion with the given float coordinates
  76164. * @param x defines the x coordinate
  76165. * @param y defines the y coordinate
  76166. * @param z defines the z coordinate
  76167. * @param w defines the w coordinate
  76168. * @returns the updated current quaternion
  76169. */
  76170. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  76171. this.x = x;
  76172. this.y = y;
  76173. this.z = z;
  76174. this.w = w;
  76175. return this;
  76176. };
  76177. /**
  76178. * Updates the current quaternion from the given float coordinates
  76179. * @param x defines the x coordinate
  76180. * @param y defines the y coordinate
  76181. * @param z defines the z coordinate
  76182. * @param w defines the w coordinate
  76183. * @returns the updated current quaternion
  76184. */
  76185. Quaternion.prototype.set = function (x, y, z, w) {
  76186. return this.copyFromFloats(x, y, z, w);
  76187. };
  76188. /**
  76189. * Adds two quaternions
  76190. * @param other defines the second operand
  76191. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76192. */
  76193. Quaternion.prototype.add = function (other) {
  76194. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  76195. };
  76196. /**
  76197. * Add a quaternion to the current one
  76198. * @param other defines the quaternion to add
  76199. * @returns the current quaternion
  76200. */
  76201. Quaternion.prototype.addInPlace = function (other) {
  76202. this.x += other.x;
  76203. this.y += other.y;
  76204. this.z += other.z;
  76205. this.w += other.w;
  76206. return this;
  76207. };
  76208. /**
  76209. * Subtract two quaternions
  76210. * @param other defines the second operand
  76211. * @returns a new quaternion as the subtraction result of the given one from the current one
  76212. */
  76213. Quaternion.prototype.subtract = function (other) {
  76214. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  76215. };
  76216. /**
  76217. * Multiplies the current quaternion by a scale factor
  76218. * @param value defines the scale factor
  76219. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76220. */
  76221. Quaternion.prototype.scale = function (value) {
  76222. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  76223. };
  76224. /**
  76225. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76226. * @param scale defines the scale factor
  76227. * @param result defines the Quaternion object where to store the result
  76228. * @returns the unmodified current quaternion
  76229. */
  76230. Quaternion.prototype.scaleToRef = function (scale, result) {
  76231. result.x = this.x * scale;
  76232. result.y = this.y * scale;
  76233. result.z = this.z * scale;
  76234. result.w = this.w * scale;
  76235. return this;
  76236. };
  76237. /**
  76238. * Multiplies in place the current quaternion by a scale factor
  76239. * @param value defines the scale factor
  76240. * @returns the current modified quaternion
  76241. */
  76242. Quaternion.prototype.scaleInPlace = function (value) {
  76243. this.x *= value;
  76244. this.y *= value;
  76245. this.z *= value;
  76246. this.w *= value;
  76247. return this;
  76248. };
  76249. /**
  76250. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76251. * @param scale defines the scale factor
  76252. * @param result defines the Quaternion object where to store the result
  76253. * @returns the unmodified current quaternion
  76254. */
  76255. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  76256. result.x += this.x * scale;
  76257. result.y += this.y * scale;
  76258. result.z += this.z * scale;
  76259. result.w += this.w * scale;
  76260. return this;
  76261. };
  76262. /**
  76263. * Multiplies two quaternions
  76264. * @param q1 defines the second operand
  76265. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76266. */
  76267. Quaternion.prototype.multiply = function (q1) {
  76268. var result = new Quaternion(0, 0, 0, 1.0);
  76269. this.multiplyToRef(q1, result);
  76270. return result;
  76271. };
  76272. /**
  76273. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76274. * @param q1 defines the second operand
  76275. * @param result defines the target quaternion
  76276. * @returns the current quaternion
  76277. */
  76278. Quaternion.prototype.multiplyToRef = function (q1, result) {
  76279. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  76280. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  76281. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  76282. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  76283. result.copyFromFloats(x, y, z, w);
  76284. return this;
  76285. };
  76286. /**
  76287. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76288. * @param q1 defines the second operand
  76289. * @returns the currentupdated quaternion
  76290. */
  76291. Quaternion.prototype.multiplyInPlace = function (q1) {
  76292. this.multiplyToRef(q1, this);
  76293. return this;
  76294. };
  76295. /**
  76296. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76297. * @param ref defines the target quaternion
  76298. * @returns the current quaternion
  76299. */
  76300. Quaternion.prototype.conjugateToRef = function (ref) {
  76301. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  76302. return this;
  76303. };
  76304. /**
  76305. * Conjugates in place (1-q) the current quaternion
  76306. * @returns the current updated quaternion
  76307. */
  76308. Quaternion.prototype.conjugateInPlace = function () {
  76309. this.x *= -1;
  76310. this.y *= -1;
  76311. this.z *= -1;
  76312. return this;
  76313. };
  76314. /**
  76315. * Conjugates in place (1-q) the current quaternion
  76316. * @returns a new quaternion
  76317. */
  76318. Quaternion.prototype.conjugate = function () {
  76319. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  76320. return result;
  76321. };
  76322. /**
  76323. * Gets length of current quaternion
  76324. * @returns the quaternion length (float)
  76325. */
  76326. Quaternion.prototype.length = function () {
  76327. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  76328. };
  76329. /**
  76330. * Normalize in place the current quaternion
  76331. * @returns the current updated quaternion
  76332. */
  76333. Quaternion.prototype.normalize = function () {
  76334. var len = this.length();
  76335. if (len === 0) {
  76336. return this;
  76337. }
  76338. var inv = 1.0 / len;
  76339. this.x *= inv;
  76340. this.y *= inv;
  76341. this.z *= inv;
  76342. this.w *= inv;
  76343. return this;
  76344. };
  76345. /**
  76346. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76347. * @param order is a reserved parameter and is ignore for now
  76348. * @returns a new Vector3 containing the Euler angles
  76349. */
  76350. Quaternion.prototype.toEulerAngles = function (order) {
  76351. if (order === void 0) { order = "YZX"; }
  76352. var result = Vector3.Zero();
  76353. this.toEulerAnglesToRef(result);
  76354. return result;
  76355. };
  76356. /**
  76357. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76358. * @param result defines the vector which will be filled with the Euler angles
  76359. * @param order is a reserved parameter and is ignore for now
  76360. * @returns the current unchanged quaternion
  76361. */
  76362. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  76363. var qz = this.z;
  76364. var qx = this.x;
  76365. var qy = this.y;
  76366. var qw = this.w;
  76367. var sqw = qw * qw;
  76368. var sqz = qz * qz;
  76369. var sqx = qx * qx;
  76370. var sqy = qy * qy;
  76371. var zAxisY = qy * qz - qx * qw;
  76372. var limit = .4999999;
  76373. if (zAxisY < -limit) {
  76374. result.y = 2 * Math.atan2(qy, qw);
  76375. result.x = Math.PI / 2;
  76376. result.z = 0;
  76377. }
  76378. else if (zAxisY > limit) {
  76379. result.y = 2 * Math.atan2(qy, qw);
  76380. result.x = -Math.PI / 2;
  76381. result.z = 0;
  76382. }
  76383. else {
  76384. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  76385. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  76386. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  76387. }
  76388. return this;
  76389. };
  76390. /**
  76391. * Updates the given rotation matrix with the current quaternion values
  76392. * @param result defines the target matrix
  76393. * @returns the current unchanged quaternion
  76394. */
  76395. Quaternion.prototype.toRotationMatrix = function (result) {
  76396. Matrix.FromQuaternionToRef(this, result);
  76397. return this;
  76398. };
  76399. /**
  76400. * Updates the current quaternion from the given rotation matrix values
  76401. * @param matrix defines the source matrix
  76402. * @returns the current updated quaternion
  76403. */
  76404. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  76405. Quaternion.FromRotationMatrixToRef(matrix, this);
  76406. return this;
  76407. };
  76408. // Statics
  76409. /**
  76410. * Creates a new quaternion from a rotation matrix
  76411. * @param matrix defines the source matrix
  76412. * @returns a new quaternion created from the given rotation matrix values
  76413. */
  76414. Quaternion.FromRotationMatrix = function (matrix) {
  76415. var result = new Quaternion();
  76416. Quaternion.FromRotationMatrixToRef(matrix, result);
  76417. return result;
  76418. };
  76419. /**
  76420. * Updates the given quaternion with the given rotation matrix values
  76421. * @param matrix defines the source matrix
  76422. * @param result defines the target quaternion
  76423. */
  76424. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  76425. var data = matrix.m;
  76426. var m11 = data[0], m12 = data[4], m13 = data[8];
  76427. var m21 = data[1], m22 = data[5], m23 = data[9];
  76428. var m31 = data[2], m32 = data[6], m33 = data[10];
  76429. var trace = m11 + m22 + m33;
  76430. var s;
  76431. if (trace > 0) {
  76432. s = 0.5 / Math.sqrt(trace + 1.0);
  76433. result.w = 0.25 / s;
  76434. result.x = (m32 - m23) * s;
  76435. result.y = (m13 - m31) * s;
  76436. result.z = (m21 - m12) * s;
  76437. }
  76438. else if (m11 > m22 && m11 > m33) {
  76439. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  76440. result.w = (m32 - m23) / s;
  76441. result.x = 0.25 * s;
  76442. result.y = (m12 + m21) / s;
  76443. result.z = (m13 + m31) / s;
  76444. }
  76445. else if (m22 > m33) {
  76446. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  76447. result.w = (m13 - m31) / s;
  76448. result.x = (m12 + m21) / s;
  76449. result.y = 0.25 * s;
  76450. result.z = (m23 + m32) / s;
  76451. }
  76452. else {
  76453. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  76454. result.w = (m21 - m12) / s;
  76455. result.x = (m13 + m31) / s;
  76456. result.y = (m23 + m32) / s;
  76457. result.z = 0.25 * s;
  76458. }
  76459. };
  76460. /**
  76461. * Returns the dot product (float) between the quaternions "left" and "right"
  76462. * @param left defines the left operand
  76463. * @param right defines the right operand
  76464. * @returns the dot product
  76465. */
  76466. Quaternion.Dot = function (left, right) {
  76467. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  76468. };
  76469. /**
  76470. * Checks if the two quaternions are close to each other
  76471. * @param quat0 defines the first quaternion to check
  76472. * @param quat1 defines the second quaternion to check
  76473. * @returns true if the two quaternions are close to each other
  76474. */
  76475. Quaternion.AreClose = function (quat0, quat1) {
  76476. var dot = Quaternion.Dot(quat0, quat1);
  76477. return dot >= 0;
  76478. };
  76479. /**
  76480. * Creates an empty quaternion
  76481. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76482. */
  76483. Quaternion.Zero = function () {
  76484. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  76485. };
  76486. /**
  76487. * Inverse a given quaternion
  76488. * @param q defines the source quaternion
  76489. * @returns a new quaternion as the inverted current quaternion
  76490. */
  76491. Quaternion.Inverse = function (q) {
  76492. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  76493. };
  76494. /**
  76495. * Inverse a given quaternion
  76496. * @param q defines the source quaternion
  76497. * @param result the quaternion the result will be stored in
  76498. * @returns the result quaternion
  76499. */
  76500. Quaternion.InverseToRef = function (q, result) {
  76501. result.set(-q.x, -q.y, -q.z, q.w);
  76502. return result;
  76503. };
  76504. /**
  76505. * Creates an identity quaternion
  76506. * @returns the identity quaternion
  76507. */
  76508. Quaternion.Identity = function () {
  76509. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  76510. };
  76511. /**
  76512. * Gets a boolean indicating if the given quaternion is identity
  76513. * @param quaternion defines the quaternion to check
  76514. * @returns true if the quaternion is identity
  76515. */
  76516. Quaternion.IsIdentity = function (quaternion) {
  76517. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  76518. };
  76519. /**
  76520. * Creates a quaternion from a rotation around an axis
  76521. * @param axis defines the axis to use
  76522. * @param angle defines the angle to use
  76523. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76524. */
  76525. Quaternion.RotationAxis = function (axis, angle) {
  76526. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  76527. };
  76528. /**
  76529. * Creates a rotation around an axis and stores it into the given quaternion
  76530. * @param axis defines the axis to use
  76531. * @param angle defines the angle to use
  76532. * @param result defines the target quaternion
  76533. * @returns the target quaternion
  76534. */
  76535. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  76536. var sin = Math.sin(angle / 2);
  76537. axis.normalize();
  76538. result.w = Math.cos(angle / 2);
  76539. result.x = axis.x * sin;
  76540. result.y = axis.y * sin;
  76541. result.z = axis.z * sin;
  76542. return result;
  76543. };
  76544. /**
  76545. * Creates a new quaternion from data stored into an array
  76546. * @param array defines the data source
  76547. * @param offset defines the offset in the source array where the data starts
  76548. * @returns a new quaternion
  76549. */
  76550. Quaternion.FromArray = function (array, offset) {
  76551. if (!offset) {
  76552. offset = 0;
  76553. }
  76554. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  76555. };
  76556. /**
  76557. * Create a quaternion from Euler rotation angles
  76558. * @param x Pitch
  76559. * @param y Yaw
  76560. * @param z Roll
  76561. * @returns the new Quaternion
  76562. */
  76563. Quaternion.FromEulerAngles = function (x, y, z) {
  76564. var q = new Quaternion();
  76565. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  76566. return q;
  76567. };
  76568. /**
  76569. * Updates a quaternion from Euler rotation angles
  76570. * @param x Pitch
  76571. * @param y Yaw
  76572. * @param z Roll
  76573. * @param result the quaternion to store the result
  76574. * @returns the updated quaternion
  76575. */
  76576. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  76577. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  76578. return result;
  76579. };
  76580. /**
  76581. * Create a quaternion from Euler rotation vector
  76582. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76583. * @returns the new Quaternion
  76584. */
  76585. Quaternion.FromEulerVector = function (vec) {
  76586. var q = new Quaternion();
  76587. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  76588. return q;
  76589. };
  76590. /**
  76591. * Updates a quaternion from Euler rotation vector
  76592. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76593. * @param result the quaternion to store the result
  76594. * @returns the updated quaternion
  76595. */
  76596. Quaternion.FromEulerVectorToRef = function (vec, result) {
  76597. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  76598. return result;
  76599. };
  76600. /**
  76601. * Creates a new quaternion from the given Euler float angles (y, x, z)
  76602. * @param yaw defines the rotation around Y axis
  76603. * @param pitch defines the rotation around X axis
  76604. * @param roll defines the rotation around Z axis
  76605. * @returns the new quaternion
  76606. */
  76607. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  76608. var q = new Quaternion();
  76609. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  76610. return q;
  76611. };
  76612. /**
  76613. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  76614. * @param yaw defines the rotation around Y axis
  76615. * @param pitch defines the rotation around X axis
  76616. * @param roll defines the rotation around Z axis
  76617. * @param result defines the target quaternion
  76618. */
  76619. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  76620. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  76621. var halfRoll = roll * 0.5;
  76622. var halfPitch = pitch * 0.5;
  76623. var halfYaw = yaw * 0.5;
  76624. var sinRoll = Math.sin(halfRoll);
  76625. var cosRoll = Math.cos(halfRoll);
  76626. var sinPitch = Math.sin(halfPitch);
  76627. var cosPitch = Math.cos(halfPitch);
  76628. var sinYaw = Math.sin(halfYaw);
  76629. var cosYaw = Math.cos(halfYaw);
  76630. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  76631. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  76632. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  76633. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  76634. };
  76635. /**
  76636. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  76637. * @param alpha defines the rotation around first axis
  76638. * @param beta defines the rotation around second axis
  76639. * @param gamma defines the rotation around third axis
  76640. * @returns the new quaternion
  76641. */
  76642. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  76643. var result = new Quaternion();
  76644. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  76645. return result;
  76646. };
  76647. /**
  76648. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  76649. * @param alpha defines the rotation around first axis
  76650. * @param beta defines the rotation around second axis
  76651. * @param gamma defines the rotation around third axis
  76652. * @param result defines the target quaternion
  76653. */
  76654. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  76655. // Produces a quaternion from Euler angles in the z-x-z orientation
  76656. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  76657. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  76658. var halfBeta = beta * 0.5;
  76659. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  76660. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  76661. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  76662. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  76663. };
  76664. /**
  76665. * 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)
  76666. * @param axis1 defines the first axis
  76667. * @param axis2 defines the second axis
  76668. * @param axis3 defines the third axis
  76669. * @returns the new quaternion
  76670. */
  76671. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  76672. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  76673. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  76674. return quat;
  76675. };
  76676. /**
  76677. * 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
  76678. * @param axis1 defines the first axis
  76679. * @param axis2 defines the second axis
  76680. * @param axis3 defines the third axis
  76681. * @param ref defines the target quaternion
  76682. */
  76683. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  76684. var rotMat = MathTmp.Matrix[0];
  76685. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  76686. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  76687. };
  76688. /**
  76689. * Interpolates between two quaternions
  76690. * @param left defines first quaternion
  76691. * @param right defines second quaternion
  76692. * @param amount defines the gradient to use
  76693. * @returns the new interpolated quaternion
  76694. */
  76695. Quaternion.Slerp = function (left, right, amount) {
  76696. var result = Quaternion.Identity();
  76697. Quaternion.SlerpToRef(left, right, amount, result);
  76698. return result;
  76699. };
  76700. /**
  76701. * Interpolates between two quaternions and stores it into a target quaternion
  76702. * @param left defines first quaternion
  76703. * @param right defines second quaternion
  76704. * @param amount defines the gradient to use
  76705. * @param result defines the target quaternion
  76706. */
  76707. Quaternion.SlerpToRef = function (left, right, amount, result) {
  76708. var num2;
  76709. var num3;
  76710. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  76711. var flag = false;
  76712. if (num4 < 0) {
  76713. flag = true;
  76714. num4 = -num4;
  76715. }
  76716. if (num4 > 0.999999) {
  76717. num3 = 1 - amount;
  76718. num2 = flag ? -amount : amount;
  76719. }
  76720. else {
  76721. var num5 = Math.acos(num4);
  76722. var num6 = (1.0 / Math.sin(num5));
  76723. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  76724. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  76725. }
  76726. result.x = (num3 * left.x) + (num2 * right.x);
  76727. result.y = (num3 * left.y) + (num2 * right.y);
  76728. result.z = (num3 * left.z) + (num2 * right.z);
  76729. result.w = (num3 * left.w) + (num2 * right.w);
  76730. };
  76731. /**
  76732. * Interpolate between two quaternions using Hermite interpolation
  76733. * @param value1 defines first quaternion
  76734. * @param tangent1 defines the incoming tangent
  76735. * @param value2 defines second quaternion
  76736. * @param tangent2 defines the outgoing tangent
  76737. * @param amount defines the target quaternion
  76738. * @returns the new interpolated quaternion
  76739. */
  76740. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  76741. var squared = amount * amount;
  76742. var cubed = amount * squared;
  76743. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  76744. var part2 = (-2.0 * cubed) + (3.0 * squared);
  76745. var part3 = (cubed - (2.0 * squared)) + amount;
  76746. var part4 = cubed - squared;
  76747. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  76748. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  76749. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  76750. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  76751. return new Quaternion(x, y, z, w);
  76752. };
  76753. return Quaternion;
  76754. }());
  76755. /**
  76756. * Class used to store matrix data (4x4)
  76757. */
  76758. var Matrix = /** @class */ (function () {
  76759. /**
  76760. * Creates an empty matrix (filled with zeros)
  76761. */
  76762. function Matrix() {
  76763. this._isIdentity = false;
  76764. this._isIdentityDirty = true;
  76765. this._isIdentity3x2 = true;
  76766. this._isIdentity3x2Dirty = true;
  76767. /**
  76768. * Gets the update flag of the matrix which is an unique number for the matrix.
  76769. * It will be incremented every time the matrix data change.
  76770. * You can use it to speed the comparison between two versions of the same matrix.
  76771. */
  76772. this.updateFlag = -1;
  76773. this._m = new Float32Array(16);
  76774. this._updateIdentityStatus(false);
  76775. }
  76776. Object.defineProperty(Matrix.prototype, "m", {
  76777. /**
  76778. * Gets the internal data of the matrix
  76779. */
  76780. get: function () { return this._m; },
  76781. enumerable: true,
  76782. configurable: true
  76783. });
  76784. /** @hidden */
  76785. Matrix.prototype._markAsUpdated = function () {
  76786. this.updateFlag = Matrix._updateFlagSeed++;
  76787. this._isIdentity = false;
  76788. this._isIdentity3x2 = false;
  76789. this._isIdentityDirty = true;
  76790. this._isIdentity3x2Dirty = true;
  76791. };
  76792. /** @hidden */
  76793. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  76794. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  76795. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  76796. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  76797. this.updateFlag = Matrix._updateFlagSeed++;
  76798. this._isIdentity = isIdentity;
  76799. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  76800. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  76801. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  76802. };
  76803. // Properties
  76804. /**
  76805. * Check if the current matrix is identity
  76806. * @returns true is the matrix is the identity matrix
  76807. */
  76808. Matrix.prototype.isIdentity = function () {
  76809. if (this._isIdentityDirty) {
  76810. this._isIdentityDirty = false;
  76811. var m = this._m;
  76812. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  76813. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  76814. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  76815. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  76816. }
  76817. return this._isIdentity;
  76818. };
  76819. /**
  76820. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  76821. * @returns true is the matrix is the identity matrix
  76822. */
  76823. Matrix.prototype.isIdentityAs3x2 = function () {
  76824. if (this._isIdentity3x2Dirty) {
  76825. this._isIdentity3x2Dirty = false;
  76826. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  76827. this._isIdentity3x2 = false;
  76828. }
  76829. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  76830. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  76831. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  76832. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  76833. this._isIdentity3x2 = false;
  76834. }
  76835. else {
  76836. this._isIdentity3x2 = true;
  76837. }
  76838. }
  76839. return this._isIdentity3x2;
  76840. };
  76841. /**
  76842. * Gets the determinant of the matrix
  76843. * @returns the matrix determinant
  76844. */
  76845. Matrix.prototype.determinant = function () {
  76846. if (this._isIdentity === true) {
  76847. return 1;
  76848. }
  76849. var m = this._m;
  76850. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  76851. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  76852. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  76853. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  76854. // https://en.wikipedia.org/wiki/Laplace_expansion
  76855. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  76856. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  76857. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  76858. // where
  76859. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  76860. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  76861. //
  76862. // Here we do that for the 1st row.
  76863. var det_22_33 = m22 * m33 - m32 * m23;
  76864. var det_21_33 = m21 * m33 - m31 * m23;
  76865. var det_21_32 = m21 * m32 - m31 * m22;
  76866. var det_20_33 = m20 * m33 - m30 * m23;
  76867. var det_20_32 = m20 * m32 - m22 * m30;
  76868. var det_20_31 = m20 * m31 - m30 * m21;
  76869. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  76870. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  76871. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  76872. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  76873. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  76874. };
  76875. // Methods
  76876. /**
  76877. * Returns the matrix as a Float32Array
  76878. * @returns the matrix underlying array
  76879. */
  76880. Matrix.prototype.toArray = function () {
  76881. return this._m;
  76882. };
  76883. /**
  76884. * Returns the matrix as a Float32Array
  76885. * @returns the matrix underlying array.
  76886. */
  76887. Matrix.prototype.asArray = function () {
  76888. return this._m;
  76889. };
  76890. /**
  76891. * Inverts the current matrix in place
  76892. * @returns the current inverted matrix
  76893. */
  76894. Matrix.prototype.invert = function () {
  76895. this.invertToRef(this);
  76896. return this;
  76897. };
  76898. /**
  76899. * Sets all the matrix elements to zero
  76900. * @returns the current matrix
  76901. */
  76902. Matrix.prototype.reset = function () {
  76903. 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);
  76904. this._updateIdentityStatus(false);
  76905. return this;
  76906. };
  76907. /**
  76908. * Adds the current matrix with a second one
  76909. * @param other defines the matrix to add
  76910. * @returns a new matrix as the addition of the current matrix and the given one
  76911. */
  76912. Matrix.prototype.add = function (other) {
  76913. var result = new Matrix();
  76914. this.addToRef(other, result);
  76915. return result;
  76916. };
  76917. /**
  76918. * Sets the given matrix "result" to the addition of the current matrix and the given one
  76919. * @param other defines the matrix to add
  76920. * @param result defines the target matrix
  76921. * @returns the current matrix
  76922. */
  76923. Matrix.prototype.addToRef = function (other, result) {
  76924. var m = this._m;
  76925. var resultM = result._m;
  76926. var otherM = other.m;
  76927. for (var index = 0; index < 16; index++) {
  76928. resultM[index] = m[index] + otherM[index];
  76929. }
  76930. result._markAsUpdated();
  76931. return this;
  76932. };
  76933. /**
  76934. * Adds in place the given matrix to the current matrix
  76935. * @param other defines the second operand
  76936. * @returns the current updated matrix
  76937. */
  76938. Matrix.prototype.addToSelf = function (other) {
  76939. var m = this._m;
  76940. var otherM = other.m;
  76941. for (var index = 0; index < 16; index++) {
  76942. m[index] += otherM[index];
  76943. }
  76944. this._markAsUpdated();
  76945. return this;
  76946. };
  76947. /**
  76948. * Sets the given matrix to the current inverted Matrix
  76949. * @param other defines the target matrix
  76950. * @returns the unmodified current matrix
  76951. */
  76952. Matrix.prototype.invertToRef = function (other) {
  76953. if (this._isIdentity === true) {
  76954. Matrix.IdentityToRef(other);
  76955. return this;
  76956. }
  76957. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  76958. var m = this._m;
  76959. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  76960. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  76961. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  76962. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  76963. var det_22_33 = m22 * m33 - m32 * m23;
  76964. var det_21_33 = m21 * m33 - m31 * m23;
  76965. var det_21_32 = m21 * m32 - m31 * m22;
  76966. var det_20_33 = m20 * m33 - m30 * m23;
  76967. var det_20_32 = m20 * m32 - m22 * m30;
  76968. var det_20_31 = m20 * m31 - m30 * m21;
  76969. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  76970. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  76971. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  76972. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  76973. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  76974. if (det === 0) {
  76975. // not invertible
  76976. other.copyFrom(this);
  76977. return this;
  76978. }
  76979. var detInv = 1 / det;
  76980. var det_12_33 = m12 * m33 - m32 * m13;
  76981. var det_11_33 = m11 * m33 - m31 * m13;
  76982. var det_11_32 = m11 * m32 - m31 * m12;
  76983. var det_10_33 = m10 * m33 - m30 * m13;
  76984. var det_10_32 = m10 * m32 - m30 * m12;
  76985. var det_10_31 = m10 * m31 - m30 * m11;
  76986. var det_12_23 = m12 * m23 - m22 * m13;
  76987. var det_11_23 = m11 * m23 - m21 * m13;
  76988. var det_11_22 = m11 * m22 - m21 * m12;
  76989. var det_10_23 = m10 * m23 - m20 * m13;
  76990. var det_10_22 = m10 * m22 - m20 * m12;
  76991. var det_10_21 = m10 * m21 - m20 * m11;
  76992. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  76993. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  76994. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  76995. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  76996. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  76997. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  76998. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  76999. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  77000. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  77001. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  77002. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  77003. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  77004. 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);
  77005. return this;
  77006. };
  77007. /**
  77008. * add a value at the specified position in the current Matrix
  77009. * @param index the index of the value within the matrix. between 0 and 15.
  77010. * @param value the value to be added
  77011. * @returns the current updated matrix
  77012. */
  77013. Matrix.prototype.addAtIndex = function (index, value) {
  77014. this._m[index] += value;
  77015. this._markAsUpdated();
  77016. return this;
  77017. };
  77018. /**
  77019. * mutiply the specified position in the current Matrix by a value
  77020. * @param index the index of the value within the matrix. between 0 and 15.
  77021. * @param value the value to be added
  77022. * @returns the current updated matrix
  77023. */
  77024. Matrix.prototype.multiplyAtIndex = function (index, value) {
  77025. this._m[index] *= value;
  77026. this._markAsUpdated();
  77027. return this;
  77028. };
  77029. /**
  77030. * Inserts the translation vector (using 3 floats) in the current matrix
  77031. * @param x defines the 1st component of the translation
  77032. * @param y defines the 2nd component of the translation
  77033. * @param z defines the 3rd component of the translation
  77034. * @returns the current updated matrix
  77035. */
  77036. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  77037. this._m[12] = x;
  77038. this._m[13] = y;
  77039. this._m[14] = z;
  77040. this._markAsUpdated();
  77041. return this;
  77042. };
  77043. /**
  77044. * Adds the translation vector (using 3 floats) in the current matrix
  77045. * @param x defines the 1st component of the translation
  77046. * @param y defines the 2nd component of the translation
  77047. * @param z defines the 3rd component of the translation
  77048. * @returns the current updated matrix
  77049. */
  77050. Matrix.prototype.addTranslationFromFloats = function (x, y, z) {
  77051. this._m[12] += x;
  77052. this._m[13] += y;
  77053. this._m[14] += z;
  77054. this._markAsUpdated();
  77055. return this;
  77056. };
  77057. /**
  77058. * Inserts the translation vector in the current matrix
  77059. * @param vector3 defines the translation to insert
  77060. * @returns the current updated matrix
  77061. */
  77062. Matrix.prototype.setTranslation = function (vector3) {
  77063. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  77064. };
  77065. /**
  77066. * Gets the translation value of the current matrix
  77067. * @returns a new Vector3 as the extracted translation from the matrix
  77068. */
  77069. Matrix.prototype.getTranslation = function () {
  77070. return new Vector3(this._m[12], this._m[13], this._m[14]);
  77071. };
  77072. /**
  77073. * Fill a Vector3 with the extracted translation from the matrix
  77074. * @param result defines the Vector3 where to store the translation
  77075. * @returns the current matrix
  77076. */
  77077. Matrix.prototype.getTranslationToRef = function (result) {
  77078. result.x = this._m[12];
  77079. result.y = this._m[13];
  77080. result.z = this._m[14];
  77081. return this;
  77082. };
  77083. /**
  77084. * Remove rotation and scaling part from the matrix
  77085. * @returns the updated matrix
  77086. */
  77087. Matrix.prototype.removeRotationAndScaling = function () {
  77088. var m = this.m;
  77089. 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);
  77090. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  77091. return this;
  77092. };
  77093. /**
  77094. * Multiply two matrices
  77095. * @param other defines the second operand
  77096. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77097. */
  77098. Matrix.prototype.multiply = function (other) {
  77099. var result = new Matrix();
  77100. this.multiplyToRef(other, result);
  77101. return result;
  77102. };
  77103. /**
  77104. * Copy the current matrix from the given one
  77105. * @param other defines the source matrix
  77106. * @returns the current updated matrix
  77107. */
  77108. Matrix.prototype.copyFrom = function (other) {
  77109. other.copyToArray(this._m);
  77110. var o = other;
  77111. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  77112. return this;
  77113. };
  77114. /**
  77115. * Populates the given array from the starting index with the current matrix values
  77116. * @param array defines the target array
  77117. * @param offset defines the offset in the target array where to start storing values
  77118. * @returns the current matrix
  77119. */
  77120. Matrix.prototype.copyToArray = function (array, offset) {
  77121. if (offset === void 0) { offset = 0; }
  77122. for (var index = 0; index < 16; index++) {
  77123. array[offset + index] = this._m[index];
  77124. }
  77125. return this;
  77126. };
  77127. /**
  77128. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77129. * @param other defines the second operand
  77130. * @param result defines the matrix where to store the multiplication
  77131. * @returns the current matrix
  77132. */
  77133. Matrix.prototype.multiplyToRef = function (other, result) {
  77134. if (this._isIdentity) {
  77135. result.copyFrom(other);
  77136. return this;
  77137. }
  77138. if (other._isIdentity) {
  77139. result.copyFrom(this);
  77140. return this;
  77141. }
  77142. this.multiplyToArray(other, result._m, 0);
  77143. result._markAsUpdated();
  77144. return this;
  77145. };
  77146. /**
  77147. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77148. * @param other defines the second operand
  77149. * @param result defines the array where to store the multiplication
  77150. * @param offset defines the offset in the target array where to start storing values
  77151. * @returns the current matrix
  77152. */
  77153. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  77154. var m = this._m;
  77155. var otherM = other.m;
  77156. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  77157. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  77158. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  77159. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  77160. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  77161. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  77162. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  77163. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  77164. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  77165. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  77166. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  77167. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  77168. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  77169. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  77170. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  77171. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  77172. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  77173. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  77174. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  77175. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  77176. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  77177. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  77178. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  77179. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  77180. return this;
  77181. };
  77182. /**
  77183. * Check equality between this matrix and a second one
  77184. * @param value defines the second matrix to compare
  77185. * @returns true is the current matrix and the given one values are strictly equal
  77186. */
  77187. Matrix.prototype.equals = function (value) {
  77188. var other = value;
  77189. if (!other) {
  77190. return false;
  77191. }
  77192. if (this._isIdentity || other._isIdentity) {
  77193. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  77194. return this._isIdentity && other._isIdentity;
  77195. }
  77196. }
  77197. var m = this.m;
  77198. var om = other.m;
  77199. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  77200. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  77201. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  77202. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  77203. };
  77204. /**
  77205. * Clone the current matrix
  77206. * @returns a new matrix from the current matrix
  77207. */
  77208. Matrix.prototype.clone = function () {
  77209. var matrix = new Matrix();
  77210. matrix.copyFrom(this);
  77211. return matrix;
  77212. };
  77213. /**
  77214. * Returns the name of the current matrix class
  77215. * @returns the string "Matrix"
  77216. */
  77217. Matrix.prototype.getClassName = function () {
  77218. return "Matrix";
  77219. };
  77220. /**
  77221. * Gets the hash code of the current matrix
  77222. * @returns the hash code
  77223. */
  77224. Matrix.prototype.getHashCode = function () {
  77225. var hash = this._m[0] || 0;
  77226. for (var i = 1; i < 16; i++) {
  77227. hash = (hash * 397) ^ (this._m[i] || 0);
  77228. }
  77229. return hash;
  77230. };
  77231. /**
  77232. * Decomposes the current Matrix into a translation, rotation and scaling components
  77233. * @param scale defines the scale vector3 given as a reference to update
  77234. * @param rotation defines the rotation quaternion given as a reference to update
  77235. * @param translation defines the translation vector3 given as a reference to update
  77236. * @returns true if operation was successful
  77237. */
  77238. Matrix.prototype.decompose = function (scale, rotation, translation) {
  77239. if (this._isIdentity) {
  77240. if (translation) {
  77241. translation.setAll(0);
  77242. }
  77243. if (scale) {
  77244. scale.setAll(1);
  77245. }
  77246. if (rotation) {
  77247. rotation.copyFromFloats(0, 0, 0, 1);
  77248. }
  77249. return true;
  77250. }
  77251. var m = this._m;
  77252. if (translation) {
  77253. translation.copyFromFloats(m[12], m[13], m[14]);
  77254. }
  77255. scale = scale || MathTmp.Vector3[0];
  77256. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  77257. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  77258. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  77259. if (this.determinant() <= 0) {
  77260. scale.y *= -1;
  77261. }
  77262. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  77263. if (rotation) {
  77264. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  77265. }
  77266. return false;
  77267. }
  77268. if (rotation) {
  77269. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  77270. 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]);
  77271. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  77272. }
  77273. return true;
  77274. };
  77275. /**
  77276. * Gets specific row of the matrix
  77277. * @param index defines the number of the row to get
  77278. * @returns the index-th row of the current matrix as a new Vector4
  77279. */
  77280. Matrix.prototype.getRow = function (index) {
  77281. if (index < 0 || index > 3) {
  77282. return null;
  77283. }
  77284. var i = index * 4;
  77285. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  77286. };
  77287. /**
  77288. * Sets the index-th row of the current matrix to the vector4 values
  77289. * @param index defines the number of the row to set
  77290. * @param row defines the target vector4
  77291. * @returns the updated current matrix
  77292. */
  77293. Matrix.prototype.setRow = function (index, row) {
  77294. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  77295. };
  77296. /**
  77297. * Compute the transpose of the matrix
  77298. * @returns the new transposed matrix
  77299. */
  77300. Matrix.prototype.transpose = function () {
  77301. return Matrix.Transpose(this);
  77302. };
  77303. /**
  77304. * Compute the transpose of the matrix and store it in a given matrix
  77305. * @param result defines the target matrix
  77306. * @returns the current matrix
  77307. */
  77308. Matrix.prototype.transposeToRef = function (result) {
  77309. Matrix.TransposeToRef(this, result);
  77310. return this;
  77311. };
  77312. /**
  77313. * Sets the index-th row of the current matrix with the given 4 x float values
  77314. * @param index defines the row index
  77315. * @param x defines the x component to set
  77316. * @param y defines the y component to set
  77317. * @param z defines the z component to set
  77318. * @param w defines the w component to set
  77319. * @returns the updated current matrix
  77320. */
  77321. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  77322. if (index < 0 || index > 3) {
  77323. return this;
  77324. }
  77325. var i = index * 4;
  77326. this._m[i + 0] = x;
  77327. this._m[i + 1] = y;
  77328. this._m[i + 2] = z;
  77329. this._m[i + 3] = w;
  77330. this._markAsUpdated();
  77331. return this;
  77332. };
  77333. /**
  77334. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77335. * @param scale defines the scale factor
  77336. * @returns a new matrix
  77337. */
  77338. Matrix.prototype.scale = function (scale) {
  77339. var result = new Matrix();
  77340. this.scaleToRef(scale, result);
  77341. return result;
  77342. };
  77343. /**
  77344. * Scale the current matrix values by a factor to a given result matrix
  77345. * @param scale defines the scale factor
  77346. * @param result defines the matrix to store the result
  77347. * @returns the current matrix
  77348. */
  77349. Matrix.prototype.scaleToRef = function (scale, result) {
  77350. for (var index = 0; index < 16; index++) {
  77351. result._m[index] = this._m[index] * scale;
  77352. }
  77353. result._markAsUpdated();
  77354. return this;
  77355. };
  77356. /**
  77357. * Scale the current matrix values by a factor and add the result to a given matrix
  77358. * @param scale defines the scale factor
  77359. * @param result defines the Matrix to store the result
  77360. * @returns the current matrix
  77361. */
  77362. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  77363. for (var index = 0; index < 16; index++) {
  77364. result._m[index] += this._m[index] * scale;
  77365. }
  77366. result._markAsUpdated();
  77367. return this;
  77368. };
  77369. /**
  77370. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77371. * @param ref matrix to store the result
  77372. */
  77373. Matrix.prototype.toNormalMatrix = function (ref) {
  77374. var tmp = MathTmp.Matrix[0];
  77375. this.invertToRef(tmp);
  77376. tmp.transposeToRef(ref);
  77377. var m = ref._m;
  77378. 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);
  77379. };
  77380. /**
  77381. * Gets only rotation part of the current matrix
  77382. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77383. */
  77384. Matrix.prototype.getRotationMatrix = function () {
  77385. var result = new Matrix();
  77386. this.getRotationMatrixToRef(result);
  77387. return result;
  77388. };
  77389. /**
  77390. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77391. * @param result defines the target matrix to store data to
  77392. * @returns the current matrix
  77393. */
  77394. Matrix.prototype.getRotationMatrixToRef = function (result) {
  77395. var scale = MathTmp.Vector3[0];
  77396. if (!this.decompose(scale)) {
  77397. Matrix.IdentityToRef(result);
  77398. return this;
  77399. }
  77400. var m = this._m;
  77401. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  77402. 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);
  77403. return this;
  77404. };
  77405. /**
  77406. * Toggles model matrix from being right handed to left handed in place and vice versa
  77407. */
  77408. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  77409. var m = this._m;
  77410. m[2] *= -1;
  77411. m[6] *= -1;
  77412. m[8] *= -1;
  77413. m[9] *= -1;
  77414. m[14] *= -1;
  77415. this._markAsUpdated();
  77416. };
  77417. /**
  77418. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77419. */
  77420. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  77421. var m = this._m;
  77422. m[8] *= -1;
  77423. m[9] *= -1;
  77424. m[10] *= -1;
  77425. m[11] *= -1;
  77426. this._markAsUpdated();
  77427. };
  77428. // Statics
  77429. /**
  77430. * Creates a matrix from an array
  77431. * @param array defines the source array
  77432. * @param offset defines an offset in the source array
  77433. * @returns a new Matrix set from the starting index of the given array
  77434. */
  77435. Matrix.FromArray = function (array, offset) {
  77436. if (offset === void 0) { offset = 0; }
  77437. var result = new Matrix();
  77438. Matrix.FromArrayToRef(array, offset, result);
  77439. return result;
  77440. };
  77441. /**
  77442. * Copy the content of an array into a given matrix
  77443. * @param array defines the source array
  77444. * @param offset defines an offset in the source array
  77445. * @param result defines the target matrix
  77446. */
  77447. Matrix.FromArrayToRef = function (array, offset, result) {
  77448. for (var index = 0; index < 16; index++) {
  77449. result._m[index] = array[index + offset];
  77450. }
  77451. result._markAsUpdated();
  77452. };
  77453. /**
  77454. * Stores an array into a matrix after having multiplied each component by a given factor
  77455. * @param array defines the source array
  77456. * @param offset defines the offset in the source array
  77457. * @param scale defines the scaling factor
  77458. * @param result defines the target matrix
  77459. */
  77460. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  77461. for (var index = 0; index < 16; index++) {
  77462. result._m[index] = array[index + offset] * scale;
  77463. }
  77464. result._markAsUpdated();
  77465. };
  77466. Object.defineProperty(Matrix, "IdentityReadOnly", {
  77467. /**
  77468. * Gets an identity matrix that must not be updated
  77469. */
  77470. get: function () {
  77471. return Matrix._identityReadOnly;
  77472. },
  77473. enumerable: true,
  77474. configurable: true
  77475. });
  77476. /**
  77477. * Stores a list of values (16) inside a given matrix
  77478. * @param initialM11 defines 1st value of 1st row
  77479. * @param initialM12 defines 2nd value of 1st row
  77480. * @param initialM13 defines 3rd value of 1st row
  77481. * @param initialM14 defines 4th value of 1st row
  77482. * @param initialM21 defines 1st value of 2nd row
  77483. * @param initialM22 defines 2nd value of 2nd row
  77484. * @param initialM23 defines 3rd value of 2nd row
  77485. * @param initialM24 defines 4th value of 2nd row
  77486. * @param initialM31 defines 1st value of 3rd row
  77487. * @param initialM32 defines 2nd value of 3rd row
  77488. * @param initialM33 defines 3rd value of 3rd row
  77489. * @param initialM34 defines 4th value of 3rd row
  77490. * @param initialM41 defines 1st value of 4th row
  77491. * @param initialM42 defines 2nd value of 4th row
  77492. * @param initialM43 defines 3rd value of 4th row
  77493. * @param initialM44 defines 4th value of 4th row
  77494. * @param result defines the target matrix
  77495. */
  77496. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  77497. var m = result._m;
  77498. m[0] = initialM11;
  77499. m[1] = initialM12;
  77500. m[2] = initialM13;
  77501. m[3] = initialM14;
  77502. m[4] = initialM21;
  77503. m[5] = initialM22;
  77504. m[6] = initialM23;
  77505. m[7] = initialM24;
  77506. m[8] = initialM31;
  77507. m[9] = initialM32;
  77508. m[10] = initialM33;
  77509. m[11] = initialM34;
  77510. m[12] = initialM41;
  77511. m[13] = initialM42;
  77512. m[14] = initialM43;
  77513. m[15] = initialM44;
  77514. result._markAsUpdated();
  77515. };
  77516. /**
  77517. * Creates new matrix from a list of values (16)
  77518. * @param initialM11 defines 1st value of 1st row
  77519. * @param initialM12 defines 2nd value of 1st row
  77520. * @param initialM13 defines 3rd value of 1st row
  77521. * @param initialM14 defines 4th value of 1st row
  77522. * @param initialM21 defines 1st value of 2nd row
  77523. * @param initialM22 defines 2nd value of 2nd row
  77524. * @param initialM23 defines 3rd value of 2nd row
  77525. * @param initialM24 defines 4th value of 2nd row
  77526. * @param initialM31 defines 1st value of 3rd row
  77527. * @param initialM32 defines 2nd value of 3rd row
  77528. * @param initialM33 defines 3rd value of 3rd row
  77529. * @param initialM34 defines 4th value of 3rd row
  77530. * @param initialM41 defines 1st value of 4th row
  77531. * @param initialM42 defines 2nd value of 4th row
  77532. * @param initialM43 defines 3rd value of 4th row
  77533. * @param initialM44 defines 4th value of 4th row
  77534. * @returns the new matrix
  77535. */
  77536. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  77537. var result = new Matrix();
  77538. var m = result._m;
  77539. m[0] = initialM11;
  77540. m[1] = initialM12;
  77541. m[2] = initialM13;
  77542. m[3] = initialM14;
  77543. m[4] = initialM21;
  77544. m[5] = initialM22;
  77545. m[6] = initialM23;
  77546. m[7] = initialM24;
  77547. m[8] = initialM31;
  77548. m[9] = initialM32;
  77549. m[10] = initialM33;
  77550. m[11] = initialM34;
  77551. m[12] = initialM41;
  77552. m[13] = initialM42;
  77553. m[14] = initialM43;
  77554. m[15] = initialM44;
  77555. result._markAsUpdated();
  77556. return result;
  77557. };
  77558. /**
  77559. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77560. * @param scale defines the scale vector3
  77561. * @param rotation defines the rotation quaternion
  77562. * @param translation defines the translation vector3
  77563. * @returns a new matrix
  77564. */
  77565. Matrix.Compose = function (scale, rotation, translation) {
  77566. var result = new Matrix();
  77567. Matrix.ComposeToRef(scale, rotation, translation, result);
  77568. return result;
  77569. };
  77570. /**
  77571. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77572. * @param scale defines the scale vector3
  77573. * @param rotation defines the rotation quaternion
  77574. * @param translation defines the translation vector3
  77575. * @param result defines the target matrix
  77576. */
  77577. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  77578. var m = result._m;
  77579. var x = rotation.x, y = rotation.y, z = rotation.z, w = rotation.w;
  77580. var x2 = x + x, y2 = y + y, z2 = z + z;
  77581. var xx = x * x2, xy = x * y2, xz = x * z2;
  77582. var yy = y * y2, yz = y * z2, zz = z * z2;
  77583. var wx = w * x2, wy = w * y2, wz = w * z2;
  77584. var sx = scale.x, sy = scale.y, sz = scale.z;
  77585. m[0] = (1 - (yy + zz)) * sx;
  77586. m[1] = (xy + wz) * sx;
  77587. m[2] = (xz - wy) * sx;
  77588. m[3] = 0;
  77589. m[4] = (xy - wz) * sy;
  77590. m[5] = (1 - (xx + zz)) * sy;
  77591. m[6] = (yz + wx) * sy;
  77592. m[7] = 0;
  77593. m[8] = (xz + wy) * sz;
  77594. m[9] = (yz - wx) * sz;
  77595. m[10] = (1 - (xx + yy)) * sz;
  77596. m[11] = 0;
  77597. m[12] = translation.x;
  77598. m[13] = translation.y;
  77599. m[14] = translation.z;
  77600. m[15] = 1;
  77601. result._markAsUpdated();
  77602. };
  77603. /**
  77604. * Creates a new identity matrix
  77605. * @returns a new identity matrix
  77606. */
  77607. Matrix.Identity = function () {
  77608. 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);
  77609. identity._updateIdentityStatus(true);
  77610. return identity;
  77611. };
  77612. /**
  77613. * Creates a new identity matrix and stores the result in a given matrix
  77614. * @param result defines the target matrix
  77615. */
  77616. Matrix.IdentityToRef = function (result) {
  77617. 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);
  77618. result._updateIdentityStatus(true);
  77619. };
  77620. /**
  77621. * Creates a new zero matrix
  77622. * @returns a new zero matrix
  77623. */
  77624. Matrix.Zero = function () {
  77625. 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);
  77626. zero._updateIdentityStatus(false);
  77627. return zero;
  77628. };
  77629. /**
  77630. * Creates a new rotation matrix for "angle" radians around the X axis
  77631. * @param angle defines the angle (in radians) to use
  77632. * @return the new matrix
  77633. */
  77634. Matrix.RotationX = function (angle) {
  77635. var result = new Matrix();
  77636. Matrix.RotationXToRef(angle, result);
  77637. return result;
  77638. };
  77639. /**
  77640. * Creates a new matrix as the invert of a given matrix
  77641. * @param source defines the source matrix
  77642. * @returns the new matrix
  77643. */
  77644. Matrix.Invert = function (source) {
  77645. var result = new Matrix();
  77646. source.invertToRef(result);
  77647. return result;
  77648. };
  77649. /**
  77650. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77651. * @param angle defines the angle (in radians) to use
  77652. * @param result defines the target matrix
  77653. */
  77654. Matrix.RotationXToRef = function (angle, result) {
  77655. var s = Math.sin(angle);
  77656. var c = Math.cos(angle);
  77657. 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);
  77658. result._updateIdentityStatus(c === 1 && s === 0);
  77659. };
  77660. /**
  77661. * Creates a new rotation matrix for "angle" radians around the Y axis
  77662. * @param angle defines the angle (in radians) to use
  77663. * @return the new matrix
  77664. */
  77665. Matrix.RotationY = function (angle) {
  77666. var result = new Matrix();
  77667. Matrix.RotationYToRef(angle, result);
  77668. return result;
  77669. };
  77670. /**
  77671. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77672. * @param angle defines the angle (in radians) to use
  77673. * @param result defines the target matrix
  77674. */
  77675. Matrix.RotationYToRef = function (angle, result) {
  77676. var s = Math.sin(angle);
  77677. var c = Math.cos(angle);
  77678. 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);
  77679. result._updateIdentityStatus(c === 1 && s === 0);
  77680. };
  77681. /**
  77682. * Creates a new rotation matrix for "angle" radians around the Z axis
  77683. * @param angle defines the angle (in radians) to use
  77684. * @return the new matrix
  77685. */
  77686. Matrix.RotationZ = function (angle) {
  77687. var result = new Matrix();
  77688. Matrix.RotationZToRef(angle, result);
  77689. return result;
  77690. };
  77691. /**
  77692. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77693. * @param angle defines the angle (in radians) to use
  77694. * @param result defines the target matrix
  77695. */
  77696. Matrix.RotationZToRef = function (angle, result) {
  77697. var s = Math.sin(angle);
  77698. var c = Math.cos(angle);
  77699. 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);
  77700. result._updateIdentityStatus(c === 1 && s === 0);
  77701. };
  77702. /**
  77703. * Creates a new rotation matrix for "angle" radians around the given axis
  77704. * @param axis defines the axis to use
  77705. * @param angle defines the angle (in radians) to use
  77706. * @return the new matrix
  77707. */
  77708. Matrix.RotationAxis = function (axis, angle) {
  77709. var result = new Matrix();
  77710. Matrix.RotationAxisToRef(axis, angle, result);
  77711. return result;
  77712. };
  77713. /**
  77714. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77715. * @param axis defines the axis to use
  77716. * @param angle defines the angle (in radians) to use
  77717. * @param result defines the target matrix
  77718. */
  77719. Matrix.RotationAxisToRef = function (axis, angle, result) {
  77720. var s = Math.sin(-angle);
  77721. var c = Math.cos(-angle);
  77722. var c1 = 1 - c;
  77723. axis.normalize();
  77724. var m = result._m;
  77725. m[0] = (axis.x * axis.x) * c1 + c;
  77726. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  77727. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  77728. m[3] = 0.0;
  77729. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  77730. m[5] = (axis.y * axis.y) * c1 + c;
  77731. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  77732. m[7] = 0.0;
  77733. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  77734. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  77735. m[10] = (axis.z * axis.z) * c1 + c;
  77736. m[11] = 0.0;
  77737. m[12] = 0.0;
  77738. m[13] = 0.0;
  77739. m[14] = 0.0;
  77740. m[15] = 1.0;
  77741. result._markAsUpdated();
  77742. };
  77743. /**
  77744. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77745. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77746. * @param from defines the vector to align
  77747. * @param to defines the vector to align to
  77748. * @param result defines the target matrix
  77749. */
  77750. Matrix.RotationAlignToRef = function (from, to, result) {
  77751. var v = Vector3.Cross(to, from);
  77752. var c = Vector3.Dot(to, from);
  77753. var k = 1 / (1 + c);
  77754. var m = result._m;
  77755. m[0] = v.x * v.x * k + c;
  77756. m[1] = v.y * v.x * k - v.z;
  77757. m[2] = v.z * v.x * k + v.y;
  77758. m[3] = 0;
  77759. m[4] = v.x * v.y * k + v.z;
  77760. m[5] = v.y * v.y * k + c;
  77761. m[6] = v.z * v.y * k - v.x;
  77762. m[7] = 0;
  77763. m[8] = v.x * v.z * k - v.y;
  77764. m[9] = v.y * v.z * k + v.x;
  77765. m[10] = v.z * v.z * k + c;
  77766. m[11] = 0;
  77767. m[12] = 0;
  77768. m[13] = 0;
  77769. m[14] = 0;
  77770. m[15] = 1;
  77771. result._markAsUpdated();
  77772. };
  77773. /**
  77774. * Creates a rotation matrix
  77775. * @param yaw defines the yaw angle in radians (Y axis)
  77776. * @param pitch defines the pitch angle in radians (X axis)
  77777. * @param roll defines the roll angle in radians (X axis)
  77778. * @returns the new rotation matrix
  77779. */
  77780. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  77781. var result = new Matrix();
  77782. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  77783. return result;
  77784. };
  77785. /**
  77786. * Creates a rotation matrix and stores it in a given matrix
  77787. * @param yaw defines the yaw angle in radians (Y axis)
  77788. * @param pitch defines the pitch angle in radians (X axis)
  77789. * @param roll defines the roll angle in radians (X axis)
  77790. * @param result defines the target matrix
  77791. */
  77792. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  77793. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  77794. MathTmp.Quaternion[0].toRotationMatrix(result);
  77795. };
  77796. /**
  77797. * Creates a scaling matrix
  77798. * @param x defines the scale factor on X axis
  77799. * @param y defines the scale factor on Y axis
  77800. * @param z defines the scale factor on Z axis
  77801. * @returns the new matrix
  77802. */
  77803. Matrix.Scaling = function (x, y, z) {
  77804. var result = new Matrix();
  77805. Matrix.ScalingToRef(x, y, z, result);
  77806. return result;
  77807. };
  77808. /**
  77809. * Creates a scaling matrix and stores it in a given matrix
  77810. * @param x defines the scale factor on X axis
  77811. * @param y defines the scale factor on Y axis
  77812. * @param z defines the scale factor on Z axis
  77813. * @param result defines the target matrix
  77814. */
  77815. Matrix.ScalingToRef = function (x, y, z, result) {
  77816. 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);
  77817. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  77818. };
  77819. /**
  77820. * Creates a translation matrix
  77821. * @param x defines the translation on X axis
  77822. * @param y defines the translation on Y axis
  77823. * @param z defines the translationon Z axis
  77824. * @returns the new matrix
  77825. */
  77826. Matrix.Translation = function (x, y, z) {
  77827. var result = new Matrix();
  77828. Matrix.TranslationToRef(x, y, z, result);
  77829. return result;
  77830. };
  77831. /**
  77832. * Creates a translation matrix and stores it in a given matrix
  77833. * @param x defines the translation on X axis
  77834. * @param y defines the translation on Y axis
  77835. * @param z defines the translationon Z axis
  77836. * @param result defines the target matrix
  77837. */
  77838. Matrix.TranslationToRef = function (x, y, z, result) {
  77839. 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);
  77840. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  77841. };
  77842. /**
  77843. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77844. * @param startValue defines the start value
  77845. * @param endValue defines the end value
  77846. * @param gradient defines the gradient factor
  77847. * @returns the new matrix
  77848. */
  77849. Matrix.Lerp = function (startValue, endValue, gradient) {
  77850. var result = new Matrix();
  77851. Matrix.LerpToRef(startValue, endValue, gradient, result);
  77852. return result;
  77853. };
  77854. /**
  77855. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77856. * @param startValue defines the start value
  77857. * @param endValue defines the end value
  77858. * @param gradient defines the gradient factor
  77859. * @param result defines the Matrix object where to store data
  77860. */
  77861. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  77862. var resultM = result._m;
  77863. var startM = startValue.m;
  77864. var endM = endValue.m;
  77865. for (var index = 0; index < 16; index++) {
  77866. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  77867. }
  77868. result._markAsUpdated();
  77869. };
  77870. /**
  77871. * Builds a new matrix whose values are computed by:
  77872. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77873. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77874. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77875. * @param startValue defines the first matrix
  77876. * @param endValue defines the second matrix
  77877. * @param gradient defines the gradient between the two matrices
  77878. * @returns the new matrix
  77879. */
  77880. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  77881. var result = new Matrix();
  77882. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  77883. return result;
  77884. };
  77885. /**
  77886. * Update a matrix to values which are computed by:
  77887. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77888. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77889. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77890. * @param startValue defines the first matrix
  77891. * @param endValue defines the second matrix
  77892. * @param gradient defines the gradient between the two matrices
  77893. * @param result defines the target matrix
  77894. */
  77895. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  77896. var startScale = MathTmp.Vector3[0];
  77897. var startRotation = MathTmp.Quaternion[0];
  77898. var startTranslation = MathTmp.Vector3[1];
  77899. startValue.decompose(startScale, startRotation, startTranslation);
  77900. var endScale = MathTmp.Vector3[2];
  77901. var endRotation = MathTmp.Quaternion[1];
  77902. var endTranslation = MathTmp.Vector3[3];
  77903. endValue.decompose(endScale, endRotation, endTranslation);
  77904. var resultScale = MathTmp.Vector3[4];
  77905. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  77906. var resultRotation = MathTmp.Quaternion[2];
  77907. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  77908. var resultTranslation = MathTmp.Vector3[5];
  77909. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  77910. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  77911. };
  77912. /**
  77913. * 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"
  77914. * This function works in left handed mode
  77915. * @param eye defines the final position of the entity
  77916. * @param target defines where the entity should look at
  77917. * @param up defines the up vector for the entity
  77918. * @returns the new matrix
  77919. */
  77920. Matrix.LookAtLH = function (eye, target, up) {
  77921. var result = new Matrix();
  77922. Matrix.LookAtLHToRef(eye, target, up, result);
  77923. return result;
  77924. };
  77925. /**
  77926. * 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".
  77927. * This function works in left handed mode
  77928. * @param eye defines the final position of the entity
  77929. * @param target defines where the entity should look at
  77930. * @param up defines the up vector for the entity
  77931. * @param result defines the target matrix
  77932. */
  77933. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  77934. var xAxis = MathTmp.Vector3[0];
  77935. var yAxis = MathTmp.Vector3[1];
  77936. var zAxis = MathTmp.Vector3[2];
  77937. // Z axis
  77938. target.subtractToRef(eye, zAxis);
  77939. zAxis.normalize();
  77940. // X axis
  77941. Vector3.CrossToRef(up, zAxis, xAxis);
  77942. var xSquareLength = xAxis.lengthSquared();
  77943. if (xSquareLength === 0) {
  77944. xAxis.x = 1.0;
  77945. }
  77946. else {
  77947. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  77948. }
  77949. // Y axis
  77950. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  77951. yAxis.normalize();
  77952. // Eye angles
  77953. var ex = -Vector3.Dot(xAxis, eye);
  77954. var ey = -Vector3.Dot(yAxis, eye);
  77955. var ez = -Vector3.Dot(zAxis, eye);
  77956. 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);
  77957. };
  77958. /**
  77959. * 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"
  77960. * This function works in right handed mode
  77961. * @param eye defines the final position of the entity
  77962. * @param target defines where the entity should look at
  77963. * @param up defines the up vector for the entity
  77964. * @returns the new matrix
  77965. */
  77966. Matrix.LookAtRH = function (eye, target, up) {
  77967. var result = new Matrix();
  77968. Matrix.LookAtRHToRef(eye, target, up, result);
  77969. return result;
  77970. };
  77971. /**
  77972. * 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".
  77973. * This function works in right handed mode
  77974. * @param eye defines the final position of the entity
  77975. * @param target defines where the entity should look at
  77976. * @param up defines the up vector for the entity
  77977. * @param result defines the target matrix
  77978. */
  77979. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  77980. var xAxis = MathTmp.Vector3[0];
  77981. var yAxis = MathTmp.Vector3[1];
  77982. var zAxis = MathTmp.Vector3[2];
  77983. // Z axis
  77984. eye.subtractToRef(target, zAxis);
  77985. zAxis.normalize();
  77986. // X axis
  77987. Vector3.CrossToRef(up, zAxis, xAxis);
  77988. var xSquareLength = xAxis.lengthSquared();
  77989. if (xSquareLength === 0) {
  77990. xAxis.x = 1.0;
  77991. }
  77992. else {
  77993. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  77994. }
  77995. // Y axis
  77996. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  77997. yAxis.normalize();
  77998. // Eye angles
  77999. var ex = -Vector3.Dot(xAxis, eye);
  78000. var ey = -Vector3.Dot(yAxis, eye);
  78001. var ez = -Vector3.Dot(zAxis, eye);
  78002. 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);
  78003. };
  78004. /**
  78005. * Create a left-handed orthographic projection matrix
  78006. * @param width defines the viewport width
  78007. * @param height defines the viewport height
  78008. * @param znear defines the near clip plane
  78009. * @param zfar defines the far clip plane
  78010. * @returns a new matrix as a left-handed orthographic projection matrix
  78011. */
  78012. Matrix.OrthoLH = function (width, height, znear, zfar) {
  78013. var matrix = new Matrix();
  78014. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  78015. return matrix;
  78016. };
  78017. /**
  78018. * Store a left-handed orthographic projection to a given matrix
  78019. * @param width defines the viewport width
  78020. * @param height defines the viewport height
  78021. * @param znear defines the near clip plane
  78022. * @param zfar defines the far clip plane
  78023. * @param result defines the target matrix
  78024. */
  78025. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  78026. var n = znear;
  78027. var f = zfar;
  78028. var a = 2.0 / width;
  78029. var b = 2.0 / height;
  78030. var c = 2.0 / (f - n);
  78031. var d = -(f + n) / (f - n);
  78032. 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);
  78033. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  78034. };
  78035. /**
  78036. * Create a left-handed orthographic projection matrix
  78037. * @param left defines the viewport left coordinate
  78038. * @param right defines the viewport right coordinate
  78039. * @param bottom defines the viewport bottom coordinate
  78040. * @param top defines the viewport top coordinate
  78041. * @param znear defines the near clip plane
  78042. * @param zfar defines the far clip plane
  78043. * @returns a new matrix as a left-handed orthographic projection matrix
  78044. */
  78045. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  78046. var matrix = new Matrix();
  78047. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  78048. return matrix;
  78049. };
  78050. /**
  78051. * Stores a left-handed orthographic projection into a given matrix
  78052. * @param left defines the viewport left coordinate
  78053. * @param right defines the viewport right coordinate
  78054. * @param bottom defines the viewport bottom coordinate
  78055. * @param top defines the viewport top coordinate
  78056. * @param znear defines the near clip plane
  78057. * @param zfar defines the far clip plane
  78058. * @param result defines the target matrix
  78059. */
  78060. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  78061. var n = znear;
  78062. var f = zfar;
  78063. var a = 2.0 / (right - left);
  78064. var b = 2.0 / (top - bottom);
  78065. var c = 2.0 / (f - n);
  78066. var d = -(f + n) / (f - n);
  78067. var i0 = (left + right) / (left - right);
  78068. var i1 = (top + bottom) / (bottom - top);
  78069. 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);
  78070. result._markAsUpdated();
  78071. };
  78072. /**
  78073. * Creates a right-handed orthographic projection matrix
  78074. * @param left defines the viewport left coordinate
  78075. * @param right defines the viewport right coordinate
  78076. * @param bottom defines the viewport bottom coordinate
  78077. * @param top defines the viewport top coordinate
  78078. * @param znear defines the near clip plane
  78079. * @param zfar defines the far clip plane
  78080. * @returns a new matrix as a right-handed orthographic projection matrix
  78081. */
  78082. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  78083. var matrix = new Matrix();
  78084. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  78085. return matrix;
  78086. };
  78087. /**
  78088. * Stores a right-handed orthographic projection into a given matrix
  78089. * @param left defines the viewport left coordinate
  78090. * @param right defines the viewport right coordinate
  78091. * @param bottom defines the viewport bottom coordinate
  78092. * @param top defines the viewport top coordinate
  78093. * @param znear defines the near clip plane
  78094. * @param zfar defines the far clip plane
  78095. * @param result defines the target matrix
  78096. */
  78097. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  78098. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  78099. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  78100. };
  78101. /**
  78102. * Creates a left-handed perspective projection matrix
  78103. * @param width defines the viewport width
  78104. * @param height defines the viewport height
  78105. * @param znear defines the near clip plane
  78106. * @param zfar defines the far clip plane
  78107. * @returns a new matrix as a left-handed perspective projection matrix
  78108. */
  78109. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  78110. var matrix = new Matrix();
  78111. var n = znear;
  78112. var f = zfar;
  78113. var a = 2.0 * n / width;
  78114. var b = 2.0 * n / height;
  78115. var c = (f + n) / (f - n);
  78116. var d = -2.0 * f * n / (f - n);
  78117. 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);
  78118. matrix._updateIdentityStatus(false);
  78119. return matrix;
  78120. };
  78121. /**
  78122. * Creates a left-handed perspective projection matrix
  78123. * @param fov defines the horizontal field of view
  78124. * @param aspect defines the aspect ratio
  78125. * @param znear defines the near clip plane
  78126. * @param zfar defines the far clip plane
  78127. * @returns a new matrix as a left-handed perspective projection matrix
  78128. */
  78129. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  78130. var matrix = new Matrix();
  78131. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  78132. return matrix;
  78133. };
  78134. /**
  78135. * Stores a left-handed perspective projection into a given matrix
  78136. * @param fov defines the horizontal field of view
  78137. * @param aspect defines the aspect ratio
  78138. * @param znear defines the near clip plane
  78139. * @param zfar defines the far clip plane
  78140. * @param result defines the target matrix
  78141. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78142. */
  78143. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  78144. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  78145. var n = znear;
  78146. var f = zfar;
  78147. var t = 1.0 / (Math.tan(fov * 0.5));
  78148. var a = isVerticalFovFixed ? (t / aspect) : t;
  78149. var b = isVerticalFovFixed ? t : (t * aspect);
  78150. var c = (f + n) / (f - n);
  78151. var d = -2.0 * f * n / (f - n);
  78152. 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);
  78153. result._updateIdentityStatus(false);
  78154. };
  78155. /**
  78156. * Creates a right-handed perspective projection matrix
  78157. * @param fov defines the horizontal field of view
  78158. * @param aspect defines the aspect ratio
  78159. * @param znear defines the near clip plane
  78160. * @param zfar defines the far clip plane
  78161. * @returns a new matrix as a right-handed perspective projection matrix
  78162. */
  78163. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  78164. var matrix = new Matrix();
  78165. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  78166. return matrix;
  78167. };
  78168. /**
  78169. * Stores a right-handed perspective projection into a given matrix
  78170. * @param fov defines the horizontal field of view
  78171. * @param aspect defines the aspect ratio
  78172. * @param znear defines the near clip plane
  78173. * @param zfar defines the far clip plane
  78174. * @param result defines the target matrix
  78175. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78176. */
  78177. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  78178. //alternatively this could be expressed as:
  78179. // m = PerspectiveFovLHToRef
  78180. // m[10] *= -1.0;
  78181. // m[11] *= -1.0;
  78182. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  78183. var n = znear;
  78184. var f = zfar;
  78185. var t = 1.0 / (Math.tan(fov * 0.5));
  78186. var a = isVerticalFovFixed ? (t / aspect) : t;
  78187. var b = isVerticalFovFixed ? t : (t * aspect);
  78188. var c = -(f + n) / (f - n);
  78189. var d = -2 * f * n / (f - n);
  78190. 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);
  78191. result._updateIdentityStatus(false);
  78192. };
  78193. /**
  78194. * Stores a perspective projection for WebVR info a given matrix
  78195. * @param fov defines the field of view
  78196. * @param znear defines the near clip plane
  78197. * @param zfar defines the far clip plane
  78198. * @param result defines the target matrix
  78199. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  78200. */
  78201. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  78202. if (rightHanded === void 0) { rightHanded = false; }
  78203. var rightHandedFactor = rightHanded ? -1 : 1;
  78204. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  78205. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  78206. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  78207. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  78208. var xScale = 2.0 / (leftTan + rightTan);
  78209. var yScale = 2.0 / (upTan + downTan);
  78210. var m = result._m;
  78211. m[0] = xScale;
  78212. m[1] = m[2] = m[3] = m[4] = 0.0;
  78213. m[5] = yScale;
  78214. m[6] = m[7] = 0.0;
  78215. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  78216. m[9] = -((upTan - downTan) * yScale * 0.5);
  78217. m[10] = -zfar / (znear - zfar);
  78218. m[11] = 1.0 * rightHandedFactor;
  78219. m[12] = m[13] = m[15] = 0.0;
  78220. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  78221. result._markAsUpdated();
  78222. };
  78223. /**
  78224. * Computes a complete transformation matrix
  78225. * @param viewport defines the viewport to use
  78226. * @param world defines the world matrix
  78227. * @param view defines the view matrix
  78228. * @param projection defines the projection matrix
  78229. * @param zmin defines the near clip plane
  78230. * @param zmax defines the far clip plane
  78231. * @returns the transformation matrix
  78232. */
  78233. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  78234. var cw = viewport.width;
  78235. var ch = viewport.height;
  78236. var cx = viewport.x;
  78237. var cy = viewport.y;
  78238. 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);
  78239. var matrix = MathTmp.Matrix[0];
  78240. world.multiplyToRef(view, matrix);
  78241. matrix.multiplyToRef(projection, matrix);
  78242. return matrix.multiply(viewportMatrix);
  78243. };
  78244. /**
  78245. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  78246. * @param matrix defines the matrix to use
  78247. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  78248. */
  78249. Matrix.GetAsMatrix2x2 = function (matrix) {
  78250. var m = matrix.m;
  78251. return new Float32Array([m[0], m[1], m[4], m[5]]);
  78252. };
  78253. /**
  78254. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  78255. * @param matrix defines the matrix to use
  78256. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  78257. */
  78258. Matrix.GetAsMatrix3x3 = function (matrix) {
  78259. var m = matrix.m;
  78260. return new Float32Array([
  78261. m[0], m[1], m[2],
  78262. m[4], m[5], m[6],
  78263. m[8], m[9], m[10]
  78264. ]);
  78265. };
  78266. /**
  78267. * Compute the transpose of a given matrix
  78268. * @param matrix defines the matrix to transpose
  78269. * @returns the new matrix
  78270. */
  78271. Matrix.Transpose = function (matrix) {
  78272. var result = new Matrix();
  78273. Matrix.TransposeToRef(matrix, result);
  78274. return result;
  78275. };
  78276. /**
  78277. * Compute the transpose of a matrix and store it in a target matrix
  78278. * @param matrix defines the matrix to transpose
  78279. * @param result defines the target matrix
  78280. */
  78281. Matrix.TransposeToRef = function (matrix, result) {
  78282. var rm = result._m;
  78283. var mm = matrix.m;
  78284. rm[0] = mm[0];
  78285. rm[1] = mm[4];
  78286. rm[2] = mm[8];
  78287. rm[3] = mm[12];
  78288. rm[4] = mm[1];
  78289. rm[5] = mm[5];
  78290. rm[6] = mm[9];
  78291. rm[7] = mm[13];
  78292. rm[8] = mm[2];
  78293. rm[9] = mm[6];
  78294. rm[10] = mm[10];
  78295. rm[11] = mm[14];
  78296. rm[12] = mm[3];
  78297. rm[13] = mm[7];
  78298. rm[14] = mm[11];
  78299. rm[15] = mm[15];
  78300. // identity-ness does not change when transposing
  78301. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  78302. };
  78303. /**
  78304. * Computes a reflection matrix from a plane
  78305. * @param plane defines the reflection plane
  78306. * @returns a new matrix
  78307. */
  78308. Matrix.Reflection = function (plane) {
  78309. var matrix = new Matrix();
  78310. Matrix.ReflectionToRef(plane, matrix);
  78311. return matrix;
  78312. };
  78313. /**
  78314. * Computes a reflection matrix from a plane
  78315. * @param plane defines the reflection plane
  78316. * @param result defines the target matrix
  78317. */
  78318. Matrix.ReflectionToRef = function (plane, result) {
  78319. plane.normalize();
  78320. var x = plane.normal.x;
  78321. var y = plane.normal.y;
  78322. var z = plane.normal.z;
  78323. var temp = -2 * x;
  78324. var temp2 = -2 * y;
  78325. var temp3 = -2 * z;
  78326. 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);
  78327. };
  78328. /**
  78329. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78330. * @param xaxis defines the value of the 1st axis
  78331. * @param yaxis defines the value of the 2nd axis
  78332. * @param zaxis defines the value of the 3rd axis
  78333. * @param result defines the target matrix
  78334. */
  78335. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  78336. 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);
  78337. };
  78338. /**
  78339. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78340. * @param quat defines the quaternion to use
  78341. * @param result defines the target matrix
  78342. */
  78343. Matrix.FromQuaternionToRef = function (quat, result) {
  78344. var xx = quat.x * quat.x;
  78345. var yy = quat.y * quat.y;
  78346. var zz = quat.z * quat.z;
  78347. var xy = quat.x * quat.y;
  78348. var zw = quat.z * quat.w;
  78349. var zx = quat.z * quat.x;
  78350. var yw = quat.y * quat.w;
  78351. var yz = quat.y * quat.z;
  78352. var xw = quat.x * quat.w;
  78353. result._m[0] = 1.0 - (2.0 * (yy + zz));
  78354. result._m[1] = 2.0 * (xy + zw);
  78355. result._m[2] = 2.0 * (zx - yw);
  78356. result._m[3] = 0.0;
  78357. result._m[4] = 2.0 * (xy - zw);
  78358. result._m[5] = 1.0 - (2.0 * (zz + xx));
  78359. result._m[6] = 2.0 * (yz + xw);
  78360. result._m[7] = 0.0;
  78361. result._m[8] = 2.0 * (zx + yw);
  78362. result._m[9] = 2.0 * (yz - xw);
  78363. result._m[10] = 1.0 - (2.0 * (yy + xx));
  78364. result._m[11] = 0.0;
  78365. result._m[12] = 0.0;
  78366. result._m[13] = 0.0;
  78367. result._m[14] = 0.0;
  78368. result._m[15] = 1.0;
  78369. result._markAsUpdated();
  78370. };
  78371. Matrix._updateFlagSeed = 0;
  78372. Matrix._identityReadOnly = Matrix.Identity();
  78373. return Matrix;
  78374. }());
  78375. /**
  78376. * Represens a plane by the equation ax + by + cz + d = 0
  78377. */
  78378. var Plane = /** @class */ (function () {
  78379. /**
  78380. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  78381. * @param a a component of the plane
  78382. * @param b b component of the plane
  78383. * @param c c component of the plane
  78384. * @param d d component of the plane
  78385. */
  78386. function Plane(a, b, c, d) {
  78387. this.normal = new Vector3(a, b, c);
  78388. this.d = d;
  78389. }
  78390. /**
  78391. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  78392. */
  78393. Plane.prototype.asArray = function () {
  78394. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  78395. };
  78396. // Methods
  78397. /**
  78398. * @returns a new plane copied from the current Plane.
  78399. */
  78400. Plane.prototype.clone = function () {
  78401. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  78402. };
  78403. /**
  78404. * @returns the string "Plane".
  78405. */
  78406. Plane.prototype.getClassName = function () {
  78407. return "Plane";
  78408. };
  78409. /**
  78410. * @returns the Plane hash code.
  78411. */
  78412. Plane.prototype.getHashCode = function () {
  78413. var hash = this.normal.getHashCode();
  78414. hash = (hash * 397) ^ (this.d || 0);
  78415. return hash;
  78416. };
  78417. /**
  78418. * Normalize the current Plane in place.
  78419. * @returns the updated Plane.
  78420. */
  78421. Plane.prototype.normalize = function () {
  78422. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  78423. var magnitude = 0.0;
  78424. if (norm !== 0) {
  78425. magnitude = 1.0 / norm;
  78426. }
  78427. this.normal.x *= magnitude;
  78428. this.normal.y *= magnitude;
  78429. this.normal.z *= magnitude;
  78430. this.d *= magnitude;
  78431. return this;
  78432. };
  78433. /**
  78434. * Applies a transformation the plane and returns the result
  78435. * @param transformation the transformation matrix to be applied to the plane
  78436. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  78437. */
  78438. Plane.prototype.transform = function (transformation) {
  78439. var transposedMatrix = MathTmp.Matrix[0];
  78440. Matrix.TransposeToRef(transformation, transposedMatrix);
  78441. var m = transposedMatrix.m;
  78442. var x = this.normal.x;
  78443. var y = this.normal.y;
  78444. var z = this.normal.z;
  78445. var d = this.d;
  78446. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  78447. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  78448. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  78449. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  78450. return new Plane(normalX, normalY, normalZ, finalD);
  78451. };
  78452. /**
  78453. * Calcualtte the dot product between the point and the plane normal
  78454. * @param point point to calculate the dot product with
  78455. * @returns the dot product (float) of the point coordinates and the plane normal.
  78456. */
  78457. Plane.prototype.dotCoordinate = function (point) {
  78458. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  78459. };
  78460. /**
  78461. * Updates the current Plane from the plane defined by the three given points.
  78462. * @param point1 one of the points used to contruct the plane
  78463. * @param point2 one of the points used to contruct the plane
  78464. * @param point3 one of the points used to contruct the plane
  78465. * @returns the updated Plane.
  78466. */
  78467. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  78468. var x1 = point2.x - point1.x;
  78469. var y1 = point2.y - point1.y;
  78470. var z1 = point2.z - point1.z;
  78471. var x2 = point3.x - point1.x;
  78472. var y2 = point3.y - point1.y;
  78473. var z2 = point3.z - point1.z;
  78474. var yz = (y1 * z2) - (z1 * y2);
  78475. var xz = (z1 * x2) - (x1 * z2);
  78476. var xy = (x1 * y2) - (y1 * x2);
  78477. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  78478. var invPyth;
  78479. if (pyth !== 0) {
  78480. invPyth = 1.0 / pyth;
  78481. }
  78482. else {
  78483. invPyth = 0.0;
  78484. }
  78485. this.normal.x = yz * invPyth;
  78486. this.normal.y = xz * invPyth;
  78487. this.normal.z = xy * invPyth;
  78488. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  78489. return this;
  78490. };
  78491. /**
  78492. * Checks if the plane is facing a given direction
  78493. * @param direction the direction to check if the plane is facing
  78494. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  78495. * @returns True is the vector "direction" is the same side than the plane normal.
  78496. */
  78497. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  78498. var dot = Vector3.Dot(this.normal, direction);
  78499. return (dot <= epsilon);
  78500. };
  78501. /**
  78502. * Calculates the distance to a point
  78503. * @param point point to calculate distance to
  78504. * @returns the signed distance (float) from the given point to the Plane.
  78505. */
  78506. Plane.prototype.signedDistanceTo = function (point) {
  78507. return Vector3.Dot(point, this.normal) + this.d;
  78508. };
  78509. // Statics
  78510. /**
  78511. * Creates a plane from an array
  78512. * @param array the array to create a plane from
  78513. * @returns a new Plane from the given array.
  78514. */
  78515. Plane.FromArray = function (array) {
  78516. return new Plane(array[0], array[1], array[2], array[3]);
  78517. };
  78518. /**
  78519. * Creates a plane from three points
  78520. * @param point1 point used to create the plane
  78521. * @param point2 point used to create the plane
  78522. * @param point3 point used to create the plane
  78523. * @returns a new Plane defined by the three given points.
  78524. */
  78525. Plane.FromPoints = function (point1, point2, point3) {
  78526. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  78527. result.copyFromPoints(point1, point2, point3);
  78528. return result;
  78529. };
  78530. /**
  78531. * Creates a plane from an origin point and a normal
  78532. * @param origin origin of the plane to be constructed
  78533. * @param normal normal of the plane to be constructed
  78534. * @returns a new Plane the normal vector to this plane at the given origin point.
  78535. * Note : the vector "normal" is updated because normalized.
  78536. */
  78537. Plane.FromPositionAndNormal = function (origin, normal) {
  78538. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  78539. normal.normalize();
  78540. result.normal = normal;
  78541. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  78542. return result;
  78543. };
  78544. /**
  78545. * Calculates the distance from a plane and a point
  78546. * @param origin origin of the plane to be constructed
  78547. * @param normal normal of the plane to be constructed
  78548. * @param point point to calculate distance to
  78549. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  78550. */
  78551. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  78552. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  78553. return Vector3.Dot(point, normal) + d;
  78554. };
  78555. return Plane;
  78556. }());
  78557. /**
  78558. * Class used to represent a viewport on screen
  78559. */
  78560. var Viewport = /** @class */ (function () {
  78561. /**
  78562. * Creates a Viewport object located at (x, y) and sized (width, height)
  78563. * @param x defines viewport left coordinate
  78564. * @param y defines viewport top coordinate
  78565. * @param width defines the viewport width
  78566. * @param height defines the viewport height
  78567. */
  78568. function Viewport(
  78569. /** viewport left coordinate */
  78570. x,
  78571. /** viewport top coordinate */
  78572. y,
  78573. /**viewport width */
  78574. width,
  78575. /** viewport height */
  78576. height) {
  78577. this.x = x;
  78578. this.y = y;
  78579. this.width = width;
  78580. this.height = height;
  78581. }
  78582. /**
  78583. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  78584. * @param renderWidth defines the rendering width
  78585. * @param renderHeight defines the rendering height
  78586. * @returns a new Viewport
  78587. */
  78588. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  78589. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  78590. };
  78591. /**
  78592. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  78593. * @param renderWidth defines the rendering width
  78594. * @param renderHeight defines the rendering height
  78595. * @param ref defines the target viewport
  78596. * @returns the current viewport
  78597. */
  78598. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  78599. ref.x = this.x * renderWidth;
  78600. ref.y = this.y * renderHeight;
  78601. ref.width = this.width * renderWidth;
  78602. ref.height = this.height * renderHeight;
  78603. return this;
  78604. };
  78605. /**
  78606. * Returns a new Viewport copied from the current one
  78607. * @returns a new Viewport
  78608. */
  78609. Viewport.prototype.clone = function () {
  78610. return new Viewport(this.x, this.y, this.width, this.height);
  78611. };
  78612. return Viewport;
  78613. }());
  78614. /**
  78615. * Reprasents a camera frustum
  78616. */
  78617. var Frustum = /** @class */ (function () {
  78618. function Frustum() {
  78619. }
  78620. /**
  78621. * Gets the planes representing the frustum
  78622. * @param transform matrix to be applied to the returned planes
  78623. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  78624. */
  78625. Frustum.GetPlanes = function (transform) {
  78626. var frustumPlanes = [];
  78627. for (var index = 0; index < 6; index++) {
  78628. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  78629. }
  78630. Frustum.GetPlanesToRef(transform, frustumPlanes);
  78631. return frustumPlanes;
  78632. };
  78633. /**
  78634. * Gets the near frustum plane transformed by the transform matrix
  78635. * @param transform transformation matrix to be applied to the resulting frustum plane
  78636. * @param frustumPlane the resuling frustum plane
  78637. */
  78638. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  78639. var m = transform.m;
  78640. frustumPlane.normal.x = m[3] + m[2];
  78641. frustumPlane.normal.y = m[7] + m[6];
  78642. frustumPlane.normal.z = m[11] + m[10];
  78643. frustumPlane.d = m[15] + m[14];
  78644. frustumPlane.normalize();
  78645. };
  78646. /**
  78647. * Gets the far frustum plane transformed by the transform matrix
  78648. * @param transform transformation matrix to be applied to the resulting frustum plane
  78649. * @param frustumPlane the resuling frustum plane
  78650. */
  78651. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  78652. var m = transform.m;
  78653. frustumPlane.normal.x = m[3] - m[2];
  78654. frustumPlane.normal.y = m[7] - m[6];
  78655. frustumPlane.normal.z = m[11] - m[10];
  78656. frustumPlane.d = m[15] - m[14];
  78657. frustumPlane.normalize();
  78658. };
  78659. /**
  78660. * Gets the left frustum plane transformed by the transform matrix
  78661. * @param transform transformation matrix to be applied to the resulting frustum plane
  78662. * @param frustumPlane the resuling frustum plane
  78663. */
  78664. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  78665. var m = transform.m;
  78666. frustumPlane.normal.x = m[3] + m[0];
  78667. frustumPlane.normal.y = m[7] + m[4];
  78668. frustumPlane.normal.z = m[11] + m[8];
  78669. frustumPlane.d = m[15] + m[12];
  78670. frustumPlane.normalize();
  78671. };
  78672. /**
  78673. * Gets the right frustum plane transformed by the transform matrix
  78674. * @param transform transformation matrix to be applied to the resulting frustum plane
  78675. * @param frustumPlane the resuling frustum plane
  78676. */
  78677. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  78678. var m = transform.m;
  78679. frustumPlane.normal.x = m[3] - m[0];
  78680. frustumPlane.normal.y = m[7] - m[4];
  78681. frustumPlane.normal.z = m[11] - m[8];
  78682. frustumPlane.d = m[15] - m[12];
  78683. frustumPlane.normalize();
  78684. };
  78685. /**
  78686. * Gets the top frustum plane transformed by the transform matrix
  78687. * @param transform transformation matrix to be applied to the resulting frustum plane
  78688. * @param frustumPlane the resuling frustum plane
  78689. */
  78690. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  78691. var m = transform.m;
  78692. frustumPlane.normal.x = m[3] - m[1];
  78693. frustumPlane.normal.y = m[7] - m[5];
  78694. frustumPlane.normal.z = m[11] - m[9];
  78695. frustumPlane.d = m[15] - m[13];
  78696. frustumPlane.normalize();
  78697. };
  78698. /**
  78699. * Gets the bottom frustum plane transformed by the transform matrix
  78700. * @param transform transformation matrix to be applied to the resulting frustum plane
  78701. * @param frustumPlane the resuling frustum plane
  78702. */
  78703. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  78704. var m = transform.m;
  78705. frustumPlane.normal.x = m[3] + m[1];
  78706. frustumPlane.normal.y = m[7] + m[5];
  78707. frustumPlane.normal.z = m[11] + m[9];
  78708. frustumPlane.d = m[15] + m[13];
  78709. frustumPlane.normalize();
  78710. };
  78711. /**
  78712. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  78713. * @param transform transformation matrix to be applied to the resulting frustum planes
  78714. * @param frustumPlanes the resuling frustum planes
  78715. */
  78716. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  78717. // Near
  78718. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  78719. // Far
  78720. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  78721. // Left
  78722. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  78723. // Right
  78724. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  78725. // Top
  78726. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  78727. // Bottom
  78728. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  78729. };
  78730. return Frustum;
  78731. }());
  78732. /** Defines supported spaces */
  78733. var Space;
  78734. (function (Space) {
  78735. /** Local (object) space */
  78736. Space[Space["LOCAL"] = 0] = "LOCAL";
  78737. /** World space */
  78738. Space[Space["WORLD"] = 1] = "WORLD";
  78739. /** Bone space */
  78740. Space[Space["BONE"] = 2] = "BONE";
  78741. })(Space || (Space = {}));
  78742. /** Defines the 3 main axes */
  78743. var Axis = /** @class */ (function () {
  78744. function Axis() {
  78745. }
  78746. /** X axis */
  78747. Axis.X = new Vector3(1.0, 0.0, 0.0);
  78748. /** Y axis */
  78749. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  78750. /** Z axis */
  78751. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  78752. return Axis;
  78753. }());
  78754. /** Class used to represent a Bezier curve */
  78755. var BezierCurve = /** @class */ (function () {
  78756. function BezierCurve() {
  78757. }
  78758. /**
  78759. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78760. * @param t defines the time
  78761. * @param x1 defines the left coordinate on X axis
  78762. * @param y1 defines the left coordinate on Y axis
  78763. * @param x2 defines the right coordinate on X axis
  78764. * @param y2 defines the right coordinate on Y axis
  78765. * @returns the interpolated value
  78766. */
  78767. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  78768. // Extract X (which is equal to time here)
  78769. var f0 = 1 - 3 * x2 + 3 * x1;
  78770. var f1 = 3 * x2 - 6 * x1;
  78771. var f2 = 3 * x1;
  78772. var refinedT = t;
  78773. for (var i = 0; i < 5; i++) {
  78774. var refinedT2 = refinedT * refinedT;
  78775. var refinedT3 = refinedT2 * refinedT;
  78776. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  78777. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  78778. refinedT -= (x - t) * slope;
  78779. refinedT = Math.min(1, Math.max(0, refinedT));
  78780. }
  78781. // Resolve cubic bezier for the given x
  78782. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  78783. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  78784. Math.pow(refinedT, 3);
  78785. };
  78786. return BezierCurve;
  78787. }());
  78788. /**
  78789. * Defines potential orientation for back face culling
  78790. */
  78791. var Orientation;
  78792. (function (Orientation) {
  78793. /**
  78794. * Clockwise
  78795. */
  78796. Orientation[Orientation["CW"] = 0] = "CW";
  78797. /** Counter clockwise */
  78798. Orientation[Orientation["CCW"] = 1] = "CCW";
  78799. })(Orientation || (Orientation = {}));
  78800. /**
  78801. * Defines angle representation
  78802. */
  78803. var Angle = /** @class */ (function () {
  78804. /**
  78805. * Creates an Angle object of "radians" radians (float).
  78806. * @param radians the angle in radians
  78807. */
  78808. function Angle(radians) {
  78809. this._radians = radians;
  78810. if (this._radians < 0.0) {
  78811. this._radians += (2.0 * Math.PI);
  78812. }
  78813. }
  78814. /**
  78815. * Get value in degrees
  78816. * @returns the Angle value in degrees (float)
  78817. */
  78818. Angle.prototype.degrees = function () {
  78819. return this._radians * 180.0 / Math.PI;
  78820. };
  78821. /**
  78822. * Get value in radians
  78823. * @returns the Angle value in radians (float)
  78824. */
  78825. Angle.prototype.radians = function () {
  78826. return this._radians;
  78827. };
  78828. /**
  78829. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78830. * @param a defines first vector
  78831. * @param b defines second vector
  78832. * @returns a new Angle
  78833. */
  78834. Angle.BetweenTwoPoints = function (a, b) {
  78835. var delta = b.subtract(a);
  78836. var theta = Math.atan2(delta.y, delta.x);
  78837. return new Angle(theta);
  78838. };
  78839. /**
  78840. * Gets a new Angle object from the given float in radians
  78841. * @param radians defines the angle value in radians
  78842. * @returns a new Angle
  78843. */
  78844. Angle.FromRadians = function (radians) {
  78845. return new Angle(radians);
  78846. };
  78847. /**
  78848. * Gets a new Angle object from the given float in degrees
  78849. * @param degrees defines the angle value in degrees
  78850. * @returns a new Angle
  78851. */
  78852. Angle.FromDegrees = function (degrees) {
  78853. return new Angle(degrees * Math.PI / 180.0);
  78854. };
  78855. return Angle;
  78856. }());
  78857. /**
  78858. * This represents an arc in a 2d space.
  78859. */
  78860. var Arc2 = /** @class */ (function () {
  78861. /**
  78862. * Creates an Arc object from the three given points : start, middle and end.
  78863. * @param startPoint Defines the start point of the arc
  78864. * @param midPoint Defines the midlle point of the arc
  78865. * @param endPoint Defines the end point of the arc
  78866. */
  78867. function Arc2(
  78868. /** Defines the start point of the arc */
  78869. startPoint,
  78870. /** Defines the mid point of the arc */
  78871. midPoint,
  78872. /** Defines the end point of the arc */
  78873. endPoint) {
  78874. this.startPoint = startPoint;
  78875. this.midPoint = midPoint;
  78876. this.endPoint = endPoint;
  78877. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  78878. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  78879. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  78880. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  78881. 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);
  78882. this.radius = this.centerPoint.subtract(this.startPoint).length();
  78883. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  78884. var a1 = this.startAngle.degrees();
  78885. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  78886. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  78887. // angles correction
  78888. if (a2 - a1 > +180.0) {
  78889. a2 -= 360.0;
  78890. }
  78891. if (a2 - a1 < -180.0) {
  78892. a2 += 360.0;
  78893. }
  78894. if (a3 - a2 > +180.0) {
  78895. a3 -= 360.0;
  78896. }
  78897. if (a3 - a2 < -180.0) {
  78898. a3 += 360.0;
  78899. }
  78900. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  78901. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  78902. }
  78903. return Arc2;
  78904. }());
  78905. /**
  78906. * Represents a 2D path made up of multiple 2D points
  78907. */
  78908. var Path2 = /** @class */ (function () {
  78909. /**
  78910. * Creates a Path2 object from the starting 2D coordinates x and y.
  78911. * @param x the starting points x value
  78912. * @param y the starting points y value
  78913. */
  78914. function Path2(x, y) {
  78915. this._points = new Array();
  78916. this._length = 0.0;
  78917. /**
  78918. * If the path start and end point are the same
  78919. */
  78920. this.closed = false;
  78921. this._points.push(new Vector2(x, y));
  78922. }
  78923. /**
  78924. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78925. * @param x the added points x value
  78926. * @param y the added points y value
  78927. * @returns the updated Path2.
  78928. */
  78929. Path2.prototype.addLineTo = function (x, y) {
  78930. if (this.closed) {
  78931. return this;
  78932. }
  78933. var newPoint = new Vector2(x, y);
  78934. var previousPoint = this._points[this._points.length - 1];
  78935. this._points.push(newPoint);
  78936. this._length += newPoint.subtract(previousPoint).length();
  78937. return this;
  78938. };
  78939. /**
  78940. * 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.
  78941. * @param midX middle point x value
  78942. * @param midY middle point y value
  78943. * @param endX end point x value
  78944. * @param endY end point y value
  78945. * @param numberOfSegments (default: 36)
  78946. * @returns the updated Path2.
  78947. */
  78948. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  78949. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  78950. if (this.closed) {
  78951. return this;
  78952. }
  78953. var startPoint = this._points[this._points.length - 1];
  78954. var midPoint = new Vector2(midX, midY);
  78955. var endPoint = new Vector2(endX, endY);
  78956. var arc = new Arc2(startPoint, midPoint, endPoint);
  78957. var increment = arc.angle.radians() / numberOfSegments;
  78958. if (arc.orientation === Orientation.CW) {
  78959. increment *= -1;
  78960. }
  78961. var currentAngle = arc.startAngle.radians() + increment;
  78962. for (var i = 0; i < numberOfSegments; i++) {
  78963. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  78964. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  78965. this.addLineTo(x, y);
  78966. currentAngle += increment;
  78967. }
  78968. return this;
  78969. };
  78970. /**
  78971. * Closes the Path2.
  78972. * @returns the Path2.
  78973. */
  78974. Path2.prototype.close = function () {
  78975. this.closed = true;
  78976. return this;
  78977. };
  78978. /**
  78979. * Gets the sum of the distance between each sequential point in the path
  78980. * @returns the Path2 total length (float).
  78981. */
  78982. Path2.prototype.length = function () {
  78983. var result = this._length;
  78984. if (!this.closed) {
  78985. var lastPoint = this._points[this._points.length - 1];
  78986. var firstPoint = this._points[0];
  78987. result += (firstPoint.subtract(lastPoint).length());
  78988. }
  78989. return result;
  78990. };
  78991. /**
  78992. * Gets the points which construct the path
  78993. * @returns the Path2 internal array of points.
  78994. */
  78995. Path2.prototype.getPoints = function () {
  78996. return this._points;
  78997. };
  78998. /**
  78999. * Retreives the point at the distance aways from the starting point
  79000. * @param normalizedLengthPosition the length along the path to retreive the point from
  79001. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  79002. */
  79003. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  79004. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  79005. return Vector2.Zero();
  79006. }
  79007. var lengthPosition = normalizedLengthPosition * this.length();
  79008. var previousOffset = 0;
  79009. for (var i = 0; i < this._points.length; i++) {
  79010. var j = (i + 1) % this._points.length;
  79011. var a = this._points[i];
  79012. var b = this._points[j];
  79013. var bToA = b.subtract(a);
  79014. var nextOffset = (bToA.length() + previousOffset);
  79015. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  79016. var dir = bToA.normalize();
  79017. var localOffset = lengthPosition - previousOffset;
  79018. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  79019. }
  79020. previousOffset = nextOffset;
  79021. }
  79022. return Vector2.Zero();
  79023. };
  79024. /**
  79025. * Creates a new path starting from an x and y position
  79026. * @param x starting x value
  79027. * @param y starting y value
  79028. * @returns a new Path2 starting at the coordinates (x, y).
  79029. */
  79030. Path2.StartingAt = function (x, y) {
  79031. return new Path2(x, y);
  79032. };
  79033. return Path2;
  79034. }());
  79035. /**
  79036. * Represents a 3D path made up of multiple 3D points
  79037. */
  79038. var Path3D = /** @class */ (function () {
  79039. /**
  79040. * new Path3D(path, normal, raw)
  79041. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  79042. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  79043. * @param path an array of Vector3, the curve axis of the Path3D
  79044. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  79045. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  79046. */
  79047. function Path3D(
  79048. /**
  79049. * an array of Vector3, the curve axis of the Path3D
  79050. */
  79051. path, firstNormal, raw) {
  79052. if (firstNormal === void 0) { firstNormal = null; }
  79053. this.path = path;
  79054. this._curve = new Array();
  79055. this._distances = new Array();
  79056. this._tangents = new Array();
  79057. this._normals = new Array();
  79058. this._binormals = new Array();
  79059. for (var p = 0; p < path.length; p++) {
  79060. this._curve[p] = path[p].clone(); // hard copy
  79061. }
  79062. this._raw = raw || false;
  79063. this._compute(firstNormal);
  79064. }
  79065. /**
  79066. * Returns the Path3D array of successive Vector3 designing its curve.
  79067. * @returns the Path3D array of successive Vector3 designing its curve.
  79068. */
  79069. Path3D.prototype.getCurve = function () {
  79070. return this._curve;
  79071. };
  79072. /**
  79073. * Returns an array populated with tangent vectors on each Path3D curve point.
  79074. * @returns an array populated with tangent vectors on each Path3D curve point.
  79075. */
  79076. Path3D.prototype.getTangents = function () {
  79077. return this._tangents;
  79078. };
  79079. /**
  79080. * Returns an array populated with normal vectors on each Path3D curve point.
  79081. * @returns an array populated with normal vectors on each Path3D curve point.
  79082. */
  79083. Path3D.prototype.getNormals = function () {
  79084. return this._normals;
  79085. };
  79086. /**
  79087. * Returns an array populated with binormal vectors on each Path3D curve point.
  79088. * @returns an array populated with binormal vectors on each Path3D curve point.
  79089. */
  79090. Path3D.prototype.getBinormals = function () {
  79091. return this._binormals;
  79092. };
  79093. /**
  79094. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  79095. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  79096. */
  79097. Path3D.prototype.getDistances = function () {
  79098. return this._distances;
  79099. };
  79100. /**
  79101. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  79102. * @param path path which all values are copied into the curves points
  79103. * @param firstNormal which should be projected onto the curve
  79104. * @returns the same object updated.
  79105. */
  79106. Path3D.prototype.update = function (path, firstNormal) {
  79107. if (firstNormal === void 0) { firstNormal = null; }
  79108. for (var p = 0; p < path.length; p++) {
  79109. this._curve[p].x = path[p].x;
  79110. this._curve[p].y = path[p].y;
  79111. this._curve[p].z = path[p].z;
  79112. }
  79113. this._compute(firstNormal);
  79114. return this;
  79115. };
  79116. // private function compute() : computes tangents, normals and binormals
  79117. Path3D.prototype._compute = function (firstNormal) {
  79118. var l = this._curve.length;
  79119. // first and last tangents
  79120. this._tangents[0] = this._getFirstNonNullVector(0);
  79121. if (!this._raw) {
  79122. this._tangents[0].normalize();
  79123. }
  79124. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  79125. if (!this._raw) {
  79126. this._tangents[l - 1].normalize();
  79127. }
  79128. // normals and binormals at first point : arbitrary vector with _normalVector()
  79129. var tg0 = this._tangents[0];
  79130. var pp0 = this._normalVector(tg0, firstNormal);
  79131. this._normals[0] = pp0;
  79132. if (!this._raw) {
  79133. this._normals[0].normalize();
  79134. }
  79135. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  79136. if (!this._raw) {
  79137. this._binormals[0].normalize();
  79138. }
  79139. this._distances[0] = 0.0;
  79140. // normals and binormals : next points
  79141. var prev; // previous vector (segment)
  79142. var cur; // current vector (segment)
  79143. var curTang; // current tangent
  79144. // previous normal
  79145. var prevBinor; // previous binormal
  79146. for (var i = 1; i < l; i++) {
  79147. // tangents
  79148. prev = this._getLastNonNullVector(i);
  79149. if (i < l - 1) {
  79150. cur = this._getFirstNonNullVector(i);
  79151. this._tangents[i] = prev.add(cur);
  79152. this._tangents[i].normalize();
  79153. }
  79154. this._distances[i] = this._distances[i - 1] + prev.length();
  79155. // normals and binormals
  79156. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  79157. curTang = this._tangents[i];
  79158. prevBinor = this._binormals[i - 1];
  79159. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  79160. if (!this._raw) {
  79161. this._normals[i].normalize();
  79162. }
  79163. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  79164. if (!this._raw) {
  79165. this._binormals[i].normalize();
  79166. }
  79167. }
  79168. };
  79169. // private function getFirstNonNullVector(index)
  79170. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  79171. Path3D.prototype._getFirstNonNullVector = function (index) {
  79172. var i = 1;
  79173. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  79174. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  79175. i++;
  79176. nNVector = this._curve[index + i].subtract(this._curve[index]);
  79177. }
  79178. return nNVector;
  79179. };
  79180. // private function getLastNonNullVector(index)
  79181. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  79182. Path3D.prototype._getLastNonNullVector = function (index) {
  79183. var i = 1;
  79184. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  79185. while (nLVector.length() === 0 && index > i + 1) {
  79186. i++;
  79187. nLVector = this._curve[index].subtract(this._curve[index - i]);
  79188. }
  79189. return nLVector;
  79190. };
  79191. // private function normalVector(v0, vt, va) :
  79192. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  79193. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  79194. Path3D.prototype._normalVector = function (vt, va) {
  79195. var normal0;
  79196. var tgl = vt.length();
  79197. if (tgl === 0.0) {
  79198. tgl = 1.0;
  79199. }
  79200. if (va === undefined || va === null) {
  79201. var point;
  79202. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  79203. point = new Vector3(0.0, -1.0, 0.0);
  79204. }
  79205. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  79206. point = new Vector3(1.0, 0.0, 0.0);
  79207. }
  79208. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  79209. point = new Vector3(0.0, 0.0, 1.0);
  79210. }
  79211. else {
  79212. point = Vector3.Zero();
  79213. }
  79214. normal0 = Vector3.Cross(vt, point);
  79215. }
  79216. else {
  79217. normal0 = Vector3.Cross(vt, va);
  79218. Vector3.CrossToRef(normal0, vt, normal0);
  79219. }
  79220. normal0.normalize();
  79221. return normal0;
  79222. };
  79223. return Path3D;
  79224. }());
  79225. /**
  79226. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79227. * A Curve3 is designed from a series of successive Vector3.
  79228. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  79229. */
  79230. var Curve3 = /** @class */ (function () {
  79231. /**
  79232. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79233. * A Curve3 is designed from a series of successive Vector3.
  79234. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  79235. * @param points points which make up the curve
  79236. */
  79237. function Curve3(points) {
  79238. this._length = 0.0;
  79239. this._points = points;
  79240. this._length = this._computeLength(points);
  79241. }
  79242. /**
  79243. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  79244. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  79245. * @param v1 (Vector3) the control point
  79246. * @param v2 (Vector3) the end point of the Quadratic Bezier
  79247. * @param nbPoints (integer) the wanted number of points in the curve
  79248. * @returns the created Curve3
  79249. */
  79250. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  79251. nbPoints = nbPoints > 2 ? nbPoints : 3;
  79252. var bez = new Array();
  79253. var equation = function (t, val0, val1, val2) {
  79254. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  79255. return res;
  79256. };
  79257. for (var i = 0; i <= nbPoints; i++) {
  79258. 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)));
  79259. }
  79260. return new Curve3(bez);
  79261. };
  79262. /**
  79263. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  79264. * @param v0 (Vector3) the origin point of the Cubic Bezier
  79265. * @param v1 (Vector3) the first control point
  79266. * @param v2 (Vector3) the second control point
  79267. * @param v3 (Vector3) the end point of the Cubic Bezier
  79268. * @param nbPoints (integer) the wanted number of points in the curve
  79269. * @returns the created Curve3
  79270. */
  79271. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  79272. nbPoints = nbPoints > 3 ? nbPoints : 4;
  79273. var bez = new Array();
  79274. var equation = function (t, val0, val1, val2, val3) {
  79275. 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;
  79276. return res;
  79277. };
  79278. for (var i = 0; i <= nbPoints; i++) {
  79279. 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)));
  79280. }
  79281. return new Curve3(bez);
  79282. };
  79283. /**
  79284. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  79285. * @param p1 (Vector3) the origin point of the Hermite Spline
  79286. * @param t1 (Vector3) the tangent vector at the origin point
  79287. * @param p2 (Vector3) the end point of the Hermite Spline
  79288. * @param t2 (Vector3) the tangent vector at the end point
  79289. * @param nbPoints (integer) the wanted number of points in the curve
  79290. * @returns the created Curve3
  79291. */
  79292. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  79293. var hermite = new Array();
  79294. var step = 1.0 / nbPoints;
  79295. for (var i = 0; i <= nbPoints; i++) {
  79296. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  79297. }
  79298. return new Curve3(hermite);
  79299. };
  79300. /**
  79301. * Returns a Curve3 object along a CatmullRom Spline curve :
  79302. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  79303. * @param nbPoints (integer) the wanted number of points between each curve control points
  79304. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  79305. * @returns the created Curve3
  79306. */
  79307. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  79308. var catmullRom = new Array();
  79309. var step = 1.0 / nbPoints;
  79310. var amount = 0.0;
  79311. if (closed) {
  79312. var pointsCount = points.length;
  79313. for (var i = 0; i < pointsCount; i++) {
  79314. amount = 0;
  79315. for (var c = 0; c < nbPoints; c++) {
  79316. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  79317. amount += step;
  79318. }
  79319. }
  79320. catmullRom.push(catmullRom[0]);
  79321. }
  79322. else {
  79323. var totalPoints = new Array();
  79324. totalPoints.push(points[0].clone());
  79325. Array.prototype.push.apply(totalPoints, points);
  79326. totalPoints.push(points[points.length - 1].clone());
  79327. for (var i = 0; i < totalPoints.length - 3; i++) {
  79328. amount = 0;
  79329. for (var c = 0; c < nbPoints; c++) {
  79330. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  79331. amount += step;
  79332. }
  79333. }
  79334. i--;
  79335. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  79336. }
  79337. return new Curve3(catmullRom);
  79338. };
  79339. /**
  79340. * @returns the Curve3 stored array of successive Vector3
  79341. */
  79342. Curve3.prototype.getPoints = function () {
  79343. return this._points;
  79344. };
  79345. /**
  79346. * @returns the computed length (float) of the curve.
  79347. */
  79348. Curve3.prototype.length = function () {
  79349. return this._length;
  79350. };
  79351. /**
  79352. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  79353. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  79354. * curveA and curveB keep unchanged.
  79355. * @param curve the curve to continue from this curve
  79356. * @returns the newly constructed curve
  79357. */
  79358. Curve3.prototype.continue = function (curve) {
  79359. var lastPoint = this._points[this._points.length - 1];
  79360. var continuedPoints = this._points.slice();
  79361. var curvePoints = curve.getPoints();
  79362. for (var i = 1; i < curvePoints.length; i++) {
  79363. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  79364. }
  79365. var continuedCurve = new Curve3(continuedPoints);
  79366. return continuedCurve;
  79367. };
  79368. Curve3.prototype._computeLength = function (path) {
  79369. var l = 0;
  79370. for (var i = 1; i < path.length; i++) {
  79371. l += (path[i].subtract(path[i - 1])).length();
  79372. }
  79373. return l;
  79374. };
  79375. return Curve3;
  79376. }());
  79377. // Vertex formats
  79378. /**
  79379. * Contains position and normal vectors for a vertex
  79380. */
  79381. var PositionNormalVertex = /** @class */ (function () {
  79382. /**
  79383. * Creates a PositionNormalVertex
  79384. * @param position the position of the vertex (defaut: 0,0,0)
  79385. * @param normal the normal of the vertex (defaut: 0,1,0)
  79386. */
  79387. function PositionNormalVertex(
  79388. /** the position of the vertex (defaut: 0,0,0) */
  79389. position,
  79390. /** the normal of the vertex (defaut: 0,1,0) */
  79391. normal) {
  79392. if (position === void 0) { position = Vector3.Zero(); }
  79393. if (normal === void 0) { normal = Vector3.Up(); }
  79394. this.position = position;
  79395. this.normal = normal;
  79396. }
  79397. /**
  79398. * Clones the PositionNormalVertex
  79399. * @returns the cloned PositionNormalVertex
  79400. */
  79401. PositionNormalVertex.prototype.clone = function () {
  79402. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  79403. };
  79404. return PositionNormalVertex;
  79405. }());
  79406. /**
  79407. * Contains position, normal and uv vectors for a vertex
  79408. */
  79409. var PositionNormalTextureVertex = /** @class */ (function () {
  79410. /**
  79411. * Creates a PositionNormalTextureVertex
  79412. * @param position the position of the vertex (defaut: 0,0,0)
  79413. * @param normal the normal of the vertex (defaut: 0,1,0)
  79414. * @param uv the uv of the vertex (default: 0,0)
  79415. */
  79416. function PositionNormalTextureVertex(
  79417. /** the position of the vertex (defaut: 0,0,0) */
  79418. position,
  79419. /** the normal of the vertex (defaut: 0,1,0) */
  79420. normal,
  79421. /** the uv of the vertex (default: 0,0) */
  79422. uv) {
  79423. if (position === void 0) { position = Vector3.Zero(); }
  79424. if (normal === void 0) { normal = Vector3.Up(); }
  79425. if (uv === void 0) { uv = Vector2.Zero(); }
  79426. this.position = position;
  79427. this.normal = normal;
  79428. this.uv = uv;
  79429. }
  79430. /**
  79431. * Clones the PositionNormalTextureVertex
  79432. * @returns the cloned PositionNormalTextureVertex
  79433. */
  79434. PositionNormalTextureVertex.prototype.clone = function () {
  79435. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  79436. };
  79437. return PositionNormalTextureVertex;
  79438. }());
  79439. // Temporary pre-allocated objects for engine internal use
  79440. // usage in any internal function :
  79441. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  79442. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  79443. /**
  79444. * @hidden
  79445. */
  79446. var Tmp = /** @class */ (function () {
  79447. function Tmp() {
  79448. }
  79449. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  79450. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  79451. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  79452. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  79453. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  79454. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  79455. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  79456. return Tmp;
  79457. }());
  79458. /**
  79459. * @hidden
  79460. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  79461. */
  79462. var MathTmp = /** @class */ (function () {
  79463. function MathTmp() {
  79464. }
  79465. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  79466. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  79467. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  79468. return MathTmp;
  79469. }());
  79470. /***/ }),
  79471. /***/ "./Maths/sphericalPolynomial.ts":
  79472. /*!**************************************!*\
  79473. !*** ./Maths/sphericalPolynomial.ts ***!
  79474. \**************************************/
  79475. /*! exports provided: SphericalHarmonics, SphericalPolynomial */
  79476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79477. "use strict";
  79478. __webpack_require__.r(__webpack_exports__);
  79479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  79480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  79481. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  79482. // https://dickyjim.wordpress.com/2013/09/04/spherical-harmonics-for-beginners/
  79483. // http://silviojemma.com/public/papers/lighting/spherical-harmonic-lighting.pdf
  79484. // https://www.ppsloan.org/publications/StupidSH36.pdf
  79485. // http://cseweb.ucsd.edu/~ravir/papers/envmap/envmap.pdf
  79486. // https://www.ppsloan.org/publications/SHJCGT.pdf
  79487. // https://www.ppsloan.org/publications/shdering.pdf
  79488. // https://google.github.io/filament/Filament.md.html#annex/sphericalharmonics
  79489. // https://patapom.com/blog/SHPortal/
  79490. // https://imdoingitwrong.wordpress.com/2011/04/14/spherical-harmonics-wtf/
  79491. // Using real SH basis:
  79492. // m>0 m m
  79493. // y = sqrt(2) * K * P * cos(m*phi) * cos(theta)
  79494. // l l l
  79495. //
  79496. // m<0 m |m|
  79497. // y = sqrt(2) * K * P * sin(m*phi) * cos(theta)
  79498. // l l l
  79499. //
  79500. // m=0 0 0
  79501. // y = K * P * trigono terms
  79502. // l l l
  79503. //
  79504. // m (2l + 1)(l - |m|)!
  79505. // K = sqrt(------------------)
  79506. // l 4pi(l + |m|)!
  79507. //
  79508. // and P by recursion:
  79509. //
  79510. // P00(x) = 1
  79511. // P01(x) = x
  79512. // Pll(x) = (-1^l)(2l - 1)!!(1-x*x)^(1/2)
  79513. // ((2l - 1)x[Pl-1/m]-(l + m - 1)[Pl-2/m])
  79514. // Plm(x) = ---------------------------------------
  79515. // l - m
  79516. // Leaving the trigonometric terms aside we can precompute the constants to :
  79517. var SH3ylmBasisConstants = [
  79518. Math.sqrt(1 / (4 * Math.PI)),
  79519. -Math.sqrt(3 / (4 * Math.PI)),
  79520. Math.sqrt(3 / (4 * Math.PI)),
  79521. -Math.sqrt(3 / (4 * Math.PI)),
  79522. Math.sqrt(15 / (4 * Math.PI)),
  79523. -Math.sqrt(15 / (4 * Math.PI)),
  79524. Math.sqrt(5 / (16 * Math.PI)),
  79525. -Math.sqrt(15 / (4 * Math.PI)),
  79526. Math.sqrt(15 / (16 * Math.PI)),
  79527. ];
  79528. // cm = cos(m * phi)
  79529. // sm = sin(m * phi)
  79530. // {x,y,z} = {cos(phi)sin(theta), sin(phi)sin(theta), cos(theta)}
  79531. // By recursion on using trigo identities:
  79532. var SH3ylmBasisTrigonometricTerms = [
  79533. function (direction) { return 1; },
  79534. function (direction) { return direction.y; },
  79535. function (direction) { return direction.z; },
  79536. function (direction) { return direction.x; },
  79537. function (direction) { return direction.x * direction.y; },
  79538. function (direction) { return direction.y * direction.z; },
  79539. function (direction) { return 3 * direction.z * direction.z - 1; },
  79540. function (direction) { return direction.x * direction.z; },
  79541. function (direction) { return direction.x * direction.x - direction.y * direction.y; },
  79542. ];
  79543. // Wrap the full compute
  79544. var applySH3 = function (lm, direction) {
  79545. return SH3ylmBasisConstants[lm] * SH3ylmBasisTrigonometricTerms[lm](direction);
  79546. };
  79547. // Derived from the integration of the a kernel convolution to SH.
  79548. // Great explanation here: https://patapom.com/blog/SHPortal/#about-distant-radiance-and-irradiance-environments
  79549. var SHCosKernelConvolution = [
  79550. Math.PI,
  79551. 2 * Math.PI / 3,
  79552. 2 * Math.PI / 3,
  79553. 2 * Math.PI / 3,
  79554. Math.PI / 4,
  79555. Math.PI / 4,
  79556. Math.PI / 4,
  79557. Math.PI / 4,
  79558. Math.PI / 4,
  79559. ];
  79560. /**
  79561. * Class representing spherical harmonics coefficients to the 3rd degree
  79562. */
  79563. var SphericalHarmonics = /** @class */ (function () {
  79564. function SphericalHarmonics() {
  79565. /**
  79566. * Defines whether or not the harmonics have been prescaled for rendering.
  79567. */
  79568. this.preScaled = false;
  79569. /**
  79570. * The l0,0 coefficients of the spherical harmonics
  79571. */
  79572. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79573. /**
  79574. * The l1,-1 coefficients of the spherical harmonics
  79575. */
  79576. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79577. /**
  79578. * The l1,0 coefficients of the spherical harmonics
  79579. */
  79580. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79581. /**
  79582. * The l1,1 coefficients of the spherical harmonics
  79583. */
  79584. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79585. /**
  79586. * The l2,-2 coefficients of the spherical harmonics
  79587. */
  79588. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79589. /**
  79590. * The l2,-1 coefficients of the spherical harmonics
  79591. */
  79592. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79593. /**
  79594. * The l2,0 coefficients of the spherical harmonics
  79595. */
  79596. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79597. /**
  79598. * The l2,1 coefficients of the spherical harmonics
  79599. */
  79600. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79601. /**
  79602. * The l2,2 coefficients of the spherical harmonics
  79603. */
  79604. this.l22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79605. }
  79606. /**
  79607. * Adds a light to the spherical harmonics
  79608. * @param direction the direction of the light
  79609. * @param color the color of the light
  79610. * @param deltaSolidAngle the delta solid angle of the light
  79611. */
  79612. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  79613. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  79614. var c = colorVector.scale(deltaSolidAngle);
  79615. this.l00 = this.l00.add(c.scale(applySH3(0, direction)));
  79616. this.l1_1 = this.l1_1.add(c.scale(applySH3(1, direction)));
  79617. this.l10 = this.l10.add(c.scale(applySH3(2, direction)));
  79618. this.l11 = this.l11.add(c.scale(applySH3(3, direction)));
  79619. this.l2_2 = this.l2_2.add(c.scale(applySH3(4, direction)));
  79620. this.l2_1 = this.l2_1.add(c.scale(applySH3(5, direction)));
  79621. this.l20 = this.l20.add(c.scale(applySH3(6, direction)));
  79622. this.l21 = this.l21.add(c.scale(applySH3(7, direction)));
  79623. this.l22 = this.l22.add(c.scale(applySH3(8, direction)));
  79624. };
  79625. /**
  79626. * Scales the spherical harmonics by the given amount
  79627. * @param scale the amount to scale
  79628. */
  79629. SphericalHarmonics.prototype.scaleInPlace = function (scale) {
  79630. this.l00.scaleInPlace(scale);
  79631. this.l1_1.scaleInPlace(scale);
  79632. this.l10.scaleInPlace(scale);
  79633. this.l11.scaleInPlace(scale);
  79634. this.l2_2.scaleInPlace(scale);
  79635. this.l2_1.scaleInPlace(scale);
  79636. this.l20.scaleInPlace(scale);
  79637. this.l21.scaleInPlace(scale);
  79638. this.l22.scaleInPlace(scale);
  79639. };
  79640. /**
  79641. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  79642. *
  79643. * ```
  79644. * E_lm = A_l * L_lm
  79645. * ```
  79646. *
  79647. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  79648. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  79649. * the scaling factors are given in equation 9.
  79650. */
  79651. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  79652. // Constant (Band 0)
  79653. this.l00.scaleInPlace(SHCosKernelConvolution[0]);
  79654. // Linear (Band 1)
  79655. this.l1_1.scaleInPlace(SHCosKernelConvolution[1]);
  79656. this.l10.scaleInPlace(SHCosKernelConvolution[2]);
  79657. this.l11.scaleInPlace(SHCosKernelConvolution[3]);
  79658. // Quadratic (Band 2)
  79659. this.l2_2.scaleInPlace(SHCosKernelConvolution[4]);
  79660. this.l2_1.scaleInPlace(SHCosKernelConvolution[5]);
  79661. this.l20.scaleInPlace(SHCosKernelConvolution[6]);
  79662. this.l21.scaleInPlace(SHCosKernelConvolution[7]);
  79663. this.l22.scaleInPlace(SHCosKernelConvolution[8]);
  79664. };
  79665. /**
  79666. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  79667. *
  79668. * ```
  79669. * L = (1/pi) * E * rho
  79670. * ```
  79671. *
  79672. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  79673. */
  79674. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  79675. this.scaleInPlace(1.0 / Math.PI);
  79676. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  79677. // (The pixel shader must apply albedo after texture fetches, etc).
  79678. };
  79679. /**
  79680. * Integrates the reconstruction coefficients directly in to the SH preventing further
  79681. * required operations at run time.
  79682. *
  79683. * This is simply done by scaling back the SH with Ylm constants parameter.
  79684. * The trigonometric part being applied by the shader at run time.
  79685. */
  79686. SphericalHarmonics.prototype.preScaleForRendering = function () {
  79687. this.preScaled = true;
  79688. this.l00.scaleInPlace(SH3ylmBasisConstants[0]);
  79689. this.l1_1.scaleInPlace(SH3ylmBasisConstants[1]);
  79690. this.l10.scaleInPlace(SH3ylmBasisConstants[2]);
  79691. this.l11.scaleInPlace(SH3ylmBasisConstants[3]);
  79692. this.l2_2.scaleInPlace(SH3ylmBasisConstants[4]);
  79693. this.l2_1.scaleInPlace(SH3ylmBasisConstants[5]);
  79694. this.l20.scaleInPlace(SH3ylmBasisConstants[6]);
  79695. this.l21.scaleInPlace(SH3ylmBasisConstants[7]);
  79696. this.l22.scaleInPlace(SH3ylmBasisConstants[8]);
  79697. };
  79698. /**
  79699. * Constructs a spherical harmonics from an array.
  79700. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  79701. * @returns the spherical harmonics
  79702. */
  79703. SphericalHarmonics.FromArray = function (data) {
  79704. var sh = new SphericalHarmonics();
  79705. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  79706. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  79707. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  79708. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  79709. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  79710. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  79711. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  79712. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  79713. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.l22);
  79714. return sh;
  79715. };
  79716. // Keep for references.
  79717. /**
  79718. * Gets the spherical harmonics from polynomial
  79719. * @param polynomial the spherical polynomial
  79720. * @returns the spherical harmonics
  79721. */
  79722. SphericalHarmonics.FromPolynomial = function (polynomial) {
  79723. var result = new SphericalHarmonics();
  79724. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  79725. result.l1_1 = polynomial.y.scale(0.977204);
  79726. result.l10 = polynomial.z.scale(0.977204);
  79727. result.l11 = polynomial.x.scale(0.977204);
  79728. result.l2_2 = polynomial.xy.scale(1.16538);
  79729. result.l2_1 = polynomial.yz.scale(1.16538);
  79730. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  79731. result.l21 = polynomial.zx.scale(1.16538);
  79732. result.l22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  79733. result.l1_1.scaleInPlace(-1);
  79734. result.l11.scaleInPlace(-1);
  79735. result.l2_1.scaleInPlace(-1);
  79736. result.l21.scaleInPlace(-1);
  79737. result.scaleInPlace(Math.PI);
  79738. return result;
  79739. };
  79740. return SphericalHarmonics;
  79741. }());
  79742. /**
  79743. * Class representing spherical polynomial coefficients to the 3rd degree
  79744. */
  79745. var SphericalPolynomial = /** @class */ (function () {
  79746. function SphericalPolynomial() {
  79747. /**
  79748. * The x coefficients of the spherical polynomial
  79749. */
  79750. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79751. /**
  79752. * The y coefficients of the spherical polynomial
  79753. */
  79754. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79755. /**
  79756. * The z coefficients of the spherical polynomial
  79757. */
  79758. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79759. /**
  79760. * The xx coefficients of the spherical polynomial
  79761. */
  79762. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79763. /**
  79764. * The yy coefficients of the spherical polynomial
  79765. */
  79766. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79767. /**
  79768. * The zz coefficients of the spherical polynomial
  79769. */
  79770. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79771. /**
  79772. * The xy coefficients of the spherical polynomial
  79773. */
  79774. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79775. /**
  79776. * The yz coefficients of the spherical polynomial
  79777. */
  79778. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79779. /**
  79780. * The zx coefficients of the spherical polynomial
  79781. */
  79782. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79783. }
  79784. Object.defineProperty(SphericalPolynomial.prototype, "preScaledHarmonics", {
  79785. /**
  79786. * The spherical harmonics used to create the polynomials.
  79787. */
  79788. get: function () {
  79789. if (!this._harmonics) {
  79790. this._harmonics = SphericalHarmonics.FromPolynomial(this);
  79791. }
  79792. if (!this._harmonics.preScaled) {
  79793. this._harmonics.preScaleForRendering();
  79794. }
  79795. return this._harmonics;
  79796. },
  79797. enumerable: true,
  79798. configurable: true
  79799. });
  79800. /**
  79801. * Adds an ambient color to the spherical polynomial
  79802. * @param color the color to add
  79803. */
  79804. SphericalPolynomial.prototype.addAmbient = function (color) {
  79805. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  79806. this.xx = this.xx.add(colorVector);
  79807. this.yy = this.yy.add(colorVector);
  79808. this.zz = this.zz.add(colorVector);
  79809. };
  79810. /**
  79811. * Scales the spherical polynomial by the given amount
  79812. * @param scale the amount to scale
  79813. */
  79814. SphericalPolynomial.prototype.scaleInPlace = function (scale) {
  79815. this.x.scaleInPlace(scale);
  79816. this.y.scaleInPlace(scale);
  79817. this.z.scaleInPlace(scale);
  79818. this.xx.scaleInPlace(scale);
  79819. this.yy.scaleInPlace(scale);
  79820. this.zz.scaleInPlace(scale);
  79821. this.yz.scaleInPlace(scale);
  79822. this.zx.scaleInPlace(scale);
  79823. this.xy.scaleInPlace(scale);
  79824. };
  79825. /**
  79826. * Gets the spherical polynomial from harmonics
  79827. * @param harmonics the spherical harmonics
  79828. * @returns the spherical polynomial
  79829. */
  79830. SphericalPolynomial.FromHarmonics = function (harmonics) {
  79831. var result = new SphericalPolynomial();
  79832. result._harmonics = harmonics;
  79833. result.x = harmonics.l11.scale(1.02333).scale(-1);
  79834. result.y = harmonics.l1_1.scale(1.02333).scale(-1);
  79835. result.z = harmonics.l10.scale(1.02333);
  79836. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.l22.scale(0.429043));
  79837. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.l22.scale(0.429043));
  79838. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  79839. result.yz = harmonics.l2_1.scale(0.858086).scale(-1);
  79840. result.zx = harmonics.l21.scale(0.858086).scale(-1);
  79841. result.xy = harmonics.l2_2.scale(0.858086);
  79842. result.scaleInPlace(1.0 / Math.PI);
  79843. return result;
  79844. };
  79845. /**
  79846. * Constructs a spherical polynomial from an array.
  79847. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  79848. * @returns the spherical polynomial
  79849. */
  79850. SphericalPolynomial.FromArray = function (data) {
  79851. var sp = new SphericalPolynomial();
  79852. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  79853. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  79854. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  79855. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  79856. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  79857. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  79858. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  79859. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  79860. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  79861. return sp;
  79862. };
  79863. return SphericalPolynomial;
  79864. }());
  79865. /***/ }),
  79866. /***/ "./Meshes/Builders/boxBuilder.ts":
  79867. /*!***************************************!*\
  79868. !*** ./Meshes/Builders/boxBuilder.ts ***!
  79869. \***************************************/
  79870. /*! exports provided: BoxBuilder */
  79871. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79872. "use strict";
  79873. __webpack_require__.r(__webpack_exports__);
  79874. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  79875. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79876. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79877. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79878. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  79879. var nbFaces = 6;
  79880. 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];
  79881. 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];
  79882. var uvs = [];
  79883. var positions = [];
  79884. var width = options.width || options.size || 1;
  79885. var height = options.height || options.size || 1;
  79886. var depth = options.depth || options.size || 1;
  79887. var wrap = options.wrap || false;
  79888. var topBaseAt = (options.topBaseAt === void 0) ? 1 : options.topBaseAt;
  79889. var bottomBaseAt = (options.bottomBaseAt === void 0) ? 0 : options.bottomBaseAt;
  79890. topBaseAt = (topBaseAt + 4) % 4; // places values as 0 to 3
  79891. bottomBaseAt = (bottomBaseAt + 4) % 4; // places values as 0 to 3
  79892. var topOrder = [2, 0, 3, 1];
  79893. var bottomOrder = [2, 0, 1, 3];
  79894. var topIndex = topOrder[topBaseAt];
  79895. var bottomIndex = bottomOrder[bottomBaseAt];
  79896. 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];
  79897. if (wrap) {
  79898. 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];
  79899. 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];
  79900. var topFaceBase = [[1, 1, 1], [-1, 1, 1], [-1, 1, -1], [1, 1, -1]];
  79901. var bottomFaceBase = [[-1, -1, 1], [1, -1, 1], [1, -1, -1], [-1, -1, -1]];
  79902. var topFaceOrder = [17, 18, 19, 16];
  79903. var bottomFaceOrder = [22, 23, 20, 21];
  79904. while (topIndex > 0) {
  79905. topFaceBase.unshift(topFaceBase.pop());
  79906. topFaceOrder.unshift(topFaceOrder.pop());
  79907. topIndex--;
  79908. }
  79909. while (bottomIndex > 0) {
  79910. bottomFaceBase.unshift(bottomFaceBase.pop());
  79911. bottomFaceOrder.unshift(bottomFaceOrder.pop());
  79912. bottomIndex--;
  79913. }
  79914. topFaceBase = topFaceBase.flat();
  79915. bottomFaceBase = bottomFaceBase.flat();
  79916. basePositions = basePositions.concat(topFaceBase).concat(bottomFaceBase);
  79917. indices.push(topFaceOrder[0], topFaceOrder[2], topFaceOrder[3], topFaceOrder[0], topFaceOrder[1], topFaceOrder[2]);
  79918. indices.push(bottomFaceOrder[0], bottomFaceOrder[2], bottomFaceOrder[3], bottomFaceOrder[0], bottomFaceOrder[1], bottomFaceOrder[2]);
  79919. }
  79920. var scaleArray = [width / 2, height / 2, depth / 2];
  79921. positions = basePositions.reduce(function (accumulator, currentValue, currentIndex) { return accumulator.concat(currentValue * scaleArray[currentIndex % 3]); }, []);
  79922. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  79923. var faceUV = options.faceUV || new Array(6);
  79924. var faceColors = options.faceColors;
  79925. var colors = [];
  79926. // default face colors and UV if undefined
  79927. for (var f = 0; f < 6; f++) {
  79928. if (faceUV[f] === undefined) {
  79929. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  79930. }
  79931. if (faceColors && faceColors[f] === undefined) {
  79932. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  79933. }
  79934. }
  79935. // Create each face in turn.
  79936. for (var index = 0; index < nbFaces; index++) {
  79937. uvs.push(faceUV[index].z, faceUV[index].w);
  79938. uvs.push(faceUV[index].x, faceUV[index].w);
  79939. uvs.push(faceUV[index].x, faceUV[index].y);
  79940. uvs.push(faceUV[index].z, faceUV[index].y);
  79941. if (faceColors) {
  79942. for (var c = 0; c < 4; c++) {
  79943. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  79944. }
  79945. }
  79946. }
  79947. // sides
  79948. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79949. // Result
  79950. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79951. vertexData.indices = indices;
  79952. vertexData.positions = positions;
  79953. vertexData.normals = normals;
  79954. vertexData.uvs = uvs;
  79955. if (faceColors) {
  79956. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  79957. vertexData.colors = totalColors;
  79958. }
  79959. return vertexData;
  79960. };
  79961. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  79962. if (scene === void 0) { scene = null; }
  79963. var options = {
  79964. size: size,
  79965. sideOrientation: sideOrientation,
  79966. updatable: updatable
  79967. };
  79968. return BoxBuilder.CreateBox(name, options, scene);
  79969. };
  79970. /**
  79971. * Class containing static functions to help procedurally build meshes
  79972. */
  79973. var BoxBuilder = /** @class */ (function () {
  79974. function BoxBuilder() {
  79975. }
  79976. /**
  79977. * Creates a box mesh
  79978. * * The parameter `size` sets the size (float) of each box side (default 1)
  79979. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  79980. * * 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)
  79981. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  79982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79983. * * 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
  79984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79985. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  79986. * @param name defines the name of the mesh
  79987. * @param options defines the options used to create the mesh
  79988. * @param scene defines the hosting scene
  79989. * @returns the box mesh
  79990. */
  79991. BoxBuilder.CreateBox = function (name, options, scene) {
  79992. if (scene === void 0) { scene = null; }
  79993. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79994. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79995. box._originalBuilderSideOrientation = options.sideOrientation;
  79996. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  79997. vertexData.applyToMesh(box, options.updatable);
  79998. return box;
  79999. };
  80000. return BoxBuilder;
  80001. }());
  80002. /***/ }),
  80003. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  80004. /*!********************************************!*\
  80005. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  80006. \********************************************/
  80007. /*! exports provided: CylinderBuilder */
  80008. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80009. "use strict";
  80010. __webpack_require__.r(__webpack_exports__);
  80011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  80012. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80013. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80014. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80015. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  80016. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  80017. var height = options.height || 2;
  80018. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  80019. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  80020. var tessellation = options.tessellation || 24;
  80021. var subdivisions = options.subdivisions || 1;
  80022. var hasRings = options.hasRings ? true : false;
  80023. var enclose = options.enclose ? true : false;
  80024. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  80025. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  80026. var faceUV = options.faceUV || new Array(3);
  80027. var faceColors = options.faceColors;
  80028. // default face colors and UV if undefined
  80029. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  80030. var ringNb = (hasRings) ? subdivisions : 1;
  80031. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  80032. var f;
  80033. for (f = 0; f < surfaceNb; f++) {
  80034. if (faceColors && faceColors[f] === undefined) {
  80035. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  80036. }
  80037. }
  80038. for (f = 0; f < surfaceNb; f++) {
  80039. if (faceUV && faceUV[f] === undefined) {
  80040. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  80041. }
  80042. }
  80043. var indices = new Array();
  80044. var positions = new Array();
  80045. var normals = new Array();
  80046. var uvs = new Array();
  80047. var colors = new Array();
  80048. var angle_step = Math.PI * 2 * arc / tessellation;
  80049. var angle;
  80050. var h;
  80051. var radius;
  80052. var tan = (diameterBottom - diameterTop) / 2 / height;
  80053. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80054. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80055. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80056. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80057. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80058. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  80059. // positions, normals, uvs
  80060. var i;
  80061. var j;
  80062. var r;
  80063. var ringIdx = 1;
  80064. var s = 1; // surface index
  80065. var cs = 0;
  80066. var v = 0;
  80067. for (i = 0; i <= subdivisions; i++) {
  80068. h = i / subdivisions;
  80069. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  80070. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  80071. for (r = 0; r < ringIdx; r++) {
  80072. if (hasRings) {
  80073. s += r;
  80074. }
  80075. if (enclose) {
  80076. s += 2 * r;
  80077. }
  80078. for (j = 0; j <= tessellation; j++) {
  80079. angle = j * angle_step;
  80080. // position
  80081. ringVertex.x = Math.cos(-angle) * radius;
  80082. ringVertex.y = -height / 2 + h * height;
  80083. ringVertex.z = Math.sin(-angle) * radius;
  80084. // normal
  80085. if (diameterTop === 0 && i === subdivisions) {
  80086. // if no top cap, reuse former normals
  80087. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  80088. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  80089. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  80090. }
  80091. else {
  80092. ringNormal.x = ringVertex.x;
  80093. ringNormal.z = ringVertex.z;
  80094. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  80095. ringNormal.normalize();
  80096. }
  80097. // keep first ring vertex values for enclose
  80098. if (j === 0) {
  80099. ringFirstVertex.copyFrom(ringVertex);
  80100. ringFirstNormal.copyFrom(ringNormal);
  80101. }
  80102. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  80103. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  80104. if (hasRings) {
  80105. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  80106. }
  80107. else {
  80108. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  80109. }
  80110. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  80111. if (faceColors) {
  80112. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  80113. }
  80114. }
  80115. // if enclose, add four vertices and their dedicated normals
  80116. if (arc !== 1 && enclose) {
  80117. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  80118. positions.push(0, ringVertex.y, 0);
  80119. positions.push(0, ringVertex.y, 0);
  80120. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  80121. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  80122. quadNormal.normalize();
  80123. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  80124. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  80125. quadNormal.normalize();
  80126. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  80127. if (hasRings) {
  80128. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  80129. }
  80130. else {
  80131. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  80132. }
  80133. uvs.push(faceUV[s + 1].x, v);
  80134. uvs.push(faceUV[s + 1].z, v);
  80135. if (hasRings) {
  80136. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  80137. }
  80138. else {
  80139. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  80140. }
  80141. uvs.push(faceUV[s + 2].x, v);
  80142. uvs.push(faceUV[s + 2].z, v);
  80143. if (faceColors) {
  80144. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  80145. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  80146. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  80147. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  80148. }
  80149. }
  80150. if (cs !== s) {
  80151. cs = s;
  80152. }
  80153. }
  80154. }
  80155. // indices
  80156. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  80157. var s;
  80158. i = 0;
  80159. for (s = 0; s < subdivisions; s++) {
  80160. var i0 = 0;
  80161. var i1 = 0;
  80162. var i2 = 0;
  80163. var i3 = 0;
  80164. for (j = 0; j < tessellation; j++) {
  80165. i0 = i * (e + 1) + j;
  80166. i1 = (i + 1) * (e + 1) + j;
  80167. i2 = i * (e + 1) + (j + 1);
  80168. i3 = (i + 1) * (e + 1) + (j + 1);
  80169. indices.push(i0, i1, i2);
  80170. indices.push(i3, i2, i1);
  80171. }
  80172. if (arc !== 1 && enclose) { // if enclose, add two quads
  80173. indices.push(i0 + 2, i1 + 2, i2 + 2);
  80174. indices.push(i3 + 2, i2 + 2, i1 + 2);
  80175. indices.push(i0 + 4, i1 + 4, i2 + 4);
  80176. indices.push(i3 + 4, i2 + 4, i1 + 4);
  80177. }
  80178. i = (hasRings) ? (i + 2) : (i + 1);
  80179. }
  80180. // Caps
  80181. var createCylinderCap = function (isTop) {
  80182. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  80183. if (radius === 0) {
  80184. return;
  80185. }
  80186. // Cap positions, normals & uvs
  80187. var angle;
  80188. var circleVector;
  80189. var i;
  80190. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  80191. var c = null;
  80192. if (faceColors) {
  80193. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  80194. }
  80195. // cap center
  80196. var vbase = positions.length / 3;
  80197. var offset = isTop ? height / 2 : -height / 2;
  80198. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  80199. positions.push(center.x, center.y, center.z);
  80200. normals.push(0, isTop ? 1 : -1, 0);
  80201. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  80202. if (c) {
  80203. colors.push(c.r, c.g, c.b, c.a);
  80204. }
  80205. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  80206. for (i = 0; i <= tessellation; i++) {
  80207. angle = Math.PI * 2 * i * arc / tessellation;
  80208. var cos = Math.cos(-angle);
  80209. var sin = Math.sin(-angle);
  80210. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  80211. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  80212. positions.push(circleVector.x, circleVector.y, circleVector.z);
  80213. normals.push(0, isTop ? 1 : -1, 0);
  80214. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  80215. if (c) {
  80216. colors.push(c.r, c.g, c.b, c.a);
  80217. }
  80218. }
  80219. // Cap indices
  80220. for (i = 0; i < tessellation; i++) {
  80221. if (!isTop) {
  80222. indices.push(vbase);
  80223. indices.push(vbase + (i + 1));
  80224. indices.push(vbase + (i + 2));
  80225. }
  80226. else {
  80227. indices.push(vbase);
  80228. indices.push(vbase + (i + 2));
  80229. indices.push(vbase + (i + 1));
  80230. }
  80231. }
  80232. };
  80233. // add caps to geometry
  80234. createCylinderCap(false);
  80235. createCylinderCap(true);
  80236. // Sides
  80237. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80238. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80239. vertexData.indices = indices;
  80240. vertexData.positions = positions;
  80241. vertexData.normals = normals;
  80242. vertexData.uvs = uvs;
  80243. if (faceColors) {
  80244. vertexData.colors = colors;
  80245. }
  80246. return vertexData;
  80247. };
  80248. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  80249. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  80250. if (scene !== undefined) {
  80251. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  80252. updatable = scene;
  80253. }
  80254. scene = subdivisions;
  80255. subdivisions = 1;
  80256. }
  80257. var options = {
  80258. height: height,
  80259. diameterTop: diameterTop,
  80260. diameterBottom: diameterBottom,
  80261. tessellation: tessellation,
  80262. subdivisions: subdivisions,
  80263. sideOrientation: sideOrientation,
  80264. updatable: updatable
  80265. };
  80266. return CylinderBuilder.CreateCylinder(name, options, scene);
  80267. };
  80268. /**
  80269. * Class containing static functions to help procedurally build meshes
  80270. */
  80271. var CylinderBuilder = /** @class */ (function () {
  80272. function CylinderBuilder() {
  80273. }
  80274. /**
  80275. * Creates a cylinder or a cone mesh
  80276. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  80277. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  80278. * * 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.
  80279. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  80280. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  80281. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  80282. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  80283. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  80284. * * 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).
  80285. * * 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
  80286. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  80287. * * 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
  80288. * * 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.
  80289. * * If `enclose` is false, a ring surface is one element.
  80290. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  80291. * * 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
  80292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80293. * * 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
  80294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80295. * @param name defines the name of the mesh
  80296. * @param options defines the options used to create the mesh
  80297. * @param scene defines the hosting scene
  80298. * @returns the cylinder mesh
  80299. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  80300. */
  80301. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  80302. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80303. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80304. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  80305. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  80306. vertexData.applyToMesh(cylinder, options.updatable);
  80307. return cylinder;
  80308. };
  80309. return CylinderBuilder;
  80310. }());
  80311. /***/ }),
  80312. /***/ "./Meshes/Builders/decalBuilder.ts":
  80313. /*!*****************************************!*\
  80314. !*** ./Meshes/Builders/decalBuilder.ts ***!
  80315. \*****************************************/
  80316. /*! exports provided: DecalBuilder */
  80317. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80318. "use strict";
  80319. __webpack_require__.r(__webpack_exports__);
  80320. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  80321. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80322. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80323. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  80324. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80325. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  80326. var options = {
  80327. position: position,
  80328. normal: normal,
  80329. size: size,
  80330. angle: angle
  80331. };
  80332. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  80333. };
  80334. /**
  80335. * Class containing static functions to help procedurally build meshes
  80336. */
  80337. var DecalBuilder = /** @class */ (function () {
  80338. function DecalBuilder() {
  80339. }
  80340. /**
  80341. * Creates a decal mesh.
  80342. * 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
  80343. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  80344. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  80345. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  80346. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  80347. * @param name defines the name of the mesh
  80348. * @param sourceMesh defines the mesh where the decal must be applied
  80349. * @param options defines the options used to create the mesh
  80350. * @param scene defines the hosting scene
  80351. * @returns the decal mesh
  80352. * @see https://doc.babylonjs.com/how_to/decals
  80353. */
  80354. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  80355. var indices = sourceMesh.getIndices();
  80356. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  80357. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  80358. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80359. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  80360. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  80361. var angle = options.angle || 0;
  80362. // Getting correct rotation
  80363. if (!normal) {
  80364. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  80365. var camera = sourceMesh.getScene().activeCamera;
  80366. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  80367. normal = camera.globalPosition.subtract(cameraWorldTarget);
  80368. }
  80369. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  80370. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  80371. var pitch = Math.atan2(normal.y, len);
  80372. // Matrix
  80373. 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));
  80374. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  80375. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  80376. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  80377. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  80378. vertexData.indices = [];
  80379. vertexData.positions = [];
  80380. vertexData.normals = [];
  80381. vertexData.uvs = [];
  80382. var currentVertexDataIndex = 0;
  80383. var extractDecalVector3 = function (indexId) {
  80384. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  80385. if (!indices || !positions || !normals) {
  80386. return result;
  80387. }
  80388. var vertexId = indices[indexId];
  80389. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  80390. // Send vector to decal local world
  80391. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  80392. // Get normal
  80393. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  80394. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  80395. return result;
  80396. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  80397. var clip = function (vertices, axis) {
  80398. if (vertices.length === 0) {
  80399. return vertices;
  80400. }
  80401. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  80402. var clipVertices = function (v0, v1) {
  80403. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  80404. 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));
  80405. };
  80406. var result = new Array();
  80407. for (var index = 0; index < vertices.length; index += 3) {
  80408. var v1Out;
  80409. var v2Out;
  80410. var v3Out;
  80411. var total = 0;
  80412. var nV1 = null;
  80413. var nV2 = null;
  80414. var nV3 = null;
  80415. var nV4 = null;
  80416. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  80417. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  80418. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  80419. v1Out = d1 > 0;
  80420. v2Out = d2 > 0;
  80421. v3Out = d3 > 0;
  80422. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  80423. switch (total) {
  80424. case 0:
  80425. result.push(vertices[index]);
  80426. result.push(vertices[index + 1]);
  80427. result.push(vertices[index + 2]);
  80428. break;
  80429. case 1:
  80430. if (v1Out) {
  80431. nV1 = vertices[index + 1];
  80432. nV2 = vertices[index + 2];
  80433. nV3 = clipVertices(vertices[index], nV1);
  80434. nV4 = clipVertices(vertices[index], nV2);
  80435. }
  80436. if (v2Out) {
  80437. nV1 = vertices[index];
  80438. nV2 = vertices[index + 2];
  80439. nV3 = clipVertices(vertices[index + 1], nV1);
  80440. nV4 = clipVertices(vertices[index + 1], nV2);
  80441. result.push(nV3);
  80442. result.push(nV2.clone());
  80443. result.push(nV1.clone());
  80444. result.push(nV2.clone());
  80445. result.push(nV3.clone());
  80446. result.push(nV4);
  80447. break;
  80448. }
  80449. if (v3Out) {
  80450. nV1 = vertices[index];
  80451. nV2 = vertices[index + 1];
  80452. nV3 = clipVertices(vertices[index + 2], nV1);
  80453. nV4 = clipVertices(vertices[index + 2], nV2);
  80454. }
  80455. if (nV1 && nV2 && nV3 && nV4) {
  80456. result.push(nV1.clone());
  80457. result.push(nV2.clone());
  80458. result.push(nV3);
  80459. result.push(nV4);
  80460. result.push(nV3.clone());
  80461. result.push(nV2.clone());
  80462. }
  80463. break;
  80464. case 2:
  80465. if (!v1Out) {
  80466. nV1 = vertices[index].clone();
  80467. nV2 = clipVertices(nV1, vertices[index + 1]);
  80468. nV3 = clipVertices(nV1, vertices[index + 2]);
  80469. result.push(nV1);
  80470. result.push(nV2);
  80471. result.push(nV3);
  80472. }
  80473. if (!v2Out) {
  80474. nV1 = vertices[index + 1].clone();
  80475. nV2 = clipVertices(nV1, vertices[index + 2]);
  80476. nV3 = clipVertices(nV1, vertices[index]);
  80477. result.push(nV1);
  80478. result.push(nV2);
  80479. result.push(nV3);
  80480. }
  80481. if (!v3Out) {
  80482. nV1 = vertices[index + 2].clone();
  80483. nV2 = clipVertices(nV1, vertices[index]);
  80484. nV3 = clipVertices(nV1, vertices[index + 1]);
  80485. result.push(nV1);
  80486. result.push(nV2);
  80487. result.push(nV3);
  80488. }
  80489. break;
  80490. case 3:
  80491. break;
  80492. }
  80493. }
  80494. return result;
  80495. };
  80496. for (var index = 0; index < indices.length; index += 3) {
  80497. var faceVertices = new Array();
  80498. faceVertices.push(extractDecalVector3(index));
  80499. faceVertices.push(extractDecalVector3(index + 1));
  80500. faceVertices.push(extractDecalVector3(index + 2));
  80501. // Clip
  80502. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  80503. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  80504. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  80505. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  80506. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  80507. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  80508. if (faceVertices.length === 0) {
  80509. continue;
  80510. }
  80511. // Add UVs and get back to world
  80512. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  80513. var vertex = faceVertices[vIndex];
  80514. //TODO check for Int32Array | Uint32Array | Uint16Array
  80515. vertexData.indices.push(currentVertexDataIndex);
  80516. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  80517. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  80518. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  80519. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  80520. currentVertexDataIndex++;
  80521. }
  80522. }
  80523. // Return mesh
  80524. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  80525. vertexData.applyToMesh(decal);
  80526. decal.position = position.clone();
  80527. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  80528. return decal;
  80529. };
  80530. return DecalBuilder;
  80531. }());
  80532. /***/ }),
  80533. /***/ "./Meshes/Builders/discBuilder.ts":
  80534. /*!****************************************!*\
  80535. !*** ./Meshes/Builders/discBuilder.ts ***!
  80536. \****************************************/
  80537. /*! exports provided: DiscBuilder */
  80538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80539. "use strict";
  80540. __webpack_require__.r(__webpack_exports__);
  80541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  80542. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80543. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80544. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  80545. var positions = new Array();
  80546. var indices = new Array();
  80547. var normals = new Array();
  80548. var uvs = new Array();
  80549. var radius = options.radius || 0.5;
  80550. var tessellation = options.tessellation || 64;
  80551. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  80552. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  80553. // positions and uvs
  80554. positions.push(0, 0, 0); // disc center first
  80555. uvs.push(0.5, 0.5);
  80556. var theta = Math.PI * 2 * arc;
  80557. var step = theta / tessellation;
  80558. for (var a = 0; a < theta; a += step) {
  80559. var x = Math.cos(a);
  80560. var y = Math.sin(a);
  80561. var u = (x + 1) / 2;
  80562. var v = (1 - y) / 2;
  80563. positions.push(radius * x, radius * y, 0);
  80564. uvs.push(u, v);
  80565. }
  80566. if (arc === 1) {
  80567. positions.push(positions[3], positions[4], positions[5]); // close the circle
  80568. uvs.push(uvs[2], uvs[3]);
  80569. }
  80570. //indices
  80571. var vertexNb = positions.length / 3;
  80572. for (var i = 1; i < vertexNb - 1; i++) {
  80573. indices.push(i + 1, 0, i);
  80574. }
  80575. // result
  80576. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  80577. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80578. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  80579. vertexData.indices = indices;
  80580. vertexData.positions = positions;
  80581. vertexData.normals = normals;
  80582. vertexData.uvs = uvs;
  80583. return vertexData;
  80584. };
  80585. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  80586. if (scene === void 0) { scene = null; }
  80587. var options = {
  80588. radius: radius,
  80589. tessellation: tessellation,
  80590. sideOrientation: sideOrientation,
  80591. updatable: updatable
  80592. };
  80593. return DiscBuilder.CreateDisc(name, options, scene);
  80594. };
  80595. /**
  80596. * Class containing static functions to help procedurally build meshes
  80597. */
  80598. var DiscBuilder = /** @class */ (function () {
  80599. function DiscBuilder() {
  80600. }
  80601. /**
  80602. * Creates a plane polygonal mesh. By default, this is a disc
  80603. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80604. * * 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
  80605. * * 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
  80606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80607. * * 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
  80608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80609. * @param name defines the name of the mesh
  80610. * @param options defines the options used to create the mesh
  80611. * @param scene defines the hosting scene
  80612. * @returns the plane polygonal mesh
  80613. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80614. */
  80615. DiscBuilder.CreateDisc = function (name, options, scene) {
  80616. if (scene === void 0) { scene = null; }
  80617. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  80618. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80619. disc._originalBuilderSideOrientation = options.sideOrientation;
  80620. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  80621. vertexData.applyToMesh(disc, options.updatable);
  80622. return disc;
  80623. };
  80624. return DiscBuilder;
  80625. }());
  80626. /***/ }),
  80627. /***/ "./Meshes/Builders/groundBuilder.ts":
  80628. /*!******************************************!*\
  80629. !*** ./Meshes/Builders/groundBuilder.ts ***!
  80630. \******************************************/
  80631. /*! exports provided: GroundBuilder */
  80632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80633. "use strict";
  80634. __webpack_require__.r(__webpack_exports__);
  80635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  80636. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80637. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80638. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80639. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  80640. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  80641. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  80642. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  80643. var indices = [];
  80644. var positions = [];
  80645. var normals = [];
  80646. var uvs = [];
  80647. var row, col;
  80648. var width = options.width || 1;
  80649. var height = options.height || 1;
  80650. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  80651. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  80652. for (row = 0; row <= subdivisionsY; row++) {
  80653. for (col = 0; col <= subdivisionsX; col++) {
  80654. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  80655. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  80656. positions.push(position.x, position.y, position.z);
  80657. normals.push(normal.x, normal.y, normal.z);
  80658. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  80659. }
  80660. }
  80661. for (row = 0; row < subdivisionsY; row++) {
  80662. for (col = 0; col < subdivisionsX; col++) {
  80663. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  80664. indices.push(col + 1 + row * (subdivisionsX + 1));
  80665. indices.push(col + row * (subdivisionsX + 1));
  80666. indices.push(col + (row + 1) * (subdivisionsX + 1));
  80667. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  80668. indices.push(col + row * (subdivisionsX + 1));
  80669. }
  80670. }
  80671. // Result
  80672. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80673. vertexData.indices = indices;
  80674. vertexData.positions = positions;
  80675. vertexData.normals = normals;
  80676. vertexData.uvs = uvs;
  80677. return vertexData;
  80678. };
  80679. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  80680. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  80681. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  80682. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  80683. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  80684. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  80685. var precision = options.precision || { w: 1, h: 1 };
  80686. var indices = new Array();
  80687. var positions = new Array();
  80688. var normals = new Array();
  80689. var uvs = new Array();
  80690. var row, col, tileRow, tileCol;
  80691. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  80692. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  80693. precision.w = (precision.w < 1) ? 1 : precision.w;
  80694. precision.h = (precision.h < 1) ? 1 : precision.h;
  80695. var tileSize = {
  80696. 'w': (xmax - xmin) / subdivisions.w,
  80697. 'h': (zmax - zmin) / subdivisions.h
  80698. };
  80699. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  80700. // Indices
  80701. var base = positions.length / 3;
  80702. var rowLength = precision.w + 1;
  80703. for (row = 0; row < precision.h; row++) {
  80704. for (col = 0; col < precision.w; col++) {
  80705. var square = [
  80706. base + col + row * rowLength,
  80707. base + (col + 1) + row * rowLength,
  80708. base + (col + 1) + (row + 1) * rowLength,
  80709. base + col + (row + 1) * rowLength
  80710. ];
  80711. indices.push(square[1]);
  80712. indices.push(square[2]);
  80713. indices.push(square[3]);
  80714. indices.push(square[0]);
  80715. indices.push(square[1]);
  80716. indices.push(square[3]);
  80717. }
  80718. }
  80719. // Position, normals and uvs
  80720. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80721. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  80722. for (row = 0; row <= precision.h; row++) {
  80723. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  80724. for (col = 0; col <= precision.w; col++) {
  80725. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  80726. position.y = 0;
  80727. positions.push(position.x, position.y, position.z);
  80728. normals.push(normal.x, normal.y, normal.z);
  80729. uvs.push(col / precision.w, row / precision.h);
  80730. }
  80731. }
  80732. }
  80733. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  80734. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  80735. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  80736. }
  80737. }
  80738. // Result
  80739. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80740. vertexData.indices = indices;
  80741. vertexData.positions = positions;
  80742. vertexData.normals = normals;
  80743. vertexData.uvs = uvs;
  80744. return vertexData;
  80745. };
  80746. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  80747. var indices = [];
  80748. var positions = [];
  80749. var normals = [];
  80750. var uvs = [];
  80751. var row, col;
  80752. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  80753. var alphaFilter = options.alphaFilter || 0.0;
  80754. var invert = false;
  80755. if (options.minHeight > options.maxHeight) {
  80756. invert = true;
  80757. var temp = options.maxHeight;
  80758. options.maxHeight = options.minHeight;
  80759. options.minHeight = temp;
  80760. }
  80761. // Vertices
  80762. for (row = 0; row <= options.subdivisions; row++) {
  80763. for (col = 0; col <= options.subdivisions; col++) {
  80764. 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));
  80765. // Compute height
  80766. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  80767. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  80768. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  80769. var r = options.buffer[pos] / 255.0;
  80770. var g = options.buffer[pos + 1] / 255.0;
  80771. var b = options.buffer[pos + 2] / 255.0;
  80772. var a = options.buffer[pos + 3] / 255.0;
  80773. if (invert) {
  80774. r = 1.0 - r;
  80775. g = 1.0 - g;
  80776. b = 1.0 - b;
  80777. }
  80778. var gradient = r * filter.r + g * filter.g + b * filter.b;
  80779. // If our alpha channel is not within our filter then we will assign a 'special' height
  80780. // Then when building the indices, we will ignore any vertex that is using the special height
  80781. if (a >= alphaFilter) {
  80782. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  80783. }
  80784. else {
  80785. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  80786. }
  80787. // Add vertex
  80788. positions.push(position.x, position.y, position.z);
  80789. normals.push(0, 0, 0);
  80790. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  80791. }
  80792. }
  80793. // Indices
  80794. for (row = 0; row < options.subdivisions; row++) {
  80795. for (col = 0; col < options.subdivisions; col++) {
  80796. // Calculate Indices
  80797. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  80798. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  80799. var idx3 = (col + row * (options.subdivisions + 1));
  80800. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  80801. // Check that all indices are visible (based on our special height)
  80802. // Only display the vertex if all Indices are visible
  80803. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  80804. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  80805. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  80806. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  80807. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  80808. indices.push(idx1);
  80809. indices.push(idx2);
  80810. indices.push(idx3);
  80811. }
  80812. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  80813. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  80814. indices.push(idx4);
  80815. indices.push(idx1);
  80816. indices.push(idx3);
  80817. }
  80818. }
  80819. }
  80820. // Normals
  80821. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  80822. // Result
  80823. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80824. vertexData.indices = indices;
  80825. vertexData.positions = positions;
  80826. vertexData.normals = normals;
  80827. vertexData.uvs = uvs;
  80828. return vertexData;
  80829. };
  80830. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  80831. var options = {
  80832. width: width,
  80833. height: height,
  80834. subdivisions: subdivisions,
  80835. updatable: updatable
  80836. };
  80837. return GroundBuilder.CreateGround(name, options, scene);
  80838. };
  80839. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  80840. var options = {
  80841. xmin: xmin,
  80842. zmin: zmin,
  80843. xmax: xmax,
  80844. zmax: zmax,
  80845. subdivisions: subdivisions,
  80846. precision: precision,
  80847. updatable: updatable
  80848. };
  80849. return GroundBuilder.CreateTiledGround(name, options, scene);
  80850. };
  80851. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  80852. var options = {
  80853. width: width,
  80854. height: height,
  80855. subdivisions: subdivisions,
  80856. minHeight: minHeight,
  80857. maxHeight: maxHeight,
  80858. updatable: updatable,
  80859. onReady: onReady,
  80860. alphaFilter: alphaFilter
  80861. };
  80862. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  80863. };
  80864. /**
  80865. * Class containing static functions to help procedurally build meshes
  80866. */
  80867. var GroundBuilder = /** @class */ (function () {
  80868. function GroundBuilder() {
  80869. }
  80870. /**
  80871. * Creates a ground mesh
  80872. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  80873. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  80874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80875. * @param name defines the name of the mesh
  80876. * @param options defines the options used to create the mesh
  80877. * @param scene defines the hosting scene
  80878. * @returns the ground mesh
  80879. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  80880. */
  80881. GroundBuilder.CreateGround = function (name, options, scene) {
  80882. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  80883. ground._setReady(false);
  80884. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  80885. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  80886. ground._width = options.width || 1;
  80887. ground._height = options.height || 1;
  80888. ground._maxX = ground._width / 2;
  80889. ground._maxZ = ground._height / 2;
  80890. ground._minX = -ground._maxX;
  80891. ground._minZ = -ground._maxZ;
  80892. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  80893. vertexData.applyToMesh(ground, options.updatable);
  80894. ground._setReady(true);
  80895. return ground;
  80896. };
  80897. /**
  80898. * Creates a tiled ground mesh
  80899. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  80900. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  80901. * * 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
  80902. * * 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
  80903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80904. * @param name defines the name of the mesh
  80905. * @param options defines the options used to create the mesh
  80906. * @param scene defines the hosting scene
  80907. * @returns the tiled ground mesh
  80908. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  80909. */
  80910. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  80911. if (scene === void 0) { scene = null; }
  80912. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80913. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  80914. vertexData.applyToMesh(tiledGround, options.updatable);
  80915. return tiledGround;
  80916. };
  80917. /**
  80918. * Creates a ground mesh from a height map
  80919. * * The parameter `url` sets the URL of the height map image resource.
  80920. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  80921. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  80922. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  80923. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  80924. * * 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.
  80925. * * 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).
  80926. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  80927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80928. * @param name defines the name of the mesh
  80929. * @param url defines the url to the height map
  80930. * @param options defines the options used to create the mesh
  80931. * @param scene defines the hosting scene
  80932. * @returns the ground mesh
  80933. * @see https://doc.babylonjs.com/babylon101/height_map
  80934. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  80935. */
  80936. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  80937. if (scene === void 0) { scene = null; }
  80938. var width = options.width || 10.0;
  80939. var height = options.height || 10.0;
  80940. var subdivisions = options.subdivisions || 1 | 0;
  80941. var minHeight = options.minHeight || 0.0;
  80942. var maxHeight = options.maxHeight || 1.0;
  80943. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  80944. var alphaFilter = options.alphaFilter || 0.0;
  80945. var updatable = options.updatable;
  80946. var onReady = options.onReady;
  80947. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  80948. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  80949. ground._subdivisionsX = subdivisions;
  80950. ground._subdivisionsY = subdivisions;
  80951. ground._width = width;
  80952. ground._height = height;
  80953. ground._maxX = ground._width / 2.0;
  80954. ground._maxZ = ground._height / 2.0;
  80955. ground._minX = -ground._maxX;
  80956. ground._minZ = -ground._maxZ;
  80957. ground._setReady(false);
  80958. var onload = function (img) {
  80959. // Getting height map data
  80960. var canvas = document.createElement("canvas");
  80961. var context = canvas.getContext("2d");
  80962. if (!context) {
  80963. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  80964. }
  80965. if (scene.isDisposed) {
  80966. return;
  80967. }
  80968. var bufferWidth = img.width;
  80969. var bufferHeight = img.height;
  80970. canvas.width = bufferWidth;
  80971. canvas.height = bufferHeight;
  80972. context.drawImage(img, 0, 0);
  80973. // Create VertexData from map data
  80974. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  80975. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  80976. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  80977. width: width, height: height,
  80978. subdivisions: subdivisions,
  80979. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  80980. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  80981. alphaFilter: alphaFilter
  80982. });
  80983. vertexData.applyToMesh(ground, updatable);
  80984. //execute ready callback, if set
  80985. if (onReady) {
  80986. onReady(ground);
  80987. }
  80988. ground._setReady(true);
  80989. };
  80990. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  80991. return ground;
  80992. };
  80993. return GroundBuilder;
  80994. }());
  80995. /***/ }),
  80996. /***/ "./Meshes/Builders/hemisphereBuilder.ts":
  80997. /*!**********************************************!*\
  80998. !*** ./Meshes/Builders/hemisphereBuilder.ts ***!
  80999. \**********************************************/
  81000. /*! exports provided: HemisphereBuilder */
  81001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81002. "use strict";
  81003. __webpack_require__.r(__webpack_exports__);
  81004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return HemisphereBuilder; });
  81005. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81006. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  81007. /**
  81008. * Creates a hemispheric light
  81009. */
  81010. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateHemisphere = function (name, segments, diameter, scene) {
  81011. var options = {
  81012. segments: segments,
  81013. diameter: diameter
  81014. };
  81015. return HemisphereBuilder.CreateHemisphere(name, options, scene);
  81016. };
  81017. /**
  81018. * Class containing static functions to help procedurally build meshes
  81019. */
  81020. var HemisphereBuilder = /** @class */ (function () {
  81021. function HemisphereBuilder() {
  81022. }
  81023. /**
  81024. * Creates a hemisphere mesh
  81025. * @param name defines the name of the mesh
  81026. * @param options defines the options used to create the mesh
  81027. * @param scene defines the hosting scene
  81028. * @returns the hemisphere mesh
  81029. */
  81030. HemisphereBuilder.CreateHemisphere = function (name, options, scene) {
  81031. if (!options.diameter) {
  81032. options.diameter = 1;
  81033. }
  81034. if (!options.segments) {
  81035. options.segments = 16;
  81036. }
  81037. var halfSphere = _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("", { slice: 0.5, diameter: options.diameter, segments: options.segments }, scene);
  81038. var disc = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc("", options.diameter / 2, (options.segments * 3) + (4 - options.segments), scene);
  81039. disc.rotation.x = -Math.PI / 2;
  81040. disc.parent = halfSphere;
  81041. var merged = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].MergeMeshes([disc, halfSphere], true);
  81042. merged.name = name;
  81043. return merged;
  81044. };
  81045. return HemisphereBuilder;
  81046. }());
  81047. /***/ }),
  81048. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  81049. /*!*********************************************!*\
  81050. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  81051. \*********************************************/
  81052. /*! exports provided: IcoSphereBuilder */
  81053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81054. "use strict";
  81055. __webpack_require__.r(__webpack_exports__);
  81056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  81057. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81058. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81059. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81060. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  81061. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  81062. var radius = options.radius || 1;
  81063. var flat = (options.flat === undefined) ? true : options.flat;
  81064. var subdivisions = options.subdivisions || 4;
  81065. var radiusX = options.radiusX || radius;
  81066. var radiusY = options.radiusY || radius;
  81067. var radiusZ = options.radiusZ || radius;
  81068. var t = (1 + Math.sqrt(5)) / 2;
  81069. // 12 vertex x,y,z
  81070. var ico_vertices = [
  81071. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  81072. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  81073. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  81074. ];
  81075. // index of 3 vertex makes a face of icopshere
  81076. var ico_indices = [
  81077. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  81078. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  81079. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  81080. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  81081. ];
  81082. // vertex for uv have aliased position, not for UV
  81083. var vertices_unalias_id = [
  81084. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  81085. // vertex alias
  81086. 0,
  81087. 2,
  81088. 3,
  81089. 3,
  81090. 3,
  81091. 4,
  81092. 7,
  81093. 8,
  81094. 9,
  81095. 9,
  81096. 10,
  81097. 11 // 23: B + 12
  81098. ];
  81099. // uv as integer step (not pixels !)
  81100. var ico_vertexuv = [
  81101. 5, 1, 3, 1, 6, 4, 0, 0,
  81102. 5, 3, 4, 2, 2, 2, 4, 0,
  81103. 2, 0, 1, 1, 6, 0, 6, 2,
  81104. // vertex alias (for same vertex on different faces)
  81105. 0, 4,
  81106. 3, 3,
  81107. 4, 4,
  81108. 3, 1,
  81109. 4, 2,
  81110. 4, 4,
  81111. 0, 2,
  81112. 1, 1,
  81113. 2, 2,
  81114. 3, 3,
  81115. 1, 3,
  81116. 2, 4 // 23: B + 12
  81117. ];
  81118. // Vertices[0, 1, ...9, A, B] : position on UV plane
  81119. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  81120. // First island of uv mapping
  81121. // v = 4h 3+ 2
  81122. // v = 3h 9+ 4
  81123. // v = 2h 9+ 5 B
  81124. // v = 1h 9 1 0
  81125. // v = 0h 3 8 7 A
  81126. // u = 0 1 2 3 4 5 6 *a
  81127. // Second island of uv mapping
  81128. // v = 4h 0+ B+ 4+
  81129. // v = 3h A+ 2+
  81130. // v = 2h 7+ 6 3+
  81131. // v = 1h 8+ 3+
  81132. // v = 0h
  81133. // u = 0 1 2 3 4 5 6 *a
  81134. // Face layout on texture UV mapping
  81135. // ============
  81136. // \ 4 /\ 16 / ======
  81137. // \ / \ / /\ 11 /
  81138. // \/ 7 \/ / \ /
  81139. // ======= / 10 \/
  81140. // /\ 17 /\ =======
  81141. // / \ / \ \ 15 /\
  81142. // / 8 \/ 12 \ \ / \
  81143. // ============ \/ 6 \
  81144. // \ 18 /\ ============
  81145. // \ / \ \ 5 /\ 0 /
  81146. // \/ 13 \ \ / \ /
  81147. // ======= \/ 1 \/
  81148. // =============
  81149. // /\ 19 /\ 2 /\
  81150. // / \ / \ / \
  81151. // / 14 \/ 9 \/ 3 \
  81152. // ===================
  81153. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  81154. var ustep = 138 / 1024;
  81155. var vstep = 239 / 1024;
  81156. var uoffset = 60 / 1024;
  81157. var voffset = 26 / 1024;
  81158. // Second island should have margin, not to touch the first island
  81159. // avoid any borderline artefact in pixel rounding
  81160. var island_u_offset = -40 / 1024;
  81161. var island_v_offset = +20 / 1024;
  81162. // face is either island 0 or 1 :
  81163. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  81164. var island = [
  81165. 0, 0, 0, 0, 1,
  81166. 0, 0, 1, 1, 0,
  81167. 0, 0, 1, 1, 0,
  81168. 0, 1, 1, 1, 0 // 15 - 19
  81169. ];
  81170. var indices = new Array();
  81171. var positions = new Array();
  81172. var normals = new Array();
  81173. var uvs = new Array();
  81174. var current_indice = 0;
  81175. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  81176. var face_vertex_pos = new Array(3);
  81177. var face_vertex_uv = new Array(3);
  81178. var v012;
  81179. for (v012 = 0; v012 < 3; v012++) {
  81180. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  81181. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  81182. }
  81183. // create all with normals
  81184. for (var face = 0; face < 20; face++) {
  81185. // 3 vertex per face
  81186. for (v012 = 0; v012 < 3; v012++) {
  81187. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  81188. var v_id = ico_indices[3 * face + v012];
  81189. // vertex have 3D position (x,y,z)
  81190. 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]);
  81191. // Normalize to get normal, then scale to radius
  81192. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  81193. // uv Coordinates from vertex ID
  81194. 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);
  81195. }
  81196. // Subdivide the face (interpolate pos, norm, uv)
  81197. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  81198. // - norm is linear interpolation of vertex corner normal
  81199. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  81200. // - uv is linear interpolation
  81201. //
  81202. // Topology is as below for sub-divide by 2
  81203. // vertex shown as v0,v1,v2
  81204. // interp index is i1 to progress in range [v0,v1[
  81205. // interp index is i2 to progress in range [v0,v2[
  81206. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  81207. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  81208. //
  81209. //
  81210. // i2 v2
  81211. // ^ ^
  81212. // / / \
  81213. // / / \
  81214. // / / \
  81215. // / / (0,1) \
  81216. // / #---------\
  81217. // / / \ (0,0)'/ \
  81218. // / / \ / \
  81219. // / / \ / \
  81220. // / / (0,0) \ / (1,0) \
  81221. // / #---------#---------\
  81222. // v0 v1
  81223. //
  81224. // --------------------> i1
  81225. //
  81226. // interp of (i1,i2):
  81227. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  81228. // along i1 : lerp(x0,x1, i1/(S-i2))
  81229. //
  81230. // centroid of triangle is needed to get help normal computation
  81231. // (c1,c2) are used for centroid location
  81232. var interp_vertex = function (i1, i2, c1, c2) {
  81233. // vertex is interpolated from
  81234. // - face_vertex_pos[0..2]
  81235. // - face_vertex_uv[0..2]
  81236. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  81237. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  81238. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  81239. pos_interp.normalize();
  81240. var vertex_normal;
  81241. if (flat) {
  81242. // in flat mode, recalculate normal as face centroid normal
  81243. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  81244. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  81245. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  81246. }
  81247. else {
  81248. // in smooth mode, recalculate normal from each single vertex position
  81249. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  81250. }
  81251. // Vertex normal need correction due to X,Y,Z radius scaling
  81252. vertex_normal.x /= radiusX;
  81253. vertex_normal.y /= radiusY;
  81254. vertex_normal.z /= radiusZ;
  81255. vertex_normal.normalize();
  81256. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  81257. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  81258. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  81259. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  81260. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  81261. uvs.push(uv_interp.x, uv_interp.y);
  81262. // push each vertex has member of a face
  81263. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  81264. indices.push(current_indice);
  81265. current_indice++;
  81266. };
  81267. for (var i2 = 0; i2 < subdivisions; i2++) {
  81268. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  81269. // face : (i1,i2) for /\ :
  81270. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  81271. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  81272. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  81273. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  81274. if (i1 + i2 + 1 < subdivisions) {
  81275. // face : (i1,i2)' for \/ :
  81276. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  81277. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  81278. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  81279. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  81280. }
  81281. }
  81282. }
  81283. }
  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"].CreateIcoSphere = function (name, options, scene) {
  81295. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  81296. };
  81297. /**
  81298. * Class containing static functions to help procedurally build meshes
  81299. */
  81300. var IcoSphereBuilder = /** @class */ (function () {
  81301. function IcoSphereBuilder() {
  81302. }
  81303. /**
  81304. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81305. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81306. * * 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`)
  81307. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81308. * * 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
  81309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81310. * * 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
  81311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81312. * @param name defines the name of the mesh
  81313. * @param options defines the options used to create the mesh
  81314. * @param scene defines the hosting scene
  81315. * @returns the icosahedron mesh
  81316. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81317. */
  81318. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  81319. if (scene === void 0) { scene = null; }
  81320. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  81321. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81322. sphere._originalBuilderSideOrientation = options.sideOrientation;
  81323. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  81324. vertexData.applyToMesh(sphere, options.updatable);
  81325. return sphere;
  81326. };
  81327. return IcoSphereBuilder;
  81328. }());
  81329. /***/ }),
  81330. /***/ "./Meshes/Builders/index.ts":
  81331. /*!**********************************!*\
  81332. !*** ./Meshes/Builders/index.ts ***!
  81333. \**********************************/
  81334. /*! exports provided: BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  81335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81336. "use strict";
  81337. __webpack_require__.r(__webpack_exports__);
  81338. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  81339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  81340. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  81341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  81342. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  81343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  81344. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  81345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  81346. /* harmony import */ var _hemisphereBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphereBuilder */ "./Meshes/Builders/hemisphereBuilder.ts");
  81347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _hemisphereBuilder__WEBPACK_IMPORTED_MODULE_4__["HemisphereBuilder"]; });
  81348. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  81349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__["CylinderBuilder"]; });
  81350. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  81351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusBuilder"]; });
  81352. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  81353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_7__["TorusKnotBuilder"]; });
  81354. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  81355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"]; });
  81356. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  81357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_9__["PolygonBuilder"]; });
  81358. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  81359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_10__["ShapeBuilder"]; });
  81360. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  81361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_11__["LatheBuilder"]; });
  81362. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  81363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_12__["PlaneBuilder"]; });
  81364. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  81365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_13__["GroundBuilder"]; });
  81366. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  81367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_14__["TubeBuilder"]; });
  81368. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  81369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_15__["PolyhedronBuilder"]; });
  81370. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  81371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_16__["IcoSphereBuilder"]; });
  81372. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  81373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_17__["DecalBuilder"]; });
  81374. /***/ }),
  81375. /***/ "./Meshes/Builders/latheBuilder.ts":
  81376. /*!*****************************************!*\
  81377. !*** ./Meshes/Builders/latheBuilder.ts ***!
  81378. \*****************************************/
  81379. /*! exports provided: LatheBuilder */
  81380. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81381. "use strict";
  81382. __webpack_require__.r(__webpack_exports__);
  81383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  81384. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81385. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81386. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  81387. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  81388. var options = {
  81389. shape: shape,
  81390. radius: radius,
  81391. tessellation: tessellation,
  81392. sideOrientation: sideOrientation,
  81393. updatable: updatable
  81394. };
  81395. return LatheBuilder.CreateLathe(name, options, scene);
  81396. };
  81397. /**
  81398. * Class containing static functions to help procedurally build meshes
  81399. */
  81400. var LatheBuilder = /** @class */ (function () {
  81401. function LatheBuilder() {
  81402. }
  81403. /**
  81404. * Creates lathe mesh.
  81405. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  81406. * * 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
  81407. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  81408. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  81409. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  81410. * * 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
  81411. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  81412. * * 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
  81413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81414. * * 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
  81415. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  81416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81417. * @param name defines the name of the mesh
  81418. * @param options defines the options used to create the mesh
  81419. * @param scene defines the hosting scene
  81420. * @returns the lathe mesh
  81421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  81422. */
  81423. LatheBuilder.CreateLathe = function (name, options, scene) {
  81424. if (scene === void 0) { scene = null; }
  81425. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  81426. var closed = (options.closed === undefined) ? true : options.closed;
  81427. var shape = options.shape;
  81428. var radius = options.radius || 1;
  81429. var tessellation = options.tessellation || 64;
  81430. var clip = options.clip || 0;
  81431. var updatable = options.updatable;
  81432. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81433. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  81434. var pi2 = Math.PI * 2;
  81435. var paths = new Array();
  81436. var invertUV = options.invertUV || false;
  81437. var i = 0;
  81438. var p = 0;
  81439. var step = pi2 / tessellation * arc;
  81440. var rotated;
  81441. var path = new Array();
  81442. for (i = 0; i <= tessellation - clip; i++) {
  81443. var path = [];
  81444. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  81445. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  81446. 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));
  81447. }
  81448. for (p = 0; p < shape.length; p++) {
  81449. 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);
  81450. path.push(rotated);
  81451. }
  81452. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  81453. 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));
  81454. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  81455. }
  81456. paths.push(path);
  81457. }
  81458. // lathe ribbon
  81459. 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);
  81460. return lathe;
  81461. };
  81462. return LatheBuilder;
  81463. }());
  81464. /***/ }),
  81465. /***/ "./Meshes/Builders/linesBuilder.ts":
  81466. /*!*****************************************!*\
  81467. !*** ./Meshes/Builders/linesBuilder.ts ***!
  81468. \*****************************************/
  81469. /*! exports provided: LinesBuilder */
  81470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81471. "use strict";
  81472. __webpack_require__.r(__webpack_exports__);
  81473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  81474. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81475. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81476. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81477. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  81478. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  81479. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  81480. var indices = [];
  81481. var positions = [];
  81482. var lines = options.lines;
  81483. var colors = options.colors;
  81484. var vertexColors = [];
  81485. var idx = 0;
  81486. for (var l = 0; l < lines.length; l++) {
  81487. var points = lines[l];
  81488. for (var index = 0; index < points.length; index++) {
  81489. positions.push(points[index].x, points[index].y, points[index].z);
  81490. if (colors) {
  81491. var color = colors[l];
  81492. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  81493. }
  81494. if (index > 0) {
  81495. indices.push(idx - 1);
  81496. indices.push(idx);
  81497. }
  81498. idx++;
  81499. }
  81500. }
  81501. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81502. vertexData.indices = indices;
  81503. vertexData.positions = positions;
  81504. if (colors) {
  81505. vertexData.colors = vertexColors;
  81506. }
  81507. return vertexData;
  81508. };
  81509. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  81510. var dashSize = options.dashSize || 3;
  81511. var gapSize = options.gapSize || 1;
  81512. var dashNb = options.dashNb || 200;
  81513. var points = options.points;
  81514. var positions = new Array();
  81515. var indices = new Array();
  81516. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  81517. var lg = 0;
  81518. var nb = 0;
  81519. var shft = 0;
  81520. var dashshft = 0;
  81521. var curshft = 0;
  81522. var idx = 0;
  81523. var i = 0;
  81524. for (i = 0; i < points.length - 1; i++) {
  81525. points[i + 1].subtractToRef(points[i], curvect);
  81526. lg += curvect.length();
  81527. }
  81528. shft = lg / dashNb;
  81529. dashshft = dashSize * shft / (dashSize + gapSize);
  81530. for (i = 0; i < points.length - 1; i++) {
  81531. points[i + 1].subtractToRef(points[i], curvect);
  81532. nb = Math.floor(curvect.length() / shft);
  81533. curvect.normalize();
  81534. for (var j = 0; j < nb; j++) {
  81535. curshft = shft * j;
  81536. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  81537. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  81538. indices.push(idx, idx + 1);
  81539. idx += 2;
  81540. }
  81541. }
  81542. // Result
  81543. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81544. vertexData.positions = positions;
  81545. vertexData.indices = indices;
  81546. return vertexData;
  81547. };
  81548. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  81549. if (scene === void 0) { scene = null; }
  81550. if (updatable === void 0) { updatable = false; }
  81551. if (instance === void 0) { instance = null; }
  81552. var options = {
  81553. points: points,
  81554. updatable: updatable,
  81555. instance: instance
  81556. };
  81557. return LinesBuilder.CreateLines(name, options, scene);
  81558. };
  81559. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  81560. if (scene === void 0) { scene = null; }
  81561. var options = {
  81562. points: points,
  81563. dashSize: dashSize,
  81564. gapSize: gapSize,
  81565. dashNb: dashNb,
  81566. updatable: updatable,
  81567. instance: instance
  81568. };
  81569. return LinesBuilder.CreateDashedLines(name, options, scene);
  81570. };
  81571. /**
  81572. * Class containing static functions to help procedurally build meshes
  81573. */
  81574. var LinesBuilder = /** @class */ (function () {
  81575. function LinesBuilder() {
  81576. }
  81577. /**
  81578. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  81579. * * 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
  81580. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  81581. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  81582. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  81583. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  81584. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  81585. * * 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
  81586. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  81587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  81589. * @param name defines the name of the new line system
  81590. * @param options defines the options used to create the line system
  81591. * @param scene defines the hosting scene
  81592. * @returns a new line system mesh
  81593. */
  81594. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  81595. var instance = options.instance;
  81596. var lines = options.lines;
  81597. var colors = options.colors;
  81598. if (instance) { // lines update
  81599. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  81600. var vertexColor;
  81601. var lineColors;
  81602. if (colors) {
  81603. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  81604. }
  81605. var i = 0;
  81606. var c = 0;
  81607. for (var l = 0; l < lines.length; l++) {
  81608. var points = lines[l];
  81609. for (var p = 0; p < points.length; p++) {
  81610. positions[i] = points[p].x;
  81611. positions[i + 1] = points[p].y;
  81612. positions[i + 2] = points[p].z;
  81613. if (colors && vertexColor) {
  81614. lineColors = colors[l];
  81615. vertexColor[c] = lineColors[p].r;
  81616. vertexColor[c + 1] = lineColors[p].g;
  81617. vertexColor[c + 2] = lineColors[p].b;
  81618. vertexColor[c + 3] = lineColors[p].a;
  81619. c += 4;
  81620. }
  81621. i += 3;
  81622. }
  81623. }
  81624. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  81625. if (colors && vertexColor) {
  81626. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  81627. }
  81628. return instance;
  81629. }
  81630. // line system creation
  81631. var useVertexColor = (colors) ? true : false;
  81632. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  81633. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  81634. vertexData.applyToMesh(lineSystem, options.updatable);
  81635. return lineSystem;
  81636. };
  81637. /**
  81638. * Creates a line mesh
  81639. * 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
  81640. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  81641. * * The parameter `points` is an array successive Vector3
  81642. * * 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
  81643. * * The optional parameter `colors` is an array of successive Color4, one per line point
  81644. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  81645. * * When updating an instance, remember that only point positions can change, not the number of points
  81646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  81648. * @param name defines the name of the new line system
  81649. * @param options defines the options used to create the line system
  81650. * @param scene defines the hosting scene
  81651. * @returns a new line mesh
  81652. */
  81653. LinesBuilder.CreateLines = function (name, options, scene) {
  81654. if (scene === void 0) { scene = null; }
  81655. var colors = (options.colors) ? [options.colors] : null;
  81656. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  81657. return lines;
  81658. };
  81659. /**
  81660. * Creates a dashed line mesh
  81661. * * 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
  81662. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  81663. * * The parameter `points` is an array successive Vector3
  81664. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  81665. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  81666. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81667. * * 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
  81668. * * When updating an instance, remember that only point positions can change, not the number of points
  81669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81670. * @param name defines the name of the mesh
  81671. * @param options defines the options used to create the mesh
  81672. * @param scene defines the hosting scene
  81673. * @returns the dashed line mesh
  81674. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  81675. */
  81676. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  81677. if (scene === void 0) { scene = null; }
  81678. var points = options.points;
  81679. var instance = options.instance;
  81680. var gapSize = options.gapSize || 1;
  81681. var dashSize = options.dashSize || 3;
  81682. if (instance) { // dashed lines update
  81683. var positionFunction = function (positions) {
  81684. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  81685. var nbSeg = positions.length / 6;
  81686. var lg = 0;
  81687. var nb = 0;
  81688. var shft = 0;
  81689. var dashshft = 0;
  81690. var curshft = 0;
  81691. var p = 0;
  81692. var i = 0;
  81693. var j = 0;
  81694. for (i = 0; i < points.length - 1; i++) {
  81695. points[i + 1].subtractToRef(points[i], curvect);
  81696. lg += curvect.length();
  81697. }
  81698. shft = lg / nbSeg;
  81699. var dashSize = instance._creationDataStorage.dashSize;
  81700. var gapSize = instance._creationDataStorage.gapSize;
  81701. dashshft = dashSize * shft / (dashSize + gapSize);
  81702. for (i = 0; i < points.length - 1; i++) {
  81703. points[i + 1].subtractToRef(points[i], curvect);
  81704. nb = Math.floor(curvect.length() / shft);
  81705. curvect.normalize();
  81706. j = 0;
  81707. while (j < nb && p < positions.length) {
  81708. curshft = shft * j;
  81709. positions[p] = points[i].x + curshft * curvect.x;
  81710. positions[p + 1] = points[i].y + curshft * curvect.y;
  81711. positions[p + 2] = points[i].z + curshft * curvect.z;
  81712. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  81713. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  81714. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  81715. p += 6;
  81716. j++;
  81717. }
  81718. }
  81719. while (p < positions.length) {
  81720. positions[p] = points[i].x;
  81721. positions[p + 1] = points[i].y;
  81722. positions[p + 2] = points[i].z;
  81723. p += 3;
  81724. }
  81725. };
  81726. instance.updateMeshPositions(positionFunction, false);
  81727. return instance;
  81728. }
  81729. // dashed lines creation
  81730. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  81731. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  81732. vertexData.applyToMesh(dashedLines, options.updatable);
  81733. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  81734. dashedLines._creationDataStorage.dashSize = dashSize;
  81735. dashedLines._creationDataStorage.gapSize = gapSize;
  81736. return dashedLines;
  81737. };
  81738. return LinesBuilder;
  81739. }());
  81740. /***/ }),
  81741. /***/ "./Meshes/Builders/planeBuilder.ts":
  81742. /*!*****************************************!*\
  81743. !*** ./Meshes/Builders/planeBuilder.ts ***!
  81744. \*****************************************/
  81745. /*! exports provided: PlaneBuilder */
  81746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81747. "use strict";
  81748. __webpack_require__.r(__webpack_exports__);
  81749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  81750. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81751. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81752. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  81753. var indices = [];
  81754. var positions = [];
  81755. var normals = [];
  81756. var uvs = [];
  81757. var width = options.width || options.size || 1;
  81758. var height = options.height || options.size || 1;
  81759. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  81760. // Vertices
  81761. var halfWidth = width / 2.0;
  81762. var halfHeight = height / 2.0;
  81763. positions.push(-halfWidth, -halfHeight, 0);
  81764. normals.push(0, 0, -1.0);
  81765. uvs.push(0.0, 0.0);
  81766. positions.push(halfWidth, -halfHeight, 0);
  81767. normals.push(0, 0, -1.0);
  81768. uvs.push(1.0, 0.0);
  81769. positions.push(halfWidth, halfHeight, 0);
  81770. normals.push(0, 0, -1.0);
  81771. uvs.push(1.0, 1.0);
  81772. positions.push(-halfWidth, halfHeight, 0);
  81773. normals.push(0, 0, -1.0);
  81774. uvs.push(0.0, 1.0);
  81775. // Indices
  81776. indices.push(0);
  81777. indices.push(1);
  81778. indices.push(2);
  81779. indices.push(0);
  81780. indices.push(2);
  81781. indices.push(3);
  81782. // Sides
  81783. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  81784. // Result
  81785. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  81786. vertexData.indices = indices;
  81787. vertexData.positions = positions;
  81788. vertexData.normals = normals;
  81789. vertexData.uvs = uvs;
  81790. return vertexData;
  81791. };
  81792. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  81793. var options = {
  81794. size: size,
  81795. width: size,
  81796. height: size,
  81797. sideOrientation: sideOrientation,
  81798. updatable: updatable
  81799. };
  81800. return PlaneBuilder.CreatePlane(name, options, scene);
  81801. };
  81802. /**
  81803. * Class containing static functions to help procedurally build meshes
  81804. */
  81805. var PlaneBuilder = /** @class */ (function () {
  81806. function PlaneBuilder() {
  81807. }
  81808. /**
  81809. * Creates a plane mesh
  81810. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  81811. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  81812. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  81813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81814. * * 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
  81815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81816. * @param name defines the name of the mesh
  81817. * @param options defines the options used to create the mesh
  81818. * @param scene defines the hosting scene
  81819. * @returns the plane mesh
  81820. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  81821. */
  81822. PlaneBuilder.CreatePlane = function (name, options, scene) {
  81823. if (scene === void 0) { scene = null; }
  81824. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  81825. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81826. plane._originalBuilderSideOrientation = options.sideOrientation;
  81827. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  81828. vertexData.applyToMesh(plane, options.updatable);
  81829. if (options.sourcePlane) {
  81830. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  81831. plane.setDirection(options.sourcePlane.normal.scale(-1));
  81832. }
  81833. return plane;
  81834. };
  81835. return PlaneBuilder;
  81836. }());
  81837. /***/ }),
  81838. /***/ "./Meshes/Builders/polygonBuilder.ts":
  81839. /*!*******************************************!*\
  81840. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  81841. \*******************************************/
  81842. /*! exports provided: PolygonBuilder */
  81843. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81844. "use strict";
  81845. __webpack_require__.r(__webpack_exports__);
  81846. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  81847. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81848. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81849. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81850. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  81851. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  81852. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  81853. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  81854. var faceUV = fUV || new Array(3);
  81855. var faceColors = fColors;
  81856. var colors = [];
  81857. // default face colors and UV if undefined
  81858. for (var f = 0; f < 3; f++) {
  81859. if (faceUV[f] === undefined) {
  81860. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  81861. }
  81862. if (faceColors && faceColors[f] === undefined) {
  81863. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  81864. }
  81865. }
  81866. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  81867. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  81868. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  81869. var indices = polygon.getIndices();
  81870. // set face colours and textures
  81871. var idx = 0;
  81872. var face = 0;
  81873. for (var index = 0; index < normals.length; index += 3) {
  81874. //Edge Face no. 1
  81875. if (Math.abs(normals[index + 1]) < 0.001) {
  81876. face = 1;
  81877. }
  81878. //Top Face no. 0
  81879. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  81880. face = 0;
  81881. }
  81882. //Bottom Face no. 2
  81883. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  81884. face = 2;
  81885. }
  81886. idx = index / 3;
  81887. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  81888. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  81889. if (faceColors) {
  81890. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  81891. }
  81892. }
  81893. // sides
  81894. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  81895. // Result
  81896. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81897. vertexData.indices = indices;
  81898. vertexData.positions = positions;
  81899. vertexData.normals = normals;
  81900. vertexData.uvs = uvs;
  81901. if (faceColors) {
  81902. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  81903. vertexData.colors = totalColors;
  81904. }
  81905. return vertexData;
  81906. };
  81907. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  81908. if (earcutInjection === void 0) { earcutInjection = earcut; }
  81909. var options = {
  81910. shape: shape,
  81911. holes: holes,
  81912. updatable: updatable,
  81913. sideOrientation: sideOrientation
  81914. };
  81915. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  81916. };
  81917. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  81918. if (earcutInjection === void 0) { earcutInjection = earcut; }
  81919. var options = {
  81920. shape: shape,
  81921. holes: holes,
  81922. depth: depth,
  81923. updatable: updatable,
  81924. sideOrientation: sideOrientation
  81925. };
  81926. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  81927. };
  81928. /**
  81929. * Class containing static functions to help procedurally build meshes
  81930. */
  81931. var PolygonBuilder = /** @class */ (function () {
  81932. function PolygonBuilder() {
  81933. }
  81934. /**
  81935. * Creates a polygon mesh
  81936. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  81937. * * 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
  81938. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81940. * * 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)
  81941. * * Remember you can only change the shape positions, not their number when updating a polygon
  81942. * @param name defines the name of the mesh
  81943. * @param options defines the options used to create the mesh
  81944. * @param scene defines the hosting scene
  81945. * @param earcutInjection can be used to inject your own earcut reference
  81946. * @returns the polygon mesh
  81947. */
  81948. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  81949. if (scene === void 0) { scene = null; }
  81950. if (earcutInjection === void 0) { earcutInjection = earcut; }
  81951. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81952. var shape = options.shape;
  81953. var holes = options.holes || [];
  81954. var depth = options.depth || 0;
  81955. var contours = [];
  81956. var hole = [];
  81957. for (var i = 0; i < shape.length; i++) {
  81958. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  81959. }
  81960. var epsilon = 0.00000001;
  81961. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  81962. contours.pop();
  81963. }
  81964. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene, earcutInjection);
  81965. for (var hNb = 0; hNb < holes.length; hNb++) {
  81966. hole = [];
  81967. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  81968. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  81969. }
  81970. polygonTriangulation.addHole(hole);
  81971. }
  81972. var polygon = polygonTriangulation.build(options.updatable, depth);
  81973. polygon._originalBuilderSideOrientation = options.sideOrientation;
  81974. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  81975. vertexData.applyToMesh(polygon, options.updatable);
  81976. return polygon;
  81977. };
  81978. /**
  81979. * Creates an extruded polygon mesh, with depth in the Y direction.
  81980. * * 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)
  81981. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  81982. * @param name defines the name of the mesh
  81983. * @param options defines the options used to create the mesh
  81984. * @param scene defines the hosting scene
  81985. * @param earcutInjection can be used to inject your own earcut reference
  81986. * @returns the polygon mesh
  81987. */
  81988. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  81989. if (scene === void 0) { scene = null; }
  81990. if (earcutInjection === void 0) { earcutInjection = earcut; }
  81991. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  81992. };
  81993. return PolygonBuilder;
  81994. }());
  81995. /***/ }),
  81996. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  81997. /*!**********************************************!*\
  81998. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  81999. \**********************************************/
  82000. /*! exports provided: PolyhedronBuilder */
  82001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82002. "use strict";
  82003. __webpack_require__.r(__webpack_exports__);
  82004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  82005. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  82006. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  82007. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  82008. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  82009. // provided polyhedron types :
  82010. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  82011. // 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)
  82012. var polyhedra = [];
  82013. 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]] };
  82014. 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]] };
  82015. polyhedra[2] = {
  82016. 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]],
  82017. 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]]
  82018. };
  82019. polyhedra[3] = {
  82020. 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]],
  82021. 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]]
  82022. };
  82023. polyhedra[4] = {
  82024. 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]],
  82025. 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]]
  82026. };
  82027. 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]] };
  82028. 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]] };
  82029. 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]] };
  82030. 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]] };
  82031. 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]] };
  82032. 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]] };
  82033. 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]] };
  82034. 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]] };
  82035. 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]] };
  82036. polyhedra[14] = {
  82037. 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]],
  82038. 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]]
  82039. };
  82040. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  82041. var size = options.size;
  82042. var sizeX = options.sizeX || size || 1;
  82043. var sizeY = options.sizeY || size || 1;
  82044. var sizeZ = options.sizeZ || size || 1;
  82045. var data = options.custom || polyhedra[type];
  82046. var nbfaces = data.face.length;
  82047. var faceUV = options.faceUV || new Array(nbfaces);
  82048. var faceColors = options.faceColors;
  82049. var flat = (options.flat === undefined) ? true : options.flat;
  82050. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  82051. var positions = new Array();
  82052. var indices = new Array();
  82053. var normals = new Array();
  82054. var uvs = new Array();
  82055. var colors = new Array();
  82056. var index = 0;
  82057. var faceIdx = 0; // face cursor in the array "indexes"
  82058. var indexes = new Array();
  82059. var i = 0;
  82060. var f = 0;
  82061. var u, v, ang, x, y, tmp;
  82062. // default face colors and UV if undefined
  82063. if (flat) {
  82064. for (f = 0; f < nbfaces; f++) {
  82065. if (faceColors && faceColors[f] === undefined) {
  82066. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  82067. }
  82068. if (faceUV && faceUV[f] === undefined) {
  82069. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  82070. }
  82071. }
  82072. }
  82073. if (!flat) {
  82074. for (i = 0; i < data.vertex.length; i++) {
  82075. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  82076. uvs.push(0, 0);
  82077. }
  82078. for (f = 0; f < nbfaces; f++) {
  82079. for (i = 0; i < data.face[f].length - 2; i++) {
  82080. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  82081. }
  82082. }
  82083. }
  82084. else {
  82085. for (f = 0; f < nbfaces; f++) {
  82086. var fl = data.face[f].length; // number of vertices of the current face
  82087. ang = 2 * Math.PI / fl;
  82088. x = 0.5 * Math.tan(ang / 2);
  82089. y = 0.5;
  82090. // positions, uvs, colors
  82091. for (i = 0; i < fl; i++) {
  82092. // positions
  82093. 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);
  82094. indexes.push(index);
  82095. index++;
  82096. // uvs
  82097. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  82098. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  82099. uvs.push(u, v);
  82100. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  82101. y = x * Math.sin(ang) + y * Math.cos(ang);
  82102. x = tmp;
  82103. // colors
  82104. if (faceColors) {
  82105. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  82106. }
  82107. }
  82108. // indices from indexes
  82109. for (i = 0; i < fl - 2; i++) {
  82110. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  82111. }
  82112. faceIdx += fl;
  82113. }
  82114. }
  82115. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  82116. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  82117. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  82118. vertexData.positions = positions;
  82119. vertexData.indices = indices;
  82120. vertexData.normals = normals;
  82121. vertexData.uvs = uvs;
  82122. if (faceColors && flat) {
  82123. vertexData.colors = colors;
  82124. }
  82125. return vertexData;
  82126. };
  82127. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  82128. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  82129. };
  82130. /**
  82131. * Class containing static functions to help procedurally build meshes
  82132. */
  82133. var PolyhedronBuilder = /** @class */ (function () {
  82134. function PolyhedronBuilder() {
  82135. }
  82136. /**
  82137. * Creates a polyhedron mesh
  82138. * * 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
  82139. * * The parameter `size` (positive float, default 1) sets the polygon size
  82140. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  82141. * * 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`
  82142. * * 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
  82143. * * 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)`)
  82144. * * 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
  82145. * * 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
  82146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82147. * * 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
  82148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82149. * @param name defines the name of the mesh
  82150. * @param options defines the options used to create the mesh
  82151. * @param scene defines the hosting scene
  82152. * @returns the polyhedron mesh
  82153. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  82154. */
  82155. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  82156. if (scene === void 0) { scene = null; }
  82157. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  82158. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  82159. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  82160. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  82161. vertexData.applyToMesh(polyhedron, options.updatable);
  82162. return polyhedron;
  82163. };
  82164. return PolyhedronBuilder;
  82165. }());
  82166. /***/ }),
  82167. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  82168. /*!******************************************!*\
  82169. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  82170. \******************************************/
  82171. /*! exports provided: RibbonBuilder */
  82172. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82173. "use strict";
  82174. __webpack_require__.r(__webpack_exports__);
  82175. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  82176. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  82177. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  82178. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  82179. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  82180. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  82181. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  82182. var pathArray = options.pathArray;
  82183. var closeArray = options.closeArray || false;
  82184. var closePath = options.closePath || false;
  82185. var invertUV = options.invertUV || false;
  82186. var defaultOffset = Math.floor(pathArray[0].length / 2);
  82187. var offset = options.offset || defaultOffset;
  82188. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  82189. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  82190. var customUV = options.uvs;
  82191. var customColors = options.colors;
  82192. var positions = [];
  82193. var indices = [];
  82194. var normals = [];
  82195. var uvs = [];
  82196. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  82197. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  82198. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  82199. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  82200. var minlg; // minimal length among all paths from pathArray
  82201. var lg = []; // array of path lengths : nb of vertex per path
  82202. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  82203. var p; // path iterator
  82204. var i; // point iterator
  82205. var j; // point iterator
  82206. // if single path in pathArray
  82207. if (pathArray.length < 2) {
  82208. var ar1 = [];
  82209. var ar2 = [];
  82210. for (i = 0; i < pathArray[0].length - offset; i++) {
  82211. ar1.push(pathArray[0][i]);
  82212. ar2.push(pathArray[0][i + offset]);
  82213. }
  82214. pathArray = [ar1, ar2];
  82215. }
  82216. // positions and horizontal distances (u)
  82217. var idc = 0;
  82218. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  82219. var path;
  82220. var l;
  82221. minlg = pathArray[0].length;
  82222. var vectlg;
  82223. var dist;
  82224. for (p = 0; p < pathArray.length; p++) {
  82225. uTotalDistance[p] = 0;
  82226. us[p] = [0];
  82227. path = pathArray[p];
  82228. l = path.length;
  82229. minlg = (minlg < l) ? minlg : l;
  82230. j = 0;
  82231. while (j < l) {
  82232. positions.push(path[j].x, path[j].y, path[j].z);
  82233. if (j > 0) {
  82234. vectlg = path[j].subtract(path[j - 1]).length();
  82235. dist = vectlg + uTotalDistance[p];
  82236. us[p].push(dist);
  82237. uTotalDistance[p] = dist;
  82238. }
  82239. j++;
  82240. }
  82241. if (closePath) { // an extra hidden vertex is added in the "positions" array
  82242. j--;
  82243. positions.push(path[0].x, path[0].y, path[0].z);
  82244. vectlg = path[j].subtract(path[0]).length();
  82245. dist = vectlg + uTotalDistance[p];
  82246. us[p].push(dist);
  82247. uTotalDistance[p] = dist;
  82248. }
  82249. lg[p] = l + closePathCorr;
  82250. idx[p] = idc;
  82251. idc += (l + closePathCorr);
  82252. }
  82253. // vertical distances (v)
  82254. var path1;
  82255. var path2;
  82256. var vertex1 = null;
  82257. var vertex2 = null;
  82258. for (i = 0; i < minlg + closePathCorr; i++) {
  82259. vTotalDistance[i] = 0;
  82260. vs[i] = [0];
  82261. for (p = 0; p < pathArray.length - 1; p++) {
  82262. path1 = pathArray[p];
  82263. path2 = pathArray[p + 1];
  82264. if (i === minlg) { // closePath
  82265. vertex1 = path1[0];
  82266. vertex2 = path2[0];
  82267. }
  82268. else {
  82269. vertex1 = path1[i];
  82270. vertex2 = path2[i];
  82271. }
  82272. vectlg = vertex2.subtract(vertex1).length();
  82273. dist = vectlg + vTotalDistance[i];
  82274. vs[i].push(dist);
  82275. vTotalDistance[i] = dist;
  82276. }
  82277. if (closeArray && vertex2 && vertex1) {
  82278. path1 = pathArray[p];
  82279. path2 = pathArray[0];
  82280. if (i === minlg) { // closePath
  82281. vertex2 = path2[0];
  82282. }
  82283. vectlg = vertex2.subtract(vertex1).length();
  82284. dist = vectlg + vTotalDistance[i];
  82285. vTotalDistance[i] = dist;
  82286. }
  82287. }
  82288. // uvs
  82289. var u;
  82290. var v;
  82291. if (customUV) {
  82292. for (p = 0; p < customUV.length; p++) {
  82293. uvs.push(customUV[p].x, customUV[p].y);
  82294. }
  82295. }
  82296. else {
  82297. for (p = 0; p < pathArray.length; p++) {
  82298. for (i = 0; i < minlg + closePathCorr; i++) {
  82299. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  82300. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  82301. if (invertUV) {
  82302. uvs.push(v, u);
  82303. }
  82304. else {
  82305. uvs.push(u, v);
  82306. }
  82307. }
  82308. }
  82309. }
  82310. // indices
  82311. p = 0; // path index
  82312. var pi = 0; // positions array index
  82313. var l1 = lg[p] - 1; // path1 length
  82314. var l2 = lg[p + 1] - 1; // path2 length
  82315. var min = (l1 < l2) ? l1 : l2; // current path stop index
  82316. var shft = idx[1] - idx[0]; // shift
  82317. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  82318. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  82319. // 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
  82320. indices.push(pi, pi + shft, pi + 1);
  82321. indices.push(pi + shft + 1, pi + 1, pi + shft);
  82322. pi += 1;
  82323. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  82324. p++;
  82325. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  82326. shft = idx[0] - idx[p];
  82327. l1 = lg[p] - 1;
  82328. l2 = lg[0] - 1;
  82329. }
  82330. else {
  82331. shft = idx[p + 1] - idx[p];
  82332. l1 = lg[p] - 1;
  82333. l2 = lg[p + 1] - 1;
  82334. }
  82335. pi = idx[p];
  82336. min = (l1 < l2) ? l1 + pi : l2 + pi;
  82337. }
  82338. }
  82339. // normals
  82340. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  82341. if (closePath) { // update both the first and last vertex normals to their average value
  82342. var indexFirst = 0;
  82343. var indexLast = 0;
  82344. for (p = 0; p < pathArray.length; p++) {
  82345. indexFirst = idx[p] * 3;
  82346. if (p + 1 < pathArray.length) {
  82347. indexLast = (idx[p + 1] - 1) * 3;
  82348. }
  82349. else {
  82350. indexLast = normals.length - 3;
  82351. }
  82352. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  82353. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  82354. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  82355. normals[indexLast] = normals[indexFirst];
  82356. normals[indexLast + 1] = normals[indexFirst + 1];
  82357. normals[indexLast + 2] = normals[indexFirst + 2];
  82358. }
  82359. }
  82360. // sides
  82361. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  82362. // Colors
  82363. var colors = null;
  82364. if (customColors) {
  82365. colors = new Float32Array(customColors.length * 4);
  82366. for (var c = 0; c < customColors.length; c++) {
  82367. colors[c * 4] = customColors[c].r;
  82368. colors[c * 4 + 1] = customColors[c].g;
  82369. colors[c * 4 + 2] = customColors[c].b;
  82370. colors[c * 4 + 3] = customColors[c].a;
  82371. }
  82372. }
  82373. // Result
  82374. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  82375. var positions32 = new Float32Array(positions);
  82376. var normals32 = new Float32Array(normals);
  82377. var uvs32 = new Float32Array(uvs);
  82378. vertexData.indices = indices;
  82379. vertexData.positions = positions32;
  82380. vertexData.normals = normals32;
  82381. vertexData.uvs = uvs32;
  82382. if (colors) {
  82383. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  82384. }
  82385. if (closePath) {
  82386. vertexData._idx = idx;
  82387. }
  82388. return vertexData;
  82389. };
  82390. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  82391. if (closeArray === void 0) { closeArray = false; }
  82392. if (updatable === void 0) { updatable = false; }
  82393. return RibbonBuilder.CreateRibbon(name, {
  82394. pathArray: pathArray,
  82395. closeArray: closeArray,
  82396. closePath: closePath,
  82397. offset: offset,
  82398. updatable: updatable,
  82399. sideOrientation: sideOrientation,
  82400. instance: instance
  82401. }, scene);
  82402. };
  82403. /**
  82404. * Class containing static functions to help procedurally build meshes
  82405. */
  82406. var RibbonBuilder = /** @class */ (function () {
  82407. function RibbonBuilder() {
  82408. }
  82409. /**
  82410. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  82411. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  82412. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  82413. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  82414. * * 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
  82415. * * 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
  82416. * * 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
  82417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82418. * * 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
  82419. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  82420. * * 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
  82421. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  82422. * * 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
  82423. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  82424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82425. * @param name defines the name of the mesh
  82426. * @param options defines the options used to create the mesh
  82427. * @param scene defines the hosting scene
  82428. * @returns the ribbon mesh
  82429. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  82430. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  82431. */
  82432. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  82433. if (scene === void 0) { scene = null; }
  82434. var pathArray = options.pathArray;
  82435. var closeArray = options.closeArray;
  82436. var closePath = options.closePath;
  82437. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  82438. var instance = options.instance;
  82439. var updatable = options.updatable;
  82440. if (instance) { // existing ribbon instance update
  82441. // positionFunction : ribbon case
  82442. // only pathArray and sideOrientation parameters are taken into account for positions update
  82443. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  82444. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  82445. var positionFunction = function (positions) {
  82446. var minlg = pathArray[0].length;
  82447. var mesh = instance;
  82448. var i = 0;
  82449. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  82450. for (var si = 1; si <= ns; ++si) {
  82451. for (var p = 0; p < pathArray.length; ++p) {
  82452. var path = pathArray[p];
  82453. var l = path.length;
  82454. minlg = (minlg < l) ? minlg : l;
  82455. for (var j = 0; j < minlg; ++j) {
  82456. var pathPoint = path[j];
  82457. positions[i] = pathPoint.x;
  82458. positions[i + 1] = pathPoint.y;
  82459. positions[i + 2] = pathPoint.z;
  82460. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  82461. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  82462. i += 3;
  82463. }
  82464. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  82465. var pathPoint = path[0];
  82466. positions[i] = pathPoint.x;
  82467. positions[i + 1] = pathPoint.y;
  82468. positions[i + 2] = pathPoint.z;
  82469. i += 3;
  82470. }
  82471. }
  82472. }
  82473. };
  82474. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82475. positionFunction(positions);
  82476. if (instance._boundingInfo) {
  82477. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  82478. }
  82479. else {
  82480. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  82481. }
  82482. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  82483. if (options.colors) {
  82484. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  82485. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  82486. var color = options.colors[c];
  82487. colors[colorIndex] = color.r;
  82488. colors[colorIndex + 1] = color.g;
  82489. colors[colorIndex + 2] = color.b;
  82490. colors[colorIndex + 3] = color.a;
  82491. }
  82492. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  82493. }
  82494. if (options.uvs) {
  82495. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  82496. for (var i = 0; i < options.uvs.length; i++) {
  82497. uvs[i * 2] = options.uvs[i].x;
  82498. uvs[i * 2 + 1] = options.uvs[i].y;
  82499. }
  82500. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  82501. }
  82502. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  82503. var indices = instance.getIndices();
  82504. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  82505. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  82506. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  82507. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  82508. var indexFirst = 0;
  82509. var indexLast = 0;
  82510. for (var p = 0; p < pathArray.length; p++) {
  82511. indexFirst = instance._creationDataStorage.idx[p] * 3;
  82512. if (p + 1 < pathArray.length) {
  82513. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  82514. }
  82515. else {
  82516. indexLast = normals.length - 3;
  82517. }
  82518. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  82519. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  82520. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  82521. normals[indexLast] = normals[indexFirst];
  82522. normals[indexLast + 1] = normals[indexFirst + 1];
  82523. normals[indexLast + 2] = normals[indexFirst + 2];
  82524. }
  82525. }
  82526. if (!(instance.areNormalsFrozen)) {
  82527. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  82528. }
  82529. }
  82530. return instance;
  82531. }
  82532. else { // new ribbon creation
  82533. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  82534. ribbon._originalBuilderSideOrientation = sideOrientation;
  82535. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  82536. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  82537. if (closePath) {
  82538. ribbon._creationDataStorage.idx = vertexData._idx;
  82539. }
  82540. ribbon._creationDataStorage.closePath = closePath;
  82541. ribbon._creationDataStorage.closeArray = closeArray;
  82542. vertexData.applyToMesh(ribbon, updatable);
  82543. return ribbon;
  82544. }
  82545. };
  82546. return RibbonBuilder;
  82547. }());
  82548. /***/ }),
  82549. /***/ "./Meshes/Builders/shapeBuilder.ts":
  82550. /*!*****************************************!*\
  82551. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  82552. \*****************************************/
  82553. /*! exports provided: ShapeBuilder */
  82554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82555. "use strict";
  82556. __webpack_require__.r(__webpack_exports__);
  82557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  82558. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  82559. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  82560. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  82561. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  82562. if (scene === void 0) { scene = null; }
  82563. var options = {
  82564. shape: shape,
  82565. path: path,
  82566. scale: scale,
  82567. rotation: rotation,
  82568. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  82569. sideOrientation: sideOrientation,
  82570. instance: instance,
  82571. updatable: updatable
  82572. };
  82573. return ShapeBuilder.ExtrudeShape(name, options, scene);
  82574. };
  82575. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  82576. var options = {
  82577. shape: shape,
  82578. path: path,
  82579. scaleFunction: scaleFunction,
  82580. rotationFunction: rotationFunction,
  82581. ribbonCloseArray: ribbonCloseArray,
  82582. ribbonClosePath: ribbonClosePath,
  82583. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  82584. sideOrientation: sideOrientation,
  82585. instance: instance,
  82586. updatable: updatable
  82587. };
  82588. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  82589. };
  82590. /**
  82591. * Class containing static functions to help procedurally build meshes
  82592. */
  82593. var ShapeBuilder = /** @class */ (function () {
  82594. function ShapeBuilder() {
  82595. }
  82596. /**
  82597. * 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.
  82598. * * 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.
  82599. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  82600. * * 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.
  82601. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  82602. * * 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
  82603. * * 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
  82604. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  82605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82606. * * 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
  82607. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  82608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  82609. * @param name defines the name of the mesh
  82610. * @param options defines the options used to create the mesh
  82611. * @param scene defines the hosting scene
  82612. * @returns the extruded shape mesh
  82613. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  82614. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  82615. */
  82616. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  82617. if (scene === void 0) { scene = null; }
  82618. var path = options.path;
  82619. var shape = options.shape;
  82620. var scale = options.scale || 1;
  82621. var rotation = options.rotation || 0;
  82622. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  82623. var updatable = options.updatable;
  82624. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  82625. var instance = options.instance || null;
  82626. var invertUV = options.invertUV || false;
  82627. 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);
  82628. };
  82629. /**
  82630. * Creates an custom extruded shape mesh.
  82631. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  82632. * * 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.
  82633. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  82634. * * 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
  82635. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  82636. * * 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
  82637. * * It must returns a float value that will be the scale value applied to the shape on each path point
  82638. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  82639. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  82640. * * 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
  82641. * * 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
  82642. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  82643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82644. * * 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
  82645. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  82646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82647. * @param name defines the name of the mesh
  82648. * @param options defines the options used to create the mesh
  82649. * @param scene defines the hosting scene
  82650. * @returns the custom extruded shape mesh
  82651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  82652. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  82653. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  82654. */
  82655. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  82656. if (scene === void 0) { scene = null; }
  82657. var path = options.path;
  82658. var shape = options.shape;
  82659. var scaleFunction = options.scaleFunction || (function () { return 1; });
  82660. var rotationFunction = options.rotationFunction || (function () { return 0; });
  82661. var ribbonCloseArray = options.ribbonCloseArray || false;
  82662. var ribbonClosePath = options.ribbonClosePath || false;
  82663. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  82664. var updatable = options.updatable;
  82665. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  82666. var instance = options.instance;
  82667. var invertUV = options.invertUV || false;
  82668. 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);
  82669. };
  82670. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  82671. // extrusion geometry
  82672. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  82673. var tangents = path3D.getTangents();
  82674. var normals = path3D.getNormals();
  82675. var binormals = path3D.getBinormals();
  82676. var distances = path3D.getDistances();
  82677. var angle = 0;
  82678. var returnScale = function () { return scale !== null ? scale : 1; };
  82679. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  82680. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  82681. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  82682. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  82683. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  82684. for (var i = 0; i < curve.length; i++) {
  82685. var shapePath = new Array();
  82686. var angleStep = rotate(i, distances[i]);
  82687. var scaleRatio = scl(i, distances[i]);
  82688. for (var p = 0; p < shape.length; p++) {
  82689. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  82690. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  82691. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  82692. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  82693. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  82694. shapePath[p] = rotated;
  82695. }
  82696. shapePaths[index] = shapePath;
  82697. angle += angleStep;
  82698. index++;
  82699. }
  82700. // cap
  82701. var capPath = function (shapePath) {
  82702. var pointCap = Array();
  82703. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  82704. var i;
  82705. for (i = 0; i < shapePath.length; i++) {
  82706. barycenter.addInPlace(shapePath[i]);
  82707. }
  82708. barycenter.scaleInPlace(1.0 / shapePath.length);
  82709. for (i = 0; i < shapePath.length; i++) {
  82710. pointCap.push(barycenter);
  82711. }
  82712. return pointCap;
  82713. };
  82714. switch (cap) {
  82715. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  82716. break;
  82717. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  82718. shapePaths[0] = capPath(shapePaths[2]);
  82719. shapePaths[1] = shapePaths[2];
  82720. break;
  82721. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  82722. shapePaths[index] = shapePaths[index - 1];
  82723. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  82724. break;
  82725. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  82726. shapePaths[0] = capPath(shapePaths[2]);
  82727. shapePaths[1] = shapePaths[2];
  82728. shapePaths[index] = shapePaths[index - 1];
  82729. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  82730. break;
  82731. default:
  82732. break;
  82733. }
  82734. return shapePaths;
  82735. };
  82736. var path3D;
  82737. var pathArray;
  82738. if (instance) { // instance update
  82739. var storage = instance._creationDataStorage;
  82740. path3D = storage.path3D.update(curve);
  82741. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  82742. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  82743. return instance;
  82744. }
  82745. // extruded shape creation
  82746. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  82747. var newShapePaths = new Array();
  82748. cap = (cap < 0 || cap > 3) ? 0 : cap;
  82749. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  82750. 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);
  82751. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  82752. extrudedGeneric._creationDataStorage.path3D = path3D;
  82753. extrudedGeneric._creationDataStorage.cap = cap;
  82754. return extrudedGeneric;
  82755. };
  82756. return ShapeBuilder;
  82757. }());
  82758. /***/ }),
  82759. /***/ "./Meshes/Builders/sphereBuilder.ts":
  82760. /*!******************************************!*\
  82761. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  82762. \******************************************/
  82763. /*! exports provided: SphereBuilder */
  82764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82765. "use strict";
  82766. __webpack_require__.r(__webpack_exports__);
  82767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  82768. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  82769. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  82770. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  82771. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  82772. var segments = options.segments || 32;
  82773. var diameterX = options.diameterX || options.diameter || 1;
  82774. var diameterY = options.diameterY || options.diameter || 1;
  82775. var diameterZ = options.diameterZ || options.diameter || 1;
  82776. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  82777. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  82778. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  82779. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  82780. var totalZRotationSteps = 2 + segments;
  82781. var totalYRotationSteps = 2 * totalZRotationSteps;
  82782. var indices = [];
  82783. var positions = [];
  82784. var normals = [];
  82785. var uvs = [];
  82786. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  82787. var normalizedZ = zRotationStep / totalZRotationSteps;
  82788. var angleZ = normalizedZ * Math.PI * slice;
  82789. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  82790. var normalizedY = yRotationStep / totalYRotationSteps;
  82791. var angleY = normalizedY * Math.PI * 2 * arc;
  82792. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  82793. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  82794. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  82795. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  82796. var vertex = complete.multiply(radius);
  82797. var normal = complete.divide(radius).normalize();
  82798. positions.push(vertex.x, vertex.y, vertex.z);
  82799. normals.push(normal.x, normal.y, normal.z);
  82800. uvs.push(normalizedY, normalizedZ);
  82801. }
  82802. if (zRotationStep > 0) {
  82803. var verticesCount = positions.length / 3;
  82804. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  82805. indices.push((firstIndex));
  82806. indices.push((firstIndex + 1));
  82807. indices.push(firstIndex + totalYRotationSteps + 1);
  82808. indices.push((firstIndex + totalYRotationSteps + 1));
  82809. indices.push((firstIndex + 1));
  82810. indices.push((firstIndex + totalYRotationSteps + 2));
  82811. }
  82812. }
  82813. }
  82814. // Sides
  82815. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  82816. // Result
  82817. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  82818. vertexData.indices = indices;
  82819. vertexData.positions = positions;
  82820. vertexData.normals = normals;
  82821. vertexData.uvs = uvs;
  82822. return vertexData;
  82823. };
  82824. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  82825. var options = {
  82826. segments: segments,
  82827. diameterX: diameter,
  82828. diameterY: diameter,
  82829. diameterZ: diameter,
  82830. sideOrientation: sideOrientation,
  82831. updatable: updatable
  82832. };
  82833. return SphereBuilder.CreateSphere(name, options, scene);
  82834. };
  82835. /**
  82836. * Class containing static functions to help procedurally build meshes
  82837. */
  82838. var SphereBuilder = /** @class */ (function () {
  82839. function SphereBuilder() {
  82840. }
  82841. /**
  82842. * Creates a sphere mesh
  82843. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  82844. * * 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`)
  82845. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  82846. * * 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
  82847. * * 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)
  82848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82849. * * 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
  82850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82851. * @param name defines the name of the mesh
  82852. * @param options defines the options used to create the mesh
  82853. * @param scene defines the hosting scene
  82854. * @returns the sphere mesh
  82855. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  82856. */
  82857. SphereBuilder.CreateSphere = function (name, options, scene) {
  82858. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  82859. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  82860. sphere._originalBuilderSideOrientation = options.sideOrientation;
  82861. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  82862. vertexData.applyToMesh(sphere, options.updatable);
  82863. return sphere;
  82864. };
  82865. return SphereBuilder;
  82866. }());
  82867. /***/ }),
  82868. /***/ "./Meshes/Builders/torusBuilder.ts":
  82869. /*!*****************************************!*\
  82870. !*** ./Meshes/Builders/torusBuilder.ts ***!
  82871. \*****************************************/
  82872. /*! exports provided: TorusBuilder */
  82873. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82874. "use strict";
  82875. __webpack_require__.r(__webpack_exports__);
  82876. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  82877. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  82878. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  82879. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  82880. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  82881. var indices = [];
  82882. var positions = [];
  82883. var normals = [];
  82884. var uvs = [];
  82885. var diameter = options.diameter || 1;
  82886. var thickness = options.thickness || 0.5;
  82887. var tessellation = options.tessellation || 16;
  82888. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  82889. var stride = tessellation + 1;
  82890. for (var i = 0; i <= tessellation; i++) {
  82891. var u = i / tessellation;
  82892. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  82893. 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));
  82894. for (var j = 0; j <= tessellation; j++) {
  82895. var v = 1 - j / tessellation;
  82896. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  82897. var dx = Math.cos(innerAngle);
  82898. var dy = Math.sin(innerAngle);
  82899. // Create a vertex.
  82900. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  82901. var position = normal.scale(thickness / 2);
  82902. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  82903. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  82904. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  82905. positions.push(position.x, position.y, position.z);
  82906. normals.push(normal.x, normal.y, normal.z);
  82907. uvs.push(textureCoordinate.x, textureCoordinate.y);
  82908. // And create indices for two triangles.
  82909. var nextI = (i + 1) % stride;
  82910. var nextJ = (j + 1) % stride;
  82911. indices.push(i * stride + j);
  82912. indices.push(i * stride + nextJ);
  82913. indices.push(nextI * stride + j);
  82914. indices.push(i * stride + nextJ);
  82915. indices.push(nextI * stride + nextJ);
  82916. indices.push(nextI * stride + j);
  82917. }
  82918. }
  82919. // Sides
  82920. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  82921. // Result
  82922. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  82923. vertexData.indices = indices;
  82924. vertexData.positions = positions;
  82925. vertexData.normals = normals;
  82926. vertexData.uvs = uvs;
  82927. return vertexData;
  82928. };
  82929. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  82930. var options = {
  82931. diameter: diameter,
  82932. thickness: thickness,
  82933. tessellation: tessellation,
  82934. sideOrientation: sideOrientation,
  82935. updatable: updatable
  82936. };
  82937. return TorusBuilder.CreateTorus(name, options, scene);
  82938. };
  82939. /**
  82940. * Class containing static functions to help procedurally build meshes
  82941. */
  82942. var TorusBuilder = /** @class */ (function () {
  82943. function TorusBuilder() {
  82944. }
  82945. /**
  82946. * Creates a torus mesh
  82947. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  82948. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  82949. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  82950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82951. * * 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
  82952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  82953. * @param name defines the name of the mesh
  82954. * @param options defines the options used to create the mesh
  82955. * @param scene defines the hosting scene
  82956. * @returns the torus mesh
  82957. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  82958. */
  82959. TorusBuilder.CreateTorus = function (name, options, scene) {
  82960. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  82961. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  82962. torus._originalBuilderSideOrientation = options.sideOrientation;
  82963. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  82964. vertexData.applyToMesh(torus, options.updatable);
  82965. return torus;
  82966. };
  82967. return TorusBuilder;
  82968. }());
  82969. /***/ }),
  82970. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  82971. /*!*********************************************!*\
  82972. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  82973. \*********************************************/
  82974. /*! exports provided: TorusKnotBuilder */
  82975. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82976. "use strict";
  82977. __webpack_require__.r(__webpack_exports__);
  82978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  82979. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  82980. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  82981. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  82982. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  82983. var indices = new Array();
  82984. var positions = new Array();
  82985. var normals = new Array();
  82986. var uvs = new Array();
  82987. var radius = options.radius || 2;
  82988. var tube = options.tube || 0.5;
  82989. var radialSegments = options.radialSegments || 32;
  82990. var tubularSegments = options.tubularSegments || 32;
  82991. var p = options.p || 2;
  82992. var q = options.q || 3;
  82993. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  82994. // Helper
  82995. var getPos = function (angle) {
  82996. var cu = Math.cos(angle);
  82997. var su = Math.sin(angle);
  82998. var quOverP = q / p * angle;
  82999. var cs = Math.cos(quOverP);
  83000. var tx = radius * (2 + cs) * 0.5 * cu;
  83001. var ty = radius * (2 + cs) * su * 0.5;
  83002. var tz = radius * Math.sin(quOverP) * 0.5;
  83003. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  83004. };
  83005. // Vertices
  83006. var i;
  83007. var j;
  83008. for (i = 0; i <= radialSegments; i++) {
  83009. var modI = i % radialSegments;
  83010. var u = modI / radialSegments * 2 * p * Math.PI;
  83011. var p1 = getPos(u);
  83012. var p2 = getPos(u + 0.01);
  83013. var tang = p2.subtract(p1);
  83014. var n = p2.add(p1);
  83015. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  83016. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  83017. bitan.normalize();
  83018. n.normalize();
  83019. for (j = 0; j < tubularSegments; j++) {
  83020. var modJ = j % tubularSegments;
  83021. var v = modJ / tubularSegments * 2 * Math.PI;
  83022. var cx = -tube * Math.cos(v);
  83023. var cy = tube * Math.sin(v);
  83024. positions.push(p1.x + cx * n.x + cy * bitan.x);
  83025. positions.push(p1.y + cx * n.y + cy * bitan.y);
  83026. positions.push(p1.z + cx * n.z + cy * bitan.z);
  83027. uvs.push(i / radialSegments);
  83028. uvs.push(j / tubularSegments);
  83029. }
  83030. }
  83031. for (i = 0; i < radialSegments; i++) {
  83032. for (j = 0; j < tubularSegments; j++) {
  83033. var jNext = (j + 1) % tubularSegments;
  83034. var a = i * tubularSegments + j;
  83035. var b = (i + 1) * tubularSegments + j;
  83036. var c = (i + 1) * tubularSegments + jNext;
  83037. var d = i * tubularSegments + jNext;
  83038. indices.push(d);
  83039. indices.push(b);
  83040. indices.push(a);
  83041. indices.push(d);
  83042. indices.push(c);
  83043. indices.push(b);
  83044. }
  83045. }
  83046. // Normals
  83047. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  83048. // Sides
  83049. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  83050. // Result
  83051. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  83052. vertexData.indices = indices;
  83053. vertexData.positions = positions;
  83054. vertexData.normals = normals;
  83055. vertexData.uvs = uvs;
  83056. return vertexData;
  83057. };
  83058. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  83059. var options = {
  83060. radius: radius,
  83061. tube: tube,
  83062. radialSegments: radialSegments,
  83063. tubularSegments: tubularSegments,
  83064. p: p,
  83065. q: q,
  83066. sideOrientation: sideOrientation,
  83067. updatable: updatable
  83068. };
  83069. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  83070. };
  83071. /**
  83072. * Class containing static functions to help procedurally build meshes
  83073. */
  83074. var TorusKnotBuilder = /** @class */ (function () {
  83075. function TorusKnotBuilder() {
  83076. }
  83077. /**
  83078. * Creates a torus knot mesh
  83079. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  83080. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  83081. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  83082. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  83083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83084. * * 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
  83085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  83086. * @param name defines the name of the mesh
  83087. * @param options defines the options used to create the mesh
  83088. * @param scene defines the hosting scene
  83089. * @returns the torus knot mesh
  83090. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  83091. */
  83092. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  83093. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  83094. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  83095. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  83096. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  83097. vertexData.applyToMesh(torusKnot, options.updatable);
  83098. return torusKnot;
  83099. };
  83100. return TorusKnotBuilder;
  83101. }());
  83102. /***/ }),
  83103. /***/ "./Meshes/Builders/tubeBuilder.ts":
  83104. /*!****************************************!*\
  83105. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  83106. \****************************************/
  83107. /*! exports provided: TubeBuilder */
  83108. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83109. "use strict";
  83110. __webpack_require__.r(__webpack_exports__);
  83111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  83112. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  83113. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  83114. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  83115. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  83116. var options = {
  83117. path: path,
  83118. radius: radius,
  83119. tessellation: tessellation,
  83120. radiusFunction: radiusFunction,
  83121. arc: 1,
  83122. cap: cap,
  83123. updatable: updatable,
  83124. sideOrientation: sideOrientation,
  83125. instance: instance
  83126. };
  83127. return TubeBuilder.CreateTube(name, options, scene);
  83128. };
  83129. /**
  83130. * Class containing static functions to help procedurally build meshes
  83131. */
  83132. var TubeBuilder = /** @class */ (function () {
  83133. function TubeBuilder() {
  83134. }
  83135. /**
  83136. * Creates a tube mesh.
  83137. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  83138. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  83139. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  83140. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  83141. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  83142. * * 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)
  83143. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  83144. * * 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
  83145. * * 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
  83146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83147. * * 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
  83148. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  83149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83150. * @param name defines the name of the mesh
  83151. * @param options defines the options used to create the mesh
  83152. * @param scene defines the hosting scene
  83153. * @returns the tube mesh
  83154. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  83155. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  83156. */
  83157. TubeBuilder.CreateTube = function (name, options, scene) {
  83158. if (scene === void 0) { scene = null; }
  83159. var path = options.path;
  83160. var instance = options.instance;
  83161. var radius = 1.0;
  83162. if (options.radius !== undefined) {
  83163. radius = options.radius;
  83164. }
  83165. else if (instance) {
  83166. radius = instance._creationDataStorage.radius;
  83167. }
  83168. var tessellation = options.tessellation || 64 | 0;
  83169. var radiusFunction = options.radiusFunction || null;
  83170. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  83171. var invertUV = options.invertUV || false;
  83172. var updatable = options.updatable;
  83173. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  83174. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  83175. // tube geometry
  83176. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  83177. var tangents = path3D.getTangents();
  83178. var normals = path3D.getNormals();
  83179. var distances = path3D.getDistances();
  83180. var pi2 = Math.PI * 2;
  83181. var step = pi2 / tessellation * arc;
  83182. var returnRadius = function () { return radius; };
  83183. var radiusFunctionFinal = radiusFunction || returnRadius;
  83184. var circlePath;
  83185. var rad;
  83186. var normal;
  83187. var rotated;
  83188. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  83189. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  83190. for (var i = 0; i < path.length; i++) {
  83191. rad = radiusFunctionFinal(i, distances[i]); // current radius
  83192. circlePath = Array(); // current circle array
  83193. normal = normals[i]; // current normal
  83194. for (var t = 0; t < tessellation; t++) {
  83195. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  83196. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  83197. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  83198. rotated.scaleInPlace(rad).addInPlace(path[i]);
  83199. circlePath[t] = rotated;
  83200. }
  83201. circlePaths[index] = circlePath;
  83202. index++;
  83203. }
  83204. // cap
  83205. var capPath = function (nbPoints, pathIndex) {
  83206. var pointCap = Array();
  83207. for (var i = 0; i < nbPoints; i++) {
  83208. pointCap.push(path[pathIndex]);
  83209. }
  83210. return pointCap;
  83211. };
  83212. switch (cap) {
  83213. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  83214. break;
  83215. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  83216. circlePaths[0] = capPath(tessellation, 0);
  83217. circlePaths[1] = circlePaths[2].slice(0);
  83218. break;
  83219. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  83220. circlePaths[index] = circlePaths[index - 1].slice(0);
  83221. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  83222. break;
  83223. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  83224. circlePaths[0] = capPath(tessellation, 0);
  83225. circlePaths[1] = circlePaths[2].slice(0);
  83226. circlePaths[index] = circlePaths[index - 1].slice(0);
  83227. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  83228. break;
  83229. default:
  83230. break;
  83231. }
  83232. return circlePaths;
  83233. };
  83234. var path3D;
  83235. var pathArray;
  83236. if (instance) { // tube update
  83237. var storage = instance._creationDataStorage;
  83238. var arc = options.arc || storage.arc;
  83239. path3D = storage.path3D.update(path);
  83240. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  83241. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  83242. // Update mode, no need to recreate the storage.
  83243. storage.path3D = path3D;
  83244. storage.pathArray = pathArray;
  83245. storage.arc = arc;
  83246. storage.radius = radius;
  83247. return instance;
  83248. }
  83249. // tube creation
  83250. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  83251. var newPathArray = new Array();
  83252. cap = (cap < 0 || cap > 3) ? 0 : cap;
  83253. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  83254. 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);
  83255. tube._creationDataStorage.pathArray = pathArray;
  83256. tube._creationDataStorage.path3D = path3D;
  83257. tube._creationDataStorage.tessellation = tessellation;
  83258. tube._creationDataStorage.cap = cap;
  83259. tube._creationDataStorage.arc = options.arc;
  83260. tube._creationDataStorage.radius = radius;
  83261. return tube;
  83262. };
  83263. return TubeBuilder;
  83264. }());
  83265. /***/ }),
  83266. /***/ "./Meshes/Compression/dracoCompression.ts":
  83267. /*!************************************************!*\
  83268. !*** ./Meshes/Compression/dracoCompression.ts ***!
  83269. \************************************************/
  83270. /*! exports provided: DracoCompression */
  83271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83272. "use strict";
  83273. __webpack_require__.r(__webpack_exports__);
  83274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  83275. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  83276. /* harmony import */ var _Misc_workerPool__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/workerPool */ "./Misc/workerPool.ts");
  83277. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  83278. function loadScriptAsync(url) {
  83279. if (typeof importScripts === "function") {
  83280. importScripts(url);
  83281. return Promise.resolve();
  83282. }
  83283. else {
  83284. return new Promise(function (resolve, reject) {
  83285. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  83286. resolve();
  83287. }, function (message) {
  83288. reject(new Error(message));
  83289. });
  83290. });
  83291. }
  83292. }
  83293. function loadFileAsync(url) {
  83294. return new Promise(function (resolve, reject) {
  83295. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  83296. resolve(data);
  83297. }, undefined, undefined, true, function (request, exception) {
  83298. reject(exception);
  83299. });
  83300. });
  83301. }
  83302. function createDecoderAsync(wasmUrl, wasmBinary, fallbackUrl) {
  83303. var decoderUrl = (wasmBinary && wasmUrl) || fallbackUrl;
  83304. if (decoderUrl) {
  83305. return loadScriptAsync(decoderUrl).then(function () {
  83306. return new Promise(function (resolve) {
  83307. DracoDecoderModule({ wasmBinary: wasmBinary }).then(function (module) {
  83308. resolve({ module: module });
  83309. });
  83310. });
  83311. });
  83312. }
  83313. return undefined;
  83314. }
  83315. function decodeMesh(decoderModule, dataView, attributes, onIndicesData, onAttributeData) {
  83316. var buffer = new decoderModule.DecoderBuffer();
  83317. buffer.Init(dataView, dataView.byteLength);
  83318. var decoder = new decoderModule.Decoder();
  83319. var geometry;
  83320. var status;
  83321. try {
  83322. var type = decoder.GetEncodedGeometryType(buffer);
  83323. switch (type) {
  83324. case decoderModule.TRIANGULAR_MESH:
  83325. geometry = new decoderModule.Mesh();
  83326. status = decoder.DecodeBufferToMesh(buffer, geometry);
  83327. break;
  83328. case decoderModule.POINT_CLOUD:
  83329. geometry = new decoderModule.PointCloud();
  83330. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  83331. break;
  83332. default:
  83333. throw new Error("Invalid geometry type " + type);
  83334. }
  83335. if (!status.ok() || !geometry.ptr) {
  83336. throw new Error(status.error_msg());
  83337. }
  83338. var numPoints_1 = geometry.num_points();
  83339. if (type === decoderModule.TRIANGULAR_MESH) {
  83340. var numFaces = geometry.num_faces();
  83341. var faceIndices = new decoderModule.DracoInt32Array();
  83342. try {
  83343. var indices = new Uint32Array(numFaces * 3);
  83344. for (var i = 0; i < numFaces; i++) {
  83345. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  83346. var offset = i * 3;
  83347. indices[offset + 0] = faceIndices.GetValue(0);
  83348. indices[offset + 1] = faceIndices.GetValue(1);
  83349. indices[offset + 2] = faceIndices.GetValue(2);
  83350. }
  83351. onIndicesData(indices);
  83352. }
  83353. finally {
  83354. decoderModule.destroy(faceIndices);
  83355. }
  83356. }
  83357. var processAttribute = function (kind, attribute) {
  83358. var dracoData = new decoderModule.DracoFloat32Array();
  83359. try {
  83360. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  83361. var babylonData = new Float32Array(numPoints_1 * attribute.num_components());
  83362. for (var i = 0; i < babylonData.length; i++) {
  83363. babylonData[i] = dracoData.GetValue(i);
  83364. }
  83365. onAttributeData(kind, babylonData);
  83366. }
  83367. finally {
  83368. decoderModule.destroy(dracoData);
  83369. }
  83370. };
  83371. if (attributes) {
  83372. for (var kind in attributes) {
  83373. var id = attributes[kind];
  83374. var attribute = decoder.GetAttributeByUniqueId(geometry, id);
  83375. processAttribute(kind, attribute);
  83376. }
  83377. }
  83378. else {
  83379. var nativeAttributeTypes = {
  83380. "position": "POSITION",
  83381. "normal": "NORMAL",
  83382. "color": "COLOR",
  83383. "uv": "TEX_COORD"
  83384. };
  83385. for (var kind in nativeAttributeTypes) {
  83386. var id = decoder.GetAttributeId(geometry, decoderModule[nativeAttributeTypes[kind]]);
  83387. if (id !== -1) {
  83388. var attribute = decoder.GetAttribute(geometry, id);
  83389. processAttribute(kind, attribute);
  83390. }
  83391. }
  83392. }
  83393. }
  83394. finally {
  83395. if (geometry) {
  83396. decoderModule.destroy(geometry);
  83397. }
  83398. decoderModule.destroy(decoder);
  83399. decoderModule.destroy(buffer);
  83400. }
  83401. }
  83402. /**
  83403. * The worker function that gets converted to a blob url to pass into a worker.
  83404. */
  83405. function worker() {
  83406. var decoderPromise;
  83407. onmessage = function (event) {
  83408. var data = event.data;
  83409. switch (data.id) {
  83410. case "init": {
  83411. var decoder = data.decoder;
  83412. decoderPromise = createDecoderAsync(decoder.wasmUrl, decoder.wasmBinary, decoder.fallbackUrl);
  83413. postMessage("done");
  83414. break;
  83415. }
  83416. case "decodeMesh": {
  83417. if (!decoderPromise) {
  83418. throw new Error("Draco decoder module is not available");
  83419. }
  83420. decoderPromise.then(function (decoder) {
  83421. decodeMesh(decoder.module, data.dataView, data.attributes, function (indices) {
  83422. postMessage({ id: "indices", value: indices }, [indices.buffer]);
  83423. }, function (kind, data) {
  83424. postMessage({ id: kind, value: data }, [data.buffer]);
  83425. });
  83426. postMessage("done");
  83427. });
  83428. break;
  83429. }
  83430. }
  83431. };
  83432. }
  83433. function getAbsoluteUrl(url) {
  83434. if (typeof document !== "object" || typeof url !== "string") {
  83435. return url;
  83436. }
  83437. return _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetAbsoluteUrl(url);
  83438. }
  83439. /**
  83440. * Draco compression (https://google.github.io/draco/)
  83441. *
  83442. * This class wraps the Draco module.
  83443. *
  83444. * **Encoder**
  83445. *
  83446. * The encoder is not currently implemented.
  83447. *
  83448. * **Decoder**
  83449. *
  83450. * 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.
  83451. *
  83452. * To update the configuration, use the following code:
  83453. * ```javascript
  83454. * DracoCompression.Configuration = {
  83455. * decoder: {
  83456. * wasmUrl: "<url to the WebAssembly library>",
  83457. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  83458. * fallbackUrl: "<url to the fallback JavaScript library>",
  83459. * }
  83460. * };
  83461. * ```
  83462. *
  83463. * 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.
  83464. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  83465. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  83466. *
  83467. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  83468. * ```javascript
  83469. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  83470. * ```
  83471. *
  83472. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  83473. */
  83474. var DracoCompression = /** @class */ (function () {
  83475. /**
  83476. * Constructor
  83477. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  83478. */
  83479. function DracoCompression(numWorkers) {
  83480. if (numWorkers === void 0) { numWorkers = DracoCompression.DefaultNumWorkers; }
  83481. var decoder = DracoCompression.Configuration.decoder;
  83482. var decoderWasmBinaryPromise = (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object")
  83483. ? loadFileAsync(getAbsoluteUrl(decoder.wasmBinaryUrl))
  83484. : Promise.resolve(undefined);
  83485. if (numWorkers && typeof Worker === "function") {
  83486. this._workerPoolPromise = decoderWasmBinaryPromise.then(function (decoderWasmBinary) {
  83487. var workerContent = "" + loadScriptAsync + createDecoderAsync + decodeMesh + "(" + worker + ")()";
  83488. var workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: "application/javascript" }));
  83489. var workerPromises = new Array(numWorkers);
  83490. for (var i = 0; i < workerPromises.length; i++) {
  83491. workerPromises[i] = new Promise(function (resolve, reject) {
  83492. var worker = new Worker(workerBlobUrl);
  83493. var onError = function (error) {
  83494. worker.removeEventListener("error", onError);
  83495. worker.removeEventListener("message", onMessage);
  83496. reject(error);
  83497. };
  83498. var onMessage = function (message) {
  83499. if (message.data === "done") {
  83500. worker.removeEventListener("error", onError);
  83501. worker.removeEventListener("message", onMessage);
  83502. resolve(worker);
  83503. }
  83504. };
  83505. worker.addEventListener("error", onError);
  83506. worker.addEventListener("message", onMessage);
  83507. worker.postMessage({
  83508. id: "init",
  83509. decoder: {
  83510. wasmUrl: getAbsoluteUrl(decoder.wasmUrl),
  83511. wasmBinary: decoderWasmBinary,
  83512. fallbackUrl: getAbsoluteUrl(decoder.fallbackUrl)
  83513. }
  83514. });
  83515. });
  83516. }
  83517. return Promise.all(workerPromises).then(function (workers) {
  83518. return new _Misc_workerPool__WEBPACK_IMPORTED_MODULE_1__["WorkerPool"](workers);
  83519. });
  83520. });
  83521. }
  83522. else {
  83523. this._decoderModulePromise = decoderWasmBinaryPromise.then(function (decoderWasmBinary) {
  83524. return createDecoderAsync(decoder.wasmUrl, decoderWasmBinary, decoder.fallbackUrl);
  83525. });
  83526. }
  83527. }
  83528. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  83529. /**
  83530. * Returns true if the decoder configuration is available.
  83531. */
  83532. get: function () {
  83533. var decoder = DracoCompression.Configuration.decoder;
  83534. return !!((decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") || decoder.fallbackUrl);
  83535. },
  83536. enumerable: true,
  83537. configurable: true
  83538. });
  83539. DracoCompression.GetDefaultNumWorkers = function () {
  83540. if (typeof navigator !== "object" || !navigator.hardwareConcurrency) {
  83541. return 1;
  83542. }
  83543. // Use 50% of the available logical processors but capped at 4.
  83544. return Math.min(Math.floor(navigator.hardwareConcurrency * 0.5), 4);
  83545. };
  83546. Object.defineProperty(DracoCompression, "Default", {
  83547. /**
  83548. * Default instance for the draco compression object.
  83549. */
  83550. get: function () {
  83551. if (!DracoCompression._Default) {
  83552. DracoCompression._Default = new DracoCompression();
  83553. }
  83554. return DracoCompression._Default;
  83555. },
  83556. enumerable: true,
  83557. configurable: true
  83558. });
  83559. /**
  83560. * Stop all async operations and release resources.
  83561. */
  83562. DracoCompression.prototype.dispose = function () {
  83563. if (this._workerPoolPromise) {
  83564. this._workerPoolPromise.then(function (workerPool) {
  83565. workerPool.dispose();
  83566. });
  83567. }
  83568. delete this._workerPoolPromise;
  83569. delete this._decoderModulePromise;
  83570. };
  83571. /**
  83572. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  83573. * @returns a promise that resolves when ready
  83574. */
  83575. DracoCompression.prototype.whenReadyAsync = function () {
  83576. if (this._workerPoolPromise) {
  83577. return this._workerPoolPromise.then(function () { });
  83578. }
  83579. if (this._decoderModulePromise) {
  83580. return this._decoderModulePromise.then(function () { });
  83581. }
  83582. return Promise.resolve();
  83583. };
  83584. /**
  83585. * Decode Draco compressed mesh data to vertex data.
  83586. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  83587. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  83588. * @returns A promise that resolves with the decoded vertex data
  83589. */
  83590. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  83591. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  83592. if (this._workerPoolPromise) {
  83593. return this._workerPoolPromise.then(function (workerPool) {
  83594. return new Promise(function (resolve, reject) {
  83595. workerPool.push(function (worker, onComplete) {
  83596. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  83597. var onError = function (error) {
  83598. worker.removeEventListener("error", onError);
  83599. worker.removeEventListener("message", onMessage);
  83600. reject(error);
  83601. onComplete();
  83602. };
  83603. var onMessage = function (message) {
  83604. if (message.data === "done") {
  83605. worker.removeEventListener("error", onError);
  83606. worker.removeEventListener("message", onMessage);
  83607. resolve(vertexData);
  83608. onComplete();
  83609. }
  83610. else if (message.data.id === "indices") {
  83611. vertexData.indices = message.data.value;
  83612. }
  83613. else {
  83614. vertexData.set(message.data.value, message.data.id);
  83615. }
  83616. };
  83617. worker.addEventListener("error", onError);
  83618. worker.addEventListener("message", onMessage);
  83619. var dataViewCopy = new Uint8Array(dataView.byteLength);
  83620. dataViewCopy.set(new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength));
  83621. worker.postMessage({ id: "decodeMesh", dataView: dataViewCopy, attributes: attributes }, [dataViewCopy.buffer]);
  83622. });
  83623. });
  83624. });
  83625. }
  83626. if (this._decoderModulePromise) {
  83627. return this._decoderModulePromise.then(function (decoder) {
  83628. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  83629. decodeMesh(decoder.module, dataView, attributes, function (indices) {
  83630. vertexData.indices = indices;
  83631. }, function (kind, data) {
  83632. vertexData.set(data, kind);
  83633. });
  83634. return vertexData;
  83635. });
  83636. }
  83637. throw new Error("Draco decoder module is not available");
  83638. };
  83639. /**
  83640. * The configuration. Defaults to the following urls:
  83641. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  83642. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  83643. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  83644. */
  83645. DracoCompression.Configuration = {
  83646. decoder: {
  83647. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  83648. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  83649. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  83650. }
  83651. };
  83652. /**
  83653. * Default number of workers to create when creating the draco compression object.
  83654. */
  83655. DracoCompression.DefaultNumWorkers = DracoCompression.GetDefaultNumWorkers();
  83656. DracoCompression._Default = null;
  83657. return DracoCompression;
  83658. }());
  83659. /***/ }),
  83660. /***/ "./Meshes/Compression/index.ts":
  83661. /*!*************************************!*\
  83662. !*** ./Meshes/Compression/index.ts ***!
  83663. \*************************************/
  83664. /*! exports provided: DracoCompression */
  83665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83666. "use strict";
  83667. __webpack_require__.r(__webpack_exports__);
  83668. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  83669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  83670. /***/ }),
  83671. /***/ "./Meshes/WebGL/webGLDataBuffer.ts":
  83672. /*!*****************************************!*\
  83673. !*** ./Meshes/WebGL/webGLDataBuffer.ts ***!
  83674. \*****************************************/
  83675. /*! exports provided: WebGLDataBuffer */
  83676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83677. "use strict";
  83678. __webpack_require__.r(__webpack_exports__);
  83679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebGLDataBuffer", function() { return WebGLDataBuffer; });
  83680. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83681. /* harmony import */ var _dataBuffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../dataBuffer */ "./Meshes/dataBuffer.ts");
  83682. /** @hidden */
  83683. var WebGLDataBuffer = /** @class */ (function (_super) {
  83684. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebGLDataBuffer, _super);
  83685. function WebGLDataBuffer(resource) {
  83686. var _this = _super.call(this) || this;
  83687. _this._buffer = resource;
  83688. return _this;
  83689. }
  83690. Object.defineProperty(WebGLDataBuffer.prototype, "underlyingResource", {
  83691. get: function () {
  83692. return this._buffer;
  83693. },
  83694. enumerable: true,
  83695. configurable: true
  83696. });
  83697. return WebGLDataBuffer;
  83698. }(_dataBuffer__WEBPACK_IMPORTED_MODULE_1__["DataBuffer"]));
  83699. /***/ }),
  83700. /***/ "./Meshes/abstractMesh.ts":
  83701. /*!********************************!*\
  83702. !*** ./Meshes/abstractMesh.ts ***!
  83703. \********************************/
  83704. /*! exports provided: AbstractMesh */
  83705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83706. "use strict";
  83707. __webpack_require__.r(__webpack_exports__);
  83708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  83709. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83710. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  83711. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  83712. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83713. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  83714. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83715. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  83716. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  83717. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  83718. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  83719. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  83720. /* harmony import */ var _Collisions_meshCollisionData__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Collisions/meshCollisionData */ "./Collisions/meshCollisionData.ts");
  83721. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  83722. /** @hidden */
  83723. var _FacetDataStorage = /** @class */ (function () {
  83724. function _FacetDataStorage() {
  83725. this.facetNb = 0; // facet number
  83726. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  83727. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  83728. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  83729. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  83730. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  83731. this.subDiv = {
  83732. max: 1,
  83733. X: 1,
  83734. Y: 1,
  83735. Z: 1
  83736. };
  83737. this.facetDepthSort = false; // is the facet depth sort to be computed
  83738. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  83739. }
  83740. return _FacetDataStorage;
  83741. }());
  83742. /**
  83743. * @hidden
  83744. **/
  83745. var _InternalAbstractMeshDataInfo = /** @class */ (function () {
  83746. function _InternalAbstractMeshDataInfo() {
  83747. this._hasVertexAlpha = false;
  83748. this._useVertexColors = true;
  83749. this._numBoneInfluencers = 4;
  83750. this._applyFog = true;
  83751. this._receiveShadows = false;
  83752. this._facetData = new _FacetDataStorage();
  83753. this._visibility = 1.0;
  83754. this._skeleton = null;
  83755. this._layerMask = 0x0FFFFFFF;
  83756. this._computeBonesUsingShaders = true;
  83757. this._isActive = false;
  83758. this._onlyForInstances = false;
  83759. this._isActiveIntermediate = false;
  83760. this._onlyForInstancesIntermediate = false;
  83761. }
  83762. return _InternalAbstractMeshDataInfo;
  83763. }());
  83764. /**
  83765. * Class used to store all common mesh properties
  83766. */
  83767. var AbstractMesh = /** @class */ (function (_super) {
  83768. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  83769. // Constructor
  83770. /**
  83771. * Creates a new AbstractMesh
  83772. * @param name defines the name of the mesh
  83773. * @param scene defines the hosting scene
  83774. */
  83775. function AbstractMesh(name, scene) {
  83776. if (scene === void 0) { scene = null; }
  83777. var _this = _super.call(this, name, scene, false) || this;
  83778. // Internal data
  83779. /** @hidden */
  83780. _this._internalAbstractMeshDataInfo = new _InternalAbstractMeshDataInfo();
  83781. /**
  83782. * The culling strategy to use to check whether the mesh must be rendered or not.
  83783. * This value can be changed at any time and will be used on the next render mesh selection.
  83784. * The possible values are :
  83785. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83786. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83787. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83788. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83789. * Please read each static variable documentation to get details about the culling process.
  83790. * */
  83791. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  83792. // Events
  83793. /**
  83794. * An event triggered when this mesh collides with another one
  83795. */
  83796. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  83797. /**
  83798. * An event triggered when the collision's position changes
  83799. */
  83800. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  83801. /**
  83802. * An event triggered when material is changed
  83803. */
  83804. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  83805. // Properties
  83806. /**
  83807. * Gets or sets the orientation for POV movement & rotation
  83808. */
  83809. _this.definedFacingForward = true;
  83810. /** @hidden */
  83811. _this._occlusionQuery = null;
  83812. /** @hidden */
  83813. _this._renderingGroup = null;
  83814. /** Gets or sets the alpha index used to sort transparent meshes
  83815. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  83816. */
  83817. _this.alphaIndex = Number.MAX_VALUE;
  83818. /**
  83819. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  83820. */
  83821. _this.isVisible = true;
  83822. /**
  83823. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83824. */
  83825. _this.isPickable = true;
  83826. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  83827. _this.showSubMeshesBoundingBox = false;
  83828. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  83829. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  83830. */
  83831. _this.isBlocker = false;
  83832. /**
  83833. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  83834. */
  83835. _this.enablePointerMoveEvents = false;
  83836. /**
  83837. * Specifies the rendering group id for this mesh (0 by default)
  83838. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83839. */
  83840. _this.renderingGroupId = 0;
  83841. _this._material = null;
  83842. /** Defines color to use when rendering outline */
  83843. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  83844. /** Define width to use when rendering outline */
  83845. _this.outlineWidth = 0.02;
  83846. /** Defines color to use when rendering overlay */
  83847. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  83848. /** Defines alpha to use when rendering overlay */
  83849. _this.overlayAlpha = 0.5;
  83850. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  83851. _this.useOctreeForRenderingSelection = true;
  83852. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  83853. _this.useOctreeForPicking = true;
  83854. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  83855. _this.useOctreeForCollisions = true;
  83856. /**
  83857. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  83858. */
  83859. _this.alwaysSelectAsActiveMesh = false;
  83860. /**
  83861. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  83862. */
  83863. _this.doNotSyncBoundingInfo = false;
  83864. /**
  83865. * Gets or sets the current action manager
  83866. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83867. */
  83868. _this.actionManager = null;
  83869. // Collisions
  83870. _this._meshCollisionData = new _Collisions_meshCollisionData__WEBPACK_IMPORTED_MODULE_11__["_MeshCollisionData"]();
  83871. /**
  83872. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  83873. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83874. */
  83875. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  83876. /**
  83877. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  83878. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83879. */
  83880. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  83881. // Edges
  83882. /**
  83883. * Defines edge width used when edgesRenderer is enabled
  83884. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83885. */
  83886. _this.edgesWidth = 1;
  83887. /**
  83888. * Defines edge color used when edgesRenderer is enabled
  83889. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83890. */
  83891. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  83892. /** @hidden */
  83893. _this._edgesRenderer = null;
  83894. /** @hidden */
  83895. _this._masterMesh = null;
  83896. /** @hidden */
  83897. _this._boundingInfo = null;
  83898. /** @hidden */
  83899. _this._renderId = 0;
  83900. /** @hidden */
  83901. _this._intersectionsInProgress = new Array();
  83902. /** @hidden */
  83903. _this._unIndexed = false;
  83904. /** @hidden */
  83905. _this._lightSources = new Array();
  83906. // Loading properties
  83907. /** @hidden */
  83908. _this._waitingData = {
  83909. lods: null,
  83910. actions: null,
  83911. freezeWorldMatrix: null
  83912. };
  83913. /** @hidden */
  83914. _this._bonesTransformMatrices = null;
  83915. /**
  83916. * An event triggered when the mesh is rebuilt.
  83917. */
  83918. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  83919. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  83920. if (collidedMesh === void 0) { collidedMesh = null; }
  83921. newPosition.subtractToRef(_this._meshCollisionData._oldPositionForCollisions, _this._meshCollisionData._diffPositionForCollisions);
  83922. if (_this._meshCollisionData._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  83923. _this.position.addInPlace(_this._meshCollisionData._diffPositionForCollisions);
  83924. }
  83925. if (collidedMesh) {
  83926. _this.onCollideObservable.notifyObservers(collidedMesh);
  83927. }
  83928. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  83929. };
  83930. _this.getScene().addMesh(_this);
  83931. _this._resyncLightSources();
  83932. return _this;
  83933. }
  83934. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  83935. /**
  83936. * No billboard
  83937. */
  83938. get: function () {
  83939. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  83940. },
  83941. enumerable: true,
  83942. configurable: true
  83943. });
  83944. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  83945. /** Billboard on X axis */
  83946. get: function () {
  83947. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  83948. },
  83949. enumerable: true,
  83950. configurable: true
  83951. });
  83952. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  83953. /** Billboard on Y axis */
  83954. get: function () {
  83955. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  83956. },
  83957. enumerable: true,
  83958. configurable: true
  83959. });
  83960. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  83961. /** Billboard on Z axis */
  83962. get: function () {
  83963. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  83964. },
  83965. enumerable: true,
  83966. configurable: true
  83967. });
  83968. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  83969. /** Billboard on all axes */
  83970. get: function () {
  83971. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  83972. },
  83973. enumerable: true,
  83974. configurable: true
  83975. });
  83976. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  83977. /**
  83978. * Gets the number of facets in the mesh
  83979. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83980. */
  83981. get: function () {
  83982. return this._internalAbstractMeshDataInfo._facetData.facetNb;
  83983. },
  83984. enumerable: true,
  83985. configurable: true
  83986. });
  83987. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  83988. /**
  83989. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  83990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83991. */
  83992. get: function () {
  83993. return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions;
  83994. },
  83995. set: function (nb) {
  83996. this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions = nb;
  83997. },
  83998. enumerable: true,
  83999. configurable: true
  84000. });
  84001. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  84002. /**
  84003. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  84004. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  84005. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84006. */
  84007. get: function () {
  84008. return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio;
  84009. },
  84010. set: function (ratio) {
  84011. this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio = ratio;
  84012. },
  84013. enumerable: true,
  84014. configurable: true
  84015. });
  84016. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  84017. /**
  84018. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  84019. * Works only for updatable meshes.
  84020. * Doesn't work with multi-materials
  84021. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84022. */
  84023. get: function () {
  84024. return this._internalAbstractMeshDataInfo._facetData.facetDepthSort;
  84025. },
  84026. set: function (sort) {
  84027. this._internalAbstractMeshDataInfo._facetData.facetDepthSort = sort;
  84028. },
  84029. enumerable: true,
  84030. configurable: true
  84031. });
  84032. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  84033. /**
  84034. * The location (Vector3) where the facet depth sort must be computed from.
  84035. * By default, the active camera position.
  84036. * Used only when facet depth sort is enabled
  84037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84038. */
  84039. get: function () {
  84040. return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom;
  84041. },
  84042. set: function (location) {
  84043. this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom = location;
  84044. },
  84045. enumerable: true,
  84046. configurable: true
  84047. });
  84048. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  84049. /**
  84050. * gets a boolean indicating if facetData is enabled
  84051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84052. */
  84053. get: function () {
  84054. return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled;
  84055. },
  84056. enumerable: true,
  84057. configurable: true
  84058. });
  84059. /** @hidden */
  84060. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  84061. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  84062. return false;
  84063. }
  84064. this._markSubMeshesAsMiscDirty();
  84065. return true;
  84066. };
  84067. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  84068. /** Set a function to call when this mesh collides with another one */
  84069. set: function (callback) {
  84070. if (this._meshCollisionData._onCollideObserver) {
  84071. this.onCollideObservable.remove(this._meshCollisionData._onCollideObserver);
  84072. }
  84073. this._meshCollisionData._onCollideObserver = this.onCollideObservable.add(callback);
  84074. },
  84075. enumerable: true,
  84076. configurable: true
  84077. });
  84078. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  84079. /** Set a function to call when the collision's position changes */
  84080. set: function (callback) {
  84081. if (this._meshCollisionData._onCollisionPositionChangeObserver) {
  84082. this.onCollisionPositionChangeObservable.remove(this._meshCollisionData._onCollisionPositionChangeObserver);
  84083. }
  84084. this._meshCollisionData._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  84085. },
  84086. enumerable: true,
  84087. configurable: true
  84088. });
  84089. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  84090. /**
  84091. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84092. */
  84093. get: function () {
  84094. return this._internalAbstractMeshDataInfo._visibility;
  84095. },
  84096. /**
  84097. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84098. */
  84099. set: function (value) {
  84100. if (this._internalAbstractMeshDataInfo._visibility === value) {
  84101. return;
  84102. }
  84103. this._internalAbstractMeshDataInfo._visibility = value;
  84104. this._markSubMeshesAsMiscDirty();
  84105. },
  84106. enumerable: true,
  84107. configurable: true
  84108. });
  84109. Object.defineProperty(AbstractMesh.prototype, "material", {
  84110. /** Gets or sets current material */
  84111. get: function () {
  84112. return this._material;
  84113. },
  84114. set: function (value) {
  84115. if (this._material === value) {
  84116. return;
  84117. }
  84118. // remove from material mesh map id needed
  84119. if (this._material && this._material.meshMap) {
  84120. this._material.meshMap[this.uniqueId] = undefined;
  84121. }
  84122. this._material = value;
  84123. if (value && value.meshMap) {
  84124. value.meshMap[this.uniqueId] = this;
  84125. }
  84126. if (this.onMaterialChangedObservable.hasObservers) {
  84127. this.onMaterialChangedObservable.notifyObservers(this);
  84128. }
  84129. if (!this.subMeshes) {
  84130. return;
  84131. }
  84132. this._unBindEffect();
  84133. },
  84134. enumerable: true,
  84135. configurable: true
  84136. });
  84137. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  84138. /**
  84139. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  84140. * @see http://doc.babylonjs.com/babylon101/shadows
  84141. */
  84142. get: function () {
  84143. return this._internalAbstractMeshDataInfo._receiveShadows;
  84144. },
  84145. set: function (value) {
  84146. if (this._internalAbstractMeshDataInfo._receiveShadows === value) {
  84147. return;
  84148. }
  84149. this._internalAbstractMeshDataInfo._receiveShadows = value;
  84150. this._markSubMeshesAsLightDirty();
  84151. },
  84152. enumerable: true,
  84153. configurable: true
  84154. });
  84155. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  84156. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  84157. get: function () {
  84158. return this._internalAbstractMeshDataInfo._hasVertexAlpha;
  84159. },
  84160. set: function (value) {
  84161. if (this._internalAbstractMeshDataInfo._hasVertexAlpha === value) {
  84162. return;
  84163. }
  84164. this._internalAbstractMeshDataInfo._hasVertexAlpha = value;
  84165. this._markSubMeshesAsAttributesDirty();
  84166. this._markSubMeshesAsMiscDirty();
  84167. },
  84168. enumerable: true,
  84169. configurable: true
  84170. });
  84171. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  84172. /** 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) */
  84173. get: function () {
  84174. return this._internalAbstractMeshDataInfo._useVertexColors;
  84175. },
  84176. set: function (value) {
  84177. if (this._internalAbstractMeshDataInfo._useVertexColors === value) {
  84178. return;
  84179. }
  84180. this._internalAbstractMeshDataInfo._useVertexColors = value;
  84181. this._markSubMeshesAsAttributesDirty();
  84182. },
  84183. enumerable: true,
  84184. configurable: true
  84185. });
  84186. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  84187. /**
  84188. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  84189. */
  84190. get: function () {
  84191. return this._internalAbstractMeshDataInfo._computeBonesUsingShaders;
  84192. },
  84193. set: function (value) {
  84194. if (this._internalAbstractMeshDataInfo._computeBonesUsingShaders === value) {
  84195. return;
  84196. }
  84197. this._internalAbstractMeshDataInfo._computeBonesUsingShaders = value;
  84198. this._markSubMeshesAsAttributesDirty();
  84199. },
  84200. enumerable: true,
  84201. configurable: true
  84202. });
  84203. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  84204. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  84205. get: function () {
  84206. return this._internalAbstractMeshDataInfo._numBoneInfluencers;
  84207. },
  84208. set: function (value) {
  84209. if (this._internalAbstractMeshDataInfo._numBoneInfluencers === value) {
  84210. return;
  84211. }
  84212. this._internalAbstractMeshDataInfo._numBoneInfluencers = value;
  84213. this._markSubMeshesAsAttributesDirty();
  84214. },
  84215. enumerable: true,
  84216. configurable: true
  84217. });
  84218. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  84219. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  84220. get: function () {
  84221. return this._internalAbstractMeshDataInfo._applyFog;
  84222. },
  84223. set: function (value) {
  84224. if (this._internalAbstractMeshDataInfo._applyFog === value) {
  84225. return;
  84226. }
  84227. this._internalAbstractMeshDataInfo._applyFog = value;
  84228. this._markSubMeshesAsMiscDirty();
  84229. },
  84230. enumerable: true,
  84231. configurable: true
  84232. });
  84233. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  84234. /**
  84235. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  84236. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  84237. */
  84238. get: function () {
  84239. return this._internalAbstractMeshDataInfo._layerMask;
  84240. },
  84241. set: function (value) {
  84242. if (value === this._internalAbstractMeshDataInfo._layerMask) {
  84243. return;
  84244. }
  84245. this._internalAbstractMeshDataInfo._layerMask = value;
  84246. this._resyncLightSources();
  84247. },
  84248. enumerable: true,
  84249. configurable: true
  84250. });
  84251. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  84252. /**
  84253. * Gets or sets a collision mask used to mask collisions (default is -1).
  84254. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84255. */
  84256. get: function () {
  84257. return this._meshCollisionData._collisionMask;
  84258. },
  84259. set: function (mask) {
  84260. this._meshCollisionData._collisionMask = !isNaN(mask) ? mask : -1;
  84261. },
  84262. enumerable: true,
  84263. configurable: true
  84264. });
  84265. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  84266. /**
  84267. * Gets or sets the current collision group mask (-1 by default).
  84268. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84269. */
  84270. get: function () {
  84271. return this._meshCollisionData._collisionGroup;
  84272. },
  84273. set: function (mask) {
  84274. this._meshCollisionData._collisionGroup = !isNaN(mask) ? mask : -1;
  84275. },
  84276. enumerable: true,
  84277. configurable: true
  84278. });
  84279. Object.defineProperty(AbstractMesh.prototype, "lightSources", {
  84280. /** Gets the list of lights affecting that mesh */
  84281. get: function () {
  84282. return this._lightSources;
  84283. },
  84284. enumerable: true,
  84285. configurable: true
  84286. });
  84287. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  84288. /** @hidden */
  84289. get: function () {
  84290. return null;
  84291. },
  84292. enumerable: true,
  84293. configurable: true
  84294. });
  84295. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  84296. get: function () {
  84297. return this._internalAbstractMeshDataInfo._skeleton;
  84298. },
  84299. /**
  84300. * Gets or sets a skeleton to apply skining transformations
  84301. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84302. */
  84303. set: function (value) {
  84304. var skeleton = this._internalAbstractMeshDataInfo._skeleton;
  84305. if (skeleton && skeleton.needInitialSkinMatrix) {
  84306. skeleton._unregisterMeshWithPoseMatrix(this);
  84307. }
  84308. if (value && value.needInitialSkinMatrix) {
  84309. value._registerMeshWithPoseMatrix(this);
  84310. }
  84311. this._internalAbstractMeshDataInfo._skeleton = value;
  84312. if (!this._internalAbstractMeshDataInfo._skeleton) {
  84313. this._bonesTransformMatrices = null;
  84314. }
  84315. this._markSubMeshesAsAttributesDirty();
  84316. },
  84317. enumerable: true,
  84318. configurable: true
  84319. });
  84320. /**
  84321. * Returns the string "AbstractMesh"
  84322. * @returns "AbstractMesh"
  84323. */
  84324. AbstractMesh.prototype.getClassName = function () {
  84325. return "AbstractMesh";
  84326. };
  84327. /**
  84328. * Gets a string representation of the current mesh
  84329. * @param fullDetails defines a boolean indicating if full details must be included
  84330. * @returns a string representation of the current mesh
  84331. */
  84332. AbstractMesh.prototype.toString = function (fullDetails) {
  84333. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  84334. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  84335. var skeleton = this._internalAbstractMeshDataInfo._skeleton;
  84336. if (skeleton) {
  84337. ret += ", skeleton: " + skeleton.name;
  84338. }
  84339. if (fullDetails) {
  84340. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  84341. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingData.freezeWorldMatrix ? "YES" : "NO");
  84342. }
  84343. return ret;
  84344. };
  84345. /**
  84346. * @hidden
  84347. */
  84348. AbstractMesh.prototype._getEffectiveParent = function () {
  84349. if (this._masterMesh && this.billboardMode !== _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE) {
  84350. return this._masterMesh;
  84351. }
  84352. return _super.prototype._getEffectiveParent.call(this);
  84353. };
  84354. /** @hidden */
  84355. AbstractMesh.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  84356. if (initialCall === void 0) { initialCall = true; }
  84357. if (this.actionManager && (initialCall || this.actionManager.isRecursive)) {
  84358. if (trigger) {
  84359. if (this.actionManager.hasSpecificTrigger(trigger)) {
  84360. return this.actionManager;
  84361. }
  84362. }
  84363. else {
  84364. return this.actionManager;
  84365. }
  84366. }
  84367. if (!this.parent) {
  84368. return null;
  84369. }
  84370. return this.parent._getActionManagerForTrigger(trigger, false);
  84371. };
  84372. /** @hidden */
  84373. AbstractMesh.prototype._rebuild = function () {
  84374. this.onRebuildObservable.notifyObservers(this);
  84375. if (this._occlusionQuery) {
  84376. this._occlusionQuery = null;
  84377. }
  84378. if (!this.subMeshes) {
  84379. return;
  84380. }
  84381. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84382. var subMesh = _a[_i];
  84383. subMesh._rebuild();
  84384. }
  84385. };
  84386. /** @hidden */
  84387. AbstractMesh.prototype._resyncLightSources = function () {
  84388. this._lightSources.length = 0;
  84389. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  84390. var light = _a[_i];
  84391. if (!light.isEnabled()) {
  84392. continue;
  84393. }
  84394. if (light.canAffectMesh(this)) {
  84395. this._lightSources.push(light);
  84396. }
  84397. }
  84398. this._markSubMeshesAsLightDirty();
  84399. };
  84400. /** @hidden */
  84401. AbstractMesh.prototype._resyncLighSource = function (light) {
  84402. var isIn = light.isEnabled() && light.canAffectMesh(this);
  84403. var index = this._lightSources.indexOf(light);
  84404. if (index === -1) {
  84405. if (!isIn) {
  84406. return;
  84407. }
  84408. this._lightSources.push(light);
  84409. }
  84410. else {
  84411. if (isIn) {
  84412. return;
  84413. }
  84414. this._lightSources.splice(index, 1);
  84415. }
  84416. this._markSubMeshesAsLightDirty();
  84417. };
  84418. /** @hidden */
  84419. AbstractMesh.prototype._unBindEffect = function () {
  84420. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84421. var subMesh = _a[_i];
  84422. subMesh.setEffect(null);
  84423. }
  84424. };
  84425. /** @hidden */
  84426. AbstractMesh.prototype._removeLightSource = function (light) {
  84427. var index = this._lightSources.indexOf(light);
  84428. if (index === -1) {
  84429. return;
  84430. }
  84431. this._lightSources.splice(index, 1);
  84432. this._markSubMeshesAsLightDirty();
  84433. };
  84434. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  84435. if (!this.subMeshes) {
  84436. return;
  84437. }
  84438. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84439. var subMesh = _a[_i];
  84440. if (subMesh._materialDefines) {
  84441. func(subMesh._materialDefines);
  84442. }
  84443. }
  84444. };
  84445. /** @hidden */
  84446. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  84447. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  84448. };
  84449. /** @hidden */
  84450. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  84451. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  84452. };
  84453. /** @hidden */
  84454. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  84455. if (!this.subMeshes) {
  84456. return;
  84457. }
  84458. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84459. var subMesh = _a[_i];
  84460. var material = subMesh.getMaterial();
  84461. if (material) {
  84462. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  84463. }
  84464. }
  84465. };
  84466. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  84467. /**
  84468. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84469. */
  84470. get: function () {
  84471. return this._scaling;
  84472. },
  84473. set: function (newScaling) {
  84474. this._scaling = newScaling;
  84475. if (this.physicsImpostor) {
  84476. this.physicsImpostor.forceUpdate();
  84477. }
  84478. },
  84479. enumerable: true,
  84480. configurable: true
  84481. });
  84482. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  84483. // Methods
  84484. /**
  84485. * Returns true if the mesh is blocked. Implemented by child classes
  84486. */
  84487. get: function () {
  84488. return false;
  84489. },
  84490. enumerable: true,
  84491. configurable: true
  84492. });
  84493. /**
  84494. * Returns the mesh itself by default. Implemented by child classes
  84495. * @param camera defines the camera to use to pick the right LOD level
  84496. * @returns the currentAbstractMesh
  84497. */
  84498. AbstractMesh.prototype.getLOD = function (camera) {
  84499. return this;
  84500. };
  84501. /**
  84502. * Returns 0 by default. Implemented by child classes
  84503. * @returns an integer
  84504. */
  84505. AbstractMesh.prototype.getTotalVertices = function () {
  84506. return 0;
  84507. };
  84508. /**
  84509. * Returns a positive integer : the total number of indices in this mesh geometry.
  84510. * @returns the numner of indices or zero if the mesh has no geometry.
  84511. */
  84512. AbstractMesh.prototype.getTotalIndices = function () {
  84513. return 0;
  84514. };
  84515. /**
  84516. * Returns null by default. Implemented by child classes
  84517. * @returns null
  84518. */
  84519. AbstractMesh.prototype.getIndices = function () {
  84520. return null;
  84521. };
  84522. /**
  84523. * Returns the array of the requested vertex data kind. Implemented by child classes
  84524. * @param kind defines the vertex data kind to use
  84525. * @returns null
  84526. */
  84527. AbstractMesh.prototype.getVerticesData = function (kind) {
  84528. return null;
  84529. };
  84530. /**
  84531. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84532. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84533. * Note that a new underlying VertexBuffer object is created each call.
  84534. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84535. * @param kind defines vertex data kind:
  84536. * * VertexBuffer.PositionKind
  84537. * * VertexBuffer.UVKind
  84538. * * VertexBuffer.UV2Kind
  84539. * * VertexBuffer.UV3Kind
  84540. * * VertexBuffer.UV4Kind
  84541. * * VertexBuffer.UV5Kind
  84542. * * VertexBuffer.UV6Kind
  84543. * * VertexBuffer.ColorKind
  84544. * * VertexBuffer.MatricesIndicesKind
  84545. * * VertexBuffer.MatricesIndicesExtraKind
  84546. * * VertexBuffer.MatricesWeightsKind
  84547. * * VertexBuffer.MatricesWeightsExtraKind
  84548. * @param data defines the data source
  84549. * @param updatable defines if the data must be flagged as updatable (or static)
  84550. * @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
  84551. * @returns the current mesh
  84552. */
  84553. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  84554. return this;
  84555. };
  84556. /**
  84557. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84558. * If the mesh has no geometry, it is simply returned as it is.
  84559. * @param kind defines vertex data kind:
  84560. * * VertexBuffer.PositionKind
  84561. * * VertexBuffer.UVKind
  84562. * * VertexBuffer.UV2Kind
  84563. * * VertexBuffer.UV3Kind
  84564. * * VertexBuffer.UV4Kind
  84565. * * VertexBuffer.UV5Kind
  84566. * * VertexBuffer.UV6Kind
  84567. * * VertexBuffer.ColorKind
  84568. * * VertexBuffer.MatricesIndicesKind
  84569. * * VertexBuffer.MatricesIndicesExtraKind
  84570. * * VertexBuffer.MatricesWeightsKind
  84571. * * VertexBuffer.MatricesWeightsExtraKind
  84572. * @param data defines the data source
  84573. * @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
  84574. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84575. * @returns the current mesh
  84576. */
  84577. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  84578. return this;
  84579. };
  84580. /**
  84581. * Sets the mesh indices,
  84582. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84583. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84584. * @param totalVertices Defines the total number of vertices
  84585. * @returns the current mesh
  84586. */
  84587. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  84588. return this;
  84589. };
  84590. /**
  84591. * Gets a boolean indicating if specific vertex data is present
  84592. * @param kind defines the vertex data kind to use
  84593. * @returns true is data kind is present
  84594. */
  84595. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  84596. return false;
  84597. };
  84598. /**
  84599. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84600. * @returns a BoundingInfo
  84601. */
  84602. AbstractMesh.prototype.getBoundingInfo = function () {
  84603. if (this._masterMesh) {
  84604. return this._masterMesh.getBoundingInfo();
  84605. }
  84606. if (!this._boundingInfo) {
  84607. // this._boundingInfo is being created here
  84608. this._updateBoundingInfo();
  84609. }
  84610. // cannot be null.
  84611. return this._boundingInfo;
  84612. };
  84613. /**
  84614. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84615. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84616. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84617. * @returns the current mesh
  84618. */
  84619. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants, ignoreRotation) {
  84620. if (includeDescendants === void 0) { includeDescendants = true; }
  84621. if (ignoreRotation === void 0) { ignoreRotation = false; }
  84622. var storedRotation = null;
  84623. var storedRotationQuaternion = null;
  84624. if (ignoreRotation) {
  84625. if (this.rotationQuaternion) {
  84626. storedRotationQuaternion = this.rotationQuaternion.clone();
  84627. this.rotationQuaternion.copyFromFloats(0, 0, 0, 1);
  84628. }
  84629. else if (this.rotation) {
  84630. storedRotation = this.rotation.clone();
  84631. this.rotation.copyFromFloats(0, 0, 0);
  84632. }
  84633. }
  84634. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  84635. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  84636. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  84637. if (maxDimension === 0) {
  84638. return this;
  84639. }
  84640. var scale = 1 / maxDimension;
  84641. this.scaling.scaleInPlace(scale);
  84642. if (ignoreRotation) {
  84643. if (this.rotationQuaternion && storedRotationQuaternion) {
  84644. this.rotationQuaternion.copyFrom(storedRotationQuaternion);
  84645. }
  84646. else if (this.rotation && storedRotation) {
  84647. this.rotation.copyFrom(storedRotation);
  84648. }
  84649. }
  84650. return this;
  84651. };
  84652. /**
  84653. * Overwrite the current bounding info
  84654. * @param boundingInfo defines the new bounding info
  84655. * @returns the current mesh
  84656. */
  84657. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  84658. this._boundingInfo = boundingInfo;
  84659. return this;
  84660. };
  84661. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  84662. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84663. get: function () {
  84664. 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));
  84665. },
  84666. enumerable: true,
  84667. configurable: true
  84668. });
  84669. /** @hidden */
  84670. AbstractMesh.prototype._preActivate = function () {
  84671. };
  84672. /** @hidden */
  84673. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  84674. };
  84675. /** @hidden */
  84676. AbstractMesh.prototype._activate = function (renderId, intermediateRendering) {
  84677. this._renderId = renderId;
  84678. return true;
  84679. };
  84680. /** @hidden */
  84681. AbstractMesh.prototype._postActivate = function () {
  84682. // Do nothing
  84683. };
  84684. /** @hidden */
  84685. AbstractMesh.prototype._freeze = function () {
  84686. // Do nothing
  84687. };
  84688. /** @hidden */
  84689. AbstractMesh.prototype._unFreeze = function () {
  84690. // Do nothing
  84691. };
  84692. /**
  84693. * Gets the current world matrix
  84694. * @returns a Matrix
  84695. */
  84696. AbstractMesh.prototype.getWorldMatrix = function () {
  84697. if (this._masterMesh && this.billboardMode === _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE) {
  84698. return this._masterMesh.getWorldMatrix();
  84699. }
  84700. return _super.prototype.getWorldMatrix.call(this);
  84701. };
  84702. /** @hidden */
  84703. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  84704. if (this._masterMesh) {
  84705. return this._masterMesh._getWorldMatrixDeterminant();
  84706. }
  84707. return _super.prototype._getWorldMatrixDeterminant.call(this);
  84708. };
  84709. Object.defineProperty(AbstractMesh.prototype, "isAnInstance", {
  84710. /**
  84711. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  84712. */
  84713. get: function () {
  84714. return false;
  84715. },
  84716. enumerable: true,
  84717. configurable: true
  84718. });
  84719. // ================================== Point of View Movement =================================
  84720. /**
  84721. * Perform relative position change from the point of view of behind the front of the mesh.
  84722. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84723. * Supports definition of mesh facing forward or backward
  84724. * @param amountRight defines the distance on the right axis
  84725. * @param amountUp defines the distance on the up axis
  84726. * @param amountForward defines the distance on the forward axis
  84727. * @returns the current mesh
  84728. */
  84729. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  84730. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  84731. return this;
  84732. };
  84733. /**
  84734. * Calculate relative position change from the point of view of behind the front of the mesh.
  84735. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84736. * Supports definition of mesh facing forward or backward
  84737. * @param amountRight defines the distance on the right axis
  84738. * @param amountUp defines the distance on the up axis
  84739. * @param amountForward defines the distance on the forward axis
  84740. * @returns the new displacement vector
  84741. */
  84742. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  84743. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  84744. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  84745. rotQuaternion.toRotationMatrix(rotMatrix);
  84746. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  84747. var defForwardMult = this.definedFacingForward ? -1 : 1;
  84748. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  84749. return translationDelta;
  84750. };
  84751. // ================================== Point of View Rotation =================================
  84752. /**
  84753. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84754. * Supports definition of mesh facing forward or backward
  84755. * @param flipBack defines the flip
  84756. * @param twirlClockwise defines the twirl
  84757. * @param tiltRight defines the tilt
  84758. * @returns the current mesh
  84759. */
  84760. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  84761. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  84762. return this;
  84763. };
  84764. /**
  84765. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84766. * Supports definition of mesh facing forward or backward.
  84767. * @param flipBack defines the flip
  84768. * @param twirlClockwise defines the twirl
  84769. * @param tiltRight defines the tilt
  84770. * @returns the new rotation vector
  84771. */
  84772. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  84773. var defForwardMult = this.definedFacingForward ? 1 : -1;
  84774. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  84775. };
  84776. /**
  84777. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84778. * This means the mesh underlying bounding box and sphere are recomputed.
  84779. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84780. * @returns the current mesh
  84781. */
  84782. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  84783. if (applySkeleton === void 0) { applySkeleton = false; }
  84784. if (this._boundingInfo && this._boundingInfo.isLocked) {
  84785. return this;
  84786. }
  84787. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  84788. return this;
  84789. };
  84790. /** @hidden */
  84791. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  84792. if (data) {
  84793. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  84794. if (this._boundingInfo) {
  84795. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  84796. }
  84797. else {
  84798. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  84799. }
  84800. }
  84801. if (this.subMeshes) {
  84802. for (var index = 0; index < this.subMeshes.length; index++) {
  84803. this.subMeshes[index].refreshBoundingInfo(data);
  84804. }
  84805. }
  84806. this._updateBoundingInfo();
  84807. };
  84808. /** @hidden */
  84809. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  84810. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  84811. if (data && applySkeleton && this.skeleton) {
  84812. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  84813. this._generatePointsArray();
  84814. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  84815. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  84816. if (matricesWeightsData && matricesIndicesData) {
  84817. var needExtras = this.numBoneInfluencers > 4;
  84818. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  84819. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  84820. this.skeleton.prepare();
  84821. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  84822. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  84823. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  84824. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  84825. var matWeightIdx = 0;
  84826. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  84827. finalMatrix.reset();
  84828. var inf;
  84829. var weight;
  84830. for (inf = 0; inf < 4; inf++) {
  84831. weight = matricesWeightsData[matWeightIdx + inf];
  84832. if (weight > 0) {
  84833. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  84834. finalMatrix.addToSelf(tempMatrix);
  84835. }
  84836. }
  84837. if (needExtras) {
  84838. for (inf = 0; inf < 4; inf++) {
  84839. weight = matricesWeightsExtraData[matWeightIdx + inf];
  84840. if (weight > 0) {
  84841. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  84842. finalMatrix.addToSelf(tempMatrix);
  84843. }
  84844. }
  84845. }
  84846. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  84847. tempVector.toArray(data, index);
  84848. if (this._positions) {
  84849. this._positions[index / 3].copyFrom(tempVector);
  84850. }
  84851. }
  84852. }
  84853. }
  84854. return data;
  84855. };
  84856. /** @hidden */
  84857. AbstractMesh.prototype._updateBoundingInfo = function () {
  84858. var effectiveMesh = this._effectiveMesh;
  84859. if (this._boundingInfo) {
  84860. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  84861. }
  84862. else {
  84863. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  84864. }
  84865. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  84866. return this;
  84867. };
  84868. /** @hidden */
  84869. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  84870. if (!this.subMeshes) {
  84871. return this;
  84872. }
  84873. var count = this.subMeshes.length;
  84874. for (var subIndex = 0; subIndex < count; subIndex++) {
  84875. var subMesh = this.subMeshes[subIndex];
  84876. if (count > 1 || !subMesh.IsGlobal) {
  84877. subMesh.updateBoundingInfo(matrix);
  84878. }
  84879. }
  84880. return this;
  84881. };
  84882. /** @hidden */
  84883. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  84884. if (this.doNotSyncBoundingInfo) {
  84885. return;
  84886. }
  84887. // Bounding info
  84888. this._updateBoundingInfo();
  84889. };
  84890. Object.defineProperty(AbstractMesh.prototype, "_effectiveMesh", {
  84891. /** @hidden */
  84892. get: function () {
  84893. return (this.skeleton && this.skeleton.overrideMesh) || this;
  84894. },
  84895. enumerable: true,
  84896. configurable: true
  84897. });
  84898. /**
  84899. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84900. * A mesh is in the frustum if its bounding box intersects the frustum
  84901. * @param frustumPlanes defines the frustum to test
  84902. * @returns true if the mesh is in the frustum planes
  84903. */
  84904. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  84905. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  84906. };
  84907. /**
  84908. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84909. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84910. * @param frustumPlanes defines the frustum to test
  84911. * @returns true if the mesh is completely in the frustum planes
  84912. */
  84913. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  84914. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  84915. };
  84916. /**
  84917. * True if the mesh intersects another mesh or a SolidParticle object
  84918. * @param mesh defines a target mesh or SolidParticle to test
  84919. * @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)
  84920. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84921. * @returns true if there is an intersection
  84922. */
  84923. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  84924. if (precise === void 0) { precise = false; }
  84925. if (!this._boundingInfo || !mesh._boundingInfo) {
  84926. return false;
  84927. }
  84928. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  84929. return true;
  84930. }
  84931. if (includeDescendants) {
  84932. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  84933. var child = _a[_i];
  84934. if (child.intersectsMesh(mesh, precise, true)) {
  84935. return true;
  84936. }
  84937. }
  84938. }
  84939. return false;
  84940. };
  84941. /**
  84942. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84943. * @param point defines the point to test
  84944. * @returns true if there is an intersection
  84945. */
  84946. AbstractMesh.prototype.intersectsPoint = function (point) {
  84947. if (!this._boundingInfo) {
  84948. return false;
  84949. }
  84950. return this._boundingInfo.intersectsPoint(point);
  84951. };
  84952. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  84953. // Collisions
  84954. /**
  84955. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84956. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84957. */
  84958. get: function () {
  84959. return this._meshCollisionData._checkCollisions;
  84960. },
  84961. set: function (collisionEnabled) {
  84962. this._meshCollisionData._checkCollisions = collisionEnabled;
  84963. },
  84964. enumerable: true,
  84965. configurable: true
  84966. });
  84967. Object.defineProperty(AbstractMesh.prototype, "collider", {
  84968. /**
  84969. * Gets Collider object used to compute collisions (not physics)
  84970. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84971. */
  84972. get: function () {
  84973. return this._meshCollisionData._collider;
  84974. },
  84975. enumerable: true,
  84976. configurable: true
  84977. });
  84978. /**
  84979. * Move the mesh using collision engine
  84980. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84981. * @param displacement defines the requested displacement vector
  84982. * @returns the current mesh
  84983. */
  84984. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  84985. var globalPosition = this.getAbsolutePosition();
  84986. globalPosition.addToRef(this.ellipsoidOffset, this._meshCollisionData._oldPositionForCollisions);
  84987. var coordinator = this.getScene().collisionCoordinator;
  84988. if (!this._meshCollisionData._collider) {
  84989. this._meshCollisionData._collider = coordinator.createCollider();
  84990. }
  84991. this._meshCollisionData._collider._radius = this.ellipsoid;
  84992. coordinator.getNewPosition(this._meshCollisionData._oldPositionForCollisions, displacement, this._meshCollisionData._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  84993. return this;
  84994. };
  84995. // Collisions
  84996. /** @hidden */
  84997. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  84998. this._generatePointsArray();
  84999. if (!this._positions) {
  85000. return this;
  85001. }
  85002. // Transformation
  85003. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  85004. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  85005. subMesh._lastColliderWorldVertices = [];
  85006. subMesh._trianglePlanes = [];
  85007. var start = subMesh.verticesStart;
  85008. var end = (subMesh.verticesStart + subMesh.verticesCount);
  85009. for (var i = start; i < end; i++) {
  85010. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  85011. }
  85012. }
  85013. // Collide
  85014. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  85015. if (collider.collisionFound) {
  85016. collider.collidedMesh = this;
  85017. }
  85018. return this;
  85019. };
  85020. /** @hidden */
  85021. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  85022. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  85023. var len = subMeshes.length;
  85024. for (var index = 0; index < len; index++) {
  85025. var subMesh = subMeshes.data[index];
  85026. // Bounding test
  85027. if (len > 1 && !subMesh._checkCollision(collider)) {
  85028. continue;
  85029. }
  85030. this._collideForSubMesh(subMesh, transformMatrix, collider);
  85031. }
  85032. return this;
  85033. };
  85034. /** @hidden */
  85035. AbstractMesh.prototype._checkCollision = function (collider) {
  85036. // Bounding box test
  85037. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  85038. return this;
  85039. }
  85040. // Transformation matrix
  85041. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  85042. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  85043. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  85044. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  85045. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  85046. return this;
  85047. };
  85048. // Picking
  85049. /** @hidden */
  85050. AbstractMesh.prototype._generatePointsArray = function () {
  85051. return false;
  85052. };
  85053. /**
  85054. * Checks if the passed Ray intersects with the mesh
  85055. * @param ray defines the ray to use
  85056. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  85057. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85058. * @returns the picking info
  85059. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85060. */
  85061. AbstractMesh.prototype.intersects = function (ray, fastCheck, trianglePredicate) {
  85062. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  85063. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  85064. var boundingInfo = this._boundingInfo;
  85065. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  85066. return pickingInfo;
  85067. }
  85068. if (!this._generatePointsArray()) {
  85069. return pickingInfo;
  85070. }
  85071. var intersectInfo = null;
  85072. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  85073. var len = subMeshes.length;
  85074. for (var index = 0; index < len; index++) {
  85075. var subMesh = subMeshes.data[index];
  85076. // Bounding test
  85077. if (len > 1 && !subMesh.canIntersects(ray)) {
  85078. continue;
  85079. }
  85080. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck, trianglePredicate);
  85081. if (currentIntersectInfo) {
  85082. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  85083. intersectInfo = currentIntersectInfo;
  85084. intersectInfo.subMeshId = index;
  85085. if (fastCheck) {
  85086. break;
  85087. }
  85088. }
  85089. }
  85090. }
  85091. if (intersectInfo) {
  85092. // Get picked point
  85093. var world = this.getWorldMatrix();
  85094. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  85095. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  85096. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  85097. ray.direction.scaleToRef(intersectInfo.distance, direction);
  85098. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  85099. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  85100. // Return result
  85101. pickingInfo.hit = true;
  85102. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  85103. pickingInfo.pickedPoint = pickedPoint;
  85104. pickingInfo.pickedMesh = this;
  85105. pickingInfo.bu = intersectInfo.bu || 0;
  85106. pickingInfo.bv = intersectInfo.bv || 0;
  85107. pickingInfo.faceId = intersectInfo.faceId;
  85108. pickingInfo.subMeshId = intersectInfo.subMeshId;
  85109. return pickingInfo;
  85110. }
  85111. return pickingInfo;
  85112. };
  85113. /**
  85114. * Clones the current mesh
  85115. * @param name defines the mesh name
  85116. * @param newParent defines the new mesh parent
  85117. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  85118. * @returns the new mesh
  85119. */
  85120. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  85121. return null;
  85122. };
  85123. /**
  85124. * Disposes all the submeshes of the current meshnp
  85125. * @returns the current mesh
  85126. */
  85127. AbstractMesh.prototype.releaseSubMeshes = function () {
  85128. if (this.subMeshes) {
  85129. while (this.subMeshes.length) {
  85130. this.subMeshes[0].dispose();
  85131. }
  85132. }
  85133. else {
  85134. this.subMeshes = new Array();
  85135. }
  85136. return this;
  85137. };
  85138. /**
  85139. * Releases resources associated with this abstract mesh.
  85140. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85141. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85142. */
  85143. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  85144. var _this = this;
  85145. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  85146. var index;
  85147. // Smart Array Retainers.
  85148. this.getScene().freeActiveMeshes();
  85149. this.getScene().freeRenderingGroups();
  85150. // Action manager
  85151. if (this.actionManager !== undefined && this.actionManager !== null) {
  85152. this.actionManager.dispose();
  85153. this.actionManager = null;
  85154. }
  85155. // Skeleton
  85156. this._internalAbstractMeshDataInfo._skeleton = null;
  85157. // Intersections in progress
  85158. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  85159. var other = this._intersectionsInProgress[index];
  85160. var pos = other._intersectionsInProgress.indexOf(this);
  85161. other._intersectionsInProgress.splice(pos, 1);
  85162. }
  85163. this._intersectionsInProgress = [];
  85164. // Lights
  85165. var lights = this.getScene().lights;
  85166. lights.forEach(function (light) {
  85167. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  85168. if (meshIndex !== -1) {
  85169. light.includedOnlyMeshes.splice(meshIndex, 1);
  85170. }
  85171. meshIndex = light.excludedMeshes.indexOf(_this);
  85172. if (meshIndex !== -1) {
  85173. light.excludedMeshes.splice(meshIndex, 1);
  85174. }
  85175. // Shadow generators
  85176. var generator = light.getShadowGenerator();
  85177. if (generator) {
  85178. var shadowMap = generator.getShadowMap();
  85179. if (shadowMap && shadowMap.renderList) {
  85180. meshIndex = shadowMap.renderList.indexOf(_this);
  85181. if (meshIndex !== -1) {
  85182. shadowMap.renderList.splice(meshIndex, 1);
  85183. }
  85184. }
  85185. }
  85186. });
  85187. // SubMeshes
  85188. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  85189. this.releaseSubMeshes();
  85190. }
  85191. // Query
  85192. var engine = this.getScene().getEngine();
  85193. if (this._occlusionQuery) {
  85194. this.isOcclusionQueryInProgress = false;
  85195. engine.deleteQuery(this._occlusionQuery);
  85196. this._occlusionQuery = null;
  85197. }
  85198. // Engine
  85199. engine.wipeCaches();
  85200. // Remove from scene
  85201. this.getScene().removeMesh(this);
  85202. if (disposeMaterialAndTextures) {
  85203. if (this.material) {
  85204. if (this.material.getClassName() === "MultiMaterial") {
  85205. this.material.dispose(false, true, true);
  85206. }
  85207. else {
  85208. this.material.dispose(false, true);
  85209. }
  85210. }
  85211. }
  85212. if (!doNotRecurse) {
  85213. // Particles
  85214. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  85215. if (this.getScene().particleSystems[index].emitter === this) {
  85216. this.getScene().particleSystems[index].dispose();
  85217. index--;
  85218. }
  85219. }
  85220. }
  85221. // facet data
  85222. if (this._internalAbstractMeshDataInfo._facetData.facetDataEnabled) {
  85223. this.disableFacetData();
  85224. }
  85225. this.onAfterWorldMatrixUpdateObservable.clear();
  85226. this.onCollideObservable.clear();
  85227. this.onCollisionPositionChangeObservable.clear();
  85228. this.onRebuildObservable.clear();
  85229. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  85230. };
  85231. /**
  85232. * Adds the passed mesh as a child to the current mesh
  85233. * @param mesh defines the child mesh
  85234. * @returns the current mesh
  85235. */
  85236. AbstractMesh.prototype.addChild = function (mesh) {
  85237. mesh.setParent(this);
  85238. return this;
  85239. };
  85240. /**
  85241. * Removes the passed mesh from the current mesh children list
  85242. * @param mesh defines the child mesh
  85243. * @returns the current mesh
  85244. */
  85245. AbstractMesh.prototype.removeChild = function (mesh) {
  85246. mesh.setParent(null);
  85247. return this;
  85248. };
  85249. // Facet data
  85250. /** @hidden */
  85251. AbstractMesh.prototype._initFacetData = function () {
  85252. var data = this._internalAbstractMeshDataInfo._facetData;
  85253. if (!data.facetNormals) {
  85254. data.facetNormals = new Array();
  85255. }
  85256. if (!data.facetPositions) {
  85257. data.facetPositions = new Array();
  85258. }
  85259. if (!data.facetPartitioning) {
  85260. data.facetPartitioning = new Array();
  85261. }
  85262. data.facetNb = (this.getIndices().length / 3) | 0;
  85263. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  85264. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  85265. for (var f = 0; f < data.facetNb; f++) {
  85266. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  85267. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  85268. }
  85269. data.facetDataEnabled = true;
  85270. return this;
  85271. };
  85272. /**
  85273. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  85274. * This method can be called within the render loop.
  85275. * 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
  85276. * @returns the current mesh
  85277. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85278. */
  85279. AbstractMesh.prototype.updateFacetData = function () {
  85280. var data = this._internalAbstractMeshDataInfo._facetData;
  85281. if (!data.facetDataEnabled) {
  85282. this._initFacetData();
  85283. }
  85284. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  85285. var indices = this.getIndices();
  85286. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  85287. var bInfo = this.getBoundingInfo();
  85288. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  85289. // init arrays, matrix and sort function on first call
  85290. data.facetDepthSortEnabled = true;
  85291. if (indices instanceof Uint16Array) {
  85292. data.depthSortedIndices = new Uint16Array(indices);
  85293. }
  85294. else if (indices instanceof Uint32Array) {
  85295. data.depthSortedIndices = new Uint32Array(indices);
  85296. }
  85297. else {
  85298. var needs32bits = false;
  85299. for (var i = 0; i < indices.length; i++) {
  85300. if (indices[i] > 65535) {
  85301. needs32bits = true;
  85302. break;
  85303. }
  85304. }
  85305. if (needs32bits) {
  85306. data.depthSortedIndices = new Uint32Array(indices);
  85307. }
  85308. else {
  85309. data.depthSortedIndices = new Uint16Array(indices);
  85310. }
  85311. }
  85312. data.facetDepthSortFunction = function (f1, f2) {
  85313. return (f2.sqDistance - f1.sqDistance);
  85314. };
  85315. if (!data.facetDepthSortFrom) {
  85316. var camera = this.getScene().activeCamera;
  85317. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  85318. }
  85319. data.depthSortedFacets = [];
  85320. for (var f = 0; f < data.facetNb; f++) {
  85321. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  85322. data.depthSortedFacets.push(depthSortedFacet);
  85323. }
  85324. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  85325. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  85326. }
  85327. 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"];
  85328. 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"];
  85329. 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"];
  85330. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  85331. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  85332. data.subDiv.max = data.partitioningSubdivisions;
  85333. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  85334. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  85335. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  85336. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  85337. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  85338. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  85339. // set the parameters for ComputeNormals()
  85340. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  85341. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  85342. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  85343. data.facetParameters.bInfo = bInfo;
  85344. data.facetParameters.bbSize = data.bbSize;
  85345. data.facetParameters.subDiv = data.subDiv;
  85346. data.facetParameters.ratio = this.partitioningBBoxRatio;
  85347. data.facetParameters.depthSort = data.facetDepthSort;
  85348. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  85349. this.computeWorldMatrix(true);
  85350. this._worldMatrix.invertToRef(data.invertedMatrix);
  85351. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  85352. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  85353. }
  85354. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  85355. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  85356. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  85357. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  85358. var l = (data.depthSortedIndices.length / 3) | 0;
  85359. for (var f = 0; f < l; f++) {
  85360. var sind = data.depthSortedFacets[f].ind;
  85361. data.depthSortedIndices[f * 3] = indices[sind];
  85362. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  85363. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  85364. }
  85365. this.updateIndices(data.depthSortedIndices, undefined, true);
  85366. }
  85367. return this;
  85368. };
  85369. /**
  85370. * Returns the facetLocalNormals array.
  85371. * The normals are expressed in the mesh local spac
  85372. * @returns an array of Vector3
  85373. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85374. */
  85375. AbstractMesh.prototype.getFacetLocalNormals = function () {
  85376. var facetData = this._internalAbstractMeshDataInfo._facetData;
  85377. if (!facetData.facetNormals) {
  85378. this.updateFacetData();
  85379. }
  85380. return facetData.facetNormals;
  85381. };
  85382. /**
  85383. * Returns the facetLocalPositions array.
  85384. * The facet positions are expressed in the mesh local space
  85385. * @returns an array of Vector3
  85386. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85387. */
  85388. AbstractMesh.prototype.getFacetLocalPositions = function () {
  85389. var facetData = this._internalAbstractMeshDataInfo._facetData;
  85390. if (!facetData.facetPositions) {
  85391. this.updateFacetData();
  85392. }
  85393. return facetData.facetPositions;
  85394. };
  85395. /**
  85396. * Returns the facetLocalPartioning array
  85397. * @returns an array of array of numbers
  85398. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85399. */
  85400. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  85401. var facetData = this._internalAbstractMeshDataInfo._facetData;
  85402. if (!facetData.facetPartitioning) {
  85403. this.updateFacetData();
  85404. }
  85405. return facetData.facetPartitioning;
  85406. };
  85407. /**
  85408. * Returns the i-th facet position in the world system.
  85409. * This method allocates a new Vector3 per call
  85410. * @param i defines the facet index
  85411. * @returns a new Vector3
  85412. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85413. */
  85414. AbstractMesh.prototype.getFacetPosition = function (i) {
  85415. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  85416. this.getFacetPositionToRef(i, pos);
  85417. return pos;
  85418. };
  85419. /**
  85420. * Sets the reference Vector3 with the i-th facet position in the world system
  85421. * @param i defines the facet index
  85422. * @param ref defines the target vector
  85423. * @returns the current mesh
  85424. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85425. */
  85426. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  85427. var localPos = (this.getFacetLocalPositions())[i];
  85428. var world = this.getWorldMatrix();
  85429. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  85430. return this;
  85431. };
  85432. /**
  85433. * Returns the i-th facet normal in the world system.
  85434. * This method allocates a new Vector3 per call
  85435. * @param i defines the facet index
  85436. * @returns a new Vector3
  85437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85438. */
  85439. AbstractMesh.prototype.getFacetNormal = function (i) {
  85440. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  85441. this.getFacetNormalToRef(i, norm);
  85442. return norm;
  85443. };
  85444. /**
  85445. * Sets the reference Vector3 with the i-th facet normal in the world system
  85446. * @param i defines the facet index
  85447. * @param ref defines the target vector
  85448. * @returns the current mesh
  85449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85450. */
  85451. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  85452. var localNorm = (this.getFacetLocalNormals())[i];
  85453. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  85454. return this;
  85455. };
  85456. /**
  85457. * 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)
  85458. * @param x defines x coordinate
  85459. * @param y defines y coordinate
  85460. * @param z defines z coordinate
  85461. * @returns the array of facet indexes
  85462. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85463. */
  85464. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  85465. var bInfo = this.getBoundingInfo();
  85466. var data = this._internalAbstractMeshDataInfo._facetData;
  85467. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  85468. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  85469. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  85470. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  85471. return null;
  85472. }
  85473. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  85474. };
  85475. /**
  85476. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  85477. * @param projected sets as the (x,y,z) world projection on the facet
  85478. * @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
  85479. * @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
  85480. * @param x defines x coordinate
  85481. * @param y defines y coordinate
  85482. * @param z defines z coordinate
  85483. * @returns the face index if found (or null instead)
  85484. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85485. */
  85486. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  85487. if (checkFace === void 0) { checkFace = false; }
  85488. if (facing === void 0) { facing = true; }
  85489. var world = this.getWorldMatrix();
  85490. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  85491. world.invertToRef(invMat);
  85492. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  85493. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  85494. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  85495. if (projected) {
  85496. // tranform the local computed projected vector to world coordinates
  85497. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  85498. }
  85499. return closest;
  85500. };
  85501. /**
  85502. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  85503. * @param projected sets as the (x,y,z) local projection on the facet
  85504. * @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
  85505. * @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
  85506. * @param x defines x coordinate
  85507. * @param y defines y coordinate
  85508. * @param z defines z coordinate
  85509. * @returns the face index if found (or null instead)
  85510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85511. */
  85512. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  85513. if (checkFace === void 0) { checkFace = false; }
  85514. if (facing === void 0) { facing = true; }
  85515. var closest = null;
  85516. var tmpx = 0.0;
  85517. var tmpy = 0.0;
  85518. var tmpz = 0.0;
  85519. var d = 0.0; // tmp dot facet normal * facet position
  85520. var t0 = 0.0;
  85521. var projx = 0.0;
  85522. var projy = 0.0;
  85523. var projz = 0.0;
  85524. // Get all the facets in the same partitioning block than (x, y, z)
  85525. var facetPositions = this.getFacetLocalPositions();
  85526. var facetNormals = this.getFacetLocalNormals();
  85527. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  85528. if (!facetsInBlock) {
  85529. return null;
  85530. }
  85531. // Get the closest facet to (x, y, z)
  85532. var shortest = Number.MAX_VALUE; // init distance vars
  85533. var tmpDistance = shortest;
  85534. var fib; // current facet in the block
  85535. var norm; // current facet normal
  85536. var p0; // current facet barycenter position
  85537. // loop on all the facets in the current partitioning block
  85538. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  85539. fib = facetsInBlock[idx];
  85540. norm = facetNormals[fib];
  85541. p0 = facetPositions[fib];
  85542. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  85543. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  85544. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  85545. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  85546. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  85547. projx = x + norm.x * t0;
  85548. projy = y + norm.y * t0;
  85549. projz = z + norm.z * t0;
  85550. tmpx = projx - x;
  85551. tmpy = projy - y;
  85552. tmpz = projz - z;
  85553. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  85554. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  85555. shortest = tmpDistance;
  85556. closest = fib;
  85557. if (projected) {
  85558. projected.x = projx;
  85559. projected.y = projy;
  85560. projected.z = projz;
  85561. }
  85562. }
  85563. }
  85564. }
  85565. return closest;
  85566. };
  85567. /**
  85568. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  85569. * @returns the parameters
  85570. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85571. */
  85572. AbstractMesh.prototype.getFacetDataParameters = function () {
  85573. return this._internalAbstractMeshDataInfo._facetData.facetParameters;
  85574. };
  85575. /**
  85576. * Disables the feature FacetData and frees the related memory
  85577. * @returns the current mesh
  85578. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85579. */
  85580. AbstractMesh.prototype.disableFacetData = function () {
  85581. var facetData = this._internalAbstractMeshDataInfo._facetData;
  85582. if (facetData.facetDataEnabled) {
  85583. facetData.facetDataEnabled = false;
  85584. facetData.facetPositions = new Array();
  85585. facetData.facetNormals = new Array();
  85586. facetData.facetPartitioning = new Array();
  85587. facetData.facetParameters = null;
  85588. facetData.depthSortedIndices = new Uint32Array(0);
  85589. }
  85590. return this;
  85591. };
  85592. /**
  85593. * Updates the AbstractMesh indices array
  85594. * @param indices defines the data source
  85595. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  85596. * @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)
  85597. * @returns the current mesh
  85598. */
  85599. AbstractMesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  85600. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  85601. return this;
  85602. };
  85603. /**
  85604. * Creates new normals data for the mesh
  85605. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  85606. * @returns the current mesh
  85607. */
  85608. AbstractMesh.prototype.createNormals = function (updatable) {
  85609. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  85610. var indices = this.getIndices();
  85611. var normals;
  85612. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  85613. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  85614. }
  85615. else {
  85616. normals = [];
  85617. }
  85618. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  85619. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  85620. return this;
  85621. };
  85622. /**
  85623. * Align the mesh with a normal
  85624. * @param normal defines the normal to use
  85625. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  85626. * @returns the current mesh
  85627. */
  85628. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  85629. if (!upDirection) {
  85630. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  85631. }
  85632. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  85633. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  85634. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  85635. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  85636. if (this.rotationQuaternion) {
  85637. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  85638. }
  85639. else {
  85640. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  85641. }
  85642. return this;
  85643. };
  85644. /** @hidden */
  85645. AbstractMesh.prototype._checkOcclusionQuery = function () {
  85646. return false;
  85647. };
  85648. /**
  85649. * Disables the mesh edge rendering mode
  85650. * @returns the currentAbstractMesh
  85651. */
  85652. AbstractMesh.prototype.disableEdgesRendering = function () {
  85653. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_12__["_DevTools"].WarnImport("EdgesRenderer");
  85654. };
  85655. /**
  85656. * Enables the edge rendering mode on the mesh.
  85657. * This mode makes the mesh edges visible
  85658. * @param epsilon defines the maximal distance between two angles to detect a face
  85659. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85660. * @returns the currentAbstractMesh
  85661. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85662. */
  85663. AbstractMesh.prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  85664. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_12__["_DevTools"].WarnImport("EdgesRenderer");
  85665. };
  85666. /** No occlusion */
  85667. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  85668. /** Occlusion set to optimisitic */
  85669. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  85670. /** Occlusion set to strict */
  85671. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  85672. /** Use an accurante occlusion algorithm */
  85673. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  85674. /** Use a conservative occlusion algorithm */
  85675. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  85676. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  85677. * Test order :
  85678. * Is the bounding sphere outside the frustum ?
  85679. * If not, are the bounding box vertices outside the frustum ?
  85680. * It not, then the cullable object is in the frustum.
  85681. */
  85682. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  85683. /** Culling strategy : Bounding Sphere Only.
  85684. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  85685. * It's also less accurate than the standard because some not visible objects can still be selected.
  85686. * Test : is the bounding sphere outside the frustum ?
  85687. * If not, then the cullable object is in the frustum.
  85688. */
  85689. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  85690. /** Culling strategy : Optimistic Inclusion.
  85691. * This in an inclusion test first, then the standard exclusion test.
  85692. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  85693. * 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.
  85694. * Anyway, it's as accurate as the standard strategy.
  85695. * Test :
  85696. * Is the cullable object bounding sphere center in the frustum ?
  85697. * If not, apply the default culling strategy.
  85698. */
  85699. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  85700. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  85701. * This in an inclusion test first, then the bounding sphere only exclusion test.
  85702. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  85703. * 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.
  85704. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  85705. * Test :
  85706. * Is the cullable object bounding sphere center in the frustum ?
  85707. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  85708. */
  85709. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  85710. return AbstractMesh;
  85711. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  85712. /***/ }),
  85713. /***/ "./Meshes/buffer.ts":
  85714. /*!**************************!*\
  85715. !*** ./Meshes/buffer.ts ***!
  85716. \**************************/
  85717. /*! exports provided: Buffer, VertexBuffer */
  85718. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85719. "use strict";
  85720. __webpack_require__.r(__webpack_exports__);
  85721. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  85722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  85723. /**
  85724. * Class used to store data that will be store in GPU memory
  85725. */
  85726. var Buffer = /** @class */ (function () {
  85727. /**
  85728. * Constructor
  85729. * @param engine the engine
  85730. * @param data the data to use for this buffer
  85731. * @param updatable whether the data is updatable
  85732. * @param stride the stride (optional)
  85733. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85734. * @param instanced whether the buffer is instanced (optional)
  85735. * @param useBytes set to true if the stride in in bytes (optional)
  85736. */
  85737. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  85738. if (stride === void 0) { stride = 0; }
  85739. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  85740. if (instanced === void 0) { instanced = false; }
  85741. if (useBytes === void 0) { useBytes = false; }
  85742. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  85743. this._engine = engine.getScene().getEngine();
  85744. }
  85745. else {
  85746. this._engine = engine;
  85747. }
  85748. this._updatable = updatable;
  85749. this._instanced = instanced;
  85750. this._data = data;
  85751. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  85752. if (!postponeInternalCreation) { // by default
  85753. this.create();
  85754. }
  85755. }
  85756. /**
  85757. * Create a new VertexBuffer based on the current buffer
  85758. * @param kind defines the vertex buffer kind (position, normal, etc.)
  85759. * @param offset defines offset in the buffer (0 by default)
  85760. * @param size defines the size in floats of attributes (position is 3 for instance)
  85761. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  85762. * @param instanced defines if the vertex buffer contains indexed data
  85763. * @param useBytes defines if the offset and stride are in bytes
  85764. * @returns the new vertex buffer
  85765. */
  85766. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  85767. if (useBytes === void 0) { useBytes = false; }
  85768. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  85769. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  85770. // a lot of these parameters are ignored as they are overriden by the buffer
  85771. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  85772. };
  85773. // Properties
  85774. /**
  85775. * Gets a boolean indicating if the Buffer is updatable?
  85776. * @returns true if the buffer is updatable
  85777. */
  85778. Buffer.prototype.isUpdatable = function () {
  85779. return this._updatable;
  85780. };
  85781. /**
  85782. * Gets current buffer's data
  85783. * @returns a DataArray or null
  85784. */
  85785. Buffer.prototype.getData = function () {
  85786. return this._data;
  85787. };
  85788. /**
  85789. * Gets underlying native buffer
  85790. * @returns underlying native buffer
  85791. */
  85792. Buffer.prototype.getBuffer = function () {
  85793. return this._buffer;
  85794. };
  85795. /**
  85796. * Gets the stride in float32 units (i.e. byte stride / 4).
  85797. * May not be an integer if the byte stride is not divisible by 4.
  85798. * DEPRECATED. Use byteStride instead.
  85799. * @returns the stride in float32 units
  85800. */
  85801. Buffer.prototype.getStrideSize = function () {
  85802. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  85803. };
  85804. // Methods
  85805. /**
  85806. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85807. * @param data defines the data to store
  85808. */
  85809. Buffer.prototype.create = function (data) {
  85810. if (data === void 0) { data = null; }
  85811. if (!data && this._buffer) {
  85812. return; // nothing to do
  85813. }
  85814. data = data || this._data;
  85815. if (!data) {
  85816. return;
  85817. }
  85818. if (!this._buffer) { // create buffer
  85819. if (this._updatable) {
  85820. this._buffer = this._engine.createDynamicVertexBuffer(data);
  85821. this._data = data;
  85822. }
  85823. else {
  85824. this._buffer = this._engine.createVertexBuffer(data);
  85825. }
  85826. }
  85827. else if (this._updatable) { // update buffer
  85828. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  85829. this._data = data;
  85830. }
  85831. };
  85832. /** @hidden */
  85833. Buffer.prototype._rebuild = function () {
  85834. this._buffer = null;
  85835. this.create(this._data);
  85836. };
  85837. /**
  85838. * Update current buffer data
  85839. * @param data defines the data to store
  85840. */
  85841. Buffer.prototype.update = function (data) {
  85842. this.create(data);
  85843. };
  85844. /**
  85845. * Updates the data directly.
  85846. * @param data the new data
  85847. * @param offset the new offset
  85848. * @param vertexCount the vertex count (optional)
  85849. * @param useBytes set to true if the offset is in bytes
  85850. */
  85851. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  85852. if (useBytes === void 0) { useBytes = false; }
  85853. if (!this._buffer) {
  85854. return;
  85855. }
  85856. if (this._updatable) { // update buffer
  85857. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  85858. this._data = null;
  85859. }
  85860. };
  85861. /**
  85862. * Release all resources
  85863. */
  85864. Buffer.prototype.dispose = function () {
  85865. if (!this._buffer) {
  85866. return;
  85867. }
  85868. if (this._engine._releaseBuffer(this._buffer)) {
  85869. this._buffer = null;
  85870. }
  85871. };
  85872. return Buffer;
  85873. }());
  85874. /**
  85875. * Specialized buffer used to store vertex data
  85876. */
  85877. var VertexBuffer = /** @class */ (function () {
  85878. /**
  85879. * Constructor
  85880. * @param engine the engine
  85881. * @param data the data to use for this vertex buffer
  85882. * @param kind the vertex buffer kind
  85883. * @param updatable whether the data is updatable
  85884. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85885. * @param stride the stride (optional)
  85886. * @param instanced whether the buffer is instanced (optional)
  85887. * @param offset the offset of the data (optional)
  85888. * @param size the number of components (optional)
  85889. * @param type the type of the component (optional)
  85890. * @param normalized whether the data contains normalized data (optional)
  85891. * @param useBytes set to true if stride and offset are in bytes (optional)
  85892. */
  85893. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  85894. if (normalized === void 0) { normalized = false; }
  85895. if (useBytes === void 0) { useBytes = false; }
  85896. if (data instanceof Buffer) {
  85897. this._buffer = data;
  85898. this._ownsBuffer = false;
  85899. }
  85900. else {
  85901. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  85902. this._ownsBuffer = true;
  85903. }
  85904. this._kind = kind;
  85905. if (type == undefined) {
  85906. var data_1 = this.getData();
  85907. this.type = VertexBuffer.FLOAT;
  85908. if (data_1 instanceof Int8Array) {
  85909. this.type = VertexBuffer.BYTE;
  85910. }
  85911. else if (data_1 instanceof Uint8Array) {
  85912. this.type = VertexBuffer.UNSIGNED_BYTE;
  85913. }
  85914. else if (data_1 instanceof Int16Array) {
  85915. this.type = VertexBuffer.SHORT;
  85916. }
  85917. else if (data_1 instanceof Uint16Array) {
  85918. this.type = VertexBuffer.UNSIGNED_SHORT;
  85919. }
  85920. else if (data_1 instanceof Int32Array) {
  85921. this.type = VertexBuffer.INT;
  85922. }
  85923. else if (data_1 instanceof Uint32Array) {
  85924. this.type = VertexBuffer.UNSIGNED_INT;
  85925. }
  85926. }
  85927. else {
  85928. this.type = type;
  85929. }
  85930. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  85931. if (useBytes) {
  85932. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  85933. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  85934. this.byteOffset = offset || 0;
  85935. }
  85936. else {
  85937. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  85938. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  85939. this.byteOffset = (offset || 0) * typeByteLength;
  85940. }
  85941. this.normalized = normalized;
  85942. this._instanced = instanced !== undefined ? instanced : false;
  85943. this._instanceDivisor = instanced ? 1 : 0;
  85944. }
  85945. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  85946. /**
  85947. * Gets or sets the instance divisor when in instanced mode
  85948. */
  85949. get: function () {
  85950. return this._instanceDivisor;
  85951. },
  85952. set: function (value) {
  85953. this._instanceDivisor = value;
  85954. if (value == 0) {
  85955. this._instanced = false;
  85956. }
  85957. else {
  85958. this._instanced = true;
  85959. }
  85960. },
  85961. enumerable: true,
  85962. configurable: true
  85963. });
  85964. /** @hidden */
  85965. VertexBuffer.prototype._rebuild = function () {
  85966. if (!this._buffer) {
  85967. return;
  85968. }
  85969. this._buffer._rebuild();
  85970. };
  85971. /**
  85972. * Returns the kind of the VertexBuffer (string)
  85973. * @returns a string
  85974. */
  85975. VertexBuffer.prototype.getKind = function () {
  85976. return this._kind;
  85977. };
  85978. // Properties
  85979. /**
  85980. * Gets a boolean indicating if the VertexBuffer is updatable?
  85981. * @returns true if the buffer is updatable
  85982. */
  85983. VertexBuffer.prototype.isUpdatable = function () {
  85984. return this._buffer.isUpdatable();
  85985. };
  85986. /**
  85987. * Gets current buffer's data
  85988. * @returns a DataArray or null
  85989. */
  85990. VertexBuffer.prototype.getData = function () {
  85991. return this._buffer.getData();
  85992. };
  85993. /**
  85994. * Gets underlying native buffer
  85995. * @returns underlying native buffer
  85996. */
  85997. VertexBuffer.prototype.getBuffer = function () {
  85998. return this._buffer.getBuffer();
  85999. };
  86000. /**
  86001. * Gets the stride in float32 units (i.e. byte stride / 4).
  86002. * May not be an integer if the byte stride is not divisible by 4.
  86003. * DEPRECATED. Use byteStride instead.
  86004. * @returns the stride in float32 units
  86005. */
  86006. VertexBuffer.prototype.getStrideSize = function () {
  86007. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  86008. };
  86009. /**
  86010. * Returns the offset as a multiple of the type byte length.
  86011. * DEPRECATED. Use byteOffset instead.
  86012. * @returns the offset in bytes
  86013. */
  86014. VertexBuffer.prototype.getOffset = function () {
  86015. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  86016. };
  86017. /**
  86018. * Returns the number of components per vertex attribute (integer)
  86019. * @returns the size in float
  86020. */
  86021. VertexBuffer.prototype.getSize = function () {
  86022. return this._size;
  86023. };
  86024. /**
  86025. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  86026. * @returns true if this buffer is instanced
  86027. */
  86028. VertexBuffer.prototype.getIsInstanced = function () {
  86029. return this._instanced;
  86030. };
  86031. /**
  86032. * Returns the instancing divisor, zero for non-instanced (integer).
  86033. * @returns a number
  86034. */
  86035. VertexBuffer.prototype.getInstanceDivisor = function () {
  86036. return this._instanceDivisor;
  86037. };
  86038. // Methods
  86039. /**
  86040. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86041. * @param data defines the data to store
  86042. */
  86043. VertexBuffer.prototype.create = function (data) {
  86044. this._buffer.create(data);
  86045. };
  86046. /**
  86047. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  86048. * This function will create a new buffer if the current one is not updatable
  86049. * @param data defines the data to store
  86050. */
  86051. VertexBuffer.prototype.update = function (data) {
  86052. this._buffer.update(data);
  86053. };
  86054. /**
  86055. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  86056. * Returns the directly updated WebGLBuffer.
  86057. * @param data the new data
  86058. * @param offset the new offset
  86059. * @param useBytes set to true if the offset is in bytes
  86060. */
  86061. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  86062. if (useBytes === void 0) { useBytes = false; }
  86063. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  86064. };
  86065. /**
  86066. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  86067. */
  86068. VertexBuffer.prototype.dispose = function () {
  86069. if (this._ownsBuffer) {
  86070. this._buffer.dispose();
  86071. }
  86072. };
  86073. /**
  86074. * Enumerates each value of this vertex buffer as numbers.
  86075. * @param count the number of values to enumerate
  86076. * @param callback the callback function called for each value
  86077. */
  86078. VertexBuffer.prototype.forEach = function (count, callback) {
  86079. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  86080. };
  86081. /**
  86082. * Deduces the stride given a kind.
  86083. * @param kind The kind string to deduce
  86084. * @returns The deduced stride
  86085. */
  86086. VertexBuffer.DeduceStride = function (kind) {
  86087. switch (kind) {
  86088. case VertexBuffer.UVKind:
  86089. case VertexBuffer.UV2Kind:
  86090. case VertexBuffer.UV3Kind:
  86091. case VertexBuffer.UV4Kind:
  86092. case VertexBuffer.UV5Kind:
  86093. case VertexBuffer.UV6Kind:
  86094. return 2;
  86095. case VertexBuffer.NormalKind:
  86096. case VertexBuffer.PositionKind:
  86097. return 3;
  86098. case VertexBuffer.ColorKind:
  86099. case VertexBuffer.MatricesIndicesKind:
  86100. case VertexBuffer.MatricesIndicesExtraKind:
  86101. case VertexBuffer.MatricesWeightsKind:
  86102. case VertexBuffer.MatricesWeightsExtraKind:
  86103. case VertexBuffer.TangentKind:
  86104. return 4;
  86105. default:
  86106. throw new Error("Invalid kind '" + kind + "'");
  86107. }
  86108. };
  86109. /**
  86110. * Gets the byte length of the given type.
  86111. * @param type the type
  86112. * @returns the number of bytes
  86113. */
  86114. VertexBuffer.GetTypeByteLength = function (type) {
  86115. switch (type) {
  86116. case VertexBuffer.BYTE:
  86117. case VertexBuffer.UNSIGNED_BYTE:
  86118. return 1;
  86119. case VertexBuffer.SHORT:
  86120. case VertexBuffer.UNSIGNED_SHORT:
  86121. return 2;
  86122. case VertexBuffer.INT:
  86123. case VertexBuffer.FLOAT:
  86124. return 4;
  86125. default:
  86126. throw new Error("Invalid type '" + type + "'");
  86127. }
  86128. };
  86129. /**
  86130. * Enumerates each value of the given parameters as numbers.
  86131. * @param data the data to enumerate
  86132. * @param byteOffset the byte offset of the data
  86133. * @param byteStride the byte stride of the data
  86134. * @param componentCount the number of components per element
  86135. * @param componentType the type of the component
  86136. * @param count the total number of components
  86137. * @param normalized whether the data is normalized
  86138. * @param callback the callback function called for each value
  86139. */
  86140. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  86141. if (data instanceof Array) {
  86142. var offset = byteOffset / 4;
  86143. var stride = byteStride / 4;
  86144. for (var index = 0; index < count; index += componentCount) {
  86145. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  86146. callback(data[offset + componentIndex], index + componentIndex);
  86147. }
  86148. offset += stride;
  86149. }
  86150. }
  86151. else {
  86152. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  86153. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  86154. for (var index = 0; index < count; index += componentCount) {
  86155. var componentByteOffset = byteOffset;
  86156. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  86157. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  86158. callback(value, index + componentIndex);
  86159. componentByteOffset += componentByteLength;
  86160. }
  86161. byteOffset += byteStride;
  86162. }
  86163. }
  86164. };
  86165. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  86166. switch (type) {
  86167. case VertexBuffer.BYTE: {
  86168. var value = dataView.getInt8(byteOffset);
  86169. if (normalized) {
  86170. value = Math.max(value / 127, -1);
  86171. }
  86172. return value;
  86173. }
  86174. case VertexBuffer.UNSIGNED_BYTE: {
  86175. var value = dataView.getUint8(byteOffset);
  86176. if (normalized) {
  86177. value = value / 255;
  86178. }
  86179. return value;
  86180. }
  86181. case VertexBuffer.SHORT: {
  86182. var value = dataView.getInt16(byteOffset, true);
  86183. if (normalized) {
  86184. value = Math.max(value / 16383, -1);
  86185. }
  86186. return value;
  86187. }
  86188. case VertexBuffer.UNSIGNED_SHORT: {
  86189. var value = dataView.getUint16(byteOffset, true);
  86190. if (normalized) {
  86191. value = value / 65535;
  86192. }
  86193. return value;
  86194. }
  86195. case VertexBuffer.FLOAT: {
  86196. return dataView.getFloat32(byteOffset, true);
  86197. }
  86198. default: {
  86199. throw new Error("Invalid component type " + type);
  86200. }
  86201. }
  86202. };
  86203. /**
  86204. * The byte type.
  86205. */
  86206. VertexBuffer.BYTE = 5120;
  86207. /**
  86208. * The unsigned byte type.
  86209. */
  86210. VertexBuffer.UNSIGNED_BYTE = 5121;
  86211. /**
  86212. * The short type.
  86213. */
  86214. VertexBuffer.SHORT = 5122;
  86215. /**
  86216. * The unsigned short type.
  86217. */
  86218. VertexBuffer.UNSIGNED_SHORT = 5123;
  86219. /**
  86220. * The integer type.
  86221. */
  86222. VertexBuffer.INT = 5124;
  86223. /**
  86224. * The unsigned integer type.
  86225. */
  86226. VertexBuffer.UNSIGNED_INT = 5125;
  86227. /**
  86228. * The float type.
  86229. */
  86230. VertexBuffer.FLOAT = 5126;
  86231. // Enums
  86232. /**
  86233. * Positions
  86234. */
  86235. VertexBuffer.PositionKind = "position";
  86236. /**
  86237. * Normals
  86238. */
  86239. VertexBuffer.NormalKind = "normal";
  86240. /**
  86241. * Tangents
  86242. */
  86243. VertexBuffer.TangentKind = "tangent";
  86244. /**
  86245. * Texture coordinates
  86246. */
  86247. VertexBuffer.UVKind = "uv";
  86248. /**
  86249. * Texture coordinates 2
  86250. */
  86251. VertexBuffer.UV2Kind = "uv2";
  86252. /**
  86253. * Texture coordinates 3
  86254. */
  86255. VertexBuffer.UV3Kind = "uv3";
  86256. /**
  86257. * Texture coordinates 4
  86258. */
  86259. VertexBuffer.UV4Kind = "uv4";
  86260. /**
  86261. * Texture coordinates 5
  86262. */
  86263. VertexBuffer.UV5Kind = "uv5";
  86264. /**
  86265. * Texture coordinates 6
  86266. */
  86267. VertexBuffer.UV6Kind = "uv6";
  86268. /**
  86269. * Colors
  86270. */
  86271. VertexBuffer.ColorKind = "color";
  86272. /**
  86273. * Matrix indices (for bones)
  86274. */
  86275. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  86276. /**
  86277. * Matrix weights (for bones)
  86278. */
  86279. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  86280. /**
  86281. * Additional matrix indices (for bones)
  86282. */
  86283. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  86284. /**
  86285. * Additional matrix weights (for bones)
  86286. */
  86287. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  86288. return VertexBuffer;
  86289. }());
  86290. /***/ }),
  86291. /***/ "./Meshes/csg.ts":
  86292. /*!***********************!*\
  86293. !*** ./Meshes/csg.ts ***!
  86294. \***********************/
  86295. /*! exports provided: CSG */
  86296. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86297. "use strict";
  86298. __webpack_require__.r(__webpack_exports__);
  86299. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  86300. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  86301. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  86302. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  86303. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  86304. /**
  86305. * Unique ID when we import meshes from Babylon to CSG
  86306. */
  86307. var currentCSGMeshId = 0;
  86308. /**
  86309. * Represents a vertex of a polygon. Use your own vertex class instead of this
  86310. * one to provide additional features like texture coordinates and vertex
  86311. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  86312. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  86313. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  86314. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  86315. * is not used anywhere else.
  86316. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  86317. */
  86318. var Vertex = /** @class */ (function () {
  86319. /**
  86320. * Initializes the vertex
  86321. * @param pos The position of the vertex
  86322. * @param normal The normal of the vertex
  86323. * @param uv The texture coordinate of the vertex
  86324. */
  86325. function Vertex(
  86326. /**
  86327. * The position of the vertex
  86328. */
  86329. pos,
  86330. /**
  86331. * The normal of the vertex
  86332. */
  86333. normal,
  86334. /**
  86335. * The texture coordinate of the vertex
  86336. */
  86337. uv) {
  86338. this.pos = pos;
  86339. this.normal = normal;
  86340. this.uv = uv;
  86341. }
  86342. /**
  86343. * Make a clone, or deep copy, of the vertex
  86344. * @returns A new Vertex
  86345. */
  86346. Vertex.prototype.clone = function () {
  86347. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  86348. };
  86349. /**
  86350. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  86351. * orientation of a polygon is flipped.
  86352. */
  86353. Vertex.prototype.flip = function () {
  86354. this.normal = this.normal.scale(-1);
  86355. };
  86356. /**
  86357. * Create a new vertex between this vertex and `other` by linearly
  86358. * interpolating all properties using a parameter of `t`. Subclasses should
  86359. * override this to interpolate additional properties.
  86360. * @param other the vertex to interpolate against
  86361. * @param t The factor used to linearly interpolate between the vertices
  86362. */
  86363. Vertex.prototype.interpolate = function (other, t) {
  86364. 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));
  86365. };
  86366. return Vertex;
  86367. }());
  86368. /**
  86369. * Represents a plane in 3D space.
  86370. */
  86371. var Plane = /** @class */ (function () {
  86372. /**
  86373. * Initializes the plane
  86374. * @param normal The normal for the plane
  86375. * @param w
  86376. */
  86377. function Plane(normal, w) {
  86378. this.normal = normal;
  86379. this.w = w;
  86380. }
  86381. /**
  86382. * Construct a plane from three points
  86383. * @param a Point a
  86384. * @param b Point b
  86385. * @param c Point c
  86386. */
  86387. Plane.FromPoints = function (a, b, c) {
  86388. var v0 = c.subtract(a);
  86389. var v1 = b.subtract(a);
  86390. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  86391. return null;
  86392. }
  86393. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  86394. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  86395. };
  86396. /**
  86397. * Clone, or make a deep copy of the plane
  86398. * @returns a new Plane
  86399. */
  86400. Plane.prototype.clone = function () {
  86401. return new Plane(this.normal.clone(), this.w);
  86402. };
  86403. /**
  86404. * Flip the face of the plane
  86405. */
  86406. Plane.prototype.flip = function () {
  86407. this.normal.scaleInPlace(-1);
  86408. this.w = -this.w;
  86409. };
  86410. /**
  86411. * Split `polygon` by this plane if needed, then put the polygon or polygon
  86412. * fragments in the appropriate lists. Coplanar polygons go into either
  86413. `* coplanarFront` or `coplanarBack` depending on their orientation with
  86414. * respect to this plane. Polygons in front or in back of this plane go into
  86415. * either `front` or `back`
  86416. * @param polygon The polygon to be split
  86417. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  86418. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  86419. * @param front Will contain the polygons in front of the plane
  86420. * @param back Will contain the polygons begind the plane
  86421. */
  86422. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  86423. var COPLANAR = 0;
  86424. var FRONT = 1;
  86425. var BACK = 2;
  86426. var SPANNING = 3;
  86427. // Classify each point as well as the entire polygon into one of the above
  86428. // four classes.
  86429. var polygonType = 0;
  86430. var types = [];
  86431. var i;
  86432. var t;
  86433. for (i = 0; i < polygon.vertices.length; i++) {
  86434. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  86435. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  86436. polygonType |= type;
  86437. types.push(type);
  86438. }
  86439. // Put the polygon in the correct list, splitting it when necessary
  86440. switch (polygonType) {
  86441. case COPLANAR:
  86442. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  86443. break;
  86444. case FRONT:
  86445. front.push(polygon);
  86446. break;
  86447. case BACK:
  86448. back.push(polygon);
  86449. break;
  86450. case SPANNING:
  86451. var f = [], b = [];
  86452. for (i = 0; i < polygon.vertices.length; i++) {
  86453. var j = (i + 1) % polygon.vertices.length;
  86454. var ti = types[i], tj = types[j];
  86455. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  86456. if (ti !== BACK) {
  86457. f.push(vi);
  86458. }
  86459. if (ti !== FRONT) {
  86460. b.push(ti !== BACK ? vi.clone() : vi);
  86461. }
  86462. if ((ti | tj) === SPANNING) {
  86463. 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));
  86464. var v = vi.interpolate(vj, t);
  86465. f.push(v);
  86466. b.push(v.clone());
  86467. }
  86468. }
  86469. var poly;
  86470. if (f.length >= 3) {
  86471. poly = new Polygon(f, polygon.shared);
  86472. if (poly.plane) {
  86473. front.push(poly);
  86474. }
  86475. }
  86476. if (b.length >= 3) {
  86477. poly = new Polygon(b, polygon.shared);
  86478. if (poly.plane) {
  86479. back.push(poly);
  86480. }
  86481. }
  86482. break;
  86483. }
  86484. };
  86485. /**
  86486. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  86487. * point is on the plane
  86488. */
  86489. Plane.EPSILON = 1e-5;
  86490. return Plane;
  86491. }());
  86492. /**
  86493. * Represents a convex polygon. The vertices used to initialize a polygon must
  86494. * be coplanar and form a convex loop.
  86495. *
  86496. * Each convex polygon has a `shared` property, which is shared between all
  86497. * polygons that are clones of each other or were split from the same polygon.
  86498. * This can be used to define per-polygon properties (such as surface color)
  86499. */
  86500. var Polygon = /** @class */ (function () {
  86501. /**
  86502. * Initializes the polygon
  86503. * @param vertices The vertices of the polygon
  86504. * @param shared The properties shared across all polygons
  86505. */
  86506. function Polygon(vertices, shared) {
  86507. this.vertices = vertices;
  86508. this.shared = shared;
  86509. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  86510. }
  86511. /**
  86512. * Clones, or makes a deep copy, or the polygon
  86513. */
  86514. Polygon.prototype.clone = function () {
  86515. var vertices = this.vertices.map(function (v) { return v.clone(); });
  86516. return new Polygon(vertices, this.shared);
  86517. };
  86518. /**
  86519. * Flips the faces of the polygon
  86520. */
  86521. Polygon.prototype.flip = function () {
  86522. this.vertices.reverse().map(function (v) { v.flip(); });
  86523. this.plane.flip();
  86524. };
  86525. return Polygon;
  86526. }());
  86527. /**
  86528. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  86529. * by picking a polygon to split along. That polygon (and all other coplanar
  86530. * polygons) are added directly to that node and the other polygons are added to
  86531. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  86532. * no distinction between internal and leaf nodes
  86533. */
  86534. var Node = /** @class */ (function () {
  86535. /**
  86536. * Initializes the node
  86537. * @param polygons A collection of polygons held in the node
  86538. */
  86539. function Node(polygons) {
  86540. this.plane = null;
  86541. this.front = null;
  86542. this.back = null;
  86543. this.polygons = new Array();
  86544. if (polygons) {
  86545. this.build(polygons);
  86546. }
  86547. }
  86548. /**
  86549. * Clones, or makes a deep copy, of the node
  86550. * @returns The cloned node
  86551. */
  86552. Node.prototype.clone = function () {
  86553. var node = new Node();
  86554. node.plane = this.plane && this.plane.clone();
  86555. node.front = this.front && this.front.clone();
  86556. node.back = this.back && this.back.clone();
  86557. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  86558. return node;
  86559. };
  86560. /**
  86561. * Convert solid space to empty space and empty space to solid space
  86562. */
  86563. Node.prototype.invert = function () {
  86564. for (var i = 0; i < this.polygons.length; i++) {
  86565. this.polygons[i].flip();
  86566. }
  86567. if (this.plane) {
  86568. this.plane.flip();
  86569. }
  86570. if (this.front) {
  86571. this.front.invert();
  86572. }
  86573. if (this.back) {
  86574. this.back.invert();
  86575. }
  86576. var temp = this.front;
  86577. this.front = this.back;
  86578. this.back = temp;
  86579. };
  86580. /**
  86581. * Recursively remove all polygons in `polygons` that are inside this BSP
  86582. * tree.
  86583. * @param polygons Polygons to remove from the BSP
  86584. * @returns Polygons clipped from the BSP
  86585. */
  86586. Node.prototype.clipPolygons = function (polygons) {
  86587. if (!this.plane) {
  86588. return polygons.slice();
  86589. }
  86590. var front = new Array(), back = new Array();
  86591. for (var i = 0; i < polygons.length; i++) {
  86592. this.plane.splitPolygon(polygons[i], front, back, front, back);
  86593. }
  86594. if (this.front) {
  86595. front = this.front.clipPolygons(front);
  86596. }
  86597. if (this.back) {
  86598. back = this.back.clipPolygons(back);
  86599. }
  86600. else {
  86601. back = [];
  86602. }
  86603. return front.concat(back);
  86604. };
  86605. /**
  86606. * Remove all polygons in this BSP tree that are inside the other BSP tree
  86607. * `bsp`.
  86608. * @param bsp BSP containing polygons to remove from this BSP
  86609. */
  86610. Node.prototype.clipTo = function (bsp) {
  86611. this.polygons = bsp.clipPolygons(this.polygons);
  86612. if (this.front) {
  86613. this.front.clipTo(bsp);
  86614. }
  86615. if (this.back) {
  86616. this.back.clipTo(bsp);
  86617. }
  86618. };
  86619. /**
  86620. * Return a list of all polygons in this BSP tree
  86621. * @returns List of all polygons in this BSP tree
  86622. */
  86623. Node.prototype.allPolygons = function () {
  86624. var polygons = this.polygons.slice();
  86625. if (this.front) {
  86626. polygons = polygons.concat(this.front.allPolygons());
  86627. }
  86628. if (this.back) {
  86629. polygons = polygons.concat(this.back.allPolygons());
  86630. }
  86631. return polygons;
  86632. };
  86633. /**
  86634. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  86635. * new polygons are filtered down to the bottom of the tree and become new
  86636. * nodes there. Each set of polygons is partitioned using the first polygon
  86637. * (no heuristic is used to pick a good split)
  86638. * @param polygons Polygons used to construct the BSP tree
  86639. */
  86640. Node.prototype.build = function (polygons) {
  86641. if (!polygons.length) {
  86642. return;
  86643. }
  86644. if (!this.plane) {
  86645. this.plane = polygons[0].plane.clone();
  86646. }
  86647. var front = new Array(), back = new Array();
  86648. for (var i = 0; i < polygons.length; i++) {
  86649. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  86650. }
  86651. if (front.length) {
  86652. if (!this.front) {
  86653. this.front = new Node();
  86654. }
  86655. this.front.build(front);
  86656. }
  86657. if (back.length) {
  86658. if (!this.back) {
  86659. this.back = new Node();
  86660. }
  86661. this.back.build(back);
  86662. }
  86663. };
  86664. return Node;
  86665. }());
  86666. /**
  86667. * Class for building Constructive Solid Geometry
  86668. */
  86669. var CSG = /** @class */ (function () {
  86670. function CSG() {
  86671. this.polygons = new Array();
  86672. }
  86673. /**
  86674. * Convert the Mesh to CSG
  86675. * @param mesh The Mesh to convert to CSG
  86676. * @returns A new CSG from the Mesh
  86677. */
  86678. CSG.FromMesh = function (mesh) {
  86679. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  86680. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  86681. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  86682. mesh.computeWorldMatrix(true);
  86683. matrix = mesh.getWorldMatrix();
  86684. meshPosition = mesh.position.clone();
  86685. meshRotation = mesh.rotation.clone();
  86686. if (mesh.rotationQuaternion) {
  86687. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  86688. }
  86689. meshScaling = mesh.scaling.clone();
  86690. }
  86691. else {
  86692. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  86693. }
  86694. 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);
  86695. var subMeshes = mesh.subMeshes;
  86696. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  86697. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  86698. vertices = [];
  86699. for (var j = 0; j < 3; j++) {
  86700. 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]);
  86701. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  86702. 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]);
  86703. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  86704. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  86705. vertex = new Vertex(position, normal, uv);
  86706. vertices.push(vertex);
  86707. }
  86708. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  86709. // To handle the case of degenerated triangle
  86710. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  86711. if (polygon.plane) {
  86712. polygons.push(polygon);
  86713. }
  86714. }
  86715. }
  86716. var csg = CSG.FromPolygons(polygons);
  86717. csg.matrix = matrix;
  86718. csg.position = meshPosition;
  86719. csg.rotation = meshRotation;
  86720. csg.scaling = meshScaling;
  86721. csg.rotationQuaternion = meshRotationQuaternion;
  86722. currentCSGMeshId++;
  86723. return csg;
  86724. };
  86725. /**
  86726. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  86727. * @param polygons Polygons used to construct a CSG solid
  86728. */
  86729. CSG.FromPolygons = function (polygons) {
  86730. var csg = new CSG();
  86731. csg.polygons = polygons;
  86732. return csg;
  86733. };
  86734. /**
  86735. * Clones, or makes a deep copy, of the CSG
  86736. * @returns A new CSG
  86737. */
  86738. CSG.prototype.clone = function () {
  86739. var csg = new CSG();
  86740. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  86741. csg.copyTransformAttributes(this);
  86742. return csg;
  86743. };
  86744. /**
  86745. * Unions this CSG with another CSG
  86746. * @param csg The CSG to union against this CSG
  86747. * @returns The unioned CSG
  86748. */
  86749. CSG.prototype.union = function (csg) {
  86750. var a = new Node(this.clone().polygons);
  86751. var b = new Node(csg.clone().polygons);
  86752. a.clipTo(b);
  86753. b.clipTo(a);
  86754. b.invert();
  86755. b.clipTo(a);
  86756. b.invert();
  86757. a.build(b.allPolygons());
  86758. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  86759. };
  86760. /**
  86761. * Unions this CSG with another CSG in place
  86762. * @param csg The CSG to union against this CSG
  86763. */
  86764. CSG.prototype.unionInPlace = function (csg) {
  86765. var a = new Node(this.polygons);
  86766. var b = new Node(csg.polygons);
  86767. a.clipTo(b);
  86768. b.clipTo(a);
  86769. b.invert();
  86770. b.clipTo(a);
  86771. b.invert();
  86772. a.build(b.allPolygons());
  86773. this.polygons = a.allPolygons();
  86774. };
  86775. /**
  86776. * Subtracts this CSG with another CSG
  86777. * @param csg The CSG to subtract against this CSG
  86778. * @returns A new CSG
  86779. */
  86780. CSG.prototype.subtract = function (csg) {
  86781. var a = new Node(this.clone().polygons);
  86782. var b = new Node(csg.clone().polygons);
  86783. a.invert();
  86784. a.clipTo(b);
  86785. b.clipTo(a);
  86786. b.invert();
  86787. b.clipTo(a);
  86788. b.invert();
  86789. a.build(b.allPolygons());
  86790. a.invert();
  86791. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  86792. };
  86793. /**
  86794. * Subtracts this CSG with another CSG in place
  86795. * @param csg The CSG to subtact against this CSG
  86796. */
  86797. CSG.prototype.subtractInPlace = function (csg) {
  86798. var a = new Node(this.polygons);
  86799. var b = new Node(csg.polygons);
  86800. a.invert();
  86801. a.clipTo(b);
  86802. b.clipTo(a);
  86803. b.invert();
  86804. b.clipTo(a);
  86805. b.invert();
  86806. a.build(b.allPolygons());
  86807. a.invert();
  86808. this.polygons = a.allPolygons();
  86809. };
  86810. /**
  86811. * Intersect this CSG with another CSG
  86812. * @param csg The CSG to intersect against this CSG
  86813. * @returns A new CSG
  86814. */
  86815. CSG.prototype.intersect = function (csg) {
  86816. var a = new Node(this.clone().polygons);
  86817. var b = new Node(csg.clone().polygons);
  86818. a.invert();
  86819. b.clipTo(a);
  86820. b.invert();
  86821. a.clipTo(b);
  86822. b.clipTo(a);
  86823. a.build(b.allPolygons());
  86824. a.invert();
  86825. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  86826. };
  86827. /**
  86828. * Intersects this CSG with another CSG in place
  86829. * @param csg The CSG to intersect against this CSG
  86830. */
  86831. CSG.prototype.intersectInPlace = function (csg) {
  86832. var a = new Node(this.polygons);
  86833. var b = new Node(csg.polygons);
  86834. a.invert();
  86835. b.clipTo(a);
  86836. b.invert();
  86837. a.clipTo(b);
  86838. b.clipTo(a);
  86839. a.build(b.allPolygons());
  86840. a.invert();
  86841. this.polygons = a.allPolygons();
  86842. };
  86843. /**
  86844. * Return a new CSG solid with solid and empty space switched. This solid is
  86845. * not modified.
  86846. * @returns A new CSG solid with solid and empty space switched
  86847. */
  86848. CSG.prototype.inverse = function () {
  86849. var csg = this.clone();
  86850. csg.inverseInPlace();
  86851. return csg;
  86852. };
  86853. /**
  86854. * Inverses the CSG in place
  86855. */
  86856. CSG.prototype.inverseInPlace = function () {
  86857. this.polygons.map(function (p) { p.flip(); });
  86858. };
  86859. /**
  86860. * This is used to keep meshes transformations so they can be restored
  86861. * when we build back a Babylon Mesh
  86862. * NB : All CSG operations are performed in world coordinates
  86863. * @param csg The CSG to copy the transform attributes from
  86864. * @returns This CSG
  86865. */
  86866. CSG.prototype.copyTransformAttributes = function (csg) {
  86867. this.matrix = csg.matrix;
  86868. this.position = csg.position;
  86869. this.rotation = csg.rotation;
  86870. this.scaling = csg.scaling;
  86871. this.rotationQuaternion = csg.rotationQuaternion;
  86872. return this;
  86873. };
  86874. /**
  86875. * Build Raw mesh from CSG
  86876. * Coordinates here are in world space
  86877. * @param name The name of the mesh geometry
  86878. * @param scene The Scene
  86879. * @param keepSubMeshes Specifies if the submeshes should be kept
  86880. * @returns A new Mesh
  86881. */
  86882. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  86883. var matrix = this.matrix.clone();
  86884. matrix.invert();
  86885. 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;
  86886. if (keepSubMeshes) {
  86887. // Sort Polygons, since subMeshes are indices range
  86888. polygons.sort(function (a, b) {
  86889. if (a.shared.meshId === b.shared.meshId) {
  86890. return a.shared.subMeshId - b.shared.subMeshId;
  86891. }
  86892. else {
  86893. return a.shared.meshId - b.shared.meshId;
  86894. }
  86895. });
  86896. }
  86897. for (var i = 0, il = polygons.length; i < il; i++) {
  86898. polygon = polygons[i];
  86899. // Building SubMeshes
  86900. if (!subMesh_dict[polygon.shared.meshId]) {
  86901. subMesh_dict[polygon.shared.meshId] = {};
  86902. }
  86903. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  86904. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  86905. indexStart: +Infinity,
  86906. indexEnd: -Infinity,
  86907. materialIndex: polygon.shared.materialIndex
  86908. };
  86909. }
  86910. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  86911. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  86912. polygonIndices[0] = 0;
  86913. polygonIndices[1] = j - 1;
  86914. polygonIndices[2] = j;
  86915. for (var k = 0; k < 3; k++) {
  86916. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  86917. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  86918. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  86919. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  86920. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  86921. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  86922. // Check if 2 points can be merged
  86923. if (!(typeof vertex_idx !== 'undefined' &&
  86924. normals[vertex_idx * 3] === localNormal.x &&
  86925. normals[vertex_idx * 3 + 1] === localNormal.y &&
  86926. normals[vertex_idx * 3 + 2] === localNormal.z &&
  86927. uvs[vertex_idx * 2] === uv.x &&
  86928. uvs[vertex_idx * 2 + 1] === uv.y)) {
  86929. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  86930. uvs.push(uv.x, uv.y);
  86931. normals.push(normal.x, normal.y, normal.z);
  86932. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  86933. }
  86934. indices.push(vertex_idx);
  86935. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  86936. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  86937. currentIndex++;
  86938. }
  86939. }
  86940. }
  86941. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  86942. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  86943. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  86944. mesh.setIndices(indices, null);
  86945. if (keepSubMeshes) {
  86946. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  86947. var materialIndexOffset = 0, materialMaxIndex;
  86948. mesh.subMeshes = new Array();
  86949. for (var m in subMesh_dict) {
  86950. materialMaxIndex = -1;
  86951. for (var sm in subMesh_dict[m]) {
  86952. subMesh_obj = subMesh_dict[m][sm];
  86953. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  86954. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  86955. }
  86956. materialIndexOffset += ++materialMaxIndex;
  86957. }
  86958. }
  86959. return mesh;
  86960. };
  86961. /**
  86962. * Build Mesh from CSG taking material and transforms into account
  86963. * @param name The name of the Mesh
  86964. * @param material The material of the Mesh
  86965. * @param scene The Scene
  86966. * @param keepSubMeshes Specifies if submeshes should be kept
  86967. * @returns The new Mesh
  86968. */
  86969. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  86970. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  86971. mesh.material = material;
  86972. mesh.position.copyFrom(this.position);
  86973. mesh.rotation.copyFrom(this.rotation);
  86974. if (this.rotationQuaternion) {
  86975. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  86976. }
  86977. mesh.scaling.copyFrom(this.scaling);
  86978. mesh.computeWorldMatrix(true);
  86979. return mesh;
  86980. };
  86981. return CSG;
  86982. }());
  86983. /***/ }),
  86984. /***/ "./Meshes/dataBuffer.ts":
  86985. /*!******************************!*\
  86986. !*** ./Meshes/dataBuffer.ts ***!
  86987. \******************************/
  86988. /*! exports provided: DataBuffer */
  86989. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86990. "use strict";
  86991. __webpack_require__.r(__webpack_exports__);
  86992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DataBuffer", function() { return DataBuffer; });
  86993. /**
  86994. * Class used to store gfx data (like WebGLBuffer)
  86995. */
  86996. var DataBuffer = /** @class */ (function () {
  86997. function DataBuffer() {
  86998. /**
  86999. * Gets or sets the number of objects referencing this buffer
  87000. */
  87001. this.references = 0;
  87002. /** Gets or sets the size of the underlying buffer */
  87003. this.capacity = 0;
  87004. /**
  87005. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  87006. */
  87007. this.is32Bits = false;
  87008. }
  87009. Object.defineProperty(DataBuffer.prototype, "underlyingResource", {
  87010. /**
  87011. * Gets the underlying buffer
  87012. */
  87013. get: function () {
  87014. return null;
  87015. },
  87016. enumerable: true,
  87017. configurable: true
  87018. });
  87019. return DataBuffer;
  87020. }());
  87021. /***/ }),
  87022. /***/ "./Meshes/geometry.ts":
  87023. /*!****************************!*\
  87024. !*** ./Meshes/geometry.ts ***!
  87025. \****************************/
  87026. /*! exports provided: Geometry */
  87027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87028. "use strict";
  87029. __webpack_require__.r(__webpack_exports__);
  87030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  87031. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  87032. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  87033. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  87034. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  87035. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  87036. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  87037. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  87038. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  87039. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  87040. /**
  87041. * Class used to store geometry data (vertex buffers + index buffer)
  87042. */
  87043. var Geometry = /** @class */ (function () {
  87044. /**
  87045. * Creates a new geometry
  87046. * @param id defines the unique ID
  87047. * @param scene defines the hosting scene
  87048. * @param vertexData defines the VertexData used to get geometry data
  87049. * @param updatable defines if geometry must be updatable (false by default)
  87050. * @param mesh defines the mesh that will be associated with the geometry
  87051. */
  87052. function Geometry(id, scene, vertexData, updatable, mesh) {
  87053. if (updatable === void 0) { updatable = false; }
  87054. if (mesh === void 0) { mesh = null; }
  87055. /**
  87056. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87057. */
  87058. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  87059. this._totalVertices = 0;
  87060. this._isDisposed = false;
  87061. this._indexBufferIsUpdatable = false;
  87062. this.id = id;
  87063. this.uniqueId = scene.getUniqueId();
  87064. this._engine = scene.getEngine();
  87065. this._meshes = [];
  87066. this._scene = scene;
  87067. //Init vertex buffer cache
  87068. this._vertexBuffers = {};
  87069. this._indices = [];
  87070. this._updatable = updatable;
  87071. // vertexData
  87072. if (vertexData) {
  87073. this.setAllVerticesData(vertexData, updatable);
  87074. }
  87075. else {
  87076. this._totalVertices = 0;
  87077. this._indices = [];
  87078. }
  87079. if (this._engine.getCaps().vertexArrayObject) {
  87080. this._vertexArrayObjects = {};
  87081. }
  87082. // applyToMesh
  87083. if (mesh) {
  87084. this.applyToMesh(mesh);
  87085. mesh.computeWorldMatrix(true);
  87086. }
  87087. }
  87088. Object.defineProperty(Geometry.prototype, "boundingBias", {
  87089. /**
  87090. * 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
  87091. */
  87092. get: function () {
  87093. return this._boundingBias;
  87094. },
  87095. /**
  87096. * 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
  87097. */
  87098. set: function (value) {
  87099. if (this._boundingBias) {
  87100. this._boundingBias.copyFrom(value);
  87101. }
  87102. else {
  87103. this._boundingBias = value.clone();
  87104. }
  87105. this._updateBoundingInfo(true, null);
  87106. },
  87107. enumerable: true,
  87108. configurable: true
  87109. });
  87110. /**
  87111. * Static function used to attach a new empty geometry to a mesh
  87112. * @param mesh defines the mesh to attach the geometry to
  87113. * @returns the new Geometry
  87114. */
  87115. Geometry.CreateGeometryForMesh = function (mesh) {
  87116. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  87117. geometry.applyToMesh(mesh);
  87118. return geometry;
  87119. };
  87120. Object.defineProperty(Geometry.prototype, "extend", {
  87121. /**
  87122. * Gets the current extend of the geometry
  87123. */
  87124. get: function () {
  87125. return this._extend;
  87126. },
  87127. enumerable: true,
  87128. configurable: true
  87129. });
  87130. /**
  87131. * Gets the hosting scene
  87132. * @returns the hosting Scene
  87133. */
  87134. Geometry.prototype.getScene = function () {
  87135. return this._scene;
  87136. };
  87137. /**
  87138. * Gets the hosting engine
  87139. * @returns the hosting Engine
  87140. */
  87141. Geometry.prototype.getEngine = function () {
  87142. return this._engine;
  87143. };
  87144. /**
  87145. * Defines if the geometry is ready to use
  87146. * @returns true if the geometry is ready to be used
  87147. */
  87148. Geometry.prototype.isReady = function () {
  87149. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  87150. };
  87151. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  87152. /**
  87153. * Gets a value indicating that the geometry should not be serialized
  87154. */
  87155. get: function () {
  87156. for (var index = 0; index < this._meshes.length; index++) {
  87157. if (!this._meshes[index].doNotSerialize) {
  87158. return false;
  87159. }
  87160. }
  87161. return true;
  87162. },
  87163. enumerable: true,
  87164. configurable: true
  87165. });
  87166. /** @hidden */
  87167. Geometry.prototype._rebuild = function () {
  87168. if (this._vertexArrayObjects) {
  87169. this._vertexArrayObjects = {};
  87170. }
  87171. // Index buffer
  87172. if (this._meshes.length !== 0 && this._indices) {
  87173. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  87174. }
  87175. // Vertex buffers
  87176. for (var key in this._vertexBuffers) {
  87177. var vertexBuffer = this._vertexBuffers[key];
  87178. vertexBuffer._rebuild();
  87179. }
  87180. };
  87181. /**
  87182. * Affects all geometry data in one call
  87183. * @param vertexData defines the geometry data
  87184. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87185. */
  87186. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  87187. vertexData.applyToGeometry(this, updatable);
  87188. this.notifyUpdate();
  87189. };
  87190. /**
  87191. * Set specific vertex data
  87192. * @param kind defines the data kind (Position, normal, etc...)
  87193. * @param data defines the vertex data to use
  87194. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87195. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87196. */
  87197. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  87198. if (updatable === void 0) { updatable = false; }
  87199. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  87200. this.setVerticesBuffer(buffer);
  87201. };
  87202. /**
  87203. * Removes a specific vertex data
  87204. * @param kind defines the data kind (Position, normal, etc...)
  87205. */
  87206. Geometry.prototype.removeVerticesData = function (kind) {
  87207. if (this._vertexBuffers[kind]) {
  87208. this._vertexBuffers[kind].dispose();
  87209. delete this._vertexBuffers[kind];
  87210. }
  87211. };
  87212. /**
  87213. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87214. * @param buffer defines the vertex buffer to use
  87215. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87216. */
  87217. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  87218. if (totalVertices === void 0) { totalVertices = null; }
  87219. var kind = buffer.getKind();
  87220. if (this._vertexBuffers[kind]) {
  87221. this._vertexBuffers[kind].dispose();
  87222. }
  87223. this._vertexBuffers[kind] = buffer;
  87224. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  87225. var data = buffer.getData();
  87226. if (totalVertices != null) {
  87227. this._totalVertices = totalVertices;
  87228. }
  87229. else {
  87230. if (data != null) {
  87231. this._totalVertices = data.length / (buffer.byteStride / 4);
  87232. }
  87233. }
  87234. this._updateExtend(data);
  87235. this._resetPointsArrayCache();
  87236. var meshes = this._meshes;
  87237. var numOfMeshes = meshes.length;
  87238. for (var index = 0; index < numOfMeshes; index++) {
  87239. var mesh = meshes[index];
  87240. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  87241. mesh._createGlobalSubMesh(false);
  87242. mesh.computeWorldMatrix(true);
  87243. }
  87244. }
  87245. this.notifyUpdate(kind);
  87246. if (this._vertexArrayObjects) {
  87247. this._disposeVertexArrayObjects();
  87248. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  87249. }
  87250. };
  87251. /**
  87252. * Update a specific vertex buffer
  87253. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87254. * It will do nothing if the buffer is not updatable
  87255. * @param kind defines the data kind (Position, normal, etc...)
  87256. * @param data defines the data to use
  87257. * @param offset defines the offset in the target buffer where to store the data
  87258. * @param useBytes set to true if the offset is in bytes
  87259. */
  87260. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  87261. if (useBytes === void 0) { useBytes = false; }
  87262. var vertexBuffer = this.getVertexBuffer(kind);
  87263. if (!vertexBuffer) {
  87264. return;
  87265. }
  87266. vertexBuffer.updateDirectly(data, offset, useBytes);
  87267. this.notifyUpdate(kind);
  87268. };
  87269. /**
  87270. * Update a specific vertex buffer
  87271. * This function will create a new buffer if the current one is not updatable
  87272. * @param kind defines the data kind (Position, normal, etc...)
  87273. * @param data defines the data to use
  87274. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87275. */
  87276. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  87277. if (updateExtends === void 0) { updateExtends = false; }
  87278. var vertexBuffer = this.getVertexBuffer(kind);
  87279. if (!vertexBuffer) {
  87280. return;
  87281. }
  87282. vertexBuffer.update(data);
  87283. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  87284. this._updateBoundingInfo(updateExtends, data);
  87285. }
  87286. this.notifyUpdate(kind);
  87287. };
  87288. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  87289. if (updateExtends) {
  87290. this._updateExtend(data);
  87291. }
  87292. this._resetPointsArrayCache();
  87293. if (updateExtends) {
  87294. var meshes = this._meshes;
  87295. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  87296. var mesh = meshes_1[_i];
  87297. if (mesh._boundingInfo) {
  87298. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  87299. }
  87300. else {
  87301. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  87302. }
  87303. var subMeshes = mesh.subMeshes;
  87304. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  87305. var subMesh = subMeshes_1[_a];
  87306. subMesh.refreshBoundingInfo();
  87307. }
  87308. }
  87309. }
  87310. };
  87311. /** @hidden */
  87312. Geometry.prototype._bind = function (effect, indexToBind) {
  87313. if (!effect) {
  87314. return;
  87315. }
  87316. if (indexToBind === undefined) {
  87317. indexToBind = this._indexBuffer;
  87318. }
  87319. var vbs = this.getVertexBuffers();
  87320. if (!vbs) {
  87321. return;
  87322. }
  87323. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  87324. this._engine.bindBuffers(vbs, indexToBind, effect);
  87325. return;
  87326. }
  87327. // Using VAO
  87328. if (!this._vertexArrayObjects[effect.key]) {
  87329. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  87330. }
  87331. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  87332. };
  87333. /**
  87334. * Gets total number of vertices
  87335. * @returns the total number of vertices
  87336. */
  87337. Geometry.prototype.getTotalVertices = function () {
  87338. if (!this.isReady()) {
  87339. return 0;
  87340. }
  87341. return this._totalVertices;
  87342. };
  87343. /**
  87344. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87345. * @param kind defines the data kind (Position, normal, etc...)
  87346. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87347. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87348. * @returns a float array containing vertex data
  87349. */
  87350. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  87351. var vertexBuffer = this.getVertexBuffer(kind);
  87352. if (!vertexBuffer) {
  87353. return null;
  87354. }
  87355. var data = vertexBuffer.getData();
  87356. if (!data) {
  87357. return null;
  87358. }
  87359. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  87360. var count = this._totalVertices * vertexBuffer.getSize();
  87361. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  87362. var copy_1 = [];
  87363. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  87364. return copy_1;
  87365. }
  87366. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  87367. if (data instanceof Array) {
  87368. var offset = vertexBuffer.byteOffset / 4;
  87369. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  87370. }
  87371. else if (data instanceof ArrayBuffer) {
  87372. return new Float32Array(data, vertexBuffer.byteOffset, count);
  87373. }
  87374. else {
  87375. var offset = data.byteOffset + vertexBuffer.byteOffset;
  87376. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  87377. var result = new Float32Array(count);
  87378. var source = new Float32Array(data.buffer, offset, count);
  87379. result.set(source);
  87380. return result;
  87381. }
  87382. return new Float32Array(data.buffer, offset, count);
  87383. }
  87384. }
  87385. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  87386. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  87387. }
  87388. return data;
  87389. };
  87390. /**
  87391. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87392. * @param kind defines the data kind (Position, normal, etc...)
  87393. * @returns true if the vertex buffer with the specified kind is updatable
  87394. */
  87395. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  87396. var vb = this._vertexBuffers[kind];
  87397. if (!vb) {
  87398. return false;
  87399. }
  87400. return vb.isUpdatable();
  87401. };
  87402. /**
  87403. * Gets a specific vertex buffer
  87404. * @param kind defines the data kind (Position, normal, etc...)
  87405. * @returns a VertexBuffer
  87406. */
  87407. Geometry.prototype.getVertexBuffer = function (kind) {
  87408. if (!this.isReady()) {
  87409. return null;
  87410. }
  87411. return this._vertexBuffers[kind];
  87412. };
  87413. /**
  87414. * Returns all vertex buffers
  87415. * @return an object holding all vertex buffers indexed by kind
  87416. */
  87417. Geometry.prototype.getVertexBuffers = function () {
  87418. if (!this.isReady()) {
  87419. return null;
  87420. }
  87421. return this._vertexBuffers;
  87422. };
  87423. /**
  87424. * Gets a boolean indicating if specific vertex buffer is present
  87425. * @param kind defines the data kind (Position, normal, etc...)
  87426. * @returns true if data is present
  87427. */
  87428. Geometry.prototype.isVerticesDataPresent = function (kind) {
  87429. if (!this._vertexBuffers) {
  87430. if (this._delayInfo) {
  87431. return this._delayInfo.indexOf(kind) !== -1;
  87432. }
  87433. return false;
  87434. }
  87435. return this._vertexBuffers[kind] !== undefined;
  87436. };
  87437. /**
  87438. * Gets a list of all attached data kinds (Position, normal, etc...)
  87439. * @returns a list of string containing all kinds
  87440. */
  87441. Geometry.prototype.getVerticesDataKinds = function () {
  87442. var result = [];
  87443. var kind;
  87444. if (!this._vertexBuffers && this._delayInfo) {
  87445. for (kind in this._delayInfo) {
  87446. result.push(kind);
  87447. }
  87448. }
  87449. else {
  87450. for (kind in this._vertexBuffers) {
  87451. result.push(kind);
  87452. }
  87453. }
  87454. return result;
  87455. };
  87456. /**
  87457. * Update index buffer
  87458. * @param indices defines the indices to store in the index buffer
  87459. * @param offset defines the offset in the target buffer where to store the data
  87460. * @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)
  87461. */
  87462. Geometry.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  87463. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  87464. if (!this._indexBuffer) {
  87465. return;
  87466. }
  87467. if (!this._indexBufferIsUpdatable) {
  87468. this.setIndices(indices, null, true);
  87469. }
  87470. else {
  87471. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  87472. if (!gpuMemoryOnly) {
  87473. this._indices = indices.slice();
  87474. }
  87475. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  87476. if (needToUpdateSubMeshes) {
  87477. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  87478. var mesh = _a[_i];
  87479. mesh._createGlobalSubMesh(true);
  87480. }
  87481. }
  87482. }
  87483. };
  87484. /**
  87485. * Creates a new index buffer
  87486. * @param indices defines the indices to store in the index buffer
  87487. * @param totalVertices defines the total number of vertices (could be null)
  87488. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87489. */
  87490. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  87491. if (totalVertices === void 0) { totalVertices = null; }
  87492. if (updatable === void 0) { updatable = false; }
  87493. if (this._indexBuffer) {
  87494. this._engine._releaseBuffer(this._indexBuffer);
  87495. }
  87496. this._disposeVertexArrayObjects();
  87497. this._indices = indices;
  87498. this._indexBufferIsUpdatable = updatable;
  87499. if (this._meshes.length !== 0 && this._indices) {
  87500. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  87501. }
  87502. if (totalVertices != undefined) { // including null and undefined
  87503. this._totalVertices = totalVertices;
  87504. }
  87505. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  87506. var mesh = _a[_i];
  87507. mesh._createGlobalSubMesh(true);
  87508. }
  87509. this.notifyUpdate();
  87510. };
  87511. /**
  87512. * Return the total number of indices
  87513. * @returns the total number of indices
  87514. */
  87515. Geometry.prototype.getTotalIndices = function () {
  87516. if (!this.isReady()) {
  87517. return 0;
  87518. }
  87519. return this._indices.length;
  87520. };
  87521. /**
  87522. * Gets the index buffer array
  87523. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87524. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87525. * @returns the index buffer array
  87526. */
  87527. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  87528. if (!this.isReady()) {
  87529. return null;
  87530. }
  87531. var orig = this._indices;
  87532. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  87533. return orig;
  87534. }
  87535. else {
  87536. var len = orig.length;
  87537. var copy = [];
  87538. for (var i = 0; i < len; i++) {
  87539. copy.push(orig[i]);
  87540. }
  87541. return copy;
  87542. }
  87543. };
  87544. /**
  87545. * Gets the index buffer
  87546. * @return the index buffer
  87547. */
  87548. Geometry.prototype.getIndexBuffer = function () {
  87549. if (!this.isReady()) {
  87550. return null;
  87551. }
  87552. return this._indexBuffer;
  87553. };
  87554. /** @hidden */
  87555. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  87556. if (effect === void 0) { effect = null; }
  87557. if (!effect || !this._vertexArrayObjects) {
  87558. return;
  87559. }
  87560. if (this._vertexArrayObjects[effect.key]) {
  87561. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  87562. delete this._vertexArrayObjects[effect.key];
  87563. }
  87564. };
  87565. /**
  87566. * Release the associated resources for a specific mesh
  87567. * @param mesh defines the source mesh
  87568. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  87569. */
  87570. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  87571. var meshes = this._meshes;
  87572. var index = meshes.indexOf(mesh);
  87573. if (index === -1) {
  87574. return;
  87575. }
  87576. meshes.splice(index, 1);
  87577. mesh._geometry = null;
  87578. if (meshes.length === 0 && shouldDispose) {
  87579. this.dispose();
  87580. }
  87581. };
  87582. /**
  87583. * Apply current geometry to a given mesh
  87584. * @param mesh defines the mesh to apply geometry to
  87585. */
  87586. Geometry.prototype.applyToMesh = function (mesh) {
  87587. if (mesh._geometry === this) {
  87588. return;
  87589. }
  87590. var previousGeometry = mesh._geometry;
  87591. if (previousGeometry) {
  87592. previousGeometry.releaseForMesh(mesh);
  87593. }
  87594. var meshes = this._meshes;
  87595. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  87596. mesh._geometry = this;
  87597. this._scene.pushGeometry(this);
  87598. meshes.push(mesh);
  87599. if (this.isReady()) {
  87600. this._applyToMesh(mesh);
  87601. }
  87602. else {
  87603. mesh._boundingInfo = this._boundingInfo;
  87604. }
  87605. };
  87606. Geometry.prototype._updateExtend = function (data) {
  87607. if (data === void 0) { data = null; }
  87608. if (!data) {
  87609. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  87610. }
  87611. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  87612. };
  87613. Geometry.prototype._applyToMesh = function (mesh) {
  87614. var numOfMeshes = this._meshes.length;
  87615. // vertexBuffers
  87616. for (var kind in this._vertexBuffers) {
  87617. if (numOfMeshes === 1) {
  87618. this._vertexBuffers[kind].create();
  87619. }
  87620. var buffer = this._vertexBuffers[kind].getBuffer();
  87621. if (buffer) {
  87622. buffer.references = numOfMeshes;
  87623. }
  87624. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  87625. if (!this._extend) {
  87626. this._updateExtend();
  87627. }
  87628. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  87629. mesh._createGlobalSubMesh(false);
  87630. //bounding info was just created again, world matrix should be applied again.
  87631. mesh._updateBoundingInfo();
  87632. }
  87633. }
  87634. // indexBuffer
  87635. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  87636. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  87637. }
  87638. if (this._indexBuffer) {
  87639. this._indexBuffer.references = numOfMeshes;
  87640. }
  87641. // morphTargets
  87642. mesh._syncGeometryWithMorphTargetManager();
  87643. // instances
  87644. mesh.synchronizeInstances();
  87645. };
  87646. Geometry.prototype.notifyUpdate = function (kind) {
  87647. if (this.onGeometryUpdated) {
  87648. this.onGeometryUpdated(this, kind);
  87649. }
  87650. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  87651. var mesh = _a[_i];
  87652. mesh._markSubMeshesAsAttributesDirty();
  87653. }
  87654. };
  87655. /**
  87656. * Load the geometry if it was flagged as delay loaded
  87657. * @param scene defines the hosting scene
  87658. * @param onLoaded defines a callback called when the geometry is loaded
  87659. */
  87660. Geometry.prototype.load = function (scene, onLoaded) {
  87661. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  87662. return;
  87663. }
  87664. if (this.isReady()) {
  87665. if (onLoaded) {
  87666. onLoaded();
  87667. }
  87668. return;
  87669. }
  87670. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  87671. this._queueLoad(scene, onLoaded);
  87672. };
  87673. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  87674. var _this = this;
  87675. if (!this.delayLoadingFile) {
  87676. return;
  87677. }
  87678. scene._addPendingData(this);
  87679. scene._loadFile(this.delayLoadingFile, function (data) {
  87680. if (!_this._delayLoadingFunction) {
  87681. return;
  87682. }
  87683. _this._delayLoadingFunction(JSON.parse(data), _this);
  87684. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  87685. _this._delayInfo = [];
  87686. scene._removePendingData(_this);
  87687. var meshes = _this._meshes;
  87688. var numOfMeshes = meshes.length;
  87689. for (var index = 0; index < numOfMeshes; index++) {
  87690. _this._applyToMesh(meshes[index]);
  87691. }
  87692. if (onLoaded) {
  87693. onLoaded();
  87694. }
  87695. }, undefined, true);
  87696. };
  87697. /**
  87698. * Invert the geometry to move from a right handed system to a left handed one.
  87699. */
  87700. Geometry.prototype.toLeftHanded = function () {
  87701. // Flip faces
  87702. var tIndices = this.getIndices(false);
  87703. if (tIndices != null && tIndices.length > 0) {
  87704. for (var i = 0; i < tIndices.length; i += 3) {
  87705. var tTemp = tIndices[i + 0];
  87706. tIndices[i + 0] = tIndices[i + 2];
  87707. tIndices[i + 2] = tTemp;
  87708. }
  87709. this.setIndices(tIndices);
  87710. }
  87711. // Negate position.z
  87712. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  87713. if (tPositions != null && tPositions.length > 0) {
  87714. for (var i = 0; i < tPositions.length; i += 3) {
  87715. tPositions[i + 2] = -tPositions[i + 2];
  87716. }
  87717. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  87718. }
  87719. // Negate normal.z
  87720. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  87721. if (tNormals != null && tNormals.length > 0) {
  87722. for (var i = 0; i < tNormals.length; i += 3) {
  87723. tNormals[i + 2] = -tNormals[i + 2];
  87724. }
  87725. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  87726. }
  87727. };
  87728. // Cache
  87729. /** @hidden */
  87730. Geometry.prototype._resetPointsArrayCache = function () {
  87731. this._positions = null;
  87732. };
  87733. /** @hidden */
  87734. Geometry.prototype._generatePointsArray = function () {
  87735. if (this._positions) {
  87736. return true;
  87737. }
  87738. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  87739. if (!data || data.length === 0) {
  87740. return false;
  87741. }
  87742. this._positions = [];
  87743. for (var index = 0; index < data.length; index += 3) {
  87744. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  87745. }
  87746. return true;
  87747. };
  87748. /**
  87749. * Gets a value indicating if the geometry is disposed
  87750. * @returns true if the geometry was disposed
  87751. */
  87752. Geometry.prototype.isDisposed = function () {
  87753. return this._isDisposed;
  87754. };
  87755. Geometry.prototype._disposeVertexArrayObjects = function () {
  87756. if (this._vertexArrayObjects) {
  87757. for (var kind in this._vertexArrayObjects) {
  87758. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  87759. }
  87760. this._vertexArrayObjects = {};
  87761. }
  87762. };
  87763. /**
  87764. * Free all associated resources
  87765. */
  87766. Geometry.prototype.dispose = function () {
  87767. var meshes = this._meshes;
  87768. var numOfMeshes = meshes.length;
  87769. var index;
  87770. for (index = 0; index < numOfMeshes; index++) {
  87771. this.releaseForMesh(meshes[index]);
  87772. }
  87773. this._meshes = [];
  87774. this._disposeVertexArrayObjects();
  87775. for (var kind in this._vertexBuffers) {
  87776. this._vertexBuffers[kind].dispose();
  87777. }
  87778. this._vertexBuffers = {};
  87779. this._totalVertices = 0;
  87780. if (this._indexBuffer) {
  87781. this._engine._releaseBuffer(this._indexBuffer);
  87782. }
  87783. this._indexBuffer = null;
  87784. this._indices = [];
  87785. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  87786. this.delayLoadingFile = null;
  87787. this._delayLoadingFunction = null;
  87788. this._delayInfo = [];
  87789. this._boundingInfo = null;
  87790. this._scene.removeGeometry(this);
  87791. this._isDisposed = true;
  87792. };
  87793. /**
  87794. * Clone the current geometry into a new geometry
  87795. * @param id defines the unique ID of the new geometry
  87796. * @returns a new geometry object
  87797. */
  87798. Geometry.prototype.copy = function (id) {
  87799. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  87800. vertexData.indices = [];
  87801. var indices = this.getIndices();
  87802. if (indices) {
  87803. for (var index = 0; index < indices.length; index++) {
  87804. vertexData.indices.push(indices[index]);
  87805. }
  87806. }
  87807. var updatable = false;
  87808. var stopChecking = false;
  87809. var kind;
  87810. for (kind in this._vertexBuffers) {
  87811. // using slice() to make a copy of the array and not just reference it
  87812. var data = this.getVerticesData(kind);
  87813. if (data) {
  87814. if (data instanceof Float32Array) {
  87815. vertexData.set(new Float32Array(data), kind);
  87816. }
  87817. else {
  87818. vertexData.set(data.slice(0), kind);
  87819. }
  87820. if (!stopChecking) {
  87821. var vb = this.getVertexBuffer(kind);
  87822. if (vb) {
  87823. updatable = vb.isUpdatable();
  87824. stopChecking = !updatable;
  87825. }
  87826. }
  87827. }
  87828. }
  87829. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  87830. geometry.delayLoadState = this.delayLoadState;
  87831. geometry.delayLoadingFile = this.delayLoadingFile;
  87832. geometry._delayLoadingFunction = this._delayLoadingFunction;
  87833. for (kind in this._delayInfo) {
  87834. geometry._delayInfo = geometry._delayInfo || [];
  87835. geometry._delayInfo.push(kind);
  87836. }
  87837. // Bounding info
  87838. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  87839. return geometry;
  87840. };
  87841. /**
  87842. * Serialize the current geometry info (and not the vertices data) into a JSON object
  87843. * @return a JSON representation of the current geometry data (without the vertices data)
  87844. */
  87845. Geometry.prototype.serialize = function () {
  87846. var serializationObject = {};
  87847. serializationObject.id = this.id;
  87848. serializationObject.updatable = this._updatable;
  87849. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  87850. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  87851. }
  87852. return serializationObject;
  87853. };
  87854. Geometry.prototype.toNumberArray = function (origin) {
  87855. if (Array.isArray(origin)) {
  87856. return origin;
  87857. }
  87858. else {
  87859. return Array.prototype.slice.call(origin);
  87860. }
  87861. };
  87862. /**
  87863. * Serialize all vertices data into a JSON oject
  87864. * @returns a JSON representation of the current geometry data
  87865. */
  87866. Geometry.prototype.serializeVerticeData = function () {
  87867. var serializationObject = this.serialize();
  87868. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  87869. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  87870. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  87871. serializationObject.positions._updatable = true;
  87872. }
  87873. }
  87874. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  87875. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  87876. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  87877. serializationObject.normals._updatable = true;
  87878. }
  87879. }
  87880. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  87881. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  87882. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  87883. serializationObject.tangets._updatable = true;
  87884. }
  87885. }
  87886. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  87887. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  87888. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  87889. serializationObject.uvs._updatable = true;
  87890. }
  87891. }
  87892. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  87893. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  87894. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  87895. serializationObject.uv2s._updatable = true;
  87896. }
  87897. }
  87898. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  87899. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  87900. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  87901. serializationObject.uv3s._updatable = true;
  87902. }
  87903. }
  87904. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  87905. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  87906. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  87907. serializationObject.uv4s._updatable = true;
  87908. }
  87909. }
  87910. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  87911. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  87912. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  87913. serializationObject.uv5s._updatable = true;
  87914. }
  87915. }
  87916. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  87917. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  87918. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  87919. serializationObject.uv6s._updatable = true;
  87920. }
  87921. }
  87922. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  87923. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  87924. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  87925. serializationObject.colors._updatable = true;
  87926. }
  87927. }
  87928. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  87929. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  87930. serializationObject.matricesIndices._isExpanded = true;
  87931. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  87932. serializationObject.matricesIndices._updatable = true;
  87933. }
  87934. }
  87935. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  87936. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  87937. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  87938. serializationObject.matricesWeights._updatable = true;
  87939. }
  87940. }
  87941. serializationObject.indices = this.toNumberArray(this.getIndices());
  87942. return serializationObject;
  87943. };
  87944. // Statics
  87945. /**
  87946. * Extracts a clone of a mesh geometry
  87947. * @param mesh defines the source mesh
  87948. * @param id defines the unique ID of the new geometry object
  87949. * @returns the new geometry object
  87950. */
  87951. Geometry.ExtractFromMesh = function (mesh, id) {
  87952. var geometry = mesh._geometry;
  87953. if (!geometry) {
  87954. return null;
  87955. }
  87956. return geometry.copy(id);
  87957. };
  87958. /**
  87959. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  87960. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87961. * Be aware Math.random() could cause collisions, but:
  87962. * "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"
  87963. * @returns a string containing a new GUID
  87964. */
  87965. Geometry.RandomId = function () {
  87966. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  87967. };
  87968. /** @hidden */
  87969. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  87970. var scene = mesh.getScene();
  87971. // Geometry
  87972. var geometryId = parsedGeometry.geometryId;
  87973. if (geometryId) {
  87974. var geometry = scene.getGeometryByID(geometryId);
  87975. if (geometry) {
  87976. geometry.applyToMesh(mesh);
  87977. }
  87978. }
  87979. else if (parsedGeometry instanceof ArrayBuffer) {
  87980. var binaryInfo = mesh._binaryInfo;
  87981. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  87982. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  87983. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  87984. }
  87985. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  87986. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  87987. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  87988. }
  87989. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  87990. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  87991. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  87992. }
  87993. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  87994. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  87995. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  87996. }
  87997. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  87998. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  87999. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  88000. }
  88001. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  88002. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  88003. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  88004. }
  88005. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  88006. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  88007. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  88008. }
  88009. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  88010. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  88011. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  88012. }
  88013. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  88014. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  88015. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  88016. }
  88017. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  88018. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  88019. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  88020. }
  88021. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  88022. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  88023. var floatIndices = [];
  88024. for (var i = 0; i < matricesIndicesData.length; i++) {
  88025. var index = matricesIndicesData[i];
  88026. floatIndices.push(index & 0x000000FF);
  88027. floatIndices.push((index & 0x0000FF00) >> 8);
  88028. floatIndices.push((index & 0x00FF0000) >> 16);
  88029. floatIndices.push(index >> 24);
  88030. }
  88031. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  88032. }
  88033. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  88034. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  88035. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  88036. }
  88037. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  88038. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  88039. mesh.setIndices(indicesData, null);
  88040. }
  88041. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  88042. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  88043. mesh.subMeshes = [];
  88044. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  88045. var materialIndex = subMeshesData[(i * 5) + 0];
  88046. var verticesStart = subMeshesData[(i * 5) + 1];
  88047. var verticesCount = subMeshesData[(i * 5) + 2];
  88048. var indexStart = subMeshesData[(i * 5) + 3];
  88049. var indexCount = subMeshesData[(i * 5) + 4];
  88050. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  88051. }
  88052. }
  88053. }
  88054. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  88055. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  88056. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  88057. if (parsedGeometry.tangents) {
  88058. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  88059. }
  88060. if (parsedGeometry.uvs) {
  88061. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  88062. }
  88063. if (parsedGeometry.uvs2) {
  88064. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  88065. }
  88066. if (parsedGeometry.uvs3) {
  88067. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  88068. }
  88069. if (parsedGeometry.uvs4) {
  88070. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  88071. }
  88072. if (parsedGeometry.uvs5) {
  88073. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  88074. }
  88075. if (parsedGeometry.uvs6) {
  88076. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  88077. }
  88078. if (parsedGeometry.colors) {
  88079. 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);
  88080. }
  88081. if (parsedGeometry.matricesIndices) {
  88082. if (!parsedGeometry.matricesIndices._isExpanded) {
  88083. var floatIndices = [];
  88084. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  88085. var matricesIndex = parsedGeometry.matricesIndices[i];
  88086. floatIndices.push(matricesIndex & 0x000000FF);
  88087. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  88088. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  88089. floatIndices.push(matricesIndex >> 24);
  88090. }
  88091. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  88092. }
  88093. else {
  88094. delete parsedGeometry.matricesIndices._isExpanded;
  88095. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  88096. }
  88097. }
  88098. if (parsedGeometry.matricesIndicesExtra) {
  88099. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  88100. var floatIndices = [];
  88101. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  88102. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  88103. floatIndices.push(matricesIndex & 0x000000FF);
  88104. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  88105. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  88106. floatIndices.push(matricesIndex >> 24);
  88107. }
  88108. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  88109. }
  88110. else {
  88111. delete parsedGeometry.matricesIndices._isExpanded;
  88112. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  88113. }
  88114. }
  88115. if (parsedGeometry.matricesWeights) {
  88116. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  88117. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  88118. }
  88119. if (parsedGeometry.matricesWeightsExtra) {
  88120. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  88121. }
  88122. mesh.setIndices(parsedGeometry.indices, null);
  88123. }
  88124. // SubMeshes
  88125. if (parsedGeometry.subMeshes) {
  88126. mesh.subMeshes = [];
  88127. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  88128. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  88129. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  88130. }
  88131. }
  88132. // Flat shading
  88133. if (mesh._shouldGenerateFlatShading) {
  88134. mesh.convertToFlatShadedMesh();
  88135. delete mesh._shouldGenerateFlatShading;
  88136. }
  88137. // Update
  88138. mesh.computeWorldMatrix(true);
  88139. scene.onMeshImportedObservable.notifyObservers(mesh);
  88140. };
  88141. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  88142. var epsilon = 1e-3;
  88143. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  88144. return;
  88145. }
  88146. var noInfluenceBoneIndex = 0.0;
  88147. if (parsedGeometry.skeletonId > -1) {
  88148. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  88149. if (!skeleton) {
  88150. return;
  88151. }
  88152. noInfluenceBoneIndex = skeleton.bones.length;
  88153. }
  88154. else {
  88155. return;
  88156. }
  88157. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  88158. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  88159. var matricesWeights = parsedGeometry.matricesWeights;
  88160. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  88161. var influencers = parsedGeometry.numBoneInfluencer;
  88162. var size = matricesWeights.length;
  88163. for (var i = 0; i < size; i += 4) {
  88164. var weight = 0.0;
  88165. var firstZeroWeight = -1;
  88166. for (var j = 0; j < 4; j++) {
  88167. var w = matricesWeights[i + j];
  88168. weight += w;
  88169. if (w < epsilon && firstZeroWeight < 0) {
  88170. firstZeroWeight = j;
  88171. }
  88172. }
  88173. if (matricesWeightsExtra) {
  88174. for (var j = 0; j < 4; j++) {
  88175. var w = matricesWeightsExtra[i + j];
  88176. weight += w;
  88177. if (w < epsilon && firstZeroWeight < 0) {
  88178. firstZeroWeight = j + 4;
  88179. }
  88180. }
  88181. }
  88182. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  88183. firstZeroWeight = influencers - 1;
  88184. }
  88185. if (weight > epsilon) {
  88186. var mweight = 1.0 / weight;
  88187. for (var j = 0; j < 4; j++) {
  88188. matricesWeights[i + j] *= mweight;
  88189. }
  88190. if (matricesWeightsExtra) {
  88191. for (var j = 0; j < 4; j++) {
  88192. matricesWeightsExtra[i + j] *= mweight;
  88193. }
  88194. }
  88195. }
  88196. else {
  88197. if (firstZeroWeight >= 4) {
  88198. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  88199. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  88200. }
  88201. else {
  88202. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  88203. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  88204. }
  88205. }
  88206. }
  88207. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  88208. if (parsedGeometry.matricesWeightsExtra) {
  88209. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  88210. }
  88211. };
  88212. /**
  88213. * Create a new geometry from persisted data (Using .babylon file format)
  88214. * @param parsedVertexData defines the persisted data
  88215. * @param scene defines the hosting scene
  88216. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88217. * @returns the new geometry object
  88218. */
  88219. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  88220. if (scene.getGeometryByID(parsedVertexData.id)) {
  88221. return null; // null since geometry could be something else than a box...
  88222. }
  88223. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  88224. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  88225. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  88226. }
  88227. if (parsedVertexData.delayLoadingFile) {
  88228. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  88229. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  88230. 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));
  88231. geometry._delayInfo = [];
  88232. if (parsedVertexData.hasUVs) {
  88233. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  88234. }
  88235. if (parsedVertexData.hasUVs2) {
  88236. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  88237. }
  88238. if (parsedVertexData.hasUVs3) {
  88239. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  88240. }
  88241. if (parsedVertexData.hasUVs4) {
  88242. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  88243. }
  88244. if (parsedVertexData.hasUVs5) {
  88245. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  88246. }
  88247. if (parsedVertexData.hasUVs6) {
  88248. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  88249. }
  88250. if (parsedVertexData.hasColors) {
  88251. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  88252. }
  88253. if (parsedVertexData.hasMatricesIndices) {
  88254. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  88255. }
  88256. if (parsedVertexData.hasMatricesWeights) {
  88257. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  88258. }
  88259. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  88260. }
  88261. else {
  88262. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  88263. }
  88264. scene.pushGeometry(geometry, true);
  88265. return geometry;
  88266. };
  88267. return Geometry;
  88268. }());
  88269. /***/ }),
  88270. /***/ "./Meshes/groundMesh.ts":
  88271. /*!******************************!*\
  88272. !*** ./Meshes/groundMesh.ts ***!
  88273. \******************************/
  88274. /*! exports provided: GroundMesh */
  88275. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88276. "use strict";
  88277. __webpack_require__.r(__webpack_exports__);
  88278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  88279. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  88280. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  88281. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  88282. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  88283. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  88284. return GroundMesh.Parse(parsedMesh, scene);
  88285. };
  88286. /**
  88287. * Mesh representing the gorund
  88288. */
  88289. var GroundMesh = /** @class */ (function (_super) {
  88290. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  88291. function GroundMesh(name, scene) {
  88292. var _this = _super.call(this, name, scene) || this;
  88293. /** If octree should be generated */
  88294. _this.generateOctree = false;
  88295. return _this;
  88296. }
  88297. /**
  88298. * "GroundMesh"
  88299. * @returns "GroundMesh"
  88300. */
  88301. GroundMesh.prototype.getClassName = function () {
  88302. return "GroundMesh";
  88303. };
  88304. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  88305. /**
  88306. * The minimum of x and y subdivisions
  88307. */
  88308. get: function () {
  88309. return Math.min(this._subdivisionsX, this._subdivisionsY);
  88310. },
  88311. enumerable: true,
  88312. configurable: true
  88313. });
  88314. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  88315. /**
  88316. * X subdivisions
  88317. */
  88318. get: function () {
  88319. return this._subdivisionsX;
  88320. },
  88321. enumerable: true,
  88322. configurable: true
  88323. });
  88324. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  88325. /**
  88326. * Y subdivisions
  88327. */
  88328. get: function () {
  88329. return this._subdivisionsY;
  88330. },
  88331. enumerable: true,
  88332. configurable: true
  88333. });
  88334. /**
  88335. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  88336. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  88337. * @param chunksCount the number of subdivisions for x and y
  88338. * @param octreeBlocksSize (Default: 32)
  88339. */
  88340. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  88341. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  88342. this._subdivisionsX = chunksCount;
  88343. this._subdivisionsY = chunksCount;
  88344. this.subdivide(chunksCount);
  88345. // Call the octree system optimization if it is defined.
  88346. var thisAsAny = this;
  88347. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  88348. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  88349. }
  88350. };
  88351. /**
  88352. * Returns a height (y) value in the Worl system :
  88353. * the ground altitude at the coordinates (x, z) expressed in the World system.
  88354. * @param x x coordinate
  88355. * @param z z coordinate
  88356. * @returns the ground y position if (x, z) are outside the ground surface.
  88357. */
  88358. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  88359. var world = this.getWorldMatrix();
  88360. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  88361. world.invertToRef(invMat);
  88362. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  88363. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  88364. x = tmpVect.x;
  88365. z = tmpVect.z;
  88366. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  88367. return this.position.y;
  88368. }
  88369. if (!this._heightQuads || this._heightQuads.length == 0) {
  88370. this._initHeightQuads();
  88371. this._computeHeightQuads();
  88372. }
  88373. var facet = this._getFacetAt(x, z);
  88374. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  88375. // return y in the World system
  88376. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  88377. return tmpVect.y;
  88378. };
  88379. /**
  88380. * Returns a normalized vector (Vector3) orthogonal to the ground
  88381. * at the ground coordinates (x, z) expressed in the World system.
  88382. * @param x x coordinate
  88383. * @param z z coordinate
  88384. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  88385. */
  88386. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  88387. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  88388. this.getNormalAtCoordinatesToRef(x, z, normal);
  88389. return normal;
  88390. };
  88391. /**
  88392. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  88393. * at the ground coordinates (x, z) expressed in the World system.
  88394. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  88395. * @param x x coordinate
  88396. * @param z z coordinate
  88397. * @param ref vector to store the result
  88398. * @returns the GroundMesh.
  88399. */
  88400. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  88401. var world = this.getWorldMatrix();
  88402. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  88403. world.invertToRef(tmpMat);
  88404. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  88405. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  88406. x = tmpVect.x;
  88407. z = tmpVect.z;
  88408. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  88409. return this;
  88410. }
  88411. if (!this._heightQuads || this._heightQuads.length == 0) {
  88412. this._initHeightQuads();
  88413. this._computeHeightQuads();
  88414. }
  88415. var facet = this._getFacetAt(x, z);
  88416. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  88417. return this;
  88418. };
  88419. /**
  88420. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  88421. * if the ground has been updated.
  88422. * This can be used in the render loop.
  88423. * @returns the GroundMesh.
  88424. */
  88425. GroundMesh.prototype.updateCoordinateHeights = function () {
  88426. if (!this._heightQuads || this._heightQuads.length == 0) {
  88427. this._initHeightQuads();
  88428. }
  88429. this._computeHeightQuads();
  88430. return this;
  88431. };
  88432. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  88433. GroundMesh.prototype._getFacetAt = function (x, z) {
  88434. // retrieve col and row from x, z coordinates in the ground local system
  88435. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  88436. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  88437. var quad = this._heightQuads[row * this._subdivisionsX + col];
  88438. var facet;
  88439. if (z < quad.slope.x * x + quad.slope.y) {
  88440. facet = quad.facet1;
  88441. }
  88442. else {
  88443. facet = quad.facet2;
  88444. }
  88445. return facet;
  88446. };
  88447. // Creates and populates the heightMap array with "facet" elements :
  88448. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  88449. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  88450. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  88451. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  88452. // Returns the GroundMesh.
  88453. GroundMesh.prototype._initHeightQuads = function () {
  88454. var subdivisionsX = this._subdivisionsX;
  88455. var subdivisionsY = this._subdivisionsY;
  88456. this._heightQuads = new Array();
  88457. for (var row = 0; row < subdivisionsY; row++) {
  88458. for (var col = 0; col < subdivisionsX; col++) {
  88459. 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) };
  88460. this._heightQuads[row * subdivisionsX + col] = quad;
  88461. }
  88462. }
  88463. return this;
  88464. };
  88465. // Compute each quad element values and update the the heightMap array :
  88466. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  88467. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  88468. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  88469. // Returns the GroundMesh.
  88470. GroundMesh.prototype._computeHeightQuads = function () {
  88471. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  88472. if (!positions) {
  88473. return this;
  88474. }
  88475. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  88476. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  88477. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  88478. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  88479. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  88480. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  88481. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  88482. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  88483. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  88484. var i = 0;
  88485. var j = 0;
  88486. var k = 0;
  88487. var cd = 0; // 2D slope coefficient : z = cd * x + h
  88488. var h = 0;
  88489. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  88490. var d2 = 0;
  88491. var subdivisionsX = this._subdivisionsX;
  88492. var subdivisionsY = this._subdivisionsY;
  88493. for (var row = 0; row < subdivisionsY; row++) {
  88494. for (var col = 0; col < subdivisionsX; col++) {
  88495. i = col * 3;
  88496. j = row * (subdivisionsX + 1) * 3;
  88497. k = (row + 1) * (subdivisionsX + 1) * 3;
  88498. v1.x = positions[j + i];
  88499. v1.y = positions[j + i + 1];
  88500. v1.z = positions[j + i + 2];
  88501. v2.x = positions[j + i + 3];
  88502. v2.y = positions[j + i + 4];
  88503. v2.z = positions[j + i + 5];
  88504. v3.x = positions[k + i];
  88505. v3.y = positions[k + i + 1];
  88506. v3.z = positions[k + i + 2];
  88507. v4.x = positions[k + i + 3];
  88508. v4.y = positions[k + i + 4];
  88509. v4.z = positions[k + i + 5];
  88510. // 2D slope V1V4
  88511. cd = (v4.z - v1.z) / (v4.x - v1.x);
  88512. h = v1.z - cd * v1.x; // v1 belongs to the slope
  88513. // facet equations :
  88514. // we compute each facet normal vector
  88515. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  88516. // we compute the value d by applying the equation to v1 which belongs to the plane
  88517. // then we store the facet equation in a Vector4
  88518. v2.subtractToRef(v1, v1v2);
  88519. v3.subtractToRef(v1, v1v3);
  88520. v4.subtractToRef(v1, v1v4);
  88521. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  88522. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  88523. norm1.normalize();
  88524. norm2.normalize();
  88525. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  88526. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  88527. var quad = this._heightQuads[row * subdivisionsX + col];
  88528. quad.slope.copyFromFloats(cd, h);
  88529. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  88530. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  88531. }
  88532. }
  88533. return this;
  88534. };
  88535. /**
  88536. * Serializes this ground mesh
  88537. * @param serializationObject object to write serialization to
  88538. */
  88539. GroundMesh.prototype.serialize = function (serializationObject) {
  88540. _super.prototype.serialize.call(this, serializationObject);
  88541. serializationObject.subdivisionsX = this._subdivisionsX;
  88542. serializationObject.subdivisionsY = this._subdivisionsY;
  88543. serializationObject.minX = this._minX;
  88544. serializationObject.maxX = this._maxX;
  88545. serializationObject.minZ = this._minZ;
  88546. serializationObject.maxZ = this._maxZ;
  88547. serializationObject.width = this._width;
  88548. serializationObject.height = this._height;
  88549. };
  88550. /**
  88551. * Parses a serialized ground mesh
  88552. * @param parsedMesh the serialized mesh
  88553. * @param scene the scene to create the ground mesh in
  88554. * @returns the created ground mesh
  88555. */
  88556. GroundMesh.Parse = function (parsedMesh, scene) {
  88557. var result = new GroundMesh(parsedMesh.name, scene);
  88558. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  88559. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  88560. result._minX = parsedMesh.minX;
  88561. result._maxX = parsedMesh.maxX;
  88562. result._minZ = parsedMesh.minZ;
  88563. result._maxZ = parsedMesh.maxZ;
  88564. result._width = parsedMesh.width;
  88565. result._height = parsedMesh.height;
  88566. return result;
  88567. };
  88568. return GroundMesh;
  88569. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  88570. /***/ }),
  88571. /***/ "./Meshes/index.ts":
  88572. /*!*************************!*\
  88573. !*** ./Meshes/index.ts ***!
  88574. \*************************/
  88575. /*! exports provided: AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, MeshLODLevel, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DataBuffer, WebGLDataBuffer, DracoCompression, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  88576. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88577. "use strict";
  88578. __webpack_require__.r(__webpack_exports__);
  88579. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  88580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  88581. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  88582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  88583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  88584. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  88585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  88586. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  88587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  88588. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  88589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  88590. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  88591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  88592. /* harmony import */ var _trailMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trailMesh */ "./Meshes/trailMesh.ts");
  88593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _trailMesh__WEBPACK_IMPORTED_MODULE_6__["TrailMesh"]; });
  88594. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  88595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedMesh"]; });
  88596. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  88597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["LinesMesh"]; });
  88598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["InstancedLinesMesh"]; });
  88599. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  88600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_CreationDataStorage"]; });
  88601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_InstancesBatch"]; });
  88602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["Mesh"]; });
  88603. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  88604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__["VertexData"]; });
  88605. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  88606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_11__["MeshBuilder"]; });
  88607. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  88608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationSettings"]; });
  88609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationQueue"]; });
  88610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationType"]; });
  88611. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  88612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__["SimplicationQueueSceneComponent"]; });
  88613. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  88614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["Polygon"]; });
  88615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["PolygonMeshBuilder"]; });
  88616. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  88617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["BaseSubMesh"]; });
  88618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["SubMesh"]; });
  88619. /* harmony import */ var _meshLODLevel__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./meshLODLevel */ "./Meshes/meshLODLevel.ts");
  88620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _meshLODLevel__WEBPACK_IMPORTED_MODULE_16__["MeshLODLevel"]; });
  88621. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  88622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_17__["TransformNode"]; });
  88623. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  88624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["BoxBuilder"]; });
  88625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["SphereBuilder"]; });
  88626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["CylinderBuilder"]; });
  88627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["LinesBuilder"]; });
  88628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["PlaneBuilder"]; });
  88629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["DiscBuilder"]; });
  88630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["RibbonBuilder"]; });
  88631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["HemisphereBuilder"]; });
  88632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["TorusBuilder"]; });
  88633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["TorusKnotBuilder"]; });
  88634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["PolygonBuilder"]; });
  88635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["ShapeBuilder"]; });
  88636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["LatheBuilder"]; });
  88637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["GroundBuilder"]; });
  88638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["TubeBuilder"]; });
  88639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["PolyhedronBuilder"]; });
  88640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["IcoSphereBuilder"]; });
  88641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_18__["DecalBuilder"]; });
  88642. /* harmony import */ var _dataBuffer__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./dataBuffer */ "./Meshes/dataBuffer.ts");
  88643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DataBuffer", function() { return _dataBuffer__WEBPACK_IMPORTED_MODULE_19__["DataBuffer"]; });
  88644. /* harmony import */ var _WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./WebGL/webGLDataBuffer */ "./Meshes/WebGL/webGLDataBuffer.ts");
  88645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGLDataBuffer", function() { return _WebGL_webGLDataBuffer__WEBPACK_IMPORTED_MODULE_20__["WebGLDataBuffer"]; });
  88646. /***/ }),
  88647. /***/ "./Meshes/instancedMesh.ts":
  88648. /*!*********************************!*\
  88649. !*** ./Meshes/instancedMesh.ts ***!
  88650. \*********************************/
  88651. /*! exports provided: InstancedMesh */
  88652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88653. "use strict";
  88654. __webpack_require__.r(__webpack_exports__);
  88655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  88656. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  88657. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  88658. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  88659. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  88660. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  88661. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  88662. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  88663. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  88664. return new InstancedMesh(name, mesh);
  88665. };
  88666. /**
  88667. * Creates an instance based on a source mesh.
  88668. */
  88669. var InstancedMesh = /** @class */ (function (_super) {
  88670. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  88671. function InstancedMesh(name, source) {
  88672. var _this = _super.call(this, name, source.getScene()) || this;
  88673. /** @hidden */
  88674. _this._indexInSourceMeshInstanceArray = -1;
  88675. source.addInstance(_this);
  88676. _this._sourceMesh = source;
  88677. _this.position.copyFrom(source.position);
  88678. _this.rotation.copyFrom(source.rotation);
  88679. _this.scaling.copyFrom(source.scaling);
  88680. if (source.rotationQuaternion) {
  88681. _this.rotationQuaternion = source.rotationQuaternion.clone();
  88682. }
  88683. _this.infiniteDistance = source.infiniteDistance;
  88684. _this.setPivotMatrix(source.getPivotMatrix());
  88685. _this.refreshBoundingInfo();
  88686. _this._syncSubMeshes();
  88687. return _this;
  88688. }
  88689. /**
  88690. * Returns the string "InstancedMesh".
  88691. */
  88692. InstancedMesh.prototype.getClassName = function () {
  88693. return "InstancedMesh";
  88694. };
  88695. Object.defineProperty(InstancedMesh.prototype, "lightSources", {
  88696. /** Gets the list of lights affecting that mesh */
  88697. get: function () {
  88698. return this._sourceMesh._lightSources;
  88699. },
  88700. enumerable: true,
  88701. configurable: true
  88702. });
  88703. InstancedMesh.prototype._resyncLightSources = function () {
  88704. // Do nothing as all the work will be done by source mesh
  88705. };
  88706. InstancedMesh.prototype._resyncLighSource = function (light) {
  88707. // Do nothing as all the work will be done by source mesh
  88708. };
  88709. InstancedMesh.prototype._removeLightSource = function (light) {
  88710. // Do nothing as all the work will be done by source mesh
  88711. };
  88712. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  88713. // Methods
  88714. /**
  88715. * If the source mesh receives shadows
  88716. */
  88717. get: function () {
  88718. return this._sourceMesh.receiveShadows;
  88719. },
  88720. enumerable: true,
  88721. configurable: true
  88722. });
  88723. Object.defineProperty(InstancedMesh.prototype, "material", {
  88724. /**
  88725. * The material of the source mesh
  88726. */
  88727. get: function () {
  88728. return this._sourceMesh.material;
  88729. },
  88730. enumerable: true,
  88731. configurable: true
  88732. });
  88733. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  88734. /**
  88735. * Visibility of the source mesh
  88736. */
  88737. get: function () {
  88738. return this._sourceMesh.visibility;
  88739. },
  88740. enumerable: true,
  88741. configurable: true
  88742. });
  88743. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  88744. /**
  88745. * Skeleton of the source mesh
  88746. */
  88747. get: function () {
  88748. return this._sourceMesh.skeleton;
  88749. },
  88750. enumerable: true,
  88751. configurable: true
  88752. });
  88753. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  88754. /**
  88755. * Rendering ground id of the source mesh
  88756. */
  88757. get: function () {
  88758. return this._sourceMesh.renderingGroupId;
  88759. },
  88760. set: function (value) {
  88761. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  88762. return;
  88763. }
  88764. //no-op with warning
  88765. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  88766. },
  88767. enumerable: true,
  88768. configurable: true
  88769. });
  88770. /**
  88771. * Returns the total number of vertices (integer).
  88772. */
  88773. InstancedMesh.prototype.getTotalVertices = function () {
  88774. return this._sourceMesh.getTotalVertices();
  88775. };
  88776. /**
  88777. * Returns a positive integer : the total number of indices in this mesh geometry.
  88778. * @returns the numner of indices or zero if the mesh has no geometry.
  88779. */
  88780. InstancedMesh.prototype.getTotalIndices = function () {
  88781. return this._sourceMesh.getTotalIndices();
  88782. };
  88783. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  88784. /**
  88785. * The source mesh of the instance
  88786. */
  88787. get: function () {
  88788. return this._sourceMesh;
  88789. },
  88790. enumerable: true,
  88791. configurable: true
  88792. });
  88793. /**
  88794. * Is this node ready to be used/rendered
  88795. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88796. * @return {boolean} is it ready
  88797. */
  88798. InstancedMesh.prototype.isReady = function (completeCheck) {
  88799. if (completeCheck === void 0) { completeCheck = false; }
  88800. return this._sourceMesh.isReady(completeCheck, true);
  88801. };
  88802. /**
  88803. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88804. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88805. * @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.
  88806. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88807. */
  88808. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  88809. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  88810. };
  88811. /**
  88812. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88813. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88814. * The `data` are either a numeric array either a Float32Array.
  88815. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88816. * 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).
  88817. * Note that a new underlying VertexBuffer object is created each call.
  88818. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88819. *
  88820. * Possible `kind` values :
  88821. * - VertexBuffer.PositionKind
  88822. * - VertexBuffer.UVKind
  88823. * - VertexBuffer.UV2Kind
  88824. * - VertexBuffer.UV3Kind
  88825. * - VertexBuffer.UV4Kind
  88826. * - VertexBuffer.UV5Kind
  88827. * - VertexBuffer.UV6Kind
  88828. * - VertexBuffer.ColorKind
  88829. * - VertexBuffer.MatricesIndicesKind
  88830. * - VertexBuffer.MatricesIndicesExtraKind
  88831. * - VertexBuffer.MatricesWeightsKind
  88832. * - VertexBuffer.MatricesWeightsExtraKind
  88833. *
  88834. * Returns the Mesh.
  88835. */
  88836. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  88837. if (this.sourceMesh) {
  88838. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  88839. }
  88840. return this.sourceMesh;
  88841. };
  88842. /**
  88843. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88844. * If the mesh has no geometry, it is simply returned as it is.
  88845. * The `data` are either a numeric array either a Float32Array.
  88846. * No new underlying VertexBuffer object is created.
  88847. * 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.
  88848. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88849. *
  88850. * Possible `kind` values :
  88851. * - VertexBuffer.PositionKind
  88852. * - VertexBuffer.UVKind
  88853. * - VertexBuffer.UV2Kind
  88854. * - VertexBuffer.UV3Kind
  88855. * - VertexBuffer.UV4Kind
  88856. * - VertexBuffer.UV5Kind
  88857. * - VertexBuffer.UV6Kind
  88858. * - VertexBuffer.ColorKind
  88859. * - VertexBuffer.MatricesIndicesKind
  88860. * - VertexBuffer.MatricesIndicesExtraKind
  88861. * - VertexBuffer.MatricesWeightsKind
  88862. * - VertexBuffer.MatricesWeightsExtraKind
  88863. *
  88864. * Returns the Mesh.
  88865. */
  88866. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  88867. if (this.sourceMesh) {
  88868. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  88869. }
  88870. return this.sourceMesh;
  88871. };
  88872. /**
  88873. * Sets the mesh indices.
  88874. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88875. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88876. * This method creates a new index buffer each call.
  88877. * Returns the Mesh.
  88878. */
  88879. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  88880. if (totalVertices === void 0) { totalVertices = null; }
  88881. if (this.sourceMesh) {
  88882. this.sourceMesh.setIndices(indices, totalVertices);
  88883. }
  88884. return this.sourceMesh;
  88885. };
  88886. /**
  88887. * Boolean : True if the mesh owns the requested kind of data.
  88888. */
  88889. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  88890. return this._sourceMesh.isVerticesDataPresent(kind);
  88891. };
  88892. /**
  88893. * Returns an array of indices (IndicesArray).
  88894. */
  88895. InstancedMesh.prototype.getIndices = function () {
  88896. return this._sourceMesh.getIndices();
  88897. };
  88898. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  88899. get: function () {
  88900. return this._sourceMesh._positions;
  88901. },
  88902. enumerable: true,
  88903. configurable: true
  88904. });
  88905. /**
  88906. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88907. * This means the mesh underlying bounding box and sphere are recomputed.
  88908. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88909. * @returns the current mesh
  88910. */
  88911. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  88912. if (applySkeleton === void 0) { applySkeleton = false; }
  88913. if (this._boundingInfo && this._boundingInfo.isLocked) {
  88914. return this;
  88915. }
  88916. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  88917. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  88918. return this;
  88919. };
  88920. /** @hidden */
  88921. InstancedMesh.prototype._preActivate = function () {
  88922. if (this._currentLOD) {
  88923. this._currentLOD._preActivate();
  88924. }
  88925. return this;
  88926. };
  88927. /** @hidden */
  88928. InstancedMesh.prototype._activate = function (renderId, intermediateRendering) {
  88929. if (this._currentLOD) {
  88930. this._currentLOD._registerInstanceForRenderId(this, renderId);
  88931. }
  88932. if (intermediateRendering) {
  88933. if (!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate) {
  88934. this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = true;
  88935. return true;
  88936. }
  88937. }
  88938. else {
  88939. if (!this._currentLOD._internalAbstractMeshDataInfo._isActive) {
  88940. this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances = true;
  88941. return true;
  88942. }
  88943. }
  88944. return false;
  88945. };
  88946. /** @hidden */
  88947. InstancedMesh.prototype._postActivate = function () {
  88948. if (this._edgesRenderer && this._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {
  88949. this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer);
  88950. }
  88951. };
  88952. InstancedMesh.prototype.getWorldMatrix = function () {
  88953. if (this._currentLOD && this._currentLOD.billboardMode !== _transformNode__WEBPACK_IMPORTED_MODULE_6__["TransformNode"].BILLBOARDMODE_NONE && this._currentLOD._masterMesh !== this) {
  88954. var tempMaster = this._currentLOD._masterMesh;
  88955. this._currentLOD._masterMesh = this;
  88956. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0].copyFrom(this._currentLOD.computeWorldMatrix(true));
  88957. this._currentLOD._masterMesh = tempMaster;
  88958. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  88959. }
  88960. return _super.prototype.getWorldMatrix.call(this);
  88961. };
  88962. Object.defineProperty(InstancedMesh.prototype, "isAnInstance", {
  88963. get: function () {
  88964. return true;
  88965. },
  88966. enumerable: true,
  88967. configurable: true
  88968. });
  88969. /**
  88970. * Returns the current associated LOD AbstractMesh.
  88971. */
  88972. InstancedMesh.prototype.getLOD = function (camera) {
  88973. if (!camera) {
  88974. return this;
  88975. }
  88976. var boundingInfo = this.getBoundingInfo();
  88977. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  88978. if (this._currentLOD === this.sourceMesh) {
  88979. return this.sourceMesh;
  88980. }
  88981. return this._currentLOD;
  88982. };
  88983. /** @hidden */
  88984. InstancedMesh.prototype._syncSubMeshes = function () {
  88985. this.releaseSubMeshes();
  88986. if (this._sourceMesh.subMeshes) {
  88987. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  88988. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  88989. }
  88990. }
  88991. return this;
  88992. };
  88993. /** @hidden */
  88994. InstancedMesh.prototype._generatePointsArray = function () {
  88995. return this._sourceMesh._generatePointsArray();
  88996. };
  88997. /**
  88998. * Creates a new InstancedMesh from the current mesh.
  88999. * - name (string) : the cloned mesh name
  89000. * - newParent (optional Node) : the optional Node to parent the clone to.
  89001. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89002. *
  89003. * Returns the clone.
  89004. */
  89005. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  89006. var result = this._sourceMesh.createInstance(name);
  89007. // Deep copy
  89008. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_5__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  89009. // Bounding info
  89010. this.refreshBoundingInfo();
  89011. // Parent
  89012. if (newParent) {
  89013. result.parent = newParent;
  89014. }
  89015. if (!doNotCloneChildren) {
  89016. // Children
  89017. for (var index = 0; index < this.getScene().meshes.length; index++) {
  89018. var mesh = this.getScene().meshes[index];
  89019. if (mesh.parent === this) {
  89020. mesh.clone(mesh.name, result);
  89021. }
  89022. }
  89023. }
  89024. result.computeWorldMatrix(true);
  89025. return result;
  89026. };
  89027. /**
  89028. * Disposes the InstancedMesh.
  89029. * Returns nothing.
  89030. */
  89031. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  89032. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  89033. // Remove from mesh
  89034. this._sourceMesh.removeInstance(this);
  89035. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  89036. };
  89037. return InstancedMesh;
  89038. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]));
  89039. /***/ }),
  89040. /***/ "./Meshes/linesMesh.ts":
  89041. /*!*****************************!*\
  89042. !*** ./Meshes/linesMesh.ts ***!
  89043. \*****************************/
  89044. /*! exports provided: LinesMesh, InstancedLinesMesh */
  89045. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89046. "use strict";
  89047. __webpack_require__.r(__webpack_exports__);
  89048. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  89049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  89050. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89051. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89052. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  89053. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  89054. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  89055. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  89056. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  89057. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  89058. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  89059. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  89060. /**
  89061. * Line mesh
  89062. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  89063. */
  89064. var LinesMesh = /** @class */ (function (_super) {
  89065. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  89066. /**
  89067. * Creates a new LinesMesh
  89068. * @param name defines the name
  89069. * @param scene defines the hosting scene
  89070. * @param parent defines the parent mesh if any
  89071. * @param source defines the optional source LinesMesh used to clone data from
  89072. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89073. * When false, achieved by calling a clone(), also passing False.
  89074. * This will make creation of children, recursive.
  89075. * @param useVertexColor defines if this LinesMesh supports vertex color
  89076. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  89077. */
  89078. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  89079. /**
  89080. * If vertex color should be applied to the mesh
  89081. */
  89082. useVertexColor,
  89083. /**
  89084. * If vertex alpha should be applied to the mesh
  89085. */
  89086. useVertexAlpha) {
  89087. if (scene === void 0) { scene = null; }
  89088. if (parent === void 0) { parent = null; }
  89089. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  89090. _this.useVertexColor = useVertexColor;
  89091. _this.useVertexAlpha = useVertexAlpha;
  89092. /**
  89093. * Color of the line (Default: White)
  89094. */
  89095. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  89096. /**
  89097. * Alpha of the line (Default: 1)
  89098. */
  89099. _this.alpha = 1;
  89100. if (source) {
  89101. _this.color = source.color.clone();
  89102. _this.alpha = source.alpha;
  89103. _this.useVertexColor = source.useVertexColor;
  89104. _this.useVertexAlpha = source.useVertexAlpha;
  89105. }
  89106. _this.intersectionThreshold = 0.1;
  89107. var defines = [];
  89108. var options = {
  89109. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  89110. uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "world", "viewProjection"],
  89111. needAlphaBlending: true,
  89112. defines: defines
  89113. };
  89114. if (useVertexAlpha === false) {
  89115. options.needAlphaBlending = false;
  89116. }
  89117. if (!useVertexColor) {
  89118. options.uniforms.push("color");
  89119. }
  89120. else {
  89121. options.defines.push("#define VERTEXCOLOR");
  89122. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  89123. }
  89124. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  89125. return _this;
  89126. }
  89127. LinesMesh.prototype._addClipPlaneDefine = function (label) {
  89128. var define = "#define " + label;
  89129. var index = this._colorShader.options.defines.indexOf(define);
  89130. if (index !== -1) {
  89131. return;
  89132. }
  89133. this._colorShader.options.defines.push(define);
  89134. };
  89135. LinesMesh.prototype._removeClipPlaneDefine = function (label) {
  89136. var define = "#define " + label;
  89137. var index = this._colorShader.options.defines.indexOf(define);
  89138. if (index === -1) {
  89139. return;
  89140. }
  89141. this._colorShader.options.defines.splice(index, 1);
  89142. };
  89143. LinesMesh.prototype.isReady = function () {
  89144. var scene = this.getScene();
  89145. // Clip planes
  89146. scene.clipPlane ? this._addClipPlaneDefine("CLIPPLANE") : this._removeClipPlaneDefine("CLIPPLANE");
  89147. scene.clipPlane2 ? this._addClipPlaneDefine("CLIPPLANE2") : this._removeClipPlaneDefine("CLIPPLANE2");
  89148. scene.clipPlane3 ? this._addClipPlaneDefine("CLIPPLANE3") : this._removeClipPlaneDefine("CLIPPLANE3");
  89149. scene.clipPlane4 ? this._addClipPlaneDefine("CLIPPLANE4") : this._removeClipPlaneDefine("CLIPPLANE4");
  89150. if (!this._colorShader.isReady()) {
  89151. return false;
  89152. }
  89153. return _super.prototype.isReady.call(this);
  89154. };
  89155. /**
  89156. * Returns the string "LineMesh"
  89157. */
  89158. LinesMesh.prototype.getClassName = function () {
  89159. return "LinesMesh";
  89160. };
  89161. Object.defineProperty(LinesMesh.prototype, "material", {
  89162. /**
  89163. * @hidden
  89164. */
  89165. get: function () {
  89166. return this._colorShader;
  89167. },
  89168. /**
  89169. * @hidden
  89170. */
  89171. set: function (value) {
  89172. // Do nothing
  89173. },
  89174. enumerable: true,
  89175. configurable: true
  89176. });
  89177. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  89178. /**
  89179. * @hidden
  89180. */
  89181. get: function () {
  89182. return false;
  89183. },
  89184. enumerable: true,
  89185. configurable: true
  89186. });
  89187. /** @hidden */
  89188. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  89189. if (!this._geometry) {
  89190. return this;
  89191. }
  89192. var colorEffect = this._colorShader.getEffect();
  89193. // VBOs
  89194. var indexToBind = this.isUnIndexed ? null : this._geometry.getIndexBuffer();
  89195. this._geometry._bind(colorEffect, indexToBind);
  89196. // Color
  89197. if (!this.useVertexColor) {
  89198. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  89199. }
  89200. // Clip planes
  89201. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_9__["MaterialHelper"].BindClipPlane(colorEffect, this.getScene());
  89202. return this;
  89203. };
  89204. /** @hidden */
  89205. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  89206. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  89207. return this;
  89208. }
  89209. var engine = this.getScene().getEngine();
  89210. // Draw order
  89211. if (this._unIndexed) {
  89212. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  89213. }
  89214. else {
  89215. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  89216. }
  89217. return this;
  89218. };
  89219. /**
  89220. * Disposes of the line mesh
  89221. * @param doNotRecurse If children should be disposed
  89222. */
  89223. LinesMesh.prototype.dispose = function (doNotRecurse) {
  89224. this._colorShader.dispose(false, false, true);
  89225. _super.prototype.dispose.call(this, doNotRecurse);
  89226. };
  89227. /**
  89228. * Returns a new LineMesh object cloned from the current one.
  89229. */
  89230. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  89231. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  89232. };
  89233. /**
  89234. * Creates a new InstancedLinesMesh object from the mesh model.
  89235. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89236. * @param name defines the name of the new instance
  89237. * @returns a new InstancedLinesMesh
  89238. */
  89239. LinesMesh.prototype.createInstance = function (name) {
  89240. return new InstancedLinesMesh(name, this);
  89241. };
  89242. return LinesMesh;
  89243. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  89244. /**
  89245. * Creates an instance based on a source LinesMesh
  89246. */
  89247. var InstancedLinesMesh = /** @class */ (function (_super) {
  89248. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  89249. function InstancedLinesMesh(name, source) {
  89250. var _this = _super.call(this, name, source) || this;
  89251. _this.intersectionThreshold = source.intersectionThreshold;
  89252. return _this;
  89253. }
  89254. /**
  89255. * Returns the string "InstancedLinesMesh".
  89256. */
  89257. InstancedLinesMesh.prototype.getClassName = function () {
  89258. return "InstancedLinesMesh";
  89259. };
  89260. return InstancedLinesMesh;
  89261. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  89262. /***/ }),
  89263. /***/ "./Meshes/mesh.ts":
  89264. /*!************************!*\
  89265. !*** ./Meshes/mesh.ts ***!
  89266. \************************/
  89267. /*! exports provided: _CreationDataStorage, _InstancesBatch, Mesh */
  89268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89269. "use strict";
  89270. __webpack_require__.r(__webpack_exports__);
  89271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  89272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  89273. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  89274. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89275. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  89276. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  89277. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  89278. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  89279. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89280. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  89281. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  89282. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  89283. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  89284. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  89285. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  89286. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  89287. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  89288. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  89289. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  89290. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  89291. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  89292. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  89293. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  89294. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  89295. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  89296. /* harmony import */ var _meshLODLevel__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./meshLODLevel */ "./Meshes/meshLODLevel.ts");
  89297. /**
  89298. * @hidden
  89299. **/
  89300. var _CreationDataStorage = /** @class */ (function () {
  89301. function _CreationDataStorage() {
  89302. }
  89303. return _CreationDataStorage;
  89304. }());
  89305. /**
  89306. * @hidden
  89307. **/
  89308. var _InstanceDataStorage = /** @class */ (function () {
  89309. function _InstanceDataStorage() {
  89310. this.visibleInstances = {};
  89311. this.batchCache = new _InstancesBatch();
  89312. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  89313. }
  89314. return _InstanceDataStorage;
  89315. }());
  89316. /**
  89317. * @hidden
  89318. **/
  89319. var _InstancesBatch = /** @class */ (function () {
  89320. function _InstancesBatch() {
  89321. this.mustReturn = false;
  89322. this.visibleInstances = new Array();
  89323. this.renderSelf = new Array();
  89324. this.hardwareInstancedRendering = new Array();
  89325. }
  89326. return _InstancesBatch;
  89327. }());
  89328. /**
  89329. * @hidden
  89330. **/
  89331. var _InternalMeshDataInfo = /** @class */ (function () {
  89332. function _InternalMeshDataInfo() {
  89333. this._areNormalsFrozen = false; // Will be used by ribbons mainly
  89334. // Will be used to save a source mesh reference, If any
  89335. this._source = null;
  89336. // Will be used to for fast cloned mesh lookup
  89337. this.meshMap = null;
  89338. this._preActivateId = -1;
  89339. this._LODLevels = new Array();
  89340. // Morph
  89341. this._morphTargetManager = null;
  89342. }
  89343. return _InternalMeshDataInfo;
  89344. }());
  89345. /**
  89346. * Class used to represent renderable models
  89347. */
  89348. var Mesh = /** @class */ (function (_super) {
  89349. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  89350. /**
  89351. * @constructor
  89352. * @param name The value used by scene.getMeshByName() to do a lookup.
  89353. * @param scene The scene to add this mesh to.
  89354. * @param parent The parent of this mesh, if it has one
  89355. * @param source An optional Mesh from which geometry is shared, cloned.
  89356. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89357. * When false, achieved by calling a clone(), also passing False.
  89358. * This will make creation of children, recursive.
  89359. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  89360. */
  89361. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  89362. if (scene === void 0) { scene = null; }
  89363. if (parent === void 0) { parent = null; }
  89364. if (source === void 0) { source = null; }
  89365. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  89366. var _this = _super.call(this, name, scene) || this;
  89367. // Internal data
  89368. _this._internalMeshDataInfo = new _InternalMeshDataInfo();
  89369. // Members
  89370. /**
  89371. * Gets the delay loading state of the mesh (when delay loading is turned on)
  89372. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  89373. */
  89374. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NONE;
  89375. /**
  89376. * Gets the list of instances created from this mesh
  89377. * it is not supposed to be modified manually.
  89378. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  89379. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89380. */
  89381. _this.instances = new Array();
  89382. // Private
  89383. /** @hidden */
  89384. _this._creationDataStorage = null;
  89385. /** @hidden */
  89386. _this._geometry = null;
  89387. /** @hidden */
  89388. _this._instanceDataStorage = new _InstanceDataStorage();
  89389. _this._effectiveMaterial = null;
  89390. /** @hidden */
  89391. _this._shouldGenerateFlatShading = false;
  89392. // Use by builder only to know what orientation were the mesh build in.
  89393. /** @hidden */
  89394. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  89395. /**
  89396. * Use this property to change the original side orientation defined at construction time
  89397. */
  89398. _this.overrideMaterialSideOrientation = null;
  89399. scene = _this.getScene();
  89400. if (source) {
  89401. // Geometry
  89402. if (source._geometry) {
  89403. source._geometry.applyToMesh(_this);
  89404. }
  89405. // Deep copy
  89406. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  89407. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  89408. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  89409. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  89410. "onDisposeObservable"
  89411. ], ["_poseMatrix"]);
  89412. // Source mesh
  89413. _this._internalMeshDataInfo._source = source;
  89414. if (scene.useClonedMeshhMap) {
  89415. if (!source._internalMeshDataInfo.meshMap) {
  89416. source._internalMeshDataInfo.meshMap = {};
  89417. }
  89418. source._internalMeshDataInfo.meshMap[_this.uniqueId] = _this;
  89419. }
  89420. // Construction Params
  89421. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  89422. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  89423. _this._creationDataStorage = source._creationDataStorage;
  89424. // Animation ranges
  89425. if (source._ranges) {
  89426. var ranges = source._ranges;
  89427. for (var name in ranges) {
  89428. if (!ranges.hasOwnProperty(name)) {
  89429. continue;
  89430. }
  89431. if (!ranges[name]) {
  89432. continue;
  89433. }
  89434. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  89435. }
  89436. }
  89437. // Metadata
  89438. if (source.metadata && source.metadata.clone) {
  89439. _this.metadata = source.metadata.clone();
  89440. }
  89441. else {
  89442. _this.metadata = source.metadata;
  89443. }
  89444. // Tags
  89445. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  89446. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  89447. }
  89448. // Parent
  89449. _this.parent = source.parent;
  89450. // Pivot
  89451. _this.setPivotMatrix(source.getPivotMatrix());
  89452. _this.id = name + "." + source.id;
  89453. // Material
  89454. _this.material = source.material;
  89455. var index;
  89456. if (!doNotCloneChildren) {
  89457. // Children
  89458. var directDescendants = source.getDescendants(true);
  89459. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  89460. var child = directDescendants[index_1];
  89461. if (child.clone) {
  89462. child.clone(name + "." + child.name, _this);
  89463. }
  89464. }
  89465. }
  89466. // Physics clone
  89467. if (scene.getPhysicsEngine) {
  89468. var physicsEngine = scene.getPhysicsEngine();
  89469. if (clonePhysicsImpostor && physicsEngine) {
  89470. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  89471. if (impostor) {
  89472. _this.physicsImpostor = impostor.clone(_this);
  89473. }
  89474. }
  89475. }
  89476. // Particles
  89477. for (index = 0; index < scene.particleSystems.length; index++) {
  89478. var system = scene.particleSystems[index];
  89479. if (system.emitter === source) {
  89480. system.clone(system.name, _this);
  89481. }
  89482. }
  89483. _this.refreshBoundingInfo();
  89484. _this.computeWorldMatrix(true);
  89485. }
  89486. // Parent
  89487. if (parent !== null) {
  89488. _this.parent = parent;
  89489. }
  89490. _this._instanceDataStorage.hardwareInstancedRendering = _this.getEngine().getCaps().instancedArrays;
  89491. return _this;
  89492. }
  89493. /**
  89494. * Gets the default side orientation.
  89495. * @param orientation the orientation to value to attempt to get
  89496. * @returns the default orientation
  89497. * @hidden
  89498. */
  89499. Mesh._GetDefaultSideOrientation = function (orientation) {
  89500. return orientation || Mesh.FRONTSIDE; // works as Mesh.FRONTSIDE is 0
  89501. };
  89502. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  89503. /**
  89504. * An event triggered before rendering the mesh
  89505. */
  89506. get: function () {
  89507. if (!this._internalMeshDataInfo._onBeforeRenderObservable) {
  89508. this._internalMeshDataInfo._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  89509. }
  89510. return this._internalMeshDataInfo._onBeforeRenderObservable;
  89511. },
  89512. enumerable: true,
  89513. configurable: true
  89514. });
  89515. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  89516. /**
  89517. * An event triggered before binding the mesh
  89518. */
  89519. get: function () {
  89520. if (!this._internalMeshDataInfo._onBeforeBindObservable) {
  89521. this._internalMeshDataInfo._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  89522. }
  89523. return this._internalMeshDataInfo._onBeforeBindObservable;
  89524. },
  89525. enumerable: true,
  89526. configurable: true
  89527. });
  89528. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  89529. /**
  89530. * An event triggered after rendering the mesh
  89531. */
  89532. get: function () {
  89533. if (!this._internalMeshDataInfo._onAfterRenderObservable) {
  89534. this._internalMeshDataInfo._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  89535. }
  89536. return this._internalMeshDataInfo._onAfterRenderObservable;
  89537. },
  89538. enumerable: true,
  89539. configurable: true
  89540. });
  89541. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  89542. /**
  89543. * An event triggered before drawing the mesh
  89544. */
  89545. get: function () {
  89546. if (!this._internalMeshDataInfo._onBeforeDrawObservable) {
  89547. this._internalMeshDataInfo._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  89548. }
  89549. return this._internalMeshDataInfo._onBeforeDrawObservable;
  89550. },
  89551. enumerable: true,
  89552. configurable: true
  89553. });
  89554. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  89555. /**
  89556. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  89557. */
  89558. set: function (callback) {
  89559. if (this._onBeforeDrawObserver) {
  89560. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  89561. }
  89562. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  89563. },
  89564. enumerable: true,
  89565. configurable: true
  89566. });
  89567. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  89568. /**
  89569. * Gets or sets the morph target manager
  89570. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89571. */
  89572. get: function () {
  89573. return this._internalMeshDataInfo._morphTargetManager;
  89574. },
  89575. set: function (value) {
  89576. if (this._internalMeshDataInfo._morphTargetManager === value) {
  89577. return;
  89578. }
  89579. this._internalMeshDataInfo._morphTargetManager = value;
  89580. this._syncGeometryWithMorphTargetManager();
  89581. },
  89582. enumerable: true,
  89583. configurable: true
  89584. });
  89585. Object.defineProperty(Mesh.prototype, "source", {
  89586. /**
  89587. * Gets the source mesh (the one used to clone this one from)
  89588. */
  89589. get: function () {
  89590. return this._internalMeshDataInfo._source;
  89591. },
  89592. enumerable: true,
  89593. configurable: true
  89594. });
  89595. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  89596. /**
  89597. * Gets or sets a boolean indicating that this mesh does not use index buffer
  89598. */
  89599. get: function () {
  89600. return this._unIndexed;
  89601. },
  89602. set: function (value) {
  89603. if (this._unIndexed !== value) {
  89604. this._unIndexed = value;
  89605. this._markSubMeshesAsAttributesDirty();
  89606. }
  89607. },
  89608. enumerable: true,
  89609. configurable: true
  89610. });
  89611. // Methods
  89612. /**
  89613. * Gets the class name
  89614. * @returns the string "Mesh".
  89615. */
  89616. Mesh.prototype.getClassName = function () {
  89617. return "Mesh";
  89618. };
  89619. Object.defineProperty(Mesh.prototype, "_isMesh", {
  89620. /** @hidden */
  89621. get: function () {
  89622. return true;
  89623. },
  89624. enumerable: true,
  89625. configurable: true
  89626. });
  89627. /**
  89628. * Returns a description of this mesh
  89629. * @param fullDetails define if full details about this mesh must be used
  89630. * @returns a descriptive string representing this mesh
  89631. */
  89632. Mesh.prototype.toString = function (fullDetails) {
  89633. var ret = _super.prototype.toString.call(this, fullDetails);
  89634. ret += ", n vertices: " + this.getTotalVertices();
  89635. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  89636. if (this.animations) {
  89637. for (var i = 0; i < this.animations.length; i++) {
  89638. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  89639. }
  89640. }
  89641. if (fullDetails) {
  89642. if (this._geometry) {
  89643. var ib = this.getIndices();
  89644. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  89645. if (vb && ib) {
  89646. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  89647. }
  89648. }
  89649. else {
  89650. ret += ", flat shading: UNKNOWN";
  89651. }
  89652. }
  89653. return ret;
  89654. };
  89655. /** @hidden */
  89656. Mesh.prototype._unBindEffect = function () {
  89657. _super.prototype._unBindEffect.call(this);
  89658. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  89659. var instance = _a[_i];
  89660. instance._unBindEffect();
  89661. }
  89662. };
  89663. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  89664. /**
  89665. * Gets a boolean indicating if this mesh has LOD
  89666. */
  89667. get: function () {
  89668. return this._internalMeshDataInfo._LODLevels.length > 0;
  89669. },
  89670. enumerable: true,
  89671. configurable: true
  89672. });
  89673. /**
  89674. * Gets the list of MeshLODLevel associated with the current mesh
  89675. * @returns an array of MeshLODLevel
  89676. */
  89677. Mesh.prototype.getLODLevels = function () {
  89678. return this._internalMeshDataInfo._LODLevels;
  89679. };
  89680. Mesh.prototype._sortLODLevels = function () {
  89681. this._internalMeshDataInfo._LODLevels.sort(function (a, b) {
  89682. if (a.distance < b.distance) {
  89683. return 1;
  89684. }
  89685. if (a.distance > b.distance) {
  89686. return -1;
  89687. }
  89688. return 0;
  89689. });
  89690. };
  89691. /**
  89692. * Add a mesh as LOD level triggered at the given distance.
  89693. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89694. * @param distance The distance from the center of the object to show this level
  89695. * @param mesh The mesh to be added as LOD level (can be null)
  89696. * @return This mesh (for chaining)
  89697. */
  89698. Mesh.prototype.addLODLevel = function (distance, mesh) {
  89699. if (mesh && mesh._masterMesh) {
  89700. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  89701. return this;
  89702. }
  89703. var level = new _meshLODLevel__WEBPACK_IMPORTED_MODULE_22__["MeshLODLevel"](distance, mesh);
  89704. this._internalMeshDataInfo._LODLevels.push(level);
  89705. if (mesh) {
  89706. mesh._masterMesh = this;
  89707. }
  89708. this._sortLODLevels();
  89709. return this;
  89710. };
  89711. /**
  89712. * Returns the LOD level mesh at the passed distance or null if not found.
  89713. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89714. * @param distance The distance from the center of the object to show this level
  89715. * @returns a Mesh or `null`
  89716. */
  89717. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  89718. var internalDataInfo = this._internalMeshDataInfo;
  89719. for (var index = 0; index < internalDataInfo._LODLevels.length; index++) {
  89720. var level = internalDataInfo._LODLevels[index];
  89721. if (level.distance === distance) {
  89722. return level.mesh;
  89723. }
  89724. }
  89725. return null;
  89726. };
  89727. /**
  89728. * Remove a mesh from the LOD array
  89729. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89730. * @param mesh defines the mesh to be removed
  89731. * @return This mesh (for chaining)
  89732. */
  89733. Mesh.prototype.removeLODLevel = function (mesh) {
  89734. var internalDataInfo = this._internalMeshDataInfo;
  89735. for (var index = 0; index < internalDataInfo._LODLevels.length; index++) {
  89736. if (internalDataInfo._LODLevels[index].mesh === mesh) {
  89737. internalDataInfo._LODLevels.splice(index, 1);
  89738. if (mesh) {
  89739. mesh._masterMesh = null;
  89740. }
  89741. }
  89742. }
  89743. this._sortLODLevels();
  89744. return this;
  89745. };
  89746. /**
  89747. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89748. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89749. * @param camera defines the camera to use to compute distance
  89750. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89751. * @return This mesh (for chaining)
  89752. */
  89753. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  89754. var internalDataInfo = this._internalMeshDataInfo;
  89755. if (!internalDataInfo._LODLevels || internalDataInfo._LODLevels.length === 0) {
  89756. return this;
  89757. }
  89758. var bSphere;
  89759. if (boundingSphere) {
  89760. bSphere = boundingSphere;
  89761. }
  89762. else {
  89763. var boundingInfo = this.getBoundingInfo();
  89764. bSphere = boundingInfo.boundingSphere;
  89765. }
  89766. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  89767. if (internalDataInfo._LODLevels[internalDataInfo._LODLevels.length - 1].distance > distanceToCamera) {
  89768. if (this.onLODLevelSelection) {
  89769. this.onLODLevelSelection(distanceToCamera, this, internalDataInfo._LODLevels[internalDataInfo._LODLevels.length - 1].mesh);
  89770. }
  89771. return this;
  89772. }
  89773. for (var index = 0; index < internalDataInfo._LODLevels.length; index++) {
  89774. var level = internalDataInfo._LODLevels[index];
  89775. if (level.distance < distanceToCamera) {
  89776. if (level.mesh) {
  89777. level.mesh._preActivate();
  89778. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  89779. }
  89780. if (this.onLODLevelSelection) {
  89781. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  89782. }
  89783. return level.mesh;
  89784. }
  89785. }
  89786. if (this.onLODLevelSelection) {
  89787. this.onLODLevelSelection(distanceToCamera, this, this);
  89788. }
  89789. return this;
  89790. };
  89791. Object.defineProperty(Mesh.prototype, "geometry", {
  89792. /**
  89793. * Gets the mesh internal Geometry object
  89794. */
  89795. get: function () {
  89796. return this._geometry;
  89797. },
  89798. enumerable: true,
  89799. configurable: true
  89800. });
  89801. /**
  89802. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89803. * @returns the total number of vertices
  89804. */
  89805. Mesh.prototype.getTotalVertices = function () {
  89806. if (this._geometry === null || this._geometry === undefined) {
  89807. return 0;
  89808. }
  89809. return this._geometry.getTotalVertices();
  89810. };
  89811. /**
  89812. * Returns the content of an associated vertex buffer
  89813. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89814. * - VertexBuffer.PositionKind
  89815. * - VertexBuffer.UVKind
  89816. * - VertexBuffer.UV2Kind
  89817. * - VertexBuffer.UV3Kind
  89818. * - VertexBuffer.UV4Kind
  89819. * - VertexBuffer.UV5Kind
  89820. * - VertexBuffer.UV6Kind
  89821. * - VertexBuffer.ColorKind
  89822. * - VertexBuffer.MatricesIndicesKind
  89823. * - VertexBuffer.MatricesIndicesExtraKind
  89824. * - VertexBuffer.MatricesWeightsKind
  89825. * - VertexBuffer.MatricesWeightsExtraKind
  89826. * @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
  89827. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89828. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89829. */
  89830. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  89831. if (!this._geometry) {
  89832. return null;
  89833. }
  89834. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  89835. };
  89836. /**
  89837. * Returns the mesh VertexBuffer object from the requested `kind`
  89838. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89839. * - VertexBuffer.PositionKind
  89840. * - VertexBuffer.UVKind
  89841. * - VertexBuffer.UV2Kind
  89842. * - VertexBuffer.UV3Kind
  89843. * - VertexBuffer.UV4Kind
  89844. * - VertexBuffer.UV5Kind
  89845. * - VertexBuffer.UV6Kind
  89846. * - VertexBuffer.ColorKind
  89847. * - VertexBuffer.MatricesIndicesKind
  89848. * - VertexBuffer.MatricesIndicesExtraKind
  89849. * - VertexBuffer.MatricesWeightsKind
  89850. * - VertexBuffer.MatricesWeightsExtraKind
  89851. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89852. */
  89853. Mesh.prototype.getVertexBuffer = function (kind) {
  89854. if (!this._geometry) {
  89855. return null;
  89856. }
  89857. return this._geometry.getVertexBuffer(kind);
  89858. };
  89859. /**
  89860. * Tests if a specific vertex buffer is associated with this mesh
  89861. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89862. * - VertexBuffer.PositionKind
  89863. * - VertexBuffer.UVKind
  89864. * - VertexBuffer.UV2Kind
  89865. * - VertexBuffer.UV3Kind
  89866. * - VertexBuffer.UV4Kind
  89867. * - VertexBuffer.UV5Kind
  89868. * - VertexBuffer.UV6Kind
  89869. * - VertexBuffer.ColorKind
  89870. * - VertexBuffer.MatricesIndicesKind
  89871. * - VertexBuffer.MatricesIndicesExtraKind
  89872. * - VertexBuffer.MatricesWeightsKind
  89873. * - VertexBuffer.MatricesWeightsExtraKind
  89874. * @returns a boolean
  89875. */
  89876. Mesh.prototype.isVerticesDataPresent = function (kind) {
  89877. if (!this._geometry) {
  89878. if (this._delayInfo) {
  89879. return this._delayInfo.indexOf(kind) !== -1;
  89880. }
  89881. return false;
  89882. }
  89883. return this._geometry.isVerticesDataPresent(kind);
  89884. };
  89885. /**
  89886. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89887. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89888. * - VertexBuffer.PositionKind
  89889. * - VertexBuffer.UVKind
  89890. * - VertexBuffer.UV2Kind
  89891. * - VertexBuffer.UV3Kind
  89892. * - VertexBuffer.UV4Kind
  89893. * - VertexBuffer.UV5Kind
  89894. * - VertexBuffer.UV6Kind
  89895. * - VertexBuffer.ColorKind
  89896. * - VertexBuffer.MatricesIndicesKind
  89897. * - VertexBuffer.MatricesIndicesExtraKind
  89898. * - VertexBuffer.MatricesWeightsKind
  89899. * - VertexBuffer.MatricesWeightsExtraKind
  89900. * @returns a boolean
  89901. */
  89902. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  89903. if (!this._geometry) {
  89904. if (this._delayInfo) {
  89905. return this._delayInfo.indexOf(kind) !== -1;
  89906. }
  89907. return false;
  89908. }
  89909. return this._geometry.isVertexBufferUpdatable(kind);
  89910. };
  89911. /**
  89912. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89913. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89914. * - VertexBuffer.PositionKind
  89915. * - VertexBuffer.UVKind
  89916. * - VertexBuffer.UV2Kind
  89917. * - VertexBuffer.UV3Kind
  89918. * - VertexBuffer.UV4Kind
  89919. * - VertexBuffer.UV5Kind
  89920. * - VertexBuffer.UV6Kind
  89921. * - VertexBuffer.ColorKind
  89922. * - VertexBuffer.MatricesIndicesKind
  89923. * - VertexBuffer.MatricesIndicesExtraKind
  89924. * - VertexBuffer.MatricesWeightsKind
  89925. * - VertexBuffer.MatricesWeightsExtraKind
  89926. * @returns an array of strings
  89927. */
  89928. Mesh.prototype.getVerticesDataKinds = function () {
  89929. if (!this._geometry) {
  89930. var result = new Array();
  89931. if (this._delayInfo) {
  89932. this._delayInfo.forEach(function (kind) {
  89933. result.push(kind);
  89934. });
  89935. }
  89936. return result;
  89937. }
  89938. return this._geometry.getVerticesDataKinds();
  89939. };
  89940. /**
  89941. * Returns a positive integer : the total number of indices in this mesh geometry.
  89942. * @returns the numner of indices or zero if the mesh has no geometry.
  89943. */
  89944. Mesh.prototype.getTotalIndices = function () {
  89945. if (!this._geometry) {
  89946. return 0;
  89947. }
  89948. return this._geometry.getTotalIndices();
  89949. };
  89950. /**
  89951. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89952. * @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.
  89953. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89954. * @returns the indices array or an empty array if the mesh has no geometry
  89955. */
  89956. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  89957. if (!this._geometry) {
  89958. return [];
  89959. }
  89960. return this._geometry.getIndices(copyWhenShared, forceCopy);
  89961. };
  89962. Object.defineProperty(Mesh.prototype, "isBlocked", {
  89963. get: function () {
  89964. return this._masterMesh !== null && this._masterMesh !== undefined;
  89965. },
  89966. enumerable: true,
  89967. configurable: true
  89968. });
  89969. /**
  89970. * Determine if the current mesh is ready to be rendered
  89971. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89972. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89973. * @returns true if all associated assets are ready (material, textures, shaders)
  89974. */
  89975. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  89976. if (completeCheck === void 0) { completeCheck = false; }
  89977. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  89978. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  89979. return false;
  89980. }
  89981. if (!_super.prototype.isReady.call(this, completeCheck)) {
  89982. return false;
  89983. }
  89984. if (!this.subMeshes || this.subMeshes.length === 0) {
  89985. return true;
  89986. }
  89987. if (!completeCheck) {
  89988. return true;
  89989. }
  89990. var engine = this.getEngine();
  89991. var scene = this.getScene();
  89992. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  89993. this.computeWorldMatrix();
  89994. var mat = this.material || scene.defaultMaterial;
  89995. if (mat) {
  89996. if (mat._storeEffectOnSubMeshes) {
  89997. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  89998. var subMesh = _a[_i];
  89999. var effectiveMaterial = subMesh.getMaterial();
  90000. if (effectiveMaterial) {
  90001. if (effectiveMaterial._storeEffectOnSubMeshes) {
  90002. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  90003. return false;
  90004. }
  90005. }
  90006. else {
  90007. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  90008. return false;
  90009. }
  90010. }
  90011. }
  90012. }
  90013. }
  90014. else {
  90015. if (!mat.isReady(this, hardwareInstancedRendering)) {
  90016. return false;
  90017. }
  90018. }
  90019. }
  90020. // Shadows
  90021. for (var _b = 0, _c = this.lightSources; _b < _c.length; _b++) {
  90022. var light = _c[_b];
  90023. var generator = light.getShadowGenerator();
  90024. if (generator) {
  90025. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  90026. var subMesh = _e[_d];
  90027. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  90028. return false;
  90029. }
  90030. }
  90031. }
  90032. }
  90033. // LOD
  90034. for (var _f = 0, _g = this._internalMeshDataInfo._LODLevels; _f < _g.length; _f++) {
  90035. var lod = _g[_f];
  90036. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  90037. return false;
  90038. }
  90039. }
  90040. return true;
  90041. };
  90042. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  90043. /**
  90044. * 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.
  90045. */
  90046. get: function () {
  90047. return this._internalMeshDataInfo._areNormalsFrozen;
  90048. },
  90049. enumerable: true,
  90050. configurable: true
  90051. });
  90052. /**
  90053. * 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.
  90054. * @returns the current mesh
  90055. */
  90056. Mesh.prototype.freezeNormals = function () {
  90057. this._internalMeshDataInfo._areNormalsFrozen = true;
  90058. return this;
  90059. };
  90060. /**
  90061. * 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
  90062. * @returns the current mesh
  90063. */
  90064. Mesh.prototype.unfreezeNormals = function () {
  90065. this._internalMeshDataInfo._areNormalsFrozen = false;
  90066. return this;
  90067. };
  90068. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  90069. /**
  90070. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90071. */
  90072. set: function (count) {
  90073. this._instanceDataStorage.overridenInstanceCount = count;
  90074. },
  90075. enumerable: true,
  90076. configurable: true
  90077. });
  90078. // Methods
  90079. /** @hidden */
  90080. Mesh.prototype._preActivate = function () {
  90081. var internalDataInfo = this._internalMeshDataInfo;
  90082. var sceneRenderId = this.getScene().getRenderId();
  90083. if (internalDataInfo._preActivateId === sceneRenderId) {
  90084. return this;
  90085. }
  90086. internalDataInfo._preActivateId = sceneRenderId;
  90087. this._instanceDataStorage.visibleInstances = null;
  90088. return this;
  90089. };
  90090. /** @hidden */
  90091. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  90092. if (this._instanceDataStorage.visibleInstances) {
  90093. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  90094. }
  90095. return this;
  90096. };
  90097. /** @hidden */
  90098. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  90099. if (!this._instanceDataStorage.visibleInstances) {
  90100. this._instanceDataStorage.visibleInstances = {
  90101. defaultRenderId: renderId,
  90102. selfDefaultRenderId: this._renderId
  90103. };
  90104. }
  90105. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  90106. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  90107. }
  90108. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  90109. return this;
  90110. };
  90111. /**
  90112. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90113. * This means the mesh underlying bounding box and sphere are recomputed.
  90114. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90115. * @returns the current mesh
  90116. */
  90117. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  90118. if (applySkeleton === void 0) { applySkeleton = false; }
  90119. if (this._boundingInfo && this._boundingInfo.isLocked) {
  90120. return this;
  90121. }
  90122. var bias = this.geometry ? this.geometry.boundingBias : null;
  90123. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  90124. return this;
  90125. };
  90126. /** @hidden */
  90127. Mesh.prototype._createGlobalSubMesh = function (force) {
  90128. var totalVertices = this.getTotalVertices();
  90129. if (!totalVertices || !this.getIndices()) {
  90130. return null;
  90131. }
  90132. // Check if we need to recreate the submeshes
  90133. if (this.subMeshes && this.subMeshes.length > 0) {
  90134. var ib = this.getIndices();
  90135. if (!ib) {
  90136. return null;
  90137. }
  90138. var totalIndices = ib.length;
  90139. var needToRecreate = false;
  90140. if (force) {
  90141. needToRecreate = true;
  90142. }
  90143. else {
  90144. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  90145. var submesh = _a[_i];
  90146. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  90147. needToRecreate = true;
  90148. break;
  90149. }
  90150. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  90151. needToRecreate = true;
  90152. break;
  90153. }
  90154. }
  90155. }
  90156. if (!needToRecreate) {
  90157. return this.subMeshes[0];
  90158. }
  90159. }
  90160. this.releaseSubMeshes();
  90161. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  90162. };
  90163. /**
  90164. * This function will subdivide the mesh into multiple submeshes
  90165. * @param count defines the expected number of submeshes
  90166. */
  90167. Mesh.prototype.subdivide = function (count) {
  90168. if (count < 1) {
  90169. return;
  90170. }
  90171. var totalIndices = this.getTotalIndices();
  90172. var subdivisionSize = (totalIndices / count) | 0;
  90173. var offset = 0;
  90174. // Ensure that subdivisionSize is a multiple of 3
  90175. while (subdivisionSize % 3 !== 0) {
  90176. subdivisionSize++;
  90177. }
  90178. this.releaseSubMeshes();
  90179. for (var index = 0; index < count; index++) {
  90180. if (offset >= totalIndices) {
  90181. break;
  90182. }
  90183. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  90184. offset += subdivisionSize;
  90185. }
  90186. this.synchronizeInstances();
  90187. };
  90188. /**
  90189. * Copy a FloatArray into a specific associated vertex buffer
  90190. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90191. * - VertexBuffer.PositionKind
  90192. * - VertexBuffer.UVKind
  90193. * - VertexBuffer.UV2Kind
  90194. * - VertexBuffer.UV3Kind
  90195. * - VertexBuffer.UV4Kind
  90196. * - VertexBuffer.UV5Kind
  90197. * - VertexBuffer.UV6Kind
  90198. * - VertexBuffer.ColorKind
  90199. * - VertexBuffer.MatricesIndicesKind
  90200. * - VertexBuffer.MatricesIndicesExtraKind
  90201. * - VertexBuffer.MatricesWeightsKind
  90202. * - VertexBuffer.MatricesWeightsExtraKind
  90203. * @param data defines the data source
  90204. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90205. * @param stride defines the data stride size (can be null)
  90206. * @returns the current mesh
  90207. */
  90208. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  90209. if (updatable === void 0) { updatable = false; }
  90210. if (!this._geometry) {
  90211. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  90212. vertexData.set(data, kind);
  90213. var scene = this.getScene();
  90214. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  90215. }
  90216. else {
  90217. this._geometry.setVerticesData(kind, data, updatable, stride);
  90218. }
  90219. return this;
  90220. };
  90221. /**
  90222. * Flags an associated vertex buffer as updatable
  90223. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90224. * - VertexBuffer.PositionKind
  90225. * - VertexBuffer.UVKind
  90226. * - VertexBuffer.UV2Kind
  90227. * - VertexBuffer.UV3Kind
  90228. * - VertexBuffer.UV4Kind
  90229. * - VertexBuffer.UV5Kind
  90230. * - VertexBuffer.UV6Kind
  90231. * - VertexBuffer.ColorKind
  90232. * - VertexBuffer.MatricesIndicesKind
  90233. * - VertexBuffer.MatricesIndicesExtraKind
  90234. * - VertexBuffer.MatricesWeightsKind
  90235. * - VertexBuffer.MatricesWeightsExtraKind
  90236. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90237. */
  90238. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  90239. if (updatable === void 0) { updatable = true; }
  90240. var vb = this.getVertexBuffer(kind);
  90241. if (!vb || vb.isUpdatable() === updatable) {
  90242. return;
  90243. }
  90244. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  90245. };
  90246. /**
  90247. * Sets the mesh global Vertex Buffer
  90248. * @param buffer defines the buffer to use
  90249. * @returns the current mesh
  90250. */
  90251. Mesh.prototype.setVerticesBuffer = function (buffer) {
  90252. if (!this._geometry) {
  90253. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  90254. }
  90255. this._geometry.setVerticesBuffer(buffer);
  90256. return this;
  90257. };
  90258. /**
  90259. * Update a specific associated vertex buffer
  90260. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90261. * - VertexBuffer.PositionKind
  90262. * - VertexBuffer.UVKind
  90263. * - VertexBuffer.UV2Kind
  90264. * - VertexBuffer.UV3Kind
  90265. * - VertexBuffer.UV4Kind
  90266. * - VertexBuffer.UV5Kind
  90267. * - VertexBuffer.UV6Kind
  90268. * - VertexBuffer.ColorKind
  90269. * - VertexBuffer.MatricesIndicesKind
  90270. * - VertexBuffer.MatricesIndicesExtraKind
  90271. * - VertexBuffer.MatricesWeightsKind
  90272. * - VertexBuffer.MatricesWeightsExtraKind
  90273. * @param data defines the data source
  90274. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90275. * @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)
  90276. * @returns the current mesh
  90277. */
  90278. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  90279. if (!this._geometry) {
  90280. return this;
  90281. }
  90282. if (!makeItUnique) {
  90283. this._geometry.updateVerticesData(kind, data, updateExtends);
  90284. }
  90285. else {
  90286. this.makeGeometryUnique();
  90287. this.updateVerticesData(kind, data, updateExtends, false);
  90288. }
  90289. return this;
  90290. };
  90291. /**
  90292. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90293. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90294. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90295. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90296. * @returns the current mesh
  90297. */
  90298. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  90299. if (computeNormals === void 0) { computeNormals = true; }
  90300. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  90301. if (!positions) {
  90302. return this;
  90303. }
  90304. positionFunction(positions);
  90305. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  90306. if (computeNormals) {
  90307. var indices = this.getIndices();
  90308. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  90309. if (!normals) {
  90310. return this;
  90311. }
  90312. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  90313. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  90314. }
  90315. return this;
  90316. };
  90317. /**
  90318. * Creates a un-shared specific occurence of the geometry for the mesh.
  90319. * @returns the current mesh
  90320. */
  90321. Mesh.prototype.makeGeometryUnique = function () {
  90322. if (!this._geometry) {
  90323. return this;
  90324. }
  90325. var oldGeometry = this._geometry;
  90326. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  90327. oldGeometry.releaseForMesh(this, true);
  90328. geometry.applyToMesh(this);
  90329. return this;
  90330. };
  90331. /**
  90332. * Set the index buffer of this mesh
  90333. * @param indices defines the source data
  90334. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90335. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90336. * @returns the current mesh
  90337. */
  90338. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  90339. if (totalVertices === void 0) { totalVertices = null; }
  90340. if (updatable === void 0) { updatable = false; }
  90341. if (!this._geometry) {
  90342. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  90343. vertexData.indices = indices;
  90344. var scene = this.getScene();
  90345. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  90346. }
  90347. else {
  90348. this._geometry.setIndices(indices, totalVertices, updatable);
  90349. }
  90350. return this;
  90351. };
  90352. /**
  90353. * Update the current index buffer
  90354. * @param indices defines the source data
  90355. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90356. * @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)
  90357. * @returns the current mesh
  90358. */
  90359. Mesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  90360. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  90361. if (!this._geometry) {
  90362. return this;
  90363. }
  90364. this._geometry.updateIndices(indices, offset, gpuMemoryOnly);
  90365. return this;
  90366. };
  90367. /**
  90368. * Invert the geometry to move from a right handed system to a left handed one.
  90369. * @returns the current mesh
  90370. */
  90371. Mesh.prototype.toLeftHanded = function () {
  90372. if (!this._geometry) {
  90373. return this;
  90374. }
  90375. this._geometry.toLeftHanded();
  90376. return this;
  90377. };
  90378. /** @hidden */
  90379. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  90380. if (!this._geometry) {
  90381. return this;
  90382. }
  90383. var engine = this.getScene().getEngine();
  90384. // Wireframe
  90385. var indexToBind;
  90386. if (this._unIndexed) {
  90387. indexToBind = null;
  90388. }
  90389. else {
  90390. switch (fillMode) {
  90391. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  90392. indexToBind = null;
  90393. break;
  90394. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  90395. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  90396. break;
  90397. default:
  90398. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  90399. indexToBind = this._geometry.getIndexBuffer();
  90400. break;
  90401. }
  90402. }
  90403. // VBOs
  90404. this._geometry._bind(effect, indexToBind);
  90405. return this;
  90406. };
  90407. /** @hidden */
  90408. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  90409. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  90410. return this;
  90411. }
  90412. if (this._internalMeshDataInfo._onBeforeDrawObservable) {
  90413. this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);
  90414. }
  90415. var scene = this.getScene();
  90416. var engine = scene.getEngine();
  90417. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  90418. // or triangles as points
  90419. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  90420. }
  90421. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  90422. // Triangles as wireframe
  90423. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  90424. }
  90425. else {
  90426. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  90427. }
  90428. return this;
  90429. };
  90430. /**
  90431. * Registers for this mesh a javascript function called just before the rendering process
  90432. * @param func defines the function to call before rendering this mesh
  90433. * @returns the current mesh
  90434. */
  90435. Mesh.prototype.registerBeforeRender = function (func) {
  90436. this.onBeforeRenderObservable.add(func);
  90437. return this;
  90438. };
  90439. /**
  90440. * Disposes a previously registered javascript function called before the rendering
  90441. * @param func defines the function to remove
  90442. * @returns the current mesh
  90443. */
  90444. Mesh.prototype.unregisterBeforeRender = function (func) {
  90445. this.onBeforeRenderObservable.removeCallback(func);
  90446. return this;
  90447. };
  90448. /**
  90449. * Registers for this mesh a javascript function called just after the rendering is complete
  90450. * @param func defines the function to call after rendering this mesh
  90451. * @returns the current mesh
  90452. */
  90453. Mesh.prototype.registerAfterRender = function (func) {
  90454. this.onAfterRenderObservable.add(func);
  90455. return this;
  90456. };
  90457. /**
  90458. * Disposes a previously registered javascript function called after the rendering.
  90459. * @param func defines the function to remove
  90460. * @returns the current mesh
  90461. */
  90462. Mesh.prototype.unregisterAfterRender = function (func) {
  90463. this.onAfterRenderObservable.removeCallback(func);
  90464. return this;
  90465. };
  90466. /** @hidden */
  90467. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  90468. if (this._instanceDataStorage.isFrozen && this._instanceDataStorage.previousBatch) {
  90469. return this._instanceDataStorage.previousBatch;
  90470. }
  90471. var scene = this.getScene();
  90472. var isInIntermediateRendering = scene._isInIntermediateRendering();
  90473. var onlyForInstances = isInIntermediateRendering ? this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate : this._internalAbstractMeshDataInfo._onlyForInstances;
  90474. var batchCache = this._instanceDataStorage.batchCache;
  90475. batchCache.mustReturn = false;
  90476. batchCache.renderSelf[subMeshId] = !onlyForInstances && this.isEnabled() && this.isVisible;
  90477. batchCache.visibleInstances[subMeshId] = null;
  90478. if (this._instanceDataStorage.visibleInstances) {
  90479. var visibleInstances = this._instanceDataStorage.visibleInstances;
  90480. var currentRenderId = scene.getRenderId();
  90481. var defaultRenderId = (isInIntermediateRendering ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  90482. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  90483. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  90484. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  90485. }
  90486. }
  90487. batchCache.hardwareInstancedRendering[subMeshId] = this._instanceDataStorage.hardwareInstancedRendering && (batchCache.visibleInstances[subMeshId] !== null) && (batchCache.visibleInstances[subMeshId] !== undefined);
  90488. this._instanceDataStorage.previousBatch = batchCache;
  90489. return batchCache;
  90490. };
  90491. /** @hidden */
  90492. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  90493. var visibleInstances = batch.visibleInstances[subMesh._id];
  90494. if (!visibleInstances) {
  90495. return this;
  90496. }
  90497. var instanceStorage = this._instanceDataStorage;
  90498. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  90499. var instancesBuffer = instanceStorage.instancesBuffer;
  90500. var matricesCount = visibleInstances.length + 1;
  90501. var bufferSize = matricesCount * 16 * 4;
  90502. while (instanceStorage.instancesBufferSize < bufferSize) {
  90503. instanceStorage.instancesBufferSize *= 2;
  90504. }
  90505. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  90506. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  90507. }
  90508. var offset = 0;
  90509. var instancesCount = 0;
  90510. var world = this._effectiveMesh.getWorldMatrix();
  90511. if (batch.renderSelf[subMesh._id]) {
  90512. world.copyToArray(instanceStorage.instancesData, offset);
  90513. offset += 16;
  90514. instancesCount++;
  90515. }
  90516. if (visibleInstances) {
  90517. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  90518. var instance = visibleInstances[instanceIndex];
  90519. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  90520. offset += 16;
  90521. instancesCount++;
  90522. }
  90523. }
  90524. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  90525. if (instancesBuffer) {
  90526. instancesBuffer.dispose();
  90527. }
  90528. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  90529. instanceStorage.instancesBuffer = instancesBuffer;
  90530. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  90531. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  90532. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  90533. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  90534. }
  90535. else {
  90536. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  90537. }
  90538. this._bind(subMesh, effect, fillMode);
  90539. this._draw(subMesh, fillMode, instancesCount);
  90540. engine.unbindInstanceAttributes();
  90541. return this;
  90542. };
  90543. /** @hidden */
  90544. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  90545. var scene = this.getScene();
  90546. var engine = scene.getEngine();
  90547. if (hardwareInstancedRendering) {
  90548. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  90549. }
  90550. else {
  90551. if (batch.renderSelf[subMesh._id]) {
  90552. // Draw
  90553. if (onBeforeDraw) {
  90554. onBeforeDraw(false, this._effectiveMesh.getWorldMatrix(), effectiveMaterial);
  90555. }
  90556. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  90557. }
  90558. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  90559. if (visibleInstancesForSubMesh) {
  90560. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  90561. var instance = visibleInstancesForSubMesh[instanceIndex];
  90562. // World
  90563. var world = instance.getWorldMatrix();
  90564. if (onBeforeDraw) {
  90565. onBeforeDraw(true, world, effectiveMaterial);
  90566. }
  90567. // Draw
  90568. this._draw(subMesh, fillMode);
  90569. }
  90570. }
  90571. }
  90572. return this;
  90573. };
  90574. /** @hidden */
  90575. Mesh.prototype._freeze = function () {
  90576. this._instanceDataStorage.isFrozen = true;
  90577. if (!this.subMeshes) {
  90578. return;
  90579. }
  90580. // Prepare batches
  90581. for (var index = 0; index < this.subMeshes.length; index++) {
  90582. this._getInstancesRenderList(index);
  90583. }
  90584. };
  90585. /** @hidden */
  90586. Mesh.prototype._unFreeze = function () {
  90587. this._instanceDataStorage.isFrozen = false;
  90588. };
  90589. /**
  90590. * 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
  90591. * @param subMesh defines the subMesh to render
  90592. * @param enableAlphaMode defines if alpha mode can be changed
  90593. * @returns the current mesh
  90594. */
  90595. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  90596. var scene = this.getScene();
  90597. if (scene._isInIntermediateRendering()) {
  90598. this._internalAbstractMeshDataInfo._isActiveIntermediate = false;
  90599. }
  90600. else {
  90601. this._internalAbstractMeshDataInfo._isActive = false;
  90602. }
  90603. if (this._checkOcclusionQuery()) {
  90604. return this;
  90605. }
  90606. // Managing instances
  90607. var batch = this._getInstancesRenderList(subMesh._id);
  90608. if (batch.mustReturn) {
  90609. return this;
  90610. }
  90611. // Checking geometry state
  90612. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  90613. return this;
  90614. }
  90615. if (this._internalMeshDataInfo._onBeforeRenderObservable) {
  90616. this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);
  90617. }
  90618. var engine = scene.getEngine();
  90619. var hardwareInstancedRendering = batch.hardwareInstancedRendering[subMesh._id];
  90620. var instanceDataStorage = this._instanceDataStorage;
  90621. var material = subMesh.getMaterial();
  90622. if (!material) {
  90623. return this;
  90624. }
  90625. // Material
  90626. if (!instanceDataStorage.isFrozen || !this._effectiveMaterial || this._effectiveMaterial !== material) {
  90627. this._effectiveMaterial = material;
  90628. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  90629. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  90630. return this;
  90631. }
  90632. }
  90633. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  90634. return this;
  90635. }
  90636. }
  90637. // Alpha mode
  90638. if (enableAlphaMode) {
  90639. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  90640. }
  90641. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  90642. var step = _a[_i];
  90643. step.action(this, subMesh, batch);
  90644. }
  90645. var effect;
  90646. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  90647. effect = subMesh.effect;
  90648. }
  90649. else {
  90650. effect = this._effectiveMaterial.getEffect();
  90651. }
  90652. if (!effect) {
  90653. return this;
  90654. }
  90655. var effectiveMesh = this._effectiveMesh;
  90656. var sideOrientation;
  90657. if (!instanceDataStorage.isFrozen) {
  90658. sideOrientation = this.overrideMaterialSideOrientation;
  90659. if (sideOrientation == null) {
  90660. sideOrientation = this._effectiveMaterial.sideOrientation;
  90661. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  90662. 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);
  90663. }
  90664. }
  90665. instanceDataStorage.sideOrientation = sideOrientation;
  90666. }
  90667. else {
  90668. sideOrientation = instanceDataStorage.sideOrientation;
  90669. }
  90670. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  90671. if (this._effectiveMaterial.forceDepthWrite) {
  90672. engine.setDepthWrite(true);
  90673. }
  90674. // Bind
  90675. 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);
  90676. if (this._internalMeshDataInfo._onBeforeBindObservable) {
  90677. this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this);
  90678. }
  90679. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  90680. this._bind(subMesh, effect, fillMode);
  90681. }
  90682. var world = effectiveMesh.getWorldMatrix();
  90683. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  90684. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  90685. }
  90686. else {
  90687. this._effectiveMaterial.bind(world, this);
  90688. }
  90689. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  90690. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  90691. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  90692. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  90693. }
  90694. // Draw
  90695. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  90696. // Unbind
  90697. this._effectiveMaterial.unbind();
  90698. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  90699. var step = _c[_b];
  90700. step.action(this, subMesh, batch);
  90701. }
  90702. if (this._internalMeshDataInfo._onAfterRenderObservable) {
  90703. this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this);
  90704. }
  90705. return this;
  90706. };
  90707. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  90708. if (isInstance && effectiveMaterial) {
  90709. effectiveMaterial.bindOnlyWorldMatrix(world);
  90710. }
  90711. };
  90712. /**
  90713. * Renormalize the mesh and patch it up if there are no weights
  90714. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90715. * However in the case of zero weights then we set just a single influence to 1.
  90716. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90717. */
  90718. Mesh.prototype.cleanMatrixWeights = function () {
  90719. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  90720. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  90721. this.normalizeSkinWeightsAndExtra();
  90722. }
  90723. else {
  90724. this.normalizeSkinFourWeights();
  90725. }
  90726. }
  90727. };
  90728. // faster 4 weight version.
  90729. Mesh.prototype.normalizeSkinFourWeights = function () {
  90730. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  90731. var numWeights = matricesWeights.length;
  90732. for (var a = 0; a < numWeights; a += 4) {
  90733. // accumulate weights
  90734. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  90735. // check for invalid weight and just set it to 1.
  90736. if (t === 0) {
  90737. matricesWeights[a] = 1;
  90738. }
  90739. else {
  90740. // renormalize so everything adds to 1 use reciprical
  90741. var recip = 1 / t;
  90742. matricesWeights[a] *= recip;
  90743. matricesWeights[a + 1] *= recip;
  90744. matricesWeights[a + 2] *= recip;
  90745. matricesWeights[a + 3] *= recip;
  90746. }
  90747. }
  90748. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  90749. };
  90750. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  90751. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  90752. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  90753. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  90754. var numWeights = matricesWeights.length;
  90755. for (var a = 0; a < numWeights; a += 4) {
  90756. // accumulate weights
  90757. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  90758. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  90759. // check for invalid weight and just set it to 1.
  90760. if (t === 0) {
  90761. matricesWeights[a] = 1;
  90762. }
  90763. else {
  90764. // renormalize so everything adds to 1 use reciprical
  90765. var recip = 1 / t;
  90766. matricesWeights[a] *= recip;
  90767. matricesWeights[a + 1] *= recip;
  90768. matricesWeights[a + 2] *= recip;
  90769. matricesWeights[a + 3] *= recip;
  90770. // same goes for extras
  90771. matricesWeightsExtra[a] *= recip;
  90772. matricesWeightsExtra[a + 1] *= recip;
  90773. matricesWeightsExtra[a + 2] *= recip;
  90774. matricesWeightsExtra[a + 3] *= recip;
  90775. }
  90776. }
  90777. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  90778. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  90779. };
  90780. /**
  90781. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90782. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90783. * the user know there was an issue with importing the mesh
  90784. * @returns a validation object with skinned, valid and report string
  90785. */
  90786. Mesh.prototype.validateSkinning = function () {
  90787. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  90788. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  90789. if (matricesWeights === null || this.skeleton == null) {
  90790. return { skinned: false, valid: true, report: "not skinned" };
  90791. }
  90792. var numWeights = matricesWeights.length;
  90793. var numberNotSorted = 0;
  90794. var missingWeights = 0;
  90795. var maxUsedWeights = 0;
  90796. var numberNotNormalized = 0;
  90797. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  90798. var usedWeightCounts = new Array();
  90799. for (var a = 0; a <= numInfluences; a++) {
  90800. usedWeightCounts[a] = 0;
  90801. }
  90802. var toleranceEpsilon = 0.001;
  90803. for (var a = 0; a < numWeights; a += 4) {
  90804. var lastWeight = matricesWeights[a];
  90805. var t = lastWeight;
  90806. var usedWeights = t === 0 ? 0 : 1;
  90807. for (var b = 1; b < numInfluences; b++) {
  90808. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  90809. if (d > lastWeight) {
  90810. numberNotSorted++;
  90811. }
  90812. if (d !== 0) {
  90813. usedWeights++;
  90814. }
  90815. t += d;
  90816. lastWeight = d;
  90817. }
  90818. // count the buffer weights usage
  90819. usedWeightCounts[usedWeights]++;
  90820. // max influences
  90821. if (usedWeights > maxUsedWeights) {
  90822. maxUsedWeights = usedWeights;
  90823. }
  90824. // check for invalid weight and just set it to 1.
  90825. if (t === 0) {
  90826. missingWeights++;
  90827. }
  90828. else {
  90829. // renormalize so everything adds to 1 use reciprical
  90830. var recip = 1 / t;
  90831. var tolerance = 0;
  90832. for (b = 0; b < numInfluences; b++) {
  90833. if (b < 4) {
  90834. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  90835. }
  90836. else {
  90837. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  90838. }
  90839. }
  90840. // arbitary epsilon value for dicdating not normalized
  90841. if (tolerance > toleranceEpsilon) {
  90842. numberNotNormalized++;
  90843. }
  90844. }
  90845. }
  90846. // validate bone indices are in range of the skeleton
  90847. var numBones = this.skeleton.bones.length;
  90848. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  90849. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  90850. var numBadBoneIndices = 0;
  90851. for (var a = 0; a < numWeights; a++) {
  90852. for (var b = 0; b < numInfluences; b++) {
  90853. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  90854. if (index >= numBones || index < 0) {
  90855. numBadBoneIndices++;
  90856. }
  90857. }
  90858. }
  90859. // log mesh stats
  90860. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  90861. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  90862. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  90863. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  90864. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  90865. };
  90866. /** @hidden */
  90867. Mesh.prototype._checkDelayState = function () {
  90868. var scene = this.getScene();
  90869. if (this._geometry) {
  90870. this._geometry.load(scene);
  90871. }
  90872. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  90873. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING;
  90874. this._queueLoad(scene);
  90875. }
  90876. return this;
  90877. };
  90878. Mesh.prototype._queueLoad = function (scene) {
  90879. var _this = this;
  90880. scene._addPendingData(this);
  90881. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  90882. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  90883. if (data instanceof ArrayBuffer) {
  90884. _this._delayLoadingFunction(data, _this);
  90885. }
  90886. else {
  90887. _this._delayLoadingFunction(JSON.parse(data), _this);
  90888. }
  90889. _this.instances.forEach(function (instance) {
  90890. instance.refreshBoundingInfo();
  90891. instance._syncSubMeshes();
  90892. });
  90893. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADED;
  90894. scene._removePendingData(_this);
  90895. }, function () { }, scene.offlineProvider, getBinaryData);
  90896. return this;
  90897. };
  90898. /**
  90899. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90900. * A mesh is in the frustum if its bounding box intersects the frustum
  90901. * @param frustumPlanes defines the frustum to test
  90902. * @returns true if the mesh is in the frustum planes
  90903. */
  90904. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  90905. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  90906. return false;
  90907. }
  90908. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  90909. return false;
  90910. }
  90911. this._checkDelayState();
  90912. return true;
  90913. };
  90914. /**
  90915. * Sets the mesh material by the material or multiMaterial `id` property
  90916. * @param id is a string identifying the material or the multiMaterial
  90917. * @returns the current mesh
  90918. */
  90919. Mesh.prototype.setMaterialByID = function (id) {
  90920. var materials = this.getScene().materials;
  90921. var index;
  90922. for (index = materials.length - 1; index > -1; index--) {
  90923. if (materials[index].id === id) {
  90924. this.material = materials[index];
  90925. return this;
  90926. }
  90927. }
  90928. // Multi
  90929. var multiMaterials = this.getScene().multiMaterials;
  90930. for (index = multiMaterials.length - 1; index > -1; index--) {
  90931. if (multiMaterials[index].id === id) {
  90932. this.material = multiMaterials[index];
  90933. return this;
  90934. }
  90935. }
  90936. return this;
  90937. };
  90938. /**
  90939. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90940. * @returns an array of IAnimatable
  90941. */
  90942. Mesh.prototype.getAnimatables = function () {
  90943. var results = new Array();
  90944. if (this.material) {
  90945. results.push(this.material);
  90946. }
  90947. if (this.skeleton) {
  90948. results.push(this.skeleton);
  90949. }
  90950. return results;
  90951. };
  90952. /**
  90953. * Modifies the mesh geometry according to the passed transformation matrix.
  90954. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90955. * The mesh normals are modified using the same transformation.
  90956. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90957. * @param transform defines the transform matrix to use
  90958. * @see http://doc.babylonjs.com/resources/baking_transformations
  90959. * @returns the current mesh
  90960. */
  90961. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  90962. // Position
  90963. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  90964. return this;
  90965. }
  90966. var submeshes = this.subMeshes.splice(0);
  90967. this._resetPointsArrayCache();
  90968. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  90969. var temp = new Array();
  90970. var index;
  90971. for (index = 0; index < data.length; index += 3) {
  90972. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  90973. }
  90974. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  90975. // Normals
  90976. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  90977. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  90978. temp = [];
  90979. for (index = 0; index < data.length; index += 3) {
  90980. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  90981. }
  90982. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  90983. }
  90984. // flip faces?
  90985. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  90986. this.flipFaces();
  90987. }
  90988. // Restore submeshes
  90989. this.releaseSubMeshes();
  90990. this.subMeshes = submeshes;
  90991. return this;
  90992. };
  90993. /**
  90994. * Modifies the mesh geometry according to its own current World Matrix.
  90995. * The mesh World Matrix is then reset.
  90996. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90997. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90998. * @see http://doc.babylonjs.com/resources/baking_transformations
  90999. * @returns the current mesh
  91000. */
  91001. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  91002. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  91003. this.scaling.copyFromFloats(1, 1, 1);
  91004. this.position.copyFromFloats(0, 0, 0);
  91005. this.rotation.copyFromFloats(0, 0, 0);
  91006. //only if quaternion is already set
  91007. if (this.rotationQuaternion) {
  91008. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  91009. }
  91010. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  91011. return this;
  91012. };
  91013. Object.defineProperty(Mesh.prototype, "_positions", {
  91014. // Cache
  91015. /** @hidden */
  91016. get: function () {
  91017. if (this._geometry) {
  91018. return this._geometry._positions;
  91019. }
  91020. return null;
  91021. },
  91022. enumerable: true,
  91023. configurable: true
  91024. });
  91025. /** @hidden */
  91026. Mesh.prototype._resetPointsArrayCache = function () {
  91027. if (this._geometry) {
  91028. this._geometry._resetPointsArrayCache();
  91029. }
  91030. return this;
  91031. };
  91032. /** @hidden */
  91033. Mesh.prototype._generatePointsArray = function () {
  91034. if (this._geometry) {
  91035. return this._geometry._generatePointsArray();
  91036. }
  91037. return false;
  91038. };
  91039. /**
  91040. * Returns a new Mesh object generated from the current mesh properties.
  91041. * This method must not get confused with createInstance()
  91042. * @param name is a string, the name given to the new mesh
  91043. * @param newParent can be any Node object (default `null`)
  91044. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  91045. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  91046. * @returns a new mesh
  91047. */
  91048. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  91049. if (name === void 0) { name = ""; }
  91050. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  91051. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  91052. };
  91053. /**
  91054. * Releases resources associated with this mesh.
  91055. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91056. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91057. */
  91058. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  91059. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  91060. this.morphTargetManager = null;
  91061. if (this._geometry) {
  91062. this._geometry.releaseForMesh(this, true);
  91063. }
  91064. var internalDataInfo = this._internalMeshDataInfo;
  91065. if (internalDataInfo._onBeforeDrawObservable) {
  91066. internalDataInfo._onBeforeDrawObservable.clear();
  91067. }
  91068. if (internalDataInfo._onBeforeBindObservable) {
  91069. internalDataInfo._onBeforeBindObservable.clear();
  91070. }
  91071. if (internalDataInfo._onBeforeRenderObservable) {
  91072. internalDataInfo._onBeforeRenderObservable.clear();
  91073. }
  91074. if (internalDataInfo._onAfterRenderObservable) {
  91075. internalDataInfo._onAfterRenderObservable.clear();
  91076. }
  91077. // Sources
  91078. if (this._scene.useClonedMeshhMap) {
  91079. if (internalDataInfo.meshMap) {
  91080. for (var uniqueId in internalDataInfo.meshMap) {
  91081. var mesh = internalDataInfo.meshMap[uniqueId];
  91082. if (mesh) {
  91083. mesh._internalMeshDataInfo._source = null;
  91084. internalDataInfo.meshMap[uniqueId] = undefined;
  91085. }
  91086. }
  91087. }
  91088. if (internalDataInfo._source && internalDataInfo._source._internalMeshDataInfo.meshMap) {
  91089. internalDataInfo._source._internalMeshDataInfo.meshMap[this.uniqueId] = undefined;
  91090. }
  91091. }
  91092. else {
  91093. var meshes = this.getScene().meshes;
  91094. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  91095. var abstractMesh = meshes_1[_i];
  91096. var mesh = abstractMesh;
  91097. if (mesh._internalMeshDataInfo && mesh._internalMeshDataInfo._source && mesh._internalMeshDataInfo._source === this) {
  91098. mesh._internalMeshDataInfo._source = null;
  91099. }
  91100. }
  91101. }
  91102. internalDataInfo._source = null;
  91103. // Instances
  91104. if (this._instanceDataStorage.instancesBuffer) {
  91105. this._instanceDataStorage.instancesBuffer.dispose();
  91106. this._instanceDataStorage.instancesBuffer = null;
  91107. }
  91108. while (this.instances.length) {
  91109. this.instances[0].dispose();
  91110. }
  91111. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  91112. };
  91113. /**
  91114. * Modifies the mesh geometry according to a displacement map.
  91115. * 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.
  91116. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91117. * @param url is a string, the URL from the image file is to be downloaded.
  91118. * @param minHeight is the lower limit of the displacement.
  91119. * @param maxHeight is the upper limit of the displacement.
  91120. * @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.
  91121. * @param uvOffset is an optional vector2 used to offset UV.
  91122. * @param uvScale is an optional vector2 used to scale UV.
  91123. * @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.
  91124. * @returns the Mesh.
  91125. */
  91126. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  91127. var _this = this;
  91128. if (forceUpdate === void 0) { forceUpdate = false; }
  91129. var scene = this.getScene();
  91130. var onload = function (img) {
  91131. // Getting height map data
  91132. var canvas = document.createElement("canvas");
  91133. var context = canvas.getContext("2d");
  91134. var heightMapWidth = img.width;
  91135. var heightMapHeight = img.height;
  91136. canvas.width = heightMapWidth;
  91137. canvas.height = heightMapHeight;
  91138. context.drawImage(img, 0, 0);
  91139. // Create VertexData from map data
  91140. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  91141. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  91142. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  91143. //execute success callback, if set
  91144. if (onSuccess) {
  91145. onSuccess(_this);
  91146. }
  91147. };
  91148. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  91149. return this;
  91150. };
  91151. /**
  91152. * Modifies the mesh geometry according to a displacementMap buffer.
  91153. * 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.
  91154. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91155. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  91156. * @param heightMapWidth is the width of the buffer image.
  91157. * @param heightMapHeight is the height of the buffer image.
  91158. * @param minHeight is the lower limit of the displacement.
  91159. * @param maxHeight is the upper limit of the displacement.
  91160. * @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.
  91161. * @param uvOffset is an optional vector2 used to offset UV.
  91162. * @param uvScale is an optional vector2 used to scale UV.
  91163. * @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.
  91164. * @returns the Mesh.
  91165. */
  91166. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  91167. if (forceUpdate === void 0) { forceUpdate = false; }
  91168. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  91169. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  91170. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  91171. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  91172. return this;
  91173. }
  91174. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  91175. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  91176. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  91177. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  91178. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  91179. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  91180. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  91181. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  91182. for (var index = 0; index < positions.length; index += 3) {
  91183. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  91184. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  91185. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  91186. // Compute height
  91187. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  91188. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  91189. var pos = (u + v * heightMapWidth) * 4;
  91190. var r = buffer[pos] / 255.0;
  91191. var g = buffer[pos + 1] / 255.0;
  91192. var b = buffer[pos + 2] / 255.0;
  91193. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  91194. normal.normalize();
  91195. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  91196. position = position.add(normal);
  91197. position.toArray(positions, index);
  91198. }
  91199. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  91200. if (forceUpdate) {
  91201. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  91202. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  91203. }
  91204. else {
  91205. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  91206. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  91207. }
  91208. return this;
  91209. };
  91210. /**
  91211. * Modify the mesh to get a flat shading rendering.
  91212. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  91213. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  91214. * @returns current mesh
  91215. */
  91216. Mesh.prototype.convertToFlatShadedMesh = function () {
  91217. var kinds = this.getVerticesDataKinds();
  91218. var vbs = {};
  91219. var data = {};
  91220. var newdata = {};
  91221. var updatableNormals = false;
  91222. var kindIndex;
  91223. var kind;
  91224. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  91225. kind = kinds[kindIndex];
  91226. var vertexBuffer = this.getVertexBuffer(kind);
  91227. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  91228. updatableNormals = vertexBuffer.isUpdatable();
  91229. kinds.splice(kindIndex, 1);
  91230. kindIndex--;
  91231. continue;
  91232. }
  91233. vbs[kind] = vertexBuffer;
  91234. data[kind] = vbs[kind].getData();
  91235. newdata[kind] = [];
  91236. }
  91237. // Save previous submeshes
  91238. var previousSubmeshes = this.subMeshes.slice(0);
  91239. var indices = this.getIndices();
  91240. var totalIndices = this.getTotalIndices();
  91241. // Generating unique vertices per face
  91242. var index;
  91243. for (index = 0; index < totalIndices; index++) {
  91244. var vertexIndex = indices[index];
  91245. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  91246. kind = kinds[kindIndex];
  91247. var stride = vbs[kind].getStrideSize();
  91248. for (var offset = 0; offset < stride; offset++) {
  91249. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  91250. }
  91251. }
  91252. }
  91253. // Updating faces & normal
  91254. var normals = [];
  91255. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  91256. for (index = 0; index < totalIndices; index += 3) {
  91257. indices[index] = index;
  91258. indices[index + 1] = index + 1;
  91259. indices[index + 2] = index + 2;
  91260. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  91261. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  91262. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  91263. var p1p2 = p1.subtract(p2);
  91264. var p3p2 = p3.subtract(p2);
  91265. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  91266. // Store same normals for every vertex
  91267. for (var localIndex = 0; localIndex < 3; localIndex++) {
  91268. normals.push(normal.x);
  91269. normals.push(normal.y);
  91270. normals.push(normal.z);
  91271. }
  91272. }
  91273. this.setIndices(indices);
  91274. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  91275. // Updating vertex buffers
  91276. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  91277. kind = kinds[kindIndex];
  91278. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  91279. }
  91280. // Updating submeshes
  91281. this.releaseSubMeshes();
  91282. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  91283. var previousOne = previousSubmeshes[submeshIndex];
  91284. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  91285. }
  91286. this.synchronizeInstances();
  91287. return this;
  91288. };
  91289. /**
  91290. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  91291. * In other words, more vertices, no more indices and a single bigger VBO.
  91292. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  91293. * @returns current mesh
  91294. */
  91295. Mesh.prototype.convertToUnIndexedMesh = function () {
  91296. var kinds = this.getVerticesDataKinds();
  91297. var vbs = {};
  91298. var data = {};
  91299. var newdata = {};
  91300. var kindIndex;
  91301. var kind;
  91302. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  91303. kind = kinds[kindIndex];
  91304. var vertexBuffer = this.getVertexBuffer(kind);
  91305. vbs[kind] = vertexBuffer;
  91306. data[kind] = vbs[kind].getData();
  91307. newdata[kind] = [];
  91308. }
  91309. // Save previous submeshes
  91310. var previousSubmeshes = this.subMeshes.slice(0);
  91311. var indices = this.getIndices();
  91312. var totalIndices = this.getTotalIndices();
  91313. // Generating unique vertices per face
  91314. var index;
  91315. for (index = 0; index < totalIndices; index++) {
  91316. var vertexIndex = indices[index];
  91317. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  91318. kind = kinds[kindIndex];
  91319. var stride = vbs[kind].getStrideSize();
  91320. for (var offset = 0; offset < stride; offset++) {
  91321. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  91322. }
  91323. }
  91324. }
  91325. // Updating indices
  91326. for (index = 0; index < totalIndices; index += 3) {
  91327. indices[index] = index;
  91328. indices[index + 1] = index + 1;
  91329. indices[index + 2] = index + 2;
  91330. }
  91331. this.setIndices(indices);
  91332. // Updating vertex buffers
  91333. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  91334. kind = kinds[kindIndex];
  91335. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  91336. }
  91337. // Updating submeshes
  91338. this.releaseSubMeshes();
  91339. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  91340. var previousOne = previousSubmeshes[submeshIndex];
  91341. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  91342. }
  91343. this._unIndexed = true;
  91344. this.synchronizeInstances();
  91345. return this;
  91346. };
  91347. /**
  91348. * Inverses facet orientations.
  91349. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91350. * @param flipNormals will also inverts the normals
  91351. * @returns current mesh
  91352. */
  91353. Mesh.prototype.flipFaces = function (flipNormals) {
  91354. if (flipNormals === void 0) { flipNormals = false; }
  91355. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  91356. var i;
  91357. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  91358. for (i = 0; i < vertex_data.normals.length; i++) {
  91359. vertex_data.normals[i] *= -1;
  91360. }
  91361. }
  91362. if (vertex_data.indices) {
  91363. var temp;
  91364. for (i = 0; i < vertex_data.indices.length; i += 3) {
  91365. // reassign indices
  91366. temp = vertex_data.indices[i + 1];
  91367. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  91368. vertex_data.indices[i + 2] = temp;
  91369. }
  91370. }
  91371. vertex_data.applyToMesh(this);
  91372. return this;
  91373. };
  91374. /**
  91375. * Increase the number of facets and hence vertices in a mesh
  91376. * Vertex normals are interpolated from existing vertex normals
  91377. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91378. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  91379. */
  91380. Mesh.prototype.increaseVertices = function (numberPerEdge) {
  91381. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  91382. var uvs = vertex_data.uvs;
  91383. var currentIndices = vertex_data.indices;
  91384. var positions = vertex_data.positions;
  91385. var normals = vertex_data.normals;
  91386. if (currentIndices === null || positions === null || normals === null || uvs === null) {
  91387. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("VertexData contains null entries");
  91388. }
  91389. else {
  91390. var segments = numberPerEdge + 1; //segments per current facet edge, become sides of new facets
  91391. var tempIndices = new Array();
  91392. for (var i = 0; i < segments + 1; i++) {
  91393. tempIndices[i] = new Array();
  91394. }
  91395. var a; //vertex index of one end of a side
  91396. var b; //vertex index of other end of the side
  91397. var deltaPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  91398. var deltaNormal = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  91399. var deltaUV = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](0, 0);
  91400. var indices = new Array();
  91401. var vertexIndex = new Array();
  91402. var side = new Array();
  91403. var len;
  91404. var positionPtr = positions.length;
  91405. var uvPtr = uvs.length;
  91406. for (var i = 0; i < currentIndices.length; i += 3) {
  91407. vertexIndex[0] = currentIndices[i];
  91408. vertexIndex[1] = currentIndices[i + 1];
  91409. vertexIndex[2] = currentIndices[i + 2];
  91410. for (var j = 0; j < 3; j++) {
  91411. a = vertexIndex[j];
  91412. b = vertexIndex[(j + 1) % 3];
  91413. if (side[a] === undefined && side[b] === undefined) {
  91414. side[a] = new Array();
  91415. side[b] = new Array();
  91416. }
  91417. else {
  91418. if (side[a] === undefined) {
  91419. side[a] = new Array();
  91420. }
  91421. if (side[b] === undefined) {
  91422. side[b] = new Array();
  91423. }
  91424. }
  91425. if (side[a][b] === undefined && side[b][a] === undefined) {
  91426. side[a][b] = [];
  91427. deltaPosition.x = (positions[3 * b] - positions[3 * a]) / segments;
  91428. deltaPosition.y = (positions[3 * b + 1] - positions[3 * a + 1]) / segments;
  91429. deltaPosition.z = (positions[3 * b + 2] - positions[3 * a + 2]) / segments;
  91430. deltaNormal.x = (normals[3 * b] - normals[3 * a]) / segments;
  91431. deltaNormal.y = (normals[3 * b + 1] - normals[3 * a + 1]) / segments;
  91432. deltaNormal.z = (normals[3 * b + 2] - normals[3 * a + 2]) / segments;
  91433. deltaUV.x = (uvs[2 * b] - uvs[2 * a]) / segments;
  91434. deltaUV.y = (uvs[2 * b + 1] - uvs[2 * a + 1]) / segments;
  91435. side[a][b].push(a);
  91436. for (var k = 1; k < segments; k++) {
  91437. side[a][b].push(positions.length / 3);
  91438. positions[positionPtr] = positions[3 * a] + k * deltaPosition.x;
  91439. normals[positionPtr++] = normals[3 * a] + k * deltaNormal.x;
  91440. positions[positionPtr] = positions[3 * a + 1] + k * deltaPosition.y;
  91441. normals[positionPtr++] = normals[3 * a + 1] + k * deltaNormal.y;
  91442. positions[positionPtr] = positions[3 * a + 2] + k * deltaPosition.z;
  91443. normals[positionPtr++] = normals[3 * a + 2] + k * deltaNormal.z;
  91444. uvs[uvPtr++] = uvs[2 * a] + k * deltaUV.x;
  91445. uvs[uvPtr++] = uvs[2 * a + 1] + k * deltaUV.y;
  91446. }
  91447. side[a][b].push(b);
  91448. side[b][a] = new Array();
  91449. len = side[a][b].length;
  91450. for (var idx = 0; idx < len; idx++) {
  91451. side[b][a][idx] = side[a][b][len - 1 - idx];
  91452. }
  91453. }
  91454. }
  91455. //Calculate positions, normals and uvs of new internal vertices
  91456. tempIndices[0][0] = currentIndices[i];
  91457. tempIndices[1][0] = side[currentIndices[i]][currentIndices[i + 1]][1];
  91458. tempIndices[1][1] = side[currentIndices[i]][currentIndices[i + 2]][1];
  91459. for (var k = 2; k < segments; k++) {
  91460. tempIndices[k][0] = side[currentIndices[i]][currentIndices[i + 1]][k];
  91461. tempIndices[k][k] = side[currentIndices[i]][currentIndices[i + 2]][k];
  91462. deltaPosition.x = (positions[3 * tempIndices[k][k]] - positions[3 * tempIndices[k][0]]) / k;
  91463. deltaPosition.y = (positions[3 * tempIndices[k][k] + 1] - positions[3 * tempIndices[k][0] + 1]) / k;
  91464. deltaPosition.z = (positions[3 * tempIndices[k][k] + 2] - positions[3 * tempIndices[k][0] + 2]) / k;
  91465. deltaNormal.x = (normals[3 * tempIndices[k][k]] - normals[3 * tempIndices[k][0]]) / k;
  91466. deltaNormal.y = (normals[3 * tempIndices[k][k] + 1] - normals[3 * tempIndices[k][0] + 1]) / k;
  91467. deltaNormal.z = (normals[3 * tempIndices[k][k] + 2] - normals[3 * tempIndices[k][0] + 2]) / k;
  91468. deltaUV.x = (uvs[2 * tempIndices[k][k]] - uvs[2 * tempIndices[k][0]]) / k;
  91469. deltaUV.y = (uvs[2 * tempIndices[k][k] + 1] - uvs[2 * tempIndices[k][0] + 1]) / k;
  91470. for (var j = 1; j < k; j++) {
  91471. tempIndices[k][j] = positions.length / 3;
  91472. positions[positionPtr] = positions[3 * tempIndices[k][0]] + j * deltaPosition.x;
  91473. normals[positionPtr++] = normals[3 * tempIndices[k][0]] + j * deltaNormal.x;
  91474. positions[positionPtr] = positions[3 * tempIndices[k][0] + 1] + j * deltaPosition.y;
  91475. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 1] + j * deltaNormal.y;
  91476. positions[positionPtr] = positions[3 * tempIndices[k][0] + 2] + j * deltaPosition.z;
  91477. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 2] + j * deltaNormal.z;
  91478. uvs[uvPtr++] = uvs[2 * tempIndices[k][0]] + j * deltaUV.x;
  91479. uvs[uvPtr++] = uvs[2 * tempIndices[k][0] + 1] + j * deltaUV.y;
  91480. }
  91481. }
  91482. tempIndices[segments] = side[currentIndices[i + 1]][currentIndices[i + 2]];
  91483. // reform indices
  91484. indices.push(tempIndices[0][0], tempIndices[1][0], tempIndices[1][1]);
  91485. for (var k = 1; k < segments; k++) {
  91486. for (var j = 0; j < k; j++) {
  91487. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  91488. indices.push(tempIndices[k][j], tempIndices[k + 1][j + 1], tempIndices[k][j + 1]);
  91489. }
  91490. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  91491. }
  91492. }
  91493. vertex_data.indices = indices;
  91494. vertex_data.applyToMesh(this);
  91495. }
  91496. };
  91497. /**
  91498. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  91499. * This will undo any application of covertToFlatShadedMesh
  91500. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91501. */
  91502. Mesh.prototype.forceSharedVertices = function () {
  91503. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  91504. var currentUVs = vertex_data.uvs;
  91505. var currentIndices = vertex_data.indices;
  91506. var currentPositions = vertex_data.positions;
  91507. var currentNormals = vertex_data.normals;
  91508. if (currentIndices === null || currentPositions === null || currentNormals === null || currentUVs === null) {
  91509. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("VertexData contains null entries");
  91510. }
  91511. else {
  91512. var positions = new Array();
  91513. var indices = new Array();
  91514. var uvs = new Array();
  91515. var pstring = new Array(); //lists facet vertex positions (a,b,c) as string "a|b|c"
  91516. var indexPtr = 0; // pointer to next available index value
  91517. var uniquePositions = new Array(); // unique vertex positions
  91518. var ptr; // pointer to element in uniquePositions
  91519. var facet;
  91520. for (var i = 0; i < currentIndices.length; i += 3) {
  91521. facet = [currentIndices[i], currentIndices[i + 1], currentIndices[i + 2]]; //facet vertex indices
  91522. pstring = new Array();
  91523. for (var j = 0; j < 3; j++) {
  91524. pstring[j] = "";
  91525. for (var k = 0; k < 3; k++) {
  91526. //small values make 0
  91527. if (Math.abs(currentPositions[3 * facet[j] + k]) < 0.00000001) {
  91528. currentPositions[3 * facet[j] + k] = 0;
  91529. }
  91530. pstring[j] += currentPositions[3 * facet[j] + k] + "|";
  91531. }
  91532. pstring[j] = pstring[j].slice(0, -1);
  91533. }
  91534. //check facet vertices to see that none are repeated
  91535. // do not process any facet that has a repeated vertex, ie is a line
  91536. if (!(pstring[0] == pstring[1] || pstring[0] == pstring[2] || pstring[1] == pstring[2])) {
  91537. //for each facet position check if already listed in uniquePositions
  91538. // if not listed add to uniquePositions and set index pointer
  91539. // if listed use its index in uniquePositions and new index pointer
  91540. for (var j = 0; j < 3; j++) {
  91541. ptr = uniquePositions.indexOf(pstring[j]);
  91542. if (ptr < 0) {
  91543. uniquePositions.push(pstring[j]);
  91544. ptr = indexPtr++;
  91545. //not listed so add individual x, y, z coordinates to positions
  91546. for (var k = 0; k < 3; k++) {
  91547. positions.push(currentPositions[3 * facet[j] + k]);
  91548. }
  91549. for (var k = 0; k < 2; k++) {
  91550. uvs.push(currentUVs[2 * facet[j] + k]);
  91551. }
  91552. }
  91553. // add new index pointer to indices array
  91554. indices.push(ptr);
  91555. }
  91556. }
  91557. }
  91558. var normals = new Array();
  91559. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  91560. //create new vertex data object and update
  91561. vertex_data.positions = positions;
  91562. vertex_data.indices = indices;
  91563. vertex_data.normals = normals;
  91564. vertex_data.uvs = uvs;
  91565. vertex_data.applyToMesh(this);
  91566. }
  91567. };
  91568. // Instances
  91569. /** @hidden */
  91570. Mesh._instancedMeshFactory = function (name, mesh) {
  91571. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("InstancedMesh");
  91572. };
  91573. /** @hidden */
  91574. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  91575. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("PhysicsImpostor");
  91576. };
  91577. /**
  91578. * Creates a new InstancedMesh object from the mesh model.
  91579. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91580. * @param name defines the name of the new instance
  91581. * @returns a new InstancedMesh
  91582. */
  91583. Mesh.prototype.createInstance = function (name) {
  91584. return Mesh._instancedMeshFactory(name, this);
  91585. };
  91586. /**
  91587. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  91588. * After this call, all the mesh instances have the same submeshes than the current mesh.
  91589. * @returns the current mesh
  91590. */
  91591. Mesh.prototype.synchronizeInstances = function () {
  91592. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  91593. var instance = this.instances[instanceIndex];
  91594. instance._syncSubMeshes();
  91595. }
  91596. return this;
  91597. };
  91598. /**
  91599. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  91600. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  91601. * This should be used together with the simplification to avoid disappearing triangles.
  91602. * @param successCallback an optional success callback to be called after the optimization finished.
  91603. * @returns the current mesh
  91604. */
  91605. Mesh.prototype.optimizeIndices = function (successCallback) {
  91606. var _this = this;
  91607. var indices = this.getIndices();
  91608. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  91609. if (!positions || !indices) {
  91610. return this;
  91611. }
  91612. var vectorPositions = new Array();
  91613. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  91614. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  91615. }
  91616. var dupes = new Array();
  91617. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  91618. var realPos = vectorPositions.length - 1 - iteration;
  91619. var testedPosition = vectorPositions[realPos];
  91620. for (var j = 0; j < realPos; ++j) {
  91621. var againstPosition = vectorPositions[j];
  91622. if (testedPosition.equals(againstPosition)) {
  91623. dupes[realPos] = j;
  91624. break;
  91625. }
  91626. }
  91627. }, function () {
  91628. for (var i = 0; i < indices.length; ++i) {
  91629. indices[i] = dupes[indices[i]] || indices[i];
  91630. }
  91631. //indices are now reordered
  91632. var originalSubMeshes = _this.subMeshes.slice(0);
  91633. _this.setIndices(indices);
  91634. _this.subMeshes = originalSubMeshes;
  91635. if (successCallback) {
  91636. successCallback(_this);
  91637. }
  91638. });
  91639. return this;
  91640. };
  91641. /**
  91642. * Serialize current mesh
  91643. * @param serializationObject defines the object which will receive the serialization data
  91644. */
  91645. Mesh.prototype.serialize = function (serializationObject) {
  91646. serializationObject.name = this.name;
  91647. serializationObject.id = this.id;
  91648. serializationObject.type = this.getClassName();
  91649. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  91650. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  91651. }
  91652. serializationObject.position = this.position.asArray();
  91653. if (this.rotationQuaternion) {
  91654. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  91655. }
  91656. else if (this.rotation) {
  91657. serializationObject.rotation = this.rotation.asArray();
  91658. }
  91659. serializationObject.scaling = this.scaling.asArray();
  91660. if (this._postMultiplyPivotMatrix) {
  91661. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  91662. }
  91663. else {
  91664. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  91665. }
  91666. serializationObject.isEnabled = this.isEnabled(false);
  91667. serializationObject.isVisible = this.isVisible;
  91668. serializationObject.infiniteDistance = this.infiniteDistance;
  91669. serializationObject.pickable = this.isPickable;
  91670. serializationObject.receiveShadows = this.receiveShadows;
  91671. serializationObject.billboardMode = this.billboardMode;
  91672. serializationObject.visibility = this.visibility;
  91673. serializationObject.checkCollisions = this.checkCollisions;
  91674. serializationObject.isBlocker = this.isBlocker;
  91675. // Parent
  91676. if (this.parent) {
  91677. serializationObject.parentId = this.parent.id;
  91678. }
  91679. // Geometry
  91680. serializationObject.isUnIndexed = this.isUnIndexed;
  91681. var geometry = this._geometry;
  91682. if (geometry) {
  91683. var geometryId = geometry.id;
  91684. serializationObject.geometryId = geometryId;
  91685. // SubMeshes
  91686. serializationObject.subMeshes = [];
  91687. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  91688. var subMesh = this.subMeshes[subIndex];
  91689. serializationObject.subMeshes.push({
  91690. materialIndex: subMesh.materialIndex,
  91691. verticesStart: subMesh.verticesStart,
  91692. verticesCount: subMesh.verticesCount,
  91693. indexStart: subMesh.indexStart,
  91694. indexCount: subMesh.indexCount
  91695. });
  91696. }
  91697. }
  91698. // Material
  91699. if (this.material) {
  91700. serializationObject.materialId = this.material.id;
  91701. }
  91702. else {
  91703. this.material = null;
  91704. }
  91705. // Morph targets
  91706. if (this.morphTargetManager) {
  91707. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  91708. }
  91709. // Skeleton
  91710. if (this.skeleton) {
  91711. serializationObject.skeletonId = this.skeleton.id;
  91712. }
  91713. // Physics
  91714. //TODO implement correct serialization for physics impostors.
  91715. if (this.getScene()._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_21__["SceneComponentConstants"].NAME_PHYSICSENGINE)) {
  91716. var impostor = this.getPhysicsImpostor();
  91717. if (impostor) {
  91718. serializationObject.physicsMass = impostor.getParam("mass");
  91719. serializationObject.physicsFriction = impostor.getParam("friction");
  91720. serializationObject.physicsRestitution = impostor.getParam("mass");
  91721. serializationObject.physicsImpostor = impostor.type;
  91722. }
  91723. }
  91724. // Metadata
  91725. if (this.metadata) {
  91726. serializationObject.metadata = this.metadata;
  91727. }
  91728. // Instances
  91729. serializationObject.instances = [];
  91730. for (var index = 0; index < this.instances.length; index++) {
  91731. var instance = this.instances[index];
  91732. if (instance.doNotSerialize) {
  91733. continue;
  91734. }
  91735. var serializationInstance = {
  91736. name: instance.name,
  91737. id: instance.id,
  91738. position: instance.position.asArray(),
  91739. scaling: instance.scaling.asArray()
  91740. };
  91741. if (instance.parent) {
  91742. serializationInstance.parentId = instance.parent.id;
  91743. }
  91744. if (instance.rotationQuaternion) {
  91745. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  91746. }
  91747. else if (instance.rotation) {
  91748. serializationInstance.rotation = instance.rotation.asArray();
  91749. }
  91750. serializationObject.instances.push(serializationInstance);
  91751. // Animations
  91752. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  91753. serializationInstance.ranges = instance.serializeAnimationRanges();
  91754. }
  91755. //
  91756. // Animations
  91757. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  91758. serializationObject.ranges = this.serializeAnimationRanges();
  91759. // Layer mask
  91760. serializationObject.layerMask = this.layerMask;
  91761. // Alpha
  91762. serializationObject.alphaIndex = this.alphaIndex;
  91763. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  91764. // Overlay
  91765. serializationObject.overlayAlpha = this.overlayAlpha;
  91766. serializationObject.overlayColor = this.overlayColor.asArray();
  91767. serializationObject.renderOverlay = this.renderOverlay;
  91768. // Fog
  91769. serializationObject.applyFog = this.applyFog;
  91770. // Action Manager
  91771. if (this.actionManager) {
  91772. serializationObject.actions = this.actionManager.serialize(this.name);
  91773. }
  91774. };
  91775. /** @hidden */
  91776. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  91777. if (!this.geometry) {
  91778. return;
  91779. }
  91780. this._markSubMeshesAsAttributesDirty();
  91781. var morphTargetManager = this._internalMeshDataInfo._morphTargetManager;
  91782. if (morphTargetManager && morphTargetManager.vertexCount) {
  91783. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  91784. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  91785. this.morphTargetManager = null;
  91786. return;
  91787. }
  91788. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  91789. var morphTarget = morphTargetManager.getActiveTarget(index);
  91790. var positions = morphTarget.getPositions();
  91791. if (!positions) {
  91792. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Invalid morph target. Target must have positions.");
  91793. return;
  91794. }
  91795. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  91796. var normals = morphTarget.getNormals();
  91797. if (normals) {
  91798. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  91799. }
  91800. var tangents = morphTarget.getTangents();
  91801. if (tangents) {
  91802. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  91803. }
  91804. }
  91805. }
  91806. else {
  91807. var index = 0;
  91808. // Positions
  91809. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  91810. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  91811. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  91812. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  91813. }
  91814. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  91815. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  91816. }
  91817. index++;
  91818. }
  91819. }
  91820. };
  91821. /**
  91822. * Returns a new Mesh object parsed from the source provided.
  91823. * @param parsedMesh is the source
  91824. * @param scene defines the hosting scene
  91825. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91826. * @returns a new Mesh
  91827. */
  91828. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  91829. var mesh;
  91830. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  91831. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  91832. }
  91833. else {
  91834. mesh = new Mesh(parsedMesh.name, scene);
  91835. }
  91836. mesh.id = parsedMesh.id;
  91837. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  91838. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  91839. }
  91840. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  91841. if (parsedMesh.metadata !== undefined) {
  91842. mesh.metadata = parsedMesh.metadata;
  91843. }
  91844. if (parsedMesh.rotationQuaternion) {
  91845. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  91846. }
  91847. else if (parsedMesh.rotation) {
  91848. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  91849. }
  91850. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  91851. if (parsedMesh.localMatrix) {
  91852. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  91853. }
  91854. else if (parsedMesh.pivotMatrix) {
  91855. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  91856. }
  91857. mesh.setEnabled(parsedMesh.isEnabled);
  91858. mesh.isVisible = parsedMesh.isVisible;
  91859. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  91860. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  91861. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  91862. if (parsedMesh.applyFog !== undefined) {
  91863. mesh.applyFog = parsedMesh.applyFog;
  91864. }
  91865. if (parsedMesh.pickable !== undefined) {
  91866. mesh.isPickable = parsedMesh.pickable;
  91867. }
  91868. if (parsedMesh.alphaIndex !== undefined) {
  91869. mesh.alphaIndex = parsedMesh.alphaIndex;
  91870. }
  91871. mesh.receiveShadows = parsedMesh.receiveShadows;
  91872. mesh.billboardMode = parsedMesh.billboardMode;
  91873. if (parsedMesh.visibility !== undefined) {
  91874. mesh.visibility = parsedMesh.visibility;
  91875. }
  91876. mesh.checkCollisions = parsedMesh.checkCollisions;
  91877. if (parsedMesh.isBlocker !== undefined) {
  91878. mesh.isBlocker = parsedMesh.isBlocker;
  91879. }
  91880. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  91881. // freezeWorldMatrix
  91882. if (parsedMesh.freezeWorldMatrix) {
  91883. mesh._waitingData.freezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  91884. }
  91885. // Parent
  91886. if (parsedMesh.parentId) {
  91887. mesh._waitingParentId = parsedMesh.parentId;
  91888. }
  91889. // Actions
  91890. if (parsedMesh.actions !== undefined) {
  91891. mesh._waitingData.actions = parsedMesh.actions;
  91892. }
  91893. // Overlay
  91894. if (parsedMesh.overlayAlpha !== undefined) {
  91895. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  91896. }
  91897. if (parsedMesh.overlayColor !== undefined) {
  91898. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  91899. }
  91900. if (parsedMesh.renderOverlay !== undefined) {
  91901. mesh.renderOverlay = parsedMesh.renderOverlay;
  91902. }
  91903. // Geometry
  91904. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  91905. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  91906. if (parsedMesh.delayLoadingFile) {
  91907. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED;
  91908. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  91909. 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));
  91910. if (parsedMesh._binaryInfo) {
  91911. mesh._binaryInfo = parsedMesh._binaryInfo;
  91912. }
  91913. mesh._delayInfo = [];
  91914. if (parsedMesh.hasUVs) {
  91915. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  91916. }
  91917. if (parsedMesh.hasUVs2) {
  91918. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  91919. }
  91920. if (parsedMesh.hasUVs3) {
  91921. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  91922. }
  91923. if (parsedMesh.hasUVs4) {
  91924. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  91925. }
  91926. if (parsedMesh.hasUVs5) {
  91927. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  91928. }
  91929. if (parsedMesh.hasUVs6) {
  91930. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  91931. }
  91932. if (parsedMesh.hasColors) {
  91933. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  91934. }
  91935. if (parsedMesh.hasMatricesIndices) {
  91936. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  91937. }
  91938. if (parsedMesh.hasMatricesWeights) {
  91939. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  91940. }
  91941. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  91942. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  91943. mesh._checkDelayState();
  91944. }
  91945. }
  91946. else {
  91947. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  91948. }
  91949. // Material
  91950. if (parsedMesh.materialId) {
  91951. mesh.setMaterialByID(parsedMesh.materialId);
  91952. }
  91953. else {
  91954. mesh.material = null;
  91955. }
  91956. // Morph targets
  91957. if (parsedMesh.morphTargetManagerId > -1) {
  91958. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  91959. }
  91960. // Skeleton
  91961. if (parsedMesh.skeletonId > -1) {
  91962. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  91963. if (parsedMesh.numBoneInfluencers) {
  91964. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  91965. }
  91966. }
  91967. // Animations
  91968. if (parsedMesh.animations) {
  91969. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  91970. var parsedAnimation = parsedMesh.animations[animationIndex];
  91971. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  91972. if (internalClass) {
  91973. mesh.animations.push(internalClass.Parse(parsedAnimation));
  91974. }
  91975. }
  91976. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  91977. }
  91978. if (parsedMesh.autoAnimate) {
  91979. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  91980. }
  91981. // Layer Mask
  91982. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  91983. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  91984. }
  91985. else {
  91986. mesh.layerMask = 0x0FFFFFFF;
  91987. }
  91988. // Physics
  91989. if (parsedMesh.physicsImpostor) {
  91990. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  91991. }
  91992. // Levels
  91993. if (parsedMesh.lodMeshIds) {
  91994. mesh._waitingData.lods = {
  91995. ids: parsedMesh.lodMeshIds,
  91996. distances: (parsedMesh.lodDistances) ? parsedMesh.lodDistances : null,
  91997. coverages: (parsedMesh.lodCoverages) ? parsedMesh.lodCoverages : null
  91998. };
  91999. }
  92000. // Instances
  92001. if (parsedMesh.instances) {
  92002. for (var index = 0; index < parsedMesh.instances.length; index++) {
  92003. var parsedInstance = parsedMesh.instances[index];
  92004. var instance = mesh.createInstance(parsedInstance.name);
  92005. if (parsedInstance.id) {
  92006. instance.id = parsedInstance.id;
  92007. }
  92008. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  92009. if (parsedInstance.tags) {
  92010. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  92011. }
  92012. else {
  92013. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  92014. }
  92015. }
  92016. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  92017. if (parsedInstance.metadata !== undefined) {
  92018. instance.metadata = parsedInstance.metadata;
  92019. }
  92020. if (parsedInstance.parentId) {
  92021. instance._waitingParentId = parsedInstance.parentId;
  92022. }
  92023. if (parsedInstance.rotationQuaternion) {
  92024. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  92025. }
  92026. else if (parsedInstance.rotation) {
  92027. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  92028. }
  92029. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  92030. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  92031. instance.checkCollisions = parsedInstance.checkCollisions;
  92032. }
  92033. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  92034. instance.isPickable = parsedInstance.pickable;
  92035. }
  92036. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  92037. instance.showBoundingBox = parsedInstance.showBoundingBox;
  92038. }
  92039. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  92040. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  92041. }
  92042. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  92043. instance.alphaIndex = parsedInstance.alphaIndex;
  92044. }
  92045. // Physics
  92046. if (parsedInstance.physicsImpostor) {
  92047. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  92048. }
  92049. // Animation
  92050. if (parsedInstance.animations) {
  92051. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  92052. parsedAnimation = parsedInstance.animations[animationIndex];
  92053. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  92054. if (internalClass) {
  92055. instance.animations.push(internalClass.Parse(parsedAnimation));
  92056. }
  92057. }
  92058. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  92059. if (parsedInstance.autoAnimate) {
  92060. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  92061. }
  92062. }
  92063. }
  92064. }
  92065. return mesh;
  92066. };
  92067. /**
  92068. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  92069. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92070. * @param name defines the name of the mesh to create
  92071. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  92072. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  92073. * @param closePath creates a seam between the first and the last points of each path of the path array
  92074. * @param offset is taken in account only if the `pathArray` is containing a single path
  92075. * @param scene defines the hosting scene
  92076. * @param updatable defines if the mesh must be flagged as updatable
  92077. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92078. * @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)
  92079. * @returns a new Mesh
  92080. */
  92081. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  92082. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92083. };
  92084. /**
  92085. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  92086. * @param name defines the name of the mesh to create
  92087. * @param radius sets the radius size (float) of the polygon (default 0.5)
  92088. * @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
  92089. * @param scene defines the hosting scene
  92090. * @param updatable defines if the mesh must be flagged as updatable
  92091. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92092. * @returns a new Mesh
  92093. */
  92094. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  92095. if (scene === void 0) { scene = null; }
  92096. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92097. };
  92098. /**
  92099. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  92100. * @param name defines the name of the mesh to create
  92101. * @param size sets the size (float) of each box side (default 1)
  92102. * @param scene defines the hosting scene
  92103. * @param updatable defines if the mesh must be flagged as updatable
  92104. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92105. * @returns a new Mesh
  92106. */
  92107. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  92108. if (scene === void 0) { scene = null; }
  92109. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92110. };
  92111. /**
  92112. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  92113. * @param name defines the name of the mesh to create
  92114. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92115. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92116. * @param scene defines the hosting scene
  92117. * @param updatable defines if the mesh must be flagged as updatable
  92118. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92119. * @returns a new Mesh
  92120. */
  92121. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  92122. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92123. };
  92124. /**
  92125. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  92126. * @param name defines the name of the mesh to create
  92127. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92128. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92129. * @param scene defines the hosting scene
  92130. * @returns a new Mesh
  92131. */
  92132. Mesh.CreateHemisphere = function (name, segments, diameter, scene) {
  92133. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92134. };
  92135. /**
  92136. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  92137. * @param name defines the name of the mesh to create
  92138. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  92139. * @param diameterTop set the top cap diameter (floats, default 1)
  92140. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  92141. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  92142. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  92143. * @param scene defines the hosting scene
  92144. * @param updatable defines if the mesh must be flagged as updatable
  92145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92146. * @returns a new Mesh
  92147. */
  92148. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  92149. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92150. };
  92151. // Torus (Code from SharpDX.org)
  92152. /**
  92153. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  92154. * @param name defines the name of the mesh to create
  92155. * @param diameter sets the diameter size (float) of the torus (default 1)
  92156. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  92157. * @param tessellation sets the number of torus sides (postive integer, default 16)
  92158. * @param scene defines the hosting scene
  92159. * @param updatable defines if the mesh must be flagged as updatable
  92160. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92161. * @returns a new Mesh
  92162. */
  92163. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  92164. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92165. };
  92166. /**
  92167. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  92168. * @param name defines the name of the mesh to create
  92169. * @param radius sets the global radius size (float) of the torus knot (default 2)
  92170. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  92171. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  92172. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  92173. * @param p the number of windings on X axis (positive integers, default 2)
  92174. * @param q the number of windings on Y axis (positive integers, default 3)
  92175. * @param scene defines the hosting scene
  92176. * @param updatable defines if the mesh must be flagged as updatable
  92177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92178. * @returns a new Mesh
  92179. */
  92180. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  92181. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92182. };
  92183. /**
  92184. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  92185. * @param name defines the name of the mesh to create
  92186. * @param points is an array successive Vector3
  92187. * @param scene defines the hosting scene
  92188. * @param updatable defines if the mesh must be flagged as updatable
  92189. * @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).
  92190. * @returns a new Mesh
  92191. */
  92192. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  92193. if (scene === void 0) { scene = null; }
  92194. if (updatable === void 0) { updatable = false; }
  92195. if (instance === void 0) { instance = null; }
  92196. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92197. };
  92198. /**
  92199. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  92200. * @param name defines the name of the mesh to create
  92201. * @param points is an array successive Vector3
  92202. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  92203. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92204. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  92205. * @param scene defines the hosting scene
  92206. * @param updatable defines if the mesh must be flagged as updatable
  92207. * @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)
  92208. * @returns a new Mesh
  92209. */
  92210. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  92211. if (scene === void 0) { scene = null; }
  92212. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92213. };
  92214. /**
  92215. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  92216. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  92217. * 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.
  92218. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92219. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92220. * Remember you can only change the shape positions, not their number when updating a polygon.
  92221. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92222. * @param name defines the name of the mesh to create
  92223. * @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
  92224. * @param scene defines the hosting scene
  92225. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92226. * @param updatable defines if the mesh must be flagged as updatable
  92227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92228. * @param earcutInjection can be used to inject your own earcut reference
  92229. * @returns a new Mesh
  92230. */
  92231. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  92232. if (earcutInjection === void 0) { earcutInjection = earcut; }
  92233. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92234. };
  92235. /**
  92236. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  92237. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  92238. * @param name defines the name of the mesh to create
  92239. * @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
  92240. * @param depth defines the height of extrusion
  92241. * @param scene defines the hosting scene
  92242. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92243. * @param updatable defines if the mesh must be flagged as updatable
  92244. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92245. * @param earcutInjection can be used to inject your own earcut reference
  92246. * @returns a new Mesh
  92247. */
  92248. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  92249. if (earcutInjection === void 0) { earcutInjection = earcut; }
  92250. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92251. };
  92252. /**
  92253. * Creates an extruded shape mesh.
  92254. * 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
  92255. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92256. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92257. * @param name defines the name of the mesh to create
  92258. * @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
  92259. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92260. * @param scale is the value to scale the shape
  92261. * @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
  92262. * @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
  92263. * @param scene defines the hosting scene
  92264. * @param updatable defines if the mesh must be flagged as updatable
  92265. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92266. * @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)
  92267. * @returns a new Mesh
  92268. */
  92269. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  92270. if (scene === void 0) { scene = null; }
  92271. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92272. };
  92273. /**
  92274. * Creates an custom extruded shape mesh.
  92275. * The custom extrusion is a parametric shape.
  92276. * It has no predefined shape. Its final shape will depend on the input parameters.
  92277. * Please consider using the same method from the MeshBuilder class instead
  92278. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92279. * @param name defines the name of the mesh to create
  92280. * @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
  92281. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92282. * @param scaleFunction is a custom Javascript function called on each path point
  92283. * @param rotationFunction is a custom Javascript function called on each path point
  92284. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92285. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  92286. * @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
  92287. * @param scene defines the hosting scene
  92288. * @param updatable defines if the mesh must be flagged as updatable
  92289. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92290. * @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)
  92291. * @returns a new Mesh
  92292. */
  92293. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  92294. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92295. };
  92296. /**
  92297. * Creates lathe mesh.
  92298. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  92299. * Please consider using the same method from the MeshBuilder class instead
  92300. * @param name defines the name of the mesh to create
  92301. * @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
  92302. * @param radius is the radius value of the lathe
  92303. * @param tessellation is the side number of the lathe.
  92304. * @param scene defines the hosting scene
  92305. * @param updatable defines if the mesh must be flagged as updatable
  92306. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92307. * @returns a new Mesh
  92308. */
  92309. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  92310. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92311. };
  92312. /**
  92313. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  92314. * @param name defines the name of the mesh to create
  92315. * @param size sets the size (float) of both sides of the plane at once (default 1)
  92316. * @param scene defines the hosting scene
  92317. * @param updatable defines if the mesh must be flagged as updatable
  92318. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92319. * @returns a new Mesh
  92320. */
  92321. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  92322. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92323. };
  92324. /**
  92325. * Creates a ground mesh.
  92326. * Please consider using the same method from the MeshBuilder class instead
  92327. * @param name defines the name of the mesh to create
  92328. * @param width set the width of the ground
  92329. * @param height set the height of the ground
  92330. * @param subdivisions sets the number of subdivisions per side
  92331. * @param scene defines the hosting scene
  92332. * @param updatable defines if the mesh must be flagged as updatable
  92333. * @returns a new Mesh
  92334. */
  92335. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  92336. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92337. };
  92338. /**
  92339. * Creates a tiled ground mesh.
  92340. * Please consider using the same method from the MeshBuilder class instead
  92341. * @param name defines the name of the mesh to create
  92342. * @param xmin set the ground minimum X coordinate
  92343. * @param zmin set the ground minimum Y coordinate
  92344. * @param xmax set the ground maximum X coordinate
  92345. * @param zmax set the ground maximum Z coordinate
  92346. * @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
  92347. * @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
  92348. * @param scene defines the hosting scene
  92349. * @param updatable defines if the mesh must be flagged as updatable
  92350. * @returns a new Mesh
  92351. */
  92352. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  92353. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92354. };
  92355. /**
  92356. * Creates a ground mesh from a height map.
  92357. * Please consider using the same method from the MeshBuilder class instead
  92358. * @see http://doc.babylonjs.com/babylon101/height_map
  92359. * @param name defines the name of the mesh to create
  92360. * @param url sets the URL of the height map image resource
  92361. * @param width set the ground width size
  92362. * @param height set the ground height size
  92363. * @param subdivisions sets the number of subdivision per side
  92364. * @param minHeight is the minimum altitude on the ground
  92365. * @param maxHeight is the maximum altitude on the ground
  92366. * @param scene defines the hosting scene
  92367. * @param updatable defines if the mesh must be flagged as updatable
  92368. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  92369. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92370. * @returns a new Mesh
  92371. */
  92372. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  92373. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92374. };
  92375. /**
  92376. * Creates a tube mesh.
  92377. * The tube is a parametric shape.
  92378. * It has no predefined shape. Its final shape will depend on the input parameters.
  92379. * Please consider using the same method from the MeshBuilder class instead
  92380. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92381. * @param name defines the name of the mesh to create
  92382. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92383. * @param radius sets the tube radius size
  92384. * @param tessellation is the number of sides on the tubular surface
  92385. * @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
  92386. * @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
  92387. * @param scene defines the hosting scene
  92388. * @param updatable defines if the mesh must be flagged as updatable
  92389. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92390. * @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)
  92391. * @returns a new Mesh
  92392. */
  92393. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  92394. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92395. };
  92396. /**
  92397. * Creates a polyhedron mesh.
  92398. * Please consider using the same method from the MeshBuilder class instead.
  92399. * * 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
  92400. * * The parameter `size` (positive float, default 1) sets the polygon size
  92401. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92402. * * 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`
  92403. * * 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
  92404. * * 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)`)
  92405. * * 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
  92406. * * 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
  92407. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92408. * * 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
  92409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92410. * @param name defines the name of the mesh to create
  92411. * @param options defines the options used to create the mesh
  92412. * @param scene defines the hosting scene
  92413. * @returns a new Mesh
  92414. */
  92415. Mesh.CreatePolyhedron = function (name, options, scene) {
  92416. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92417. };
  92418. /**
  92419. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92420. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92421. * * 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`)
  92422. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92423. * * 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
  92424. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92425. * * 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
  92426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92427. * @param name defines the name of the mesh
  92428. * @param options defines the options used to create the mesh
  92429. * @param scene defines the hosting scene
  92430. * @returns a new Mesh
  92431. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92432. */
  92433. Mesh.CreateIcoSphere = function (name, options, scene) {
  92434. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92435. };
  92436. /**
  92437. * Creates a decal mesh.
  92438. * Please consider using the same method from the MeshBuilder class instead.
  92439. * A decal is a mesh usually applied as a model onto the surface of another mesh
  92440. * @param name defines the name of the mesh
  92441. * @param sourceMesh defines the mesh receiving the decal
  92442. * @param position sets the position of the decal in world coordinates
  92443. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  92444. * @param size sets the decal scaling
  92445. * @param angle sets the angle to rotate the decal
  92446. * @returns a new Mesh
  92447. */
  92448. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  92449. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  92450. };
  92451. // Skeletons
  92452. /**
  92453. * Prepare internal position array for software CPU skinning
  92454. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  92455. */
  92456. Mesh.prototype.setPositionsForCPUSkinning = function () {
  92457. var internalDataInfo = this._internalMeshDataInfo;
  92458. if (!internalDataInfo._sourcePositions) {
  92459. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  92460. if (!source) {
  92461. return internalDataInfo._sourcePositions;
  92462. }
  92463. internalDataInfo._sourcePositions = new Float32Array(source);
  92464. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  92465. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  92466. }
  92467. }
  92468. return internalDataInfo._sourcePositions;
  92469. };
  92470. /**
  92471. * Prepare internal normal array for software CPU skinning
  92472. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  92473. */
  92474. Mesh.prototype.setNormalsForCPUSkinning = function () {
  92475. var internalDataInfo = this._internalMeshDataInfo;
  92476. if (!internalDataInfo._sourceNormals) {
  92477. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  92478. if (!source) {
  92479. return internalDataInfo._sourceNormals;
  92480. }
  92481. internalDataInfo._sourceNormals = new Float32Array(source);
  92482. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  92483. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  92484. }
  92485. }
  92486. return internalDataInfo._sourceNormals;
  92487. };
  92488. /**
  92489. * Updates the vertex buffer by applying transformation from the bones
  92490. * @param skeleton defines the skeleton to apply to current mesh
  92491. * @returns the current mesh
  92492. */
  92493. Mesh.prototype.applySkeleton = function (skeleton) {
  92494. if (!this.geometry) {
  92495. return this;
  92496. }
  92497. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  92498. return this;
  92499. }
  92500. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  92501. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  92502. return this;
  92503. }
  92504. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  92505. return this;
  92506. }
  92507. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  92508. return this;
  92509. }
  92510. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  92511. return this;
  92512. }
  92513. var internalDataInfo = this._internalMeshDataInfo;
  92514. if (!internalDataInfo._sourcePositions) {
  92515. var submeshes = this.subMeshes.slice();
  92516. this.setPositionsForCPUSkinning();
  92517. this.subMeshes = submeshes;
  92518. }
  92519. if (!internalDataInfo._sourceNormals) {
  92520. this.setNormalsForCPUSkinning();
  92521. }
  92522. // positionsData checks for not being Float32Array will only pass at most once
  92523. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  92524. if (!positionsData) {
  92525. return this;
  92526. }
  92527. if (!(positionsData instanceof Float32Array)) {
  92528. positionsData = new Float32Array(positionsData);
  92529. }
  92530. // normalsData checks for not being Float32Array will only pass at most once
  92531. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  92532. if (!normalsData) {
  92533. return this;
  92534. }
  92535. if (!(normalsData instanceof Float32Array)) {
  92536. normalsData = new Float32Array(normalsData);
  92537. }
  92538. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  92539. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  92540. if (!matricesWeightsData || !matricesIndicesData) {
  92541. return this;
  92542. }
  92543. var needExtras = this.numBoneInfluencers > 4;
  92544. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  92545. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  92546. var skeletonMatrices = skeleton.getTransformMatrices(this);
  92547. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  92548. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  92549. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  92550. var matWeightIdx = 0;
  92551. var inf;
  92552. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  92553. var weight;
  92554. for (inf = 0; inf < 4; inf++) {
  92555. weight = matricesWeightsData[matWeightIdx + inf];
  92556. if (weight > 0) {
  92557. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  92558. finalMatrix.addToSelf(tempMatrix);
  92559. }
  92560. }
  92561. if (needExtras) {
  92562. for (inf = 0; inf < 4; inf++) {
  92563. weight = matricesWeightsExtraData[matWeightIdx + inf];
  92564. if (weight > 0) {
  92565. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  92566. finalMatrix.addToSelf(tempMatrix);
  92567. }
  92568. }
  92569. }
  92570. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(internalDataInfo._sourcePositions[index], internalDataInfo._sourcePositions[index + 1], internalDataInfo._sourcePositions[index + 2], finalMatrix, tempVector3);
  92571. tempVector3.toArray(positionsData, index);
  92572. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(internalDataInfo._sourceNormals[index], internalDataInfo._sourceNormals[index + 1], internalDataInfo._sourceNormals[index + 2], finalMatrix, tempVector3);
  92573. tempVector3.toArray(normalsData, index);
  92574. finalMatrix.reset();
  92575. }
  92576. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  92577. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  92578. return this;
  92579. };
  92580. // Tools
  92581. /**
  92582. * 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
  92583. * @param meshes defines the list of meshes to scan
  92584. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  92585. */
  92586. Mesh.MinMax = function (meshes) {
  92587. var minVector = null;
  92588. var maxVector = null;
  92589. meshes.forEach(function (mesh) {
  92590. var boundingInfo = mesh.getBoundingInfo();
  92591. var boundingBox = boundingInfo.boundingBox;
  92592. if (!minVector || !maxVector) {
  92593. minVector = boundingBox.minimumWorld;
  92594. maxVector = boundingBox.maximumWorld;
  92595. }
  92596. else {
  92597. minVector.minimizeInPlace(boundingBox.minimumWorld);
  92598. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  92599. }
  92600. });
  92601. if (!minVector || !maxVector) {
  92602. return {
  92603. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  92604. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  92605. };
  92606. }
  92607. return {
  92608. min: minVector,
  92609. max: maxVector
  92610. };
  92611. };
  92612. /**
  92613. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  92614. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  92615. * @returns a vector3
  92616. */
  92617. Mesh.Center = function (meshesOrMinMaxVector) {
  92618. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  92619. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  92620. };
  92621. /**
  92622. * Merge the array of meshes into a single mesh for performance reasons.
  92623. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  92624. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  92625. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  92626. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  92627. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  92628. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  92629. * @returns a new mesh
  92630. */
  92631. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes, multiMultiMaterials) {
  92632. if (disposeSource === void 0) { disposeSource = true; }
  92633. var index;
  92634. if (!allow32BitsIndices) {
  92635. var totalVertices = 0;
  92636. // Counting vertices
  92637. for (index = 0; index < meshes.length; index++) {
  92638. if (meshes[index]) {
  92639. totalVertices += meshes[index].getTotalVertices();
  92640. if (totalVertices > 65536) {
  92641. _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");
  92642. return null;
  92643. }
  92644. }
  92645. }
  92646. }
  92647. if (multiMultiMaterials) {
  92648. var newMultiMaterial = null;
  92649. var subIndex;
  92650. var matIndex;
  92651. subdivideWithSubMeshes = false;
  92652. }
  92653. var materialArray = new Array();
  92654. var materialIndexArray = new Array();
  92655. // Merge
  92656. var vertexData = null;
  92657. var otherVertexData;
  92658. var indiceArray = new Array();
  92659. var source = null;
  92660. for (index = 0; index < meshes.length; index++) {
  92661. if (meshes[index]) {
  92662. var mesh = meshes[index];
  92663. if (mesh.isAnInstance) {
  92664. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot merge instance meshes.");
  92665. return null;
  92666. }
  92667. var wm = mesh.computeWorldMatrix(true);
  92668. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(mesh, true, true);
  92669. otherVertexData.transform(wm);
  92670. if (vertexData) {
  92671. vertexData.merge(otherVertexData, allow32BitsIndices);
  92672. }
  92673. else {
  92674. vertexData = otherVertexData;
  92675. source = mesh;
  92676. }
  92677. if (subdivideWithSubMeshes) {
  92678. indiceArray.push(mesh.getTotalIndices());
  92679. }
  92680. if (multiMultiMaterials) {
  92681. if (mesh.material) {
  92682. var material = mesh.material;
  92683. if (material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"]) {
  92684. for (matIndex = 0; matIndex < material.subMaterials.length; matIndex++) {
  92685. if (materialArray.indexOf(material.subMaterials[matIndex]) < 0) {
  92686. materialArray.push(material.subMaterials[matIndex]);
  92687. }
  92688. }
  92689. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  92690. materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
  92691. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  92692. }
  92693. }
  92694. else {
  92695. if (materialArray.indexOf(material) < 0) {
  92696. materialArray.push(material);
  92697. }
  92698. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  92699. materialIndexArray.push(materialArray.indexOf(material));
  92700. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  92701. }
  92702. }
  92703. }
  92704. else {
  92705. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  92706. materialIndexArray.push(0);
  92707. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  92708. }
  92709. }
  92710. }
  92711. }
  92712. }
  92713. source = source;
  92714. if (!meshSubclass) {
  92715. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  92716. }
  92717. vertexData.applyToMesh(meshSubclass);
  92718. // Setting properties
  92719. meshSubclass.checkCollisions = source.checkCollisions;
  92720. // Cleaning
  92721. if (disposeSource) {
  92722. for (index = 0; index < meshes.length; index++) {
  92723. if (meshes[index]) {
  92724. meshes[index].dispose();
  92725. }
  92726. }
  92727. }
  92728. // Subdivide
  92729. if (subdivideWithSubMeshes || multiMultiMaterials) {
  92730. //-- removal of global submesh
  92731. meshSubclass.releaseSubMeshes();
  92732. index = 0;
  92733. var offset = 0;
  92734. //-- apply subdivision according to index table
  92735. while (index < indiceArray.length) {
  92736. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  92737. offset += indiceArray[index];
  92738. index++;
  92739. }
  92740. }
  92741. if (multiMultiMaterials) {
  92742. newMultiMaterial = new _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"](source.name + "_merged", source.getScene());
  92743. newMultiMaterial.subMaterials = materialArray;
  92744. for (subIndex = 0; subIndex < meshSubclass.subMeshes.length; subIndex++) {
  92745. meshSubclass.subMeshes[subIndex].materialIndex = materialIndexArray[subIndex];
  92746. }
  92747. meshSubclass.material = newMultiMaterial;
  92748. }
  92749. else {
  92750. meshSubclass.material = source.material;
  92751. }
  92752. return meshSubclass;
  92753. };
  92754. /** @hidden */
  92755. Mesh.prototype.addInstance = function (instance) {
  92756. instance._indexInSourceMeshInstanceArray = this.instances.length;
  92757. this.instances.push(instance);
  92758. };
  92759. /** @hidden */
  92760. Mesh.prototype.removeInstance = function (instance) {
  92761. // Remove from mesh
  92762. var index = instance._indexInSourceMeshInstanceArray;
  92763. if (index != -1) {
  92764. if (index !== this.instances.length - 1) {
  92765. var last = this.instances[this.instances.length - 1];
  92766. this.instances[index] = last;
  92767. last._indexInSourceMeshInstanceArray = index;
  92768. }
  92769. instance._indexInSourceMeshInstanceArray = -1;
  92770. this.instances.pop();
  92771. }
  92772. };
  92773. // Consts
  92774. /**
  92775. * Mesh side orientation : usually the external or front surface
  92776. */
  92777. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  92778. /**
  92779. * Mesh side orientation : usually the internal or back surface
  92780. */
  92781. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  92782. /**
  92783. * Mesh side orientation : both internal and external or front and back surfaces
  92784. */
  92785. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  92786. /**
  92787. * Mesh side orientation : by default, `FRONTSIDE`
  92788. */
  92789. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  92790. /**
  92791. * Mesh cap setting : no cap
  92792. */
  92793. Mesh.NO_CAP = 0;
  92794. /**
  92795. * Mesh cap setting : one cap at the beginning of the mesh
  92796. */
  92797. Mesh.CAP_START = 1;
  92798. /**
  92799. * Mesh cap setting : one cap at the end of the mesh
  92800. */
  92801. Mesh.CAP_END = 2;
  92802. /**
  92803. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  92804. */
  92805. Mesh.CAP_ALL = 3;
  92806. // Statics
  92807. /** @hidden */
  92808. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  92809. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("GroundMesh");
  92810. };
  92811. return Mesh;
  92812. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  92813. /***/ }),
  92814. /***/ "./Meshes/mesh.vertexData.ts":
  92815. /*!***********************************!*\
  92816. !*** ./Meshes/mesh.vertexData.ts ***!
  92817. \***********************************/
  92818. /*! exports provided: VertexData */
  92819. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92820. "use strict";
  92821. __webpack_require__.r(__webpack_exports__);
  92822. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  92823. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92824. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  92825. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  92826. /**
  92827. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  92828. */
  92829. var VertexData = /** @class */ (function () {
  92830. function VertexData() {
  92831. }
  92832. /**
  92833. * Uses the passed data array to set the set the values for the specified kind of data
  92834. * @param data a linear array of floating numbers
  92835. * @param kind the type of data that is being set, eg positions, colors etc
  92836. */
  92837. VertexData.prototype.set = function (data, kind) {
  92838. switch (kind) {
  92839. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  92840. this.positions = data;
  92841. break;
  92842. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  92843. this.normals = data;
  92844. break;
  92845. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  92846. this.tangents = data;
  92847. break;
  92848. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  92849. this.uvs = data;
  92850. break;
  92851. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  92852. this.uvs2 = data;
  92853. break;
  92854. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  92855. this.uvs3 = data;
  92856. break;
  92857. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  92858. this.uvs4 = data;
  92859. break;
  92860. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  92861. this.uvs5 = data;
  92862. break;
  92863. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  92864. this.uvs6 = data;
  92865. break;
  92866. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  92867. this.colors = data;
  92868. break;
  92869. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  92870. this.matricesIndices = data;
  92871. break;
  92872. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  92873. this.matricesWeights = data;
  92874. break;
  92875. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  92876. this.matricesIndicesExtra = data;
  92877. break;
  92878. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  92879. this.matricesWeightsExtra = data;
  92880. break;
  92881. }
  92882. };
  92883. /**
  92884. * Associates the vertexData to the passed Mesh.
  92885. * Sets it as updatable or not (default `false`)
  92886. * @param mesh the mesh the vertexData is applied to
  92887. * @param updatable when used and having the value true allows new data to update the vertexData
  92888. * @returns the VertexData
  92889. */
  92890. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  92891. this._applyTo(mesh, updatable);
  92892. return this;
  92893. };
  92894. /**
  92895. * Associates the vertexData to the passed Geometry.
  92896. * Sets it as updatable or not (default `false`)
  92897. * @param geometry the geometry the vertexData is applied to
  92898. * @param updatable when used and having the value true allows new data to update the vertexData
  92899. * @returns VertexData
  92900. */
  92901. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  92902. this._applyTo(geometry, updatable);
  92903. return this;
  92904. };
  92905. /**
  92906. * Updates the associated mesh
  92907. * @param mesh the mesh to be updated
  92908. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92909. * @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
  92910. * @returns VertexData
  92911. */
  92912. VertexData.prototype.updateMesh = function (mesh) {
  92913. this._update(mesh);
  92914. return this;
  92915. };
  92916. /**
  92917. * Updates the associated geometry
  92918. * @param geometry the geometry to be updated
  92919. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92920. * @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
  92921. * @returns VertexData.
  92922. */
  92923. VertexData.prototype.updateGeometry = function (geometry) {
  92924. this._update(geometry);
  92925. return this;
  92926. };
  92927. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  92928. if (updatable === void 0) { updatable = false; }
  92929. if (this.positions) {
  92930. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  92931. }
  92932. if (this.normals) {
  92933. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  92934. }
  92935. if (this.tangents) {
  92936. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  92937. }
  92938. if (this.uvs) {
  92939. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  92940. }
  92941. if (this.uvs2) {
  92942. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  92943. }
  92944. if (this.uvs3) {
  92945. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  92946. }
  92947. if (this.uvs4) {
  92948. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  92949. }
  92950. if (this.uvs5) {
  92951. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  92952. }
  92953. if (this.uvs6) {
  92954. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  92955. }
  92956. if (this.colors) {
  92957. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  92958. }
  92959. if (this.matricesIndices) {
  92960. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  92961. }
  92962. if (this.matricesWeights) {
  92963. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  92964. }
  92965. if (this.matricesIndicesExtra) {
  92966. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  92967. }
  92968. if (this.matricesWeightsExtra) {
  92969. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  92970. }
  92971. if (this.indices) {
  92972. meshOrGeometry.setIndices(this.indices, null, updatable);
  92973. }
  92974. else {
  92975. meshOrGeometry.setIndices([], null);
  92976. }
  92977. return this;
  92978. };
  92979. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  92980. if (this.positions) {
  92981. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  92982. }
  92983. if (this.normals) {
  92984. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  92985. }
  92986. if (this.tangents) {
  92987. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  92988. }
  92989. if (this.uvs) {
  92990. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  92991. }
  92992. if (this.uvs2) {
  92993. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  92994. }
  92995. if (this.uvs3) {
  92996. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  92997. }
  92998. if (this.uvs4) {
  92999. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  93000. }
  93001. if (this.uvs5) {
  93002. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  93003. }
  93004. if (this.uvs6) {
  93005. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  93006. }
  93007. if (this.colors) {
  93008. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  93009. }
  93010. if (this.matricesIndices) {
  93011. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  93012. }
  93013. if (this.matricesWeights) {
  93014. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  93015. }
  93016. if (this.matricesIndicesExtra) {
  93017. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  93018. }
  93019. if (this.matricesWeightsExtra) {
  93020. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  93021. }
  93022. if (this.indices) {
  93023. meshOrGeometry.setIndices(this.indices, null);
  93024. }
  93025. return this;
  93026. };
  93027. /**
  93028. * Transforms each position and each normal of the vertexData according to the passed Matrix
  93029. * @param matrix the transforming matrix
  93030. * @returns the VertexData
  93031. */
  93032. VertexData.prototype.transform = function (matrix) {
  93033. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  93034. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  93035. var index;
  93036. if (this.positions) {
  93037. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  93038. for (index = 0; index < this.positions.length; index += 3) {
  93039. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  93040. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  93041. this.positions[index] = transformed.x;
  93042. this.positions[index + 1] = transformed.y;
  93043. this.positions[index + 2] = transformed.z;
  93044. }
  93045. }
  93046. if (this.normals) {
  93047. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  93048. for (index = 0; index < this.normals.length; index += 3) {
  93049. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  93050. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  93051. this.normals[index] = transformed.x;
  93052. this.normals[index + 1] = transformed.y;
  93053. this.normals[index + 2] = transformed.z;
  93054. }
  93055. }
  93056. if (this.tangents) {
  93057. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  93058. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  93059. for (index = 0; index < this.tangents.length; index += 4) {
  93060. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  93061. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  93062. this.tangents[index] = tangentTransformed.x;
  93063. this.tangents[index + 1] = tangentTransformed.y;
  93064. this.tangents[index + 2] = tangentTransformed.z;
  93065. this.tangents[index + 3] = tangentTransformed.w;
  93066. }
  93067. }
  93068. if (flip && this.indices) {
  93069. for (index = 0; index < this.indices.length; index += 3) {
  93070. var tmp = this.indices[index + 1];
  93071. this.indices[index + 1] = this.indices[index + 2];
  93072. this.indices[index + 2] = tmp;
  93073. }
  93074. }
  93075. return this;
  93076. };
  93077. /**
  93078. * Merges the passed VertexData into the current one
  93079. * @param other the VertexData to be merged into the current one
  93080. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  93081. * @returns the modified VertexData
  93082. */
  93083. VertexData.prototype.merge = function (other, use32BitsIndices) {
  93084. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  93085. this._validate();
  93086. other._validate();
  93087. if (!this.normals !== !other.normals ||
  93088. !this.tangents !== !other.tangents ||
  93089. !this.uvs !== !other.uvs ||
  93090. !this.uvs2 !== !other.uvs2 ||
  93091. !this.uvs3 !== !other.uvs3 ||
  93092. !this.uvs4 !== !other.uvs4 ||
  93093. !this.uvs5 !== !other.uvs5 ||
  93094. !this.uvs6 !== !other.uvs6 ||
  93095. !this.colors !== !other.colors ||
  93096. !this.matricesIndices !== !other.matricesIndices ||
  93097. !this.matricesWeights !== !other.matricesWeights ||
  93098. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  93099. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  93100. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  93101. }
  93102. if (other.indices) {
  93103. if (!this.indices) {
  93104. this.indices = [];
  93105. }
  93106. var offset = this.positions ? this.positions.length / 3 : 0;
  93107. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  93108. if (isSrcTypedArray) {
  93109. var len = this.indices.length + other.indices.length;
  93110. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  93111. temp.set(this.indices);
  93112. var decal = this.indices.length;
  93113. for (var index = 0; index < other.indices.length; index++) {
  93114. temp[decal + index] = other.indices[index] + offset;
  93115. }
  93116. this.indices = temp;
  93117. }
  93118. else {
  93119. for (var index = 0; index < other.indices.length; index++) {
  93120. this.indices.push(other.indices[index] + offset);
  93121. }
  93122. }
  93123. }
  93124. this.positions = this._mergeElement(this.positions, other.positions);
  93125. this.normals = this._mergeElement(this.normals, other.normals);
  93126. this.tangents = this._mergeElement(this.tangents, other.tangents);
  93127. this.uvs = this._mergeElement(this.uvs, other.uvs);
  93128. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  93129. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  93130. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  93131. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  93132. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  93133. this.colors = this._mergeElement(this.colors, other.colors);
  93134. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  93135. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  93136. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  93137. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  93138. return this;
  93139. };
  93140. VertexData.prototype._mergeElement = function (source, other) {
  93141. if (!source) {
  93142. return other;
  93143. }
  93144. if (!other) {
  93145. return source;
  93146. }
  93147. var len = other.length + source.length;
  93148. var isSrcTypedArray = source instanceof Float32Array;
  93149. var isOthTypedArray = other instanceof Float32Array;
  93150. // use non-loop method when the source is Float32Array
  93151. if (isSrcTypedArray) {
  93152. var ret32 = new Float32Array(len);
  93153. ret32.set(source);
  93154. ret32.set(other, source.length);
  93155. return ret32;
  93156. // source is number[], when other is also use concat
  93157. }
  93158. else if (!isOthTypedArray) {
  93159. return source.concat(other);
  93160. // source is a number[], but other is a Float32Array, loop required
  93161. }
  93162. else {
  93163. var ret = source.slice(0); // copy source to a separate array
  93164. for (var i = 0, len = other.length; i < len; i++) {
  93165. ret.push(other[i]);
  93166. }
  93167. return ret;
  93168. }
  93169. };
  93170. VertexData.prototype._validate = function () {
  93171. if (!this.positions) {
  93172. throw new Error("Positions are required");
  93173. }
  93174. var getElementCount = function (kind, values) {
  93175. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  93176. if ((values.length % stride) !== 0) {
  93177. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  93178. }
  93179. return values.length / stride;
  93180. };
  93181. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  93182. var validateElementCount = function (kind, values) {
  93183. var elementCount = getElementCount(kind, values);
  93184. if (elementCount !== positionsElementCount) {
  93185. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  93186. }
  93187. };
  93188. if (this.normals) {
  93189. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  93190. }
  93191. if (this.tangents) {
  93192. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  93193. }
  93194. if (this.uvs) {
  93195. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  93196. }
  93197. if (this.uvs2) {
  93198. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  93199. }
  93200. if (this.uvs3) {
  93201. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  93202. }
  93203. if (this.uvs4) {
  93204. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  93205. }
  93206. if (this.uvs5) {
  93207. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  93208. }
  93209. if (this.uvs6) {
  93210. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  93211. }
  93212. if (this.colors) {
  93213. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  93214. }
  93215. if (this.matricesIndices) {
  93216. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  93217. }
  93218. if (this.matricesWeights) {
  93219. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  93220. }
  93221. if (this.matricesIndicesExtra) {
  93222. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  93223. }
  93224. if (this.matricesWeightsExtra) {
  93225. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  93226. }
  93227. };
  93228. /**
  93229. * Serializes the VertexData
  93230. * @returns a serialized object
  93231. */
  93232. VertexData.prototype.serialize = function () {
  93233. var serializationObject = this.serialize();
  93234. if (this.positions) {
  93235. serializationObject.positions = this.positions;
  93236. }
  93237. if (this.normals) {
  93238. serializationObject.normals = this.normals;
  93239. }
  93240. if (this.tangents) {
  93241. serializationObject.tangents = this.tangents;
  93242. }
  93243. if (this.uvs) {
  93244. serializationObject.uvs = this.uvs;
  93245. }
  93246. if (this.uvs2) {
  93247. serializationObject.uvs2 = this.uvs2;
  93248. }
  93249. if (this.uvs3) {
  93250. serializationObject.uvs3 = this.uvs3;
  93251. }
  93252. if (this.uvs4) {
  93253. serializationObject.uvs4 = this.uvs4;
  93254. }
  93255. if (this.uvs5) {
  93256. serializationObject.uvs5 = this.uvs5;
  93257. }
  93258. if (this.uvs6) {
  93259. serializationObject.uvs6 = this.uvs6;
  93260. }
  93261. if (this.colors) {
  93262. serializationObject.colors = this.colors;
  93263. }
  93264. if (this.matricesIndices) {
  93265. serializationObject.matricesIndices = this.matricesIndices;
  93266. serializationObject.matricesIndices._isExpanded = true;
  93267. }
  93268. if (this.matricesWeights) {
  93269. serializationObject.matricesWeights = this.matricesWeights;
  93270. }
  93271. if (this.matricesIndicesExtra) {
  93272. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  93273. serializationObject.matricesIndicesExtra._isExpanded = true;
  93274. }
  93275. if (this.matricesWeightsExtra) {
  93276. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  93277. }
  93278. serializationObject.indices = this.indices;
  93279. return serializationObject;
  93280. };
  93281. // Statics
  93282. /**
  93283. * Extracts the vertexData from a mesh
  93284. * @param mesh the mesh from which to extract the VertexData
  93285. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  93286. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  93287. * @returns the object VertexData associated to the passed mesh
  93288. */
  93289. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  93290. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  93291. };
  93292. /**
  93293. * Extracts the vertexData from the geometry
  93294. * @param geometry the geometry from which to extract the VertexData
  93295. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  93296. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  93297. * @returns the object VertexData associated to the passed mesh
  93298. */
  93299. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  93300. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  93301. };
  93302. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  93303. var result = new VertexData();
  93304. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  93305. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  93306. }
  93307. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  93308. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  93309. }
  93310. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  93311. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  93312. }
  93313. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  93314. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  93315. }
  93316. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  93317. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  93318. }
  93319. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  93320. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  93321. }
  93322. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  93323. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  93324. }
  93325. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  93326. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  93327. }
  93328. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  93329. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  93330. }
  93331. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  93332. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  93333. }
  93334. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  93335. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  93336. }
  93337. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  93338. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  93339. }
  93340. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  93341. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  93342. }
  93343. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  93344. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  93345. }
  93346. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  93347. return result;
  93348. };
  93349. /**
  93350. * Creates the VertexData for a Ribbon
  93351. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  93352. * * pathArray array of paths, each of which an array of successive Vector3
  93353. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  93354. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  93355. * * 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
  93356. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93357. * * 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)
  93358. * * 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)
  93359. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  93360. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  93361. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  93362. * @returns the VertexData of the ribbon
  93363. */
  93364. VertexData.CreateRibbon = function (options) {
  93365. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  93366. };
  93367. /**
  93368. * Creates the VertexData for a box
  93369. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93370. * * size sets the width, height and depth of the box to the value of size, optional default 1
  93371. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  93372. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  93373. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  93374. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  93375. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  93376. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93377. * * 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)
  93378. * * 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)
  93379. * @returns the VertexData of the box
  93380. */
  93381. VertexData.CreateBox = function (options) {
  93382. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  93383. };
  93384. /**
  93385. * Creates the VertexData for an ellipsoid, defaults to a sphere
  93386. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93387. * * segments sets the number of horizontal strips optional, default 32
  93388. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  93389. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  93390. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  93391. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  93392. * * 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
  93393. * * 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
  93394. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93395. * * 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)
  93396. * * 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)
  93397. * @returns the VertexData of the ellipsoid
  93398. */
  93399. VertexData.CreateSphere = function (options) {
  93400. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  93401. };
  93402. /**
  93403. * Creates the VertexData for a cylinder, cone or prism
  93404. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93405. * * height sets the height (y direction) of the cylinder, optional, default 2
  93406. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  93407. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  93408. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  93409. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  93410. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  93411. * * 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
  93412. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93413. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93414. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  93415. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  93416. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93417. * * 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)
  93418. * * 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)
  93419. * @returns the VertexData of the cylinder, cone or prism
  93420. */
  93421. VertexData.CreateCylinder = function (options) {
  93422. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  93423. };
  93424. /**
  93425. * Creates the VertexData for a torus
  93426. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93427. * * diameter the diameter of the torus, optional default 1
  93428. * * thickness the diameter of the tube forming the torus, optional default 0.5
  93429. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  93430. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93431. * * 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)
  93432. * * 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)
  93433. * @returns the VertexData of the torus
  93434. */
  93435. VertexData.CreateTorus = function (options) {
  93436. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  93437. };
  93438. /**
  93439. * Creates the VertexData of the LineSystem
  93440. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  93441. * - lines an array of lines, each line being an array of successive Vector3
  93442. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  93443. * @returns the VertexData of the LineSystem
  93444. */
  93445. VertexData.CreateLineSystem = function (options) {
  93446. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  93447. };
  93448. /**
  93449. * Create the VertexData for a DashedLines
  93450. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  93451. * - points an array successive Vector3
  93452. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  93453. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  93454. * - dashNb the intended total number of dashes, optional, default 200
  93455. * @returns the VertexData for the DashedLines
  93456. */
  93457. VertexData.CreateDashedLines = function (options) {
  93458. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  93459. };
  93460. /**
  93461. * Creates the VertexData for a Ground
  93462. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  93463. * - width the width (x direction) of the ground, optional, default 1
  93464. * - height the height (z direction) of the ground, optional, default 1
  93465. * - subdivisions the number of subdivisions per side, optional, default 1
  93466. * @returns the VertexData of the Ground
  93467. */
  93468. VertexData.CreateGround = function (options) {
  93469. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  93470. };
  93471. /**
  93472. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  93473. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  93474. * * xmin the ground minimum X coordinate, optional, default -1
  93475. * * zmin the ground minimum Z coordinate, optional, default -1
  93476. * * xmax the ground maximum X coordinate, optional, default 1
  93477. * * zmax the ground maximum Z coordinate, optional, default 1
  93478. * * 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}
  93479. * * 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}
  93480. * @returns the VertexData of the TiledGround
  93481. */
  93482. VertexData.CreateTiledGround = function (options) {
  93483. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  93484. };
  93485. /**
  93486. * Creates the VertexData of the Ground designed from a heightmap
  93487. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  93488. * * width the width (x direction) of the ground
  93489. * * height the height (z direction) of the ground
  93490. * * subdivisions the number of subdivisions per side
  93491. * * minHeight the minimum altitude on the ground, optional, default 0
  93492. * * maxHeight the maximum altitude on the ground, optional default 1
  93493. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  93494. * * buffer the array holding the image color data
  93495. * * bufferWidth the width of image
  93496. * * bufferHeight the height of image
  93497. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  93498. * @returns the VertexData of the Ground designed from a heightmap
  93499. */
  93500. VertexData.CreateGroundFromHeightMap = function (options) {
  93501. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  93502. };
  93503. /**
  93504. * Creates the VertexData for a Plane
  93505. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  93506. * * size sets the width and height of the plane to the value of size, optional default 1
  93507. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  93508. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  93509. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93510. * * 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)
  93511. * * 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)
  93512. * @returns the VertexData of the box
  93513. */
  93514. VertexData.CreatePlane = function (options) {
  93515. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  93516. };
  93517. /**
  93518. * Creates the VertexData of the Disc or regular Polygon
  93519. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  93520. * * radius the radius of the disc, optional default 0.5
  93521. * * tessellation the number of polygon sides, optional, default 64
  93522. * * 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
  93523. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93524. * * 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)
  93525. * * 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)
  93526. * @returns the VertexData of the box
  93527. */
  93528. VertexData.CreateDisc = function (options) {
  93529. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  93530. };
  93531. /**
  93532. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  93533. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  93534. * @param polygon a mesh built from polygonTriangulation.build()
  93535. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93536. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93537. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93538. * @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)
  93539. * @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)
  93540. * @returns the VertexData of the Polygon
  93541. */
  93542. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  93543. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  93544. };
  93545. /**
  93546. * Creates the VertexData of the IcoSphere
  93547. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  93548. * * radius the radius of the IcoSphere, optional default 1
  93549. * * radiusX allows stretching in the x direction, optional, default radius
  93550. * * radiusY allows stretching in the y direction, optional, default radius
  93551. * * radiusZ allows stretching in the z direction, optional, default radius
  93552. * * flat when true creates a flat shaded mesh, optional, default true
  93553. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  93554. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93555. * * 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)
  93556. * * 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)
  93557. * @returns the VertexData of the IcoSphere
  93558. */
  93559. VertexData.CreateIcoSphere = function (options) {
  93560. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  93561. };
  93562. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  93563. /**
  93564. * Creates the VertexData for a Polyhedron
  93565. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  93566. * * type provided types are:
  93567. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  93568. * * 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)
  93569. * * size the size of the IcoSphere, optional default 1
  93570. * * sizeX allows stretching in the x direction, optional, default size
  93571. * * sizeY allows stretching in the y direction, optional, default size
  93572. * * sizeZ allows stretching in the z direction, optional, default size
  93573. * * 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
  93574. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93575. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93576. * * flat when true creates a flat shaded mesh, optional, default true
  93577. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  93578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93579. * * 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)
  93580. * * 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)
  93581. * @returns the VertexData of the Polyhedron
  93582. */
  93583. VertexData.CreatePolyhedron = function (options) {
  93584. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  93585. };
  93586. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  93587. /**
  93588. * Creates the VertexData for a TorusKnot
  93589. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  93590. * * radius the radius of the torus knot, optional, default 2
  93591. * * tube the thickness of the tube, optional, default 0.5
  93592. * * radialSegments the number of sides on each tube segments, optional, default 32
  93593. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  93594. * * p the number of windings around the z axis, optional, default 2
  93595. * * q the number of windings around the x axis, optional, default 3
  93596. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93597. * * 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)
  93598. * * 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)
  93599. * @returns the VertexData of the Torus Knot
  93600. */
  93601. VertexData.CreateTorusKnot = function (options) {
  93602. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  93603. };
  93604. // Tools
  93605. /**
  93606. * Compute normals for given positions and indices
  93607. * @param positions an array of vertex positions, [...., x, y, z, ......]
  93608. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  93609. * @param normals an array of vertex normals, [...., x, y, z, ......]
  93610. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  93611. * * facetNormals : optional array of facet normals (vector3)
  93612. * * facetPositions : optional array of facet positions (vector3)
  93613. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  93614. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  93615. * * bInfo : optional bounding info, required for facetPartitioning computation
  93616. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  93617. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  93618. * * useRightHandedSystem: optional boolean to for right handed system computation
  93619. * * depthSort : optional boolean to enable the facet depth sort computation
  93620. * * distanceTo : optional Vector3 to compute the facet depth from this location
  93621. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  93622. */
  93623. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  93624. // temporary scalar variables
  93625. var index = 0; // facet index
  93626. var p1p2x = 0.0; // p1p2 vector x coordinate
  93627. var p1p2y = 0.0; // p1p2 vector y coordinate
  93628. var p1p2z = 0.0; // p1p2 vector z coordinate
  93629. var p3p2x = 0.0; // p3p2 vector x coordinate
  93630. var p3p2y = 0.0; // p3p2 vector y coordinate
  93631. var p3p2z = 0.0; // p3p2 vector z coordinate
  93632. var faceNormalx = 0.0; // facet normal x coordinate
  93633. var faceNormaly = 0.0; // facet normal y coordinate
  93634. var faceNormalz = 0.0; // facet normal z coordinate
  93635. var length = 0.0; // facet normal length before normalization
  93636. var v1x = 0; // vector1 x index in the positions array
  93637. var v1y = 0; // vector1 y index in the positions array
  93638. var v1z = 0; // vector1 z index in the positions array
  93639. var v2x = 0; // vector2 x index in the positions array
  93640. var v2y = 0; // vector2 y index in the positions array
  93641. var v2z = 0; // vector2 z index in the positions array
  93642. var v3x = 0; // vector3 x index in the positions array
  93643. var v3y = 0; // vector3 y index in the positions array
  93644. var v3z = 0; // vector3 z index in the positions array
  93645. var computeFacetNormals = false;
  93646. var computeFacetPositions = false;
  93647. var computeFacetPartitioning = false;
  93648. var computeDepthSort = false;
  93649. var faceNormalSign = 1;
  93650. var ratio = 0;
  93651. var distanceTo = null;
  93652. if (options) {
  93653. computeFacetNormals = (options.facetNormals) ? true : false;
  93654. computeFacetPositions = (options.facetPositions) ? true : false;
  93655. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  93656. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  93657. ratio = options.ratio || 0;
  93658. computeDepthSort = (options.depthSort) ? true : false;
  93659. distanceTo = (options.distanceTo);
  93660. if (computeDepthSort) {
  93661. if (distanceTo === undefined) {
  93662. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  93663. }
  93664. var depthSortedFacets = options.depthSortedFacets;
  93665. }
  93666. }
  93667. // facetPartitioning reinit if needed
  93668. var xSubRatio = 0;
  93669. var ySubRatio = 0;
  93670. var zSubRatio = 0;
  93671. var subSq = 0;
  93672. if (computeFacetPartitioning && options && options.bbSize) {
  93673. var ox = 0; // X partitioning index for facet position
  93674. var oy = 0; // Y partinioning index for facet position
  93675. var oz = 0; // Z partinioning index for facet position
  93676. var b1x = 0; // X partitioning index for facet v1 vertex
  93677. var b1y = 0; // Y partitioning index for facet v1 vertex
  93678. var b1z = 0; // z partitioning index for facet v1 vertex
  93679. var b2x = 0; // X partitioning index for facet v2 vertex
  93680. var b2y = 0; // Y partitioning index for facet v2 vertex
  93681. var b2z = 0; // Z partitioning index for facet v2 vertex
  93682. var b3x = 0; // X partitioning index for facet v3 vertex
  93683. var b3y = 0; // Y partitioning index for facet v3 vertex
  93684. var b3z = 0; // Z partitioning index for facet v3 vertex
  93685. var block_idx_o = 0; // facet barycenter block index
  93686. var block_idx_v1 = 0; // v1 vertex block index
  93687. var block_idx_v2 = 0; // v2 vertex block index
  93688. var block_idx_v3 = 0; // v3 vertex block index
  93689. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  93690. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  93691. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  93692. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  93693. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  93694. subSq = options.subDiv.max * options.subDiv.max;
  93695. options.facetPartitioning.length = 0;
  93696. }
  93697. // reset the normals
  93698. for (index = 0; index < positions.length; index++) {
  93699. normals[index] = 0.0;
  93700. }
  93701. // Loop : 1 indice triplet = 1 facet
  93702. var nbFaces = (indices.length / 3) | 0;
  93703. for (index = 0; index < nbFaces; index++) {
  93704. // get the indexes of the coordinates of each vertex of the facet
  93705. v1x = indices[index * 3] * 3;
  93706. v1y = v1x + 1;
  93707. v1z = v1x + 2;
  93708. v2x = indices[index * 3 + 1] * 3;
  93709. v2y = v2x + 1;
  93710. v2z = v2x + 2;
  93711. v3x = indices[index * 3 + 2] * 3;
  93712. v3y = v3x + 1;
  93713. v3z = v3x + 2;
  93714. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  93715. p1p2y = positions[v1y] - positions[v2y];
  93716. p1p2z = positions[v1z] - positions[v2z];
  93717. p3p2x = positions[v3x] - positions[v2x];
  93718. p3p2y = positions[v3y] - positions[v2y];
  93719. p3p2z = positions[v3z] - positions[v2z];
  93720. // compute the face normal with the cross product
  93721. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  93722. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  93723. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  93724. // normalize this normal and store it in the array facetData
  93725. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  93726. length = (length === 0) ? 1.0 : length;
  93727. faceNormalx /= length;
  93728. faceNormaly /= length;
  93729. faceNormalz /= length;
  93730. if (computeFacetNormals && options) {
  93731. options.facetNormals[index].x = faceNormalx;
  93732. options.facetNormals[index].y = faceNormaly;
  93733. options.facetNormals[index].z = faceNormalz;
  93734. }
  93735. if (computeFacetPositions && options) {
  93736. // compute and the facet barycenter coordinates in the array facetPositions
  93737. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  93738. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  93739. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  93740. }
  93741. if (computeFacetPartitioning && options) {
  93742. // store the facet indexes in arrays in the main facetPartitioning array :
  93743. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  93744. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  93745. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  93746. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  93747. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  93748. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  93749. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  93750. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  93751. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  93752. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  93753. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  93754. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  93755. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  93756. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  93757. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  93758. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  93759. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  93760. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  93761. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  93762. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  93763. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  93764. // push each facet index in each block containing the vertex
  93765. options.facetPartitioning[block_idx_v1].push(index);
  93766. if (block_idx_v2 != block_idx_v1) {
  93767. options.facetPartitioning[block_idx_v2].push(index);
  93768. }
  93769. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  93770. options.facetPartitioning[block_idx_v3].push(index);
  93771. }
  93772. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  93773. options.facetPartitioning[block_idx_o].push(index);
  93774. }
  93775. }
  93776. if (computeDepthSort && options && options.facetPositions) {
  93777. var dsf = depthSortedFacets[index];
  93778. dsf.ind = index * 3;
  93779. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  93780. }
  93781. // compute the normals anyway
  93782. normals[v1x] += faceNormalx; // accumulate all the normals per face
  93783. normals[v1y] += faceNormaly;
  93784. normals[v1z] += faceNormalz;
  93785. normals[v2x] += faceNormalx;
  93786. normals[v2y] += faceNormaly;
  93787. normals[v2z] += faceNormalz;
  93788. normals[v3x] += faceNormalx;
  93789. normals[v3y] += faceNormaly;
  93790. normals[v3z] += faceNormalz;
  93791. }
  93792. // last normalization of each normal
  93793. for (index = 0; index < normals.length / 3; index++) {
  93794. faceNormalx = normals[index * 3];
  93795. faceNormaly = normals[index * 3 + 1];
  93796. faceNormalz = normals[index * 3 + 2];
  93797. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  93798. length = (length === 0) ? 1.0 : length;
  93799. faceNormalx /= length;
  93800. faceNormaly /= length;
  93801. faceNormalz /= length;
  93802. normals[index * 3] = faceNormalx;
  93803. normals[index * 3 + 1] = faceNormaly;
  93804. normals[index * 3 + 2] = faceNormalz;
  93805. }
  93806. };
  93807. /** @hidden */
  93808. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  93809. var li = indices.length;
  93810. var ln = normals.length;
  93811. var i;
  93812. var n;
  93813. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  93814. switch (sideOrientation) {
  93815. case VertexData.FRONTSIDE:
  93816. // nothing changed
  93817. break;
  93818. case VertexData.BACKSIDE:
  93819. var tmp;
  93820. // indices
  93821. for (i = 0; i < li; i += 3) {
  93822. tmp = indices[i];
  93823. indices[i] = indices[i + 2];
  93824. indices[i + 2] = tmp;
  93825. }
  93826. // normals
  93827. for (n = 0; n < ln; n++) {
  93828. normals[n] = -normals[n];
  93829. }
  93830. break;
  93831. case VertexData.DOUBLESIDE:
  93832. // positions
  93833. var lp = positions.length;
  93834. var l = lp / 3;
  93835. for (var p = 0; p < lp; p++) {
  93836. positions[lp + p] = positions[p];
  93837. }
  93838. // indices
  93839. for (i = 0; i < li; i += 3) {
  93840. indices[i + li] = indices[i + 2] + l;
  93841. indices[i + 1 + li] = indices[i + 1] + l;
  93842. indices[i + 2 + li] = indices[i] + l;
  93843. }
  93844. // normals
  93845. for (n = 0; n < ln; n++) {
  93846. normals[ln + n] = -normals[n];
  93847. }
  93848. // uvs
  93849. var lu = uvs.length;
  93850. var u = 0;
  93851. for (u = 0; u < lu; u++) {
  93852. uvs[u + lu] = uvs[u];
  93853. }
  93854. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  93855. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  93856. u = 0;
  93857. for (i = 0; i < lu / 2; i++) {
  93858. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  93859. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  93860. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  93861. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  93862. u += 2;
  93863. }
  93864. break;
  93865. }
  93866. };
  93867. /**
  93868. * Applies VertexData created from the imported parameters to the geometry
  93869. * @param parsedVertexData the parsed data from an imported file
  93870. * @param geometry the geometry to apply the VertexData to
  93871. */
  93872. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  93873. var vertexData = new VertexData();
  93874. // positions
  93875. var positions = parsedVertexData.positions;
  93876. if (positions) {
  93877. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  93878. }
  93879. // normals
  93880. var normals = parsedVertexData.normals;
  93881. if (normals) {
  93882. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  93883. }
  93884. // tangents
  93885. var tangents = parsedVertexData.tangents;
  93886. if (tangents) {
  93887. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  93888. }
  93889. // uvs
  93890. var uvs = parsedVertexData.uvs;
  93891. if (uvs) {
  93892. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  93893. }
  93894. // uv2s
  93895. var uv2s = parsedVertexData.uv2s;
  93896. if (uv2s) {
  93897. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  93898. }
  93899. // uv3s
  93900. var uv3s = parsedVertexData.uv3s;
  93901. if (uv3s) {
  93902. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  93903. }
  93904. // uv4s
  93905. var uv4s = parsedVertexData.uv4s;
  93906. if (uv4s) {
  93907. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  93908. }
  93909. // uv5s
  93910. var uv5s = parsedVertexData.uv5s;
  93911. if (uv5s) {
  93912. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  93913. }
  93914. // uv6s
  93915. var uv6s = parsedVertexData.uv6s;
  93916. if (uv6s) {
  93917. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  93918. }
  93919. // colors
  93920. var colors = parsedVertexData.colors;
  93921. if (colors) {
  93922. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  93923. }
  93924. // matricesIndices
  93925. var matricesIndices = parsedVertexData.matricesIndices;
  93926. if (matricesIndices) {
  93927. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  93928. }
  93929. // matricesWeights
  93930. var matricesWeights = parsedVertexData.matricesWeights;
  93931. if (matricesWeights) {
  93932. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  93933. }
  93934. // indices
  93935. var indices = parsedVertexData.indices;
  93936. if (indices) {
  93937. vertexData.indices = indices;
  93938. }
  93939. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  93940. };
  93941. /**
  93942. * Mesh side orientation : usually the external or front surface
  93943. */
  93944. VertexData.FRONTSIDE = 0;
  93945. /**
  93946. * Mesh side orientation : usually the internal or back surface
  93947. */
  93948. VertexData.BACKSIDE = 1;
  93949. /**
  93950. * Mesh side orientation : both internal and external or front and back surfaces
  93951. */
  93952. VertexData.DOUBLESIDE = 2;
  93953. /**
  93954. * Mesh side orientation : by default, `FRONTSIDE`
  93955. */
  93956. VertexData.DEFAULTSIDE = 0;
  93957. return VertexData;
  93958. }());
  93959. /***/ }),
  93960. /***/ "./Meshes/meshBuilder.ts":
  93961. /*!*******************************!*\
  93962. !*** ./Meshes/meshBuilder.ts ***!
  93963. \*******************************/
  93964. /*! exports provided: MeshBuilder */
  93965. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93966. "use strict";
  93967. __webpack_require__.r(__webpack_exports__);
  93968. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  93969. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  93970. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  93971. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  93972. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  93973. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  93974. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  93975. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  93976. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  93977. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  93978. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  93979. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  93980. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  93981. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  93982. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  93983. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  93984. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  93985. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  93986. /**
  93987. * Class containing static functions to help procedurally build meshes
  93988. */
  93989. var MeshBuilder = /** @class */ (function () {
  93990. function MeshBuilder() {
  93991. }
  93992. /**
  93993. * Creates a box mesh
  93994. * * The parameter `size` sets the size (float) of each box side (default 1)
  93995. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  93996. * * 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)
  93997. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  93998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93999. * * 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
  94000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94001. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  94002. * @param name defines the name of the mesh
  94003. * @param options defines the options used to create the mesh
  94004. * @param scene defines the hosting scene
  94005. * @returns the box mesh
  94006. */
  94007. MeshBuilder.CreateBox = function (name, options, scene) {
  94008. if (scene === void 0) { scene = null; }
  94009. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  94010. };
  94011. /**
  94012. * Creates a sphere mesh
  94013. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  94014. * * 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`)
  94015. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  94016. * * 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
  94017. * * 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)
  94018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94019. * * 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
  94020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94021. * @param name defines the name of the mesh
  94022. * @param options defines the options used to create the mesh
  94023. * @param scene defines the hosting scene
  94024. * @returns the sphere mesh
  94025. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  94026. */
  94027. MeshBuilder.CreateSphere = function (name, options, scene) {
  94028. if (scene === void 0) { scene = null; }
  94029. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  94030. };
  94031. /**
  94032. * Creates a plane polygonal mesh. By default, this is a disc
  94033. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  94034. * * 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
  94035. * * 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
  94036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94037. * * 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
  94038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94039. * @param name defines the name of the mesh
  94040. * @param options defines the options used to create the mesh
  94041. * @param scene defines the hosting scene
  94042. * @returns the plane polygonal mesh
  94043. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  94044. */
  94045. MeshBuilder.CreateDisc = function (name, options, scene) {
  94046. if (scene === void 0) { scene = null; }
  94047. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  94048. };
  94049. /**
  94050. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  94051. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  94052. * * 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`)
  94053. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  94054. * * 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
  94055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94056. * * 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
  94057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94058. * @param name defines the name of the mesh
  94059. * @param options defines the options used to create the mesh
  94060. * @param scene defines the hosting scene
  94061. * @returns the icosahedron mesh
  94062. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  94063. */
  94064. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  94065. if (scene === void 0) { scene = null; }
  94066. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  94067. };
  94068. /**
  94069. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  94070. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  94071. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  94072. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  94073. * * 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
  94074. * * 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
  94075. * * 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
  94076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94077. * * 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
  94078. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  94079. * * 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
  94080. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  94081. * * 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
  94082. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  94083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94084. * @param name defines the name of the mesh
  94085. * @param options defines the options used to create the mesh
  94086. * @param scene defines the hosting scene
  94087. * @returns the ribbon mesh
  94088. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  94089. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  94090. */
  94091. MeshBuilder.CreateRibbon = function (name, options, scene) {
  94092. if (scene === void 0) { scene = null; }
  94093. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  94094. };
  94095. /**
  94096. * Creates a cylinder or a cone mesh
  94097. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  94098. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  94099. * * 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.
  94100. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  94101. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  94102. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  94103. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  94104. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  94105. * * 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).
  94106. * * 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
  94107. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  94108. * * 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
  94109. * * 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.
  94110. * * If `enclose` is false, a ring surface is one element.
  94111. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  94112. * * 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
  94113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94114. * * 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
  94115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94116. * @param name defines the name of the mesh
  94117. * @param options defines the options used to create the mesh
  94118. * @param scene defines the hosting scene
  94119. * @returns the cylinder mesh
  94120. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  94121. */
  94122. MeshBuilder.CreateCylinder = function (name, options, scene) {
  94123. if (scene === void 0) { scene = null; }
  94124. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  94125. };
  94126. /**
  94127. * Creates a torus mesh
  94128. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  94129. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  94130. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  94131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94132. * * 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
  94133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94134. * @param name defines the name of the mesh
  94135. * @param options defines the options used to create the mesh
  94136. * @param scene defines the hosting scene
  94137. * @returns the torus mesh
  94138. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  94139. */
  94140. MeshBuilder.CreateTorus = function (name, options, scene) {
  94141. if (scene === void 0) { scene = null; }
  94142. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  94143. };
  94144. /**
  94145. * Creates a torus knot mesh
  94146. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  94147. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  94148. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  94149. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  94150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94151. * * 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
  94152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94153. * @param name defines the name of the mesh
  94154. * @param options defines the options used to create the mesh
  94155. * @param scene defines the hosting scene
  94156. * @returns the torus knot mesh
  94157. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  94158. */
  94159. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  94160. if (scene === void 0) { scene = null; }
  94161. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  94162. };
  94163. /**
  94164. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  94165. * * 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
  94166. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  94167. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  94168. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  94169. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  94170. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  94171. * * 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
  94172. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  94173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  94175. * @param name defines the name of the new line system
  94176. * @param options defines the options used to create the line system
  94177. * @param scene defines the hosting scene
  94178. * @returns a new line system mesh
  94179. */
  94180. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  94181. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  94182. };
  94183. /**
  94184. * Creates a line mesh
  94185. * 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
  94186. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  94187. * * The parameter `points` is an array successive Vector3
  94188. * * 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
  94189. * * The optional parameter `colors` is an array of successive Color4, one per line point
  94190. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  94191. * * When updating an instance, remember that only point positions can change, not the number of points
  94192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94193. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  94194. * @param name defines the name of the new line system
  94195. * @param options defines the options used to create the line system
  94196. * @param scene defines the hosting scene
  94197. * @returns a new line mesh
  94198. */
  94199. MeshBuilder.CreateLines = function (name, options, scene) {
  94200. if (scene === void 0) { scene = null; }
  94201. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  94202. };
  94203. /**
  94204. * Creates a dashed line mesh
  94205. * * 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
  94206. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  94207. * * The parameter `points` is an array successive Vector3
  94208. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  94209. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  94210. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  94211. * * 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
  94212. * * When updating an instance, remember that only point positions can change, not the number of points
  94213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94214. * @param name defines the name of the mesh
  94215. * @param options defines the options used to create the mesh
  94216. * @param scene defines the hosting scene
  94217. * @returns the dashed line mesh
  94218. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  94219. */
  94220. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  94221. if (scene === void 0) { scene = null; }
  94222. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  94223. };
  94224. /**
  94225. * 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.
  94226. * * 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.
  94227. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  94228. * * 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.
  94229. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  94230. * * 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
  94231. * * 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
  94232. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  94233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94234. * * 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
  94235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  94236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94237. * @param name defines the name of the mesh
  94238. * @param options defines the options used to create the mesh
  94239. * @param scene defines the hosting scene
  94240. * @returns the extruded shape mesh
  94241. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  94242. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  94243. */
  94244. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  94245. if (scene === void 0) { scene = null; }
  94246. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  94247. };
  94248. /**
  94249. * Creates an custom extruded shape mesh.
  94250. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  94251. * * 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.
  94252. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  94253. * * 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
  94254. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  94255. * * 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
  94256. * * It must returns a float value that will be the scale value applied to the shape on each path point
  94257. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  94258. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  94259. * * 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
  94260. * * 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
  94261. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  94262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94263. * * 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
  94264. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  94265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94266. * @param name defines the name of the mesh
  94267. * @param options defines the options used to create the mesh
  94268. * @param scene defines the hosting scene
  94269. * @returns the custom extruded shape mesh
  94270. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  94271. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  94272. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  94273. */
  94274. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  94275. if (scene === void 0) { scene = null; }
  94276. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  94277. };
  94278. /**
  94279. * Creates lathe mesh.
  94280. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  94281. * * 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
  94282. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  94283. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  94284. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  94285. * * 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
  94286. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  94287. * * 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
  94288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94289. * * 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
  94290. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  94291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94292. * @param name defines the name of the mesh
  94293. * @param options defines the options used to create the mesh
  94294. * @param scene defines the hosting scene
  94295. * @returns the lathe mesh
  94296. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  94297. */
  94298. MeshBuilder.CreateLathe = function (name, options, scene) {
  94299. if (scene === void 0) { scene = null; }
  94300. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  94301. };
  94302. /**
  94303. * Creates a plane mesh
  94304. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  94305. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  94306. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  94307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94308. * * 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
  94309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94310. * @param name defines the name of the mesh
  94311. * @param options defines the options used to create the mesh
  94312. * @param scene defines the hosting scene
  94313. * @returns the plane mesh
  94314. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  94315. */
  94316. MeshBuilder.CreatePlane = function (name, options, scene) {
  94317. if (scene === void 0) { scene = null; }
  94318. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  94319. };
  94320. /**
  94321. * Creates a ground mesh
  94322. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  94323. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  94324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94325. * @param name defines the name of the mesh
  94326. * @param options defines the options used to create the mesh
  94327. * @param scene defines the hosting scene
  94328. * @returns the ground mesh
  94329. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  94330. */
  94331. MeshBuilder.CreateGround = function (name, options, scene) {
  94332. if (scene === void 0) { scene = null; }
  94333. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  94334. };
  94335. /**
  94336. * Creates a tiled ground mesh
  94337. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  94338. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  94339. * * 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
  94340. * * 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
  94341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94342. * @param name defines the name of the mesh
  94343. * @param options defines the options used to create the mesh
  94344. * @param scene defines the hosting scene
  94345. * @returns the tiled ground mesh
  94346. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  94347. */
  94348. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  94349. if (scene === void 0) { scene = null; }
  94350. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  94351. };
  94352. /**
  94353. * Creates a ground mesh from a height map
  94354. * * The parameter `url` sets the URL of the height map image resource.
  94355. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  94356. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  94357. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  94358. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  94359. * * 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.
  94360. * * 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).
  94361. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  94362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94363. * @param name defines the name of the mesh
  94364. * @param url defines the url to the height map
  94365. * @param options defines the options used to create the mesh
  94366. * @param scene defines the hosting scene
  94367. * @returns the ground mesh
  94368. * @see https://doc.babylonjs.com/babylon101/height_map
  94369. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  94370. */
  94371. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  94372. if (scene === void 0) { scene = null; }
  94373. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  94374. };
  94375. /**
  94376. * Creates a polygon mesh
  94377. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  94378. * * 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
  94379. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94381. * * 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)
  94382. * * Remember you can only change the shape positions, not their number when updating a polygon
  94383. * @param name defines the name of the mesh
  94384. * @param options defines the options used to create the mesh
  94385. * @param scene defines the hosting scene
  94386. * @param earcutInjection can be used to inject your own earcut reference
  94387. * @returns the polygon mesh
  94388. */
  94389. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  94390. if (scene === void 0) { scene = null; }
  94391. if (earcutInjection === void 0) { earcutInjection = earcut; }
  94392. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  94393. };
  94394. /**
  94395. * Creates an extruded polygon mesh, with depth in the Y direction.
  94396. * * 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)
  94397. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  94398. * @param name defines the name of the mesh
  94399. * @param options defines the options used to create the mesh
  94400. * @param scene defines the hosting scene
  94401. * @param earcutInjection can be used to inject your own earcut reference
  94402. * @returns the polygon mesh
  94403. */
  94404. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  94405. if (scene === void 0) { scene = null; }
  94406. if (earcutInjection === void 0) { earcutInjection = earcut; }
  94407. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  94408. };
  94409. /**
  94410. * Creates a tube mesh.
  94411. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  94412. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  94413. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  94414. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  94415. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  94416. * * 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)
  94417. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  94418. * * 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
  94419. * * 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
  94420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94421. * * 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
  94422. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  94423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94424. * @param name defines the name of the mesh
  94425. * @param options defines the options used to create the mesh
  94426. * @param scene defines the hosting scene
  94427. * @returns the tube mesh
  94428. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  94429. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  94430. */
  94431. MeshBuilder.CreateTube = function (name, options, scene) {
  94432. if (scene === void 0) { scene = null; }
  94433. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  94434. };
  94435. /**
  94436. * Creates a polyhedron mesh
  94437. * * 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
  94438. * * The parameter `size` (positive float, default 1) sets the polygon size
  94439. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  94440. * * 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`
  94441. * * 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
  94442. * * 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)`)
  94443. * * 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
  94444. * * 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
  94445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94446. * * 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
  94447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94448. * @param name defines the name of the mesh
  94449. * @param options defines the options used to create the mesh
  94450. * @param scene defines the hosting scene
  94451. * @returns the polyhedron mesh
  94452. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  94453. */
  94454. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  94455. if (scene === void 0) { scene = null; }
  94456. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  94457. };
  94458. /**
  94459. * Creates a decal mesh.
  94460. * 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
  94461. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  94462. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  94463. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  94464. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  94465. * @param name defines the name of the mesh
  94466. * @param sourceMesh defines the mesh where the decal must be applied
  94467. * @param options defines the options used to create the mesh
  94468. * @param scene defines the hosting scene
  94469. * @returns the decal mesh
  94470. * @see https://doc.babylonjs.com/how_to/decals
  94471. */
  94472. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  94473. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  94474. };
  94475. return MeshBuilder;
  94476. }());
  94477. /***/ }),
  94478. /***/ "./Meshes/meshLODLevel.ts":
  94479. /*!********************************!*\
  94480. !*** ./Meshes/meshLODLevel.ts ***!
  94481. \********************************/
  94482. /*! exports provided: MeshLODLevel */
  94483. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94484. "use strict";
  94485. __webpack_require__.r(__webpack_exports__);
  94486. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  94487. /**
  94488. * Class used to represent a specific level of detail of a mesh
  94489. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  94490. */
  94491. var MeshLODLevel = /** @class */ (function () {
  94492. /**
  94493. * Creates a new LOD level
  94494. * @param distance defines the distance where this level should star being displayed
  94495. * @param mesh defines the mesh to use to render this level
  94496. */
  94497. function MeshLODLevel(
  94498. /** Defines the distance where this level should star being displayed */
  94499. distance,
  94500. /** Defines the mesh to use to render this level */
  94501. mesh) {
  94502. this.distance = distance;
  94503. this.mesh = mesh;
  94504. }
  94505. return MeshLODLevel;
  94506. }());
  94507. /***/ }),
  94508. /***/ "./Meshes/meshSimplification.ts":
  94509. /*!**************************************!*\
  94510. !*** ./Meshes/meshSimplification.ts ***!
  94511. \**************************************/
  94512. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  94513. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94514. "use strict";
  94515. __webpack_require__.r(__webpack_exports__);
  94516. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  94517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  94518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  94519. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  94520. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  94521. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  94522. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  94523. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  94524. /**
  94525. * Class used to specify simplification options
  94526. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  94527. */
  94528. var SimplificationSettings = /** @class */ (function () {
  94529. /**
  94530. * Creates a SimplificationSettings
  94531. * @param quality expected quality
  94532. * @param distance distance when this optimized version should be used
  94533. * @param optimizeMesh already optimized mesh
  94534. */
  94535. function SimplificationSettings(
  94536. /** expected quality */
  94537. quality,
  94538. /** distance when this optimized version should be used */
  94539. distance,
  94540. /** already optimized mesh */
  94541. optimizeMesh) {
  94542. this.quality = quality;
  94543. this.distance = distance;
  94544. this.optimizeMesh = optimizeMesh;
  94545. }
  94546. return SimplificationSettings;
  94547. }());
  94548. /**
  94549. * Queue used to order the simplification tasks
  94550. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  94551. */
  94552. var SimplificationQueue = /** @class */ (function () {
  94553. /**
  94554. * Creates a new queue
  94555. */
  94556. function SimplificationQueue() {
  94557. this.running = false;
  94558. this._simplificationArray = [];
  94559. }
  94560. /**
  94561. * Adds a new simplification task
  94562. * @param task defines a task to add
  94563. */
  94564. SimplificationQueue.prototype.addTask = function (task) {
  94565. this._simplificationArray.push(task);
  94566. };
  94567. /**
  94568. * Execute next task
  94569. */
  94570. SimplificationQueue.prototype.executeNext = function () {
  94571. var task = this._simplificationArray.pop();
  94572. if (task) {
  94573. this.running = true;
  94574. this.runSimplification(task);
  94575. }
  94576. else {
  94577. this.running = false;
  94578. }
  94579. };
  94580. /**
  94581. * Execute a simplification task
  94582. * @param task defines the task to run
  94583. */
  94584. SimplificationQueue.prototype.runSimplification = function (task) {
  94585. var _this = this;
  94586. if (task.parallelProcessing) {
  94587. //parallel simplifier
  94588. task.settings.forEach(function (setting) {
  94589. var simplifier = _this.getSimplifier(task);
  94590. simplifier.simplify(setting, function (newMesh) {
  94591. task.mesh.addLODLevel(setting.distance, newMesh);
  94592. newMesh.isVisible = true;
  94593. //check if it is the last
  94594. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  94595. //all done, run the success callback.
  94596. task.successCallback();
  94597. }
  94598. _this.executeNext();
  94599. });
  94600. });
  94601. }
  94602. else {
  94603. //single simplifier.
  94604. var simplifier = this.getSimplifier(task);
  94605. var runDecimation = function (setting, callback) {
  94606. simplifier.simplify(setting, function (newMesh) {
  94607. task.mesh.addLODLevel(setting.distance, newMesh);
  94608. newMesh.isVisible = true;
  94609. //run the next quality level
  94610. callback();
  94611. });
  94612. };
  94613. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  94614. runDecimation(task.settings[loop.index], function () {
  94615. loop.executeNext();
  94616. });
  94617. }, function () {
  94618. //execution ended, run the success callback.
  94619. if (task.successCallback) {
  94620. task.successCallback();
  94621. }
  94622. _this.executeNext();
  94623. });
  94624. }
  94625. };
  94626. SimplificationQueue.prototype.getSimplifier = function (task) {
  94627. switch (task.simplificationType) {
  94628. case SimplificationType.QUADRATIC:
  94629. default:
  94630. return new QuadraticErrorSimplification(task.mesh);
  94631. }
  94632. };
  94633. return SimplificationQueue;
  94634. }());
  94635. /**
  94636. * The implemented types of simplification
  94637. * At the moment only Quadratic Error Decimation is implemented
  94638. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  94639. */
  94640. var SimplificationType;
  94641. (function (SimplificationType) {
  94642. /** Quadratic error decimation */
  94643. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  94644. })(SimplificationType || (SimplificationType = {}));
  94645. var DecimationTriangle = /** @class */ (function () {
  94646. function DecimationTriangle(vertices) {
  94647. this.vertices = vertices;
  94648. this.error = new Array(4);
  94649. this.deleted = false;
  94650. this.isDirty = false;
  94651. this.deletePending = false;
  94652. this.borderFactor = 0;
  94653. }
  94654. return DecimationTriangle;
  94655. }());
  94656. var DecimationVertex = /** @class */ (function () {
  94657. function DecimationVertex(position, id) {
  94658. this.position = position;
  94659. this.id = id;
  94660. this.isBorder = true;
  94661. this.q = new QuadraticMatrix();
  94662. this.triangleCount = 0;
  94663. this.triangleStart = 0;
  94664. this.originalOffsets = [];
  94665. }
  94666. DecimationVertex.prototype.updatePosition = function (newPosition) {
  94667. this.position.copyFrom(newPosition);
  94668. };
  94669. return DecimationVertex;
  94670. }());
  94671. var QuadraticMatrix = /** @class */ (function () {
  94672. function QuadraticMatrix(data) {
  94673. this.data = new Array(10);
  94674. for (var i = 0; i < 10; ++i) {
  94675. if (data && data[i]) {
  94676. this.data[i] = data[i];
  94677. }
  94678. else {
  94679. this.data[i] = 0;
  94680. }
  94681. }
  94682. }
  94683. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  94684. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  94685. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  94686. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  94687. return det;
  94688. };
  94689. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  94690. for (var i = 0; i < 10; ++i) {
  94691. this.data[i] += matrix.data[i];
  94692. }
  94693. };
  94694. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  94695. for (var i = 0; i < 10; ++i) {
  94696. this.data[i] += data[i];
  94697. }
  94698. };
  94699. QuadraticMatrix.prototype.add = function (matrix) {
  94700. var m = new QuadraticMatrix();
  94701. for (var i = 0; i < 10; ++i) {
  94702. m.data[i] = this.data[i] + matrix.data[i];
  94703. }
  94704. return m;
  94705. };
  94706. QuadraticMatrix.FromData = function (a, b, c, d) {
  94707. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  94708. };
  94709. //returning an array to avoid garbage collection
  94710. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  94711. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  94712. };
  94713. return QuadraticMatrix;
  94714. }());
  94715. var Reference = /** @class */ (function () {
  94716. function Reference(vertexId, triangleId) {
  94717. this.vertexId = vertexId;
  94718. this.triangleId = triangleId;
  94719. }
  94720. return Reference;
  94721. }());
  94722. /**
  94723. * An implementation of the Quadratic Error simplification algorithm.
  94724. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  94725. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  94726. * @author RaananW
  94727. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  94728. */
  94729. var QuadraticErrorSimplification = /** @class */ (function () {
  94730. function QuadraticErrorSimplification(_mesh) {
  94731. this._mesh = _mesh;
  94732. this.syncIterations = 5000;
  94733. this.aggressiveness = 7;
  94734. this.decimationIterations = 100;
  94735. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  94736. }
  94737. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  94738. var _this = this;
  94739. this.initDecimatedMesh();
  94740. //iterating through the submeshes array, one after the other.
  94741. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  94742. _this.initWithMesh(loop.index, function () {
  94743. _this.runDecimation(settings, loop.index, function () {
  94744. loop.executeNext();
  94745. });
  94746. }, settings.optimizeMesh);
  94747. }, function () {
  94748. setTimeout(function () {
  94749. successCallback(_this._reconstructedMesh);
  94750. }, 0);
  94751. });
  94752. };
  94753. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  94754. var _this = this;
  94755. var targetCount = ~~(this.triangles.length * settings.quality);
  94756. var deletedTriangles = 0;
  94757. var triangleCount = this.triangles.length;
  94758. var iterationFunction = function (iteration, callback) {
  94759. setTimeout(function () {
  94760. if (iteration % 5 === 0) {
  94761. _this.updateMesh(iteration === 0);
  94762. }
  94763. for (var i = 0; i < _this.triangles.length; ++i) {
  94764. _this.triangles[i].isDirty = false;
  94765. }
  94766. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  94767. var trianglesIterator = function (i) {
  94768. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  94769. var t = _this.triangles[tIdx];
  94770. if (!t) {
  94771. return;
  94772. }
  94773. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  94774. return;
  94775. }
  94776. for (var j = 0; j < 3; ++j) {
  94777. if (t.error[j] < threshold) {
  94778. var deleted0 = [];
  94779. var deleted1 = [];
  94780. var v0 = t.vertices[j];
  94781. var v1 = t.vertices[(j + 1) % 3];
  94782. if (v0.isBorder || v1.isBorder) {
  94783. continue;
  94784. }
  94785. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  94786. // var n = Vector3.Zero();
  94787. // var uv = Vector2.Zero();
  94788. // var color = new Color4(0, 0, 0, 1);
  94789. _this.calculateError(v0, v1, p);
  94790. var delTr = new Array();
  94791. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  94792. continue;
  94793. }
  94794. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  94795. continue;
  94796. }
  94797. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  94798. continue;
  94799. }
  94800. var uniqueArray = new Array();
  94801. delTr.forEach(function (deletedT) {
  94802. if (uniqueArray.indexOf(deletedT) === -1) {
  94803. deletedT.deletePending = true;
  94804. uniqueArray.push(deletedT);
  94805. }
  94806. });
  94807. if (uniqueArray.length % 2 !== 0) {
  94808. continue;
  94809. }
  94810. v0.q = v1.q.add(v0.q);
  94811. v0.updatePosition(p);
  94812. var tStart = _this.references.length;
  94813. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  94814. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  94815. var tCount = _this.references.length - tStart;
  94816. if (tCount <= v0.triangleCount) {
  94817. if (tCount) {
  94818. for (var c = 0; c < tCount; c++) {
  94819. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  94820. }
  94821. }
  94822. }
  94823. else {
  94824. v0.triangleStart = tStart;
  94825. }
  94826. v0.triangleCount = tCount;
  94827. break;
  94828. }
  94829. }
  94830. };
  94831. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  94832. }, 0);
  94833. };
  94834. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  94835. if (triangleCount - deletedTriangles <= targetCount) {
  94836. loop.breakLoop();
  94837. }
  94838. else {
  94839. iterationFunction(loop.index, function () {
  94840. loop.executeNext();
  94841. });
  94842. }
  94843. }, function () {
  94844. setTimeout(function () {
  94845. //reconstruct this part of the mesh
  94846. _this.reconstructMesh(submeshIndex);
  94847. successCallback();
  94848. }, 0);
  94849. });
  94850. };
  94851. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  94852. var _this = this;
  94853. this.vertices = [];
  94854. this.triangles = [];
  94855. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  94856. var indices = this._mesh.getIndices();
  94857. var submesh = this._mesh.subMeshes[submeshIndex];
  94858. var findInVertices = function (positionToSearch) {
  94859. if (optimizeMesh) {
  94860. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  94861. if (_this.vertices[ii].position.equals(positionToSearch)) {
  94862. return _this.vertices[ii];
  94863. }
  94864. }
  94865. }
  94866. return null;
  94867. };
  94868. var vertexReferences = [];
  94869. var vertexInit = function (i) {
  94870. if (!positionData) {
  94871. return;
  94872. }
  94873. var offset = i + submesh.verticesStart;
  94874. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  94875. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  94876. vertex.originalOffsets.push(offset);
  94877. if (vertex.id === _this.vertices.length) {
  94878. _this.vertices.push(vertex);
  94879. }
  94880. vertexReferences.push(vertex.id);
  94881. };
  94882. //var totalVertices = mesh.getTotalVertices();
  94883. var totalVertices = submesh.verticesCount;
  94884. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  94885. var indicesInit = function (i) {
  94886. if (!indices) {
  94887. return;
  94888. }
  94889. var offset = (submesh.indexStart / 3) + i;
  94890. var pos = (offset * 3);
  94891. var i0 = indices[pos + 0];
  94892. var i1 = indices[pos + 1];
  94893. var i2 = indices[pos + 2];
  94894. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  94895. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  94896. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  94897. var triangle = new DecimationTriangle([v0, v1, v2]);
  94898. triangle.originalOffset = pos;
  94899. _this.triangles.push(triangle);
  94900. };
  94901. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  94902. _this.init(callback);
  94903. });
  94904. });
  94905. };
  94906. QuadraticErrorSimplification.prototype.init = function (callback) {
  94907. var _this = this;
  94908. var triangleInit1 = function (i) {
  94909. var t = _this.triangles[i];
  94910. 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();
  94911. for (var j = 0; j < 3; j++) {
  94912. 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))));
  94913. }
  94914. };
  94915. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  94916. var triangleInit2 = function (i) {
  94917. var t = _this.triangles[i];
  94918. for (var j = 0; j < 3; ++j) {
  94919. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  94920. }
  94921. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  94922. };
  94923. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  94924. callback();
  94925. });
  94926. });
  94927. };
  94928. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  94929. var newTriangles = [];
  94930. var i;
  94931. for (i = 0; i < this.vertices.length; ++i) {
  94932. this.vertices[i].triangleCount = 0;
  94933. }
  94934. var t;
  94935. var j;
  94936. for (i = 0; i < this.triangles.length; ++i) {
  94937. if (!this.triangles[i].deleted) {
  94938. t = this.triangles[i];
  94939. for (j = 0; j < 3; ++j) {
  94940. t.vertices[j].triangleCount = 1;
  94941. }
  94942. newTriangles.push(t);
  94943. }
  94944. }
  94945. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  94946. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  94947. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  94948. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  94949. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  94950. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  94951. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  94952. var vertexCount = 0;
  94953. for (i = 0; i < this.vertices.length; ++i) {
  94954. var vertex = this.vertices[i];
  94955. vertex.id = vertexCount;
  94956. if (vertex.triangleCount) {
  94957. vertex.originalOffsets.forEach(function (originalOffset) {
  94958. if (!normalData) {
  94959. return;
  94960. }
  94961. newPositionData.push(vertex.position.x);
  94962. newPositionData.push(vertex.position.y);
  94963. newPositionData.push(vertex.position.z);
  94964. newNormalData.push(normalData[originalOffset * 3]);
  94965. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  94966. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  94967. if (uvs && uvs.length) {
  94968. newUVsData.push(uvs[(originalOffset * 2)]);
  94969. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  94970. }
  94971. if (colorsData && colorsData.length) {
  94972. newColorsData.push(colorsData[(originalOffset * 4)]);
  94973. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  94974. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  94975. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  94976. }
  94977. ++vertexCount;
  94978. });
  94979. }
  94980. }
  94981. var startingIndex = this._reconstructedMesh.getTotalIndices();
  94982. var startingVertex = this._reconstructedMesh.getTotalVertices();
  94983. var submeshesArray = this._reconstructedMesh.subMeshes;
  94984. this._reconstructedMesh.subMeshes = [];
  94985. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  94986. var originalIndices = this._mesh.getIndices();
  94987. for (i = 0; i < newTriangles.length; ++i) {
  94988. t = newTriangles[i]; //now get the new referencing point for each vertex
  94989. [0, 1, 2].forEach(function (idx) {
  94990. var id = originalIndices[t.originalOffset + idx];
  94991. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  94992. if (offset < 0) {
  94993. offset = 0;
  94994. }
  94995. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  94996. });
  94997. }
  94998. //overwriting the old vertex buffers and indices.
  94999. this._reconstructedMesh.setIndices(newIndicesArray);
  95000. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  95001. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  95002. if (newUVsData.length > 0) {
  95003. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  95004. }
  95005. if (newColorsData.length > 0) {
  95006. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  95007. }
  95008. //create submesh
  95009. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  95010. if (submeshIndex > 0) {
  95011. this._reconstructedMesh.subMeshes = [];
  95012. submeshesArray.forEach(function (submesh) {
  95013. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  95014. });
  95015. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  95016. }
  95017. };
  95018. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  95019. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  95020. this._reconstructedMesh.material = this._mesh.material;
  95021. this._reconstructedMesh.parent = this._mesh.parent;
  95022. this._reconstructedMesh.isVisible = false;
  95023. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  95024. };
  95025. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  95026. for (var i = 0; i < vertex1.triangleCount; ++i) {
  95027. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  95028. if (t.deleted) {
  95029. continue;
  95030. }
  95031. var s = this.references[vertex1.triangleStart + i].vertexId;
  95032. var v1 = t.vertices[(s + 1) % 3];
  95033. var v2 = t.vertices[(s + 2) % 3];
  95034. if ((v1 === vertex2 || v2 === vertex2)) {
  95035. deletedArray[i] = true;
  95036. delTr.push(t);
  95037. continue;
  95038. }
  95039. var d1 = v1.position.subtract(point);
  95040. d1 = d1.normalize();
  95041. var d2 = v2.position.subtract(point);
  95042. d2 = d2.normalize();
  95043. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  95044. return true;
  95045. }
  95046. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  95047. deletedArray[i] = false;
  95048. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  95049. return true;
  95050. }
  95051. }
  95052. return false;
  95053. };
  95054. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  95055. var newDeleted = deletedTriangles;
  95056. for (var i = 0; i < vertex.triangleCount; ++i) {
  95057. var ref = this.references[vertex.triangleStart + i];
  95058. var t = this.triangles[ref.triangleId];
  95059. if (t.deleted) {
  95060. continue;
  95061. }
  95062. if (deletedArray[i] && t.deletePending) {
  95063. t.deleted = true;
  95064. newDeleted++;
  95065. continue;
  95066. }
  95067. t.vertices[ref.vertexId] = origVertex;
  95068. t.isDirty = true;
  95069. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  95070. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  95071. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  95072. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  95073. this.references.push(ref);
  95074. }
  95075. return newDeleted;
  95076. };
  95077. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  95078. for (var i = 0; i < this.vertices.length; ++i) {
  95079. var vCount = [];
  95080. var vId = [];
  95081. var v = this.vertices[i];
  95082. var j;
  95083. for (j = 0; j < v.triangleCount; ++j) {
  95084. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  95085. for (var ii = 0; ii < 3; ii++) {
  95086. var ofs = 0;
  95087. var vv = triangle.vertices[ii];
  95088. while (ofs < vCount.length) {
  95089. if (vId[ofs] === vv.id) {
  95090. break;
  95091. }
  95092. ++ofs;
  95093. }
  95094. if (ofs === vCount.length) {
  95095. vCount.push(1);
  95096. vId.push(vv.id);
  95097. }
  95098. else {
  95099. vCount[ofs]++;
  95100. }
  95101. }
  95102. }
  95103. for (j = 0; j < vCount.length; ++j) {
  95104. if (vCount[j] === 1) {
  95105. this.vertices[vId[j]].isBorder = true;
  95106. }
  95107. else {
  95108. this.vertices[vId[j]].isBorder = false;
  95109. }
  95110. }
  95111. }
  95112. };
  95113. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  95114. if (identifyBorders === void 0) { identifyBorders = false; }
  95115. var i;
  95116. if (!identifyBorders) {
  95117. var newTrianglesVector = [];
  95118. for (i = 0; i < this.triangles.length; ++i) {
  95119. if (!this.triangles[i].deleted) {
  95120. newTrianglesVector.push(this.triangles[i]);
  95121. }
  95122. }
  95123. this.triangles = newTrianglesVector;
  95124. }
  95125. for (i = 0; i < this.vertices.length; ++i) {
  95126. this.vertices[i].triangleCount = 0;
  95127. this.vertices[i].triangleStart = 0;
  95128. }
  95129. var t;
  95130. var j;
  95131. var v;
  95132. for (i = 0; i < this.triangles.length; ++i) {
  95133. t = this.triangles[i];
  95134. for (j = 0; j < 3; ++j) {
  95135. v = t.vertices[j];
  95136. v.triangleCount++;
  95137. }
  95138. }
  95139. var tStart = 0;
  95140. for (i = 0; i < this.vertices.length; ++i) {
  95141. this.vertices[i].triangleStart = tStart;
  95142. tStart += this.vertices[i].triangleCount;
  95143. this.vertices[i].triangleCount = 0;
  95144. }
  95145. var newReferences = new Array(this.triangles.length * 3);
  95146. for (i = 0; i < this.triangles.length; ++i) {
  95147. t = this.triangles[i];
  95148. for (j = 0; j < 3; ++j) {
  95149. v = t.vertices[j];
  95150. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  95151. v.triangleCount++;
  95152. }
  95153. }
  95154. this.references = newReferences;
  95155. if (identifyBorders) {
  95156. this.identifyBorder();
  95157. }
  95158. };
  95159. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  95160. var x = point.x;
  95161. var y = point.y;
  95162. var z = point.z;
  95163. 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
  95164. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  95165. };
  95166. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  95167. var q = vertex1.q.add(vertex2.q);
  95168. var border = vertex1.isBorder && vertex2.isBorder;
  95169. var error = 0;
  95170. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  95171. if (qDet !== 0 && !border) {
  95172. if (!pointResult) {
  95173. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  95174. }
  95175. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  95176. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  95177. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  95178. error = this.vertexError(q, pointResult);
  95179. }
  95180. else {
  95181. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  95182. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  95183. var error1 = this.vertexError(q, vertex1.position);
  95184. var error2 = this.vertexError(q, vertex2.position);
  95185. var error3 = this.vertexError(q, p3);
  95186. error = Math.min(error1, error2, error3);
  95187. if (error === error1) {
  95188. if (pointResult) {
  95189. pointResult.copyFrom(vertex1.position);
  95190. }
  95191. }
  95192. else if (error === error2) {
  95193. if (pointResult) {
  95194. pointResult.copyFrom(vertex2.position);
  95195. }
  95196. }
  95197. else {
  95198. if (pointResult) {
  95199. pointResult.copyFrom(p3);
  95200. }
  95201. }
  95202. }
  95203. return error;
  95204. };
  95205. return QuadraticErrorSimplification;
  95206. }());
  95207. /***/ }),
  95208. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  95209. /*!****************************************************!*\
  95210. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  95211. \****************************************************/
  95212. /*! exports provided: SimplicationQueueSceneComponent */
  95213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95214. "use strict";
  95215. __webpack_require__.r(__webpack_exports__);
  95216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  95217. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  95218. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  95219. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  95220. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  95221. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  95222. get: function () {
  95223. if (!this._simplificationQueue) {
  95224. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  95225. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  95226. if (!component) {
  95227. component = new SimplicationQueueSceneComponent(this);
  95228. this._addComponent(component);
  95229. }
  95230. }
  95231. return this._simplificationQueue;
  95232. },
  95233. set: function (value) {
  95234. this._simplificationQueue = value;
  95235. },
  95236. enumerable: true,
  95237. configurable: true
  95238. });
  95239. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  95240. if (parallelProcessing === void 0) { parallelProcessing = true; }
  95241. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  95242. this.getScene().simplificationQueue.addTask({
  95243. settings: settings,
  95244. parallelProcessing: parallelProcessing,
  95245. mesh: this,
  95246. simplificationType: simplificationType,
  95247. successCallback: successCallback
  95248. });
  95249. return this;
  95250. };
  95251. /**
  95252. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  95253. * created in a scene
  95254. */
  95255. var SimplicationQueueSceneComponent = /** @class */ (function () {
  95256. /**
  95257. * Creates a new instance of the component for the given scene
  95258. * @param scene Defines the scene to register the component in
  95259. */
  95260. function SimplicationQueueSceneComponent(scene) {
  95261. /**
  95262. * The component name helpfull to identify the component in the list of scene components.
  95263. */
  95264. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  95265. this.scene = scene;
  95266. }
  95267. /**
  95268. * Registers the component in a given scene
  95269. */
  95270. SimplicationQueueSceneComponent.prototype.register = function () {
  95271. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  95272. };
  95273. /**
  95274. * Rebuilds the elements related to this component in case of
  95275. * context lost for instance.
  95276. */
  95277. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  95278. // Nothing to do for this component
  95279. };
  95280. /**
  95281. * Disposes the component and the associated ressources
  95282. */
  95283. SimplicationQueueSceneComponent.prototype.dispose = function () {
  95284. // Nothing to do for this component
  95285. };
  95286. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  95287. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  95288. this.scene._simplificationQueue.executeNext();
  95289. }
  95290. };
  95291. return SimplicationQueueSceneComponent;
  95292. }());
  95293. /***/ }),
  95294. /***/ "./Meshes/polygonMesh.ts":
  95295. /*!*******************************!*\
  95296. !*** ./Meshes/polygonMesh.ts ***!
  95297. \*******************************/
  95298. /*! exports provided: Polygon, PolygonMeshBuilder */
  95299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95300. "use strict";
  95301. __webpack_require__.r(__webpack_exports__);
  95302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  95303. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  95304. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  95305. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  95306. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  95307. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  95308. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  95309. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  95310. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  95311. /**
  95312. * Vector2 wth index property
  95313. */
  95314. var IndexedVector2 = /** @class */ (function (_super) {
  95315. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  95316. function IndexedVector2(original,
  95317. /** Index of the vector2 */
  95318. index) {
  95319. var _this = _super.call(this, original.x, original.y) || this;
  95320. _this.index = index;
  95321. return _this;
  95322. }
  95323. return IndexedVector2;
  95324. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  95325. /**
  95326. * Defines points to create a polygon
  95327. */
  95328. var PolygonPoints = /** @class */ (function () {
  95329. function PolygonPoints() {
  95330. this.elements = new Array();
  95331. }
  95332. PolygonPoints.prototype.add = function (originalPoints) {
  95333. var _this = this;
  95334. var result = new Array();
  95335. originalPoints.forEach(function (point) {
  95336. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  95337. var newPoint = new IndexedVector2(point, _this.elements.length);
  95338. result.push(newPoint);
  95339. _this.elements.push(newPoint);
  95340. }
  95341. });
  95342. return result;
  95343. };
  95344. PolygonPoints.prototype.computeBounds = function () {
  95345. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  95346. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  95347. this.elements.forEach(function (point) {
  95348. // x
  95349. if (point.x < lmin.x) {
  95350. lmin.x = point.x;
  95351. }
  95352. else if (point.x > lmax.x) {
  95353. lmax.x = point.x;
  95354. }
  95355. // y
  95356. if (point.y < lmin.y) {
  95357. lmin.y = point.y;
  95358. }
  95359. else if (point.y > lmax.y) {
  95360. lmax.y = point.y;
  95361. }
  95362. });
  95363. return {
  95364. min: lmin,
  95365. max: lmax,
  95366. width: lmax.x - lmin.x,
  95367. height: lmax.y - lmin.y
  95368. };
  95369. };
  95370. return PolygonPoints;
  95371. }());
  95372. /**
  95373. * Polygon
  95374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  95375. */
  95376. var Polygon = /** @class */ (function () {
  95377. function Polygon() {
  95378. }
  95379. /**
  95380. * Creates a rectangle
  95381. * @param xmin bottom X coord
  95382. * @param ymin bottom Y coord
  95383. * @param xmax top X coord
  95384. * @param ymax top Y coord
  95385. * @returns points that make the resulting rectation
  95386. */
  95387. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  95388. return [
  95389. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  95390. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  95391. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  95392. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  95393. ];
  95394. };
  95395. /**
  95396. * Creates a circle
  95397. * @param radius radius of circle
  95398. * @param cx scale in x
  95399. * @param cy scale in y
  95400. * @param numberOfSides number of sides that make up the circle
  95401. * @returns points that make the resulting circle
  95402. */
  95403. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  95404. if (cx === void 0) { cx = 0; }
  95405. if (cy === void 0) { cy = 0; }
  95406. if (numberOfSides === void 0) { numberOfSides = 32; }
  95407. var result = new Array();
  95408. var angle = 0;
  95409. var increment = (Math.PI * 2) / numberOfSides;
  95410. for (var i = 0; i < numberOfSides; i++) {
  95411. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  95412. angle -= increment;
  95413. }
  95414. return result;
  95415. };
  95416. /**
  95417. * Creates a polygon from input string
  95418. * @param input Input polygon data
  95419. * @returns the parsed points
  95420. */
  95421. Polygon.Parse = function (input) {
  95422. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  95423. var i, result = [];
  95424. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  95425. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  95426. }
  95427. return result;
  95428. };
  95429. /**
  95430. * Starts building a polygon from x and y coordinates
  95431. * @param x x coordinate
  95432. * @param y y coordinate
  95433. * @returns the started path2
  95434. */
  95435. Polygon.StartingAt = function (x, y) {
  95436. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  95437. };
  95438. return Polygon;
  95439. }());
  95440. /**
  95441. * Builds a polygon
  95442. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  95443. */
  95444. var PolygonMeshBuilder = /** @class */ (function () {
  95445. /**
  95446. * Creates a PolygonMeshBuilder
  95447. * @param name name of the builder
  95448. * @param contours Path of the polygon
  95449. * @param scene scene to add to when creating the mesh
  95450. * @param earcutInjection can be used to inject your own earcut reference
  95451. */
  95452. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  95453. if (earcutInjection === void 0) { earcutInjection = earcut; }
  95454. this._points = new PolygonPoints();
  95455. this._outlinepoints = new PolygonPoints();
  95456. this._holes = new Array();
  95457. this._epoints = new Array();
  95458. this._eholes = new Array();
  95459. this.bjsEarcut = earcutInjection;
  95460. this._name = name;
  95461. this._scene = scene || _Engines_engine__WEBPACK_IMPORTED_MODULE_6__["Engine"].LastCreatedScene;
  95462. var points;
  95463. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  95464. points = contours.getPoints();
  95465. }
  95466. else {
  95467. points = contours;
  95468. }
  95469. this._addToepoint(points);
  95470. this._points.add(points);
  95471. this._outlinepoints.add(points);
  95472. if (typeof this.bjsEarcut === 'undefined') {
  95473. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  95474. }
  95475. }
  95476. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  95477. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  95478. var p = points_1[_i];
  95479. this._epoints.push(p.x, p.y);
  95480. }
  95481. };
  95482. /**
  95483. * Adds a whole within the polygon
  95484. * @param hole Array of points defining the hole
  95485. * @returns this
  95486. */
  95487. PolygonMeshBuilder.prototype.addHole = function (hole) {
  95488. this._points.add(hole);
  95489. var holepoints = new PolygonPoints();
  95490. holepoints.add(hole);
  95491. this._holes.push(holepoints);
  95492. this._eholes.push(this._epoints.length / 2);
  95493. this._addToepoint(hole);
  95494. return this;
  95495. };
  95496. /**
  95497. * Creates the polygon
  95498. * @param updatable If the mesh should be updatable
  95499. * @param depth The depth of the mesh created
  95500. * @returns the created mesh
  95501. */
  95502. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  95503. if (updatable === void 0) { updatable = false; }
  95504. if (depth === void 0) { depth = 0; }
  95505. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  95506. var vertexData = this.buildVertexData(depth);
  95507. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, vertexData.positions, updatable);
  95508. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, vertexData.normals, updatable);
  95509. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, vertexData.uvs, updatable);
  95510. result.setIndices(vertexData.indices);
  95511. return result;
  95512. };
  95513. /**
  95514. * Creates the polygon
  95515. * @param depth The depth of the mesh created
  95516. * @returns the created VertexData
  95517. */
  95518. PolygonMeshBuilder.prototype.buildVertexData = function (depth) {
  95519. var _this = this;
  95520. if (depth === void 0) { depth = 0; }
  95521. var result = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  95522. var normals = new Array();
  95523. var positions = new Array();
  95524. var uvs = new Array();
  95525. var bounds = this._points.computeBounds();
  95526. this._points.elements.forEach(function (p) {
  95527. normals.push(0, 1.0, 0);
  95528. positions.push(p.x, 0, p.y);
  95529. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  95530. });
  95531. var indices = new Array();
  95532. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  95533. for (var i = 0; i < res.length; i++) {
  95534. indices.push(res[i]);
  95535. }
  95536. if (depth > 0) {
  95537. var positionscount = (positions.length / 3); //get the current pointcount
  95538. this._points.elements.forEach(function (p) {
  95539. normals.push(0, -1.0, 0);
  95540. positions.push(p.x, -depth, p.y);
  95541. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  95542. });
  95543. var totalCount = indices.length;
  95544. for (var i = 0; i < totalCount; i += 3) {
  95545. var i0 = indices[i + 0];
  95546. var i1 = indices[i + 1];
  95547. var i2 = indices[i + 2];
  95548. indices.push(i2 + positionscount);
  95549. indices.push(i1 + positionscount);
  95550. indices.push(i0 + positionscount);
  95551. }
  95552. //Add the sides
  95553. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  95554. this._holes.forEach(function (hole) {
  95555. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  95556. });
  95557. }
  95558. result.indices = indices;
  95559. result.positions = positions;
  95560. result.normals = normals;
  95561. result.uvs = uvs;
  95562. return result;
  95563. };
  95564. /**
  95565. * Adds a side to the polygon
  95566. * @param positions points that make the polygon
  95567. * @param normals normals of the polygon
  95568. * @param uvs uvs of the polygon
  95569. * @param indices indices of the polygon
  95570. * @param bounds bounds of the polygon
  95571. * @param points points of the polygon
  95572. * @param depth depth of the polygon
  95573. * @param flip flip of the polygon
  95574. */
  95575. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  95576. var StartIndex = positions.length / 3;
  95577. var ulength = 0;
  95578. for (var i = 0; i < points.elements.length; i++) {
  95579. var p = points.elements[i];
  95580. var p1;
  95581. if ((i + 1) > points.elements.length - 1) {
  95582. p1 = points.elements[0];
  95583. }
  95584. else {
  95585. p1 = points.elements[i + 1];
  95586. }
  95587. positions.push(p.x, 0, p.y);
  95588. positions.push(p.x, -depth, p.y);
  95589. positions.push(p1.x, 0, p1.y);
  95590. positions.push(p1.x, -depth, p1.y);
  95591. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  95592. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  95593. var v3 = v2.subtract(v1);
  95594. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  95595. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  95596. vn = vn.normalize();
  95597. uvs.push(ulength / bounds.width, 0);
  95598. uvs.push(ulength / bounds.width, 1);
  95599. ulength += v3.length();
  95600. uvs.push((ulength / bounds.width), 0);
  95601. uvs.push((ulength / bounds.width), 1);
  95602. if (!flip) {
  95603. normals.push(-vn.x, -vn.y, -vn.z);
  95604. normals.push(-vn.x, -vn.y, -vn.z);
  95605. normals.push(-vn.x, -vn.y, -vn.z);
  95606. normals.push(-vn.x, -vn.y, -vn.z);
  95607. indices.push(StartIndex);
  95608. indices.push(StartIndex + 1);
  95609. indices.push(StartIndex + 2);
  95610. indices.push(StartIndex + 1);
  95611. indices.push(StartIndex + 3);
  95612. indices.push(StartIndex + 2);
  95613. }
  95614. else {
  95615. normals.push(vn.x, vn.y, vn.z);
  95616. normals.push(vn.x, vn.y, vn.z);
  95617. normals.push(vn.x, vn.y, vn.z);
  95618. normals.push(vn.x, vn.y, vn.z);
  95619. indices.push(StartIndex);
  95620. indices.push(StartIndex + 2);
  95621. indices.push(StartIndex + 1);
  95622. indices.push(StartIndex + 1);
  95623. indices.push(StartIndex + 2);
  95624. indices.push(StartIndex + 3);
  95625. }
  95626. StartIndex += 4;
  95627. }
  95628. };
  95629. return PolygonMeshBuilder;
  95630. }());
  95631. /***/ }),
  95632. /***/ "./Meshes/subMesh.ts":
  95633. /*!***************************!*\
  95634. !*** ./Meshes/subMesh.ts ***!
  95635. \***************************/
  95636. /*! exports provided: BaseSubMesh, SubMesh */
  95637. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95638. "use strict";
  95639. __webpack_require__.r(__webpack_exports__);
  95640. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  95641. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  95642. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  95643. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  95644. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  95645. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  95646. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  95647. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  95648. /**
  95649. * Base class for submeshes
  95650. */
  95651. var BaseSubMesh = /** @class */ (function () {
  95652. function BaseSubMesh() {
  95653. /** @hidden */
  95654. this._materialDefines = null;
  95655. /** @hidden */
  95656. this._materialEffect = null;
  95657. }
  95658. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  95659. /**
  95660. * Gets associated effect
  95661. */
  95662. get: function () {
  95663. return this._materialEffect;
  95664. },
  95665. enumerable: true,
  95666. configurable: true
  95667. });
  95668. /**
  95669. * Sets associated effect (effect used to render this submesh)
  95670. * @param effect defines the effect to associate with
  95671. * @param defines defines the set of defines used to compile this effect
  95672. */
  95673. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  95674. if (defines === void 0) { defines = null; }
  95675. if (this._materialEffect === effect) {
  95676. if (!effect) {
  95677. this._materialDefines = null;
  95678. }
  95679. return;
  95680. }
  95681. this._materialDefines = defines;
  95682. this._materialEffect = effect;
  95683. };
  95684. return BaseSubMesh;
  95685. }());
  95686. /**
  95687. * Defines a subdivision inside a mesh
  95688. */
  95689. var SubMesh = /** @class */ (function (_super) {
  95690. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  95691. /**
  95692. * Creates a new submesh
  95693. * @param materialIndex defines the material index to use
  95694. * @param verticesStart defines vertex index start
  95695. * @param verticesCount defines vertices count
  95696. * @param indexStart defines index start
  95697. * @param indexCount defines indices count
  95698. * @param mesh defines the parent mesh
  95699. * @param renderingMesh defines an optional rendering mesh
  95700. * @param createBoundingBox defines if bounding box should be created for this submesh
  95701. */
  95702. function SubMesh(
  95703. /** the material index to use */
  95704. materialIndex,
  95705. /** vertex index start */
  95706. verticesStart,
  95707. /** vertices count */
  95708. verticesCount,
  95709. /** index start */
  95710. indexStart,
  95711. /** indices count */
  95712. indexCount, mesh, renderingMesh, createBoundingBox) {
  95713. if (createBoundingBox === void 0) { createBoundingBox = true; }
  95714. var _this = _super.call(this) || this;
  95715. _this.materialIndex = materialIndex;
  95716. _this.verticesStart = verticesStart;
  95717. _this.verticesCount = verticesCount;
  95718. _this.indexStart = indexStart;
  95719. _this.indexCount = indexCount;
  95720. /** @hidden */
  95721. _this._linesIndexCount = 0;
  95722. _this._linesIndexBuffer = null;
  95723. /** @hidden */
  95724. _this._lastColliderWorldVertices = null;
  95725. /** @hidden */
  95726. _this._lastColliderTransformMatrix = null;
  95727. /** @hidden */
  95728. _this._renderId = 0;
  95729. /** @hidden */
  95730. _this._alphaIndex = 0;
  95731. /** @hidden */
  95732. _this._distanceToCamera = 0;
  95733. _this._currentMaterial = null;
  95734. _this._mesh = mesh;
  95735. _this._renderingMesh = renderingMesh || mesh;
  95736. mesh.subMeshes.push(_this);
  95737. _this._trianglePlanes = [];
  95738. _this._id = mesh.subMeshes.length - 1;
  95739. if (createBoundingBox) {
  95740. _this.refreshBoundingInfo();
  95741. mesh.computeWorldMatrix(true);
  95742. }
  95743. return _this;
  95744. }
  95745. /**
  95746. * Add a new submesh to a mesh
  95747. * @param materialIndex defines the material index to use
  95748. * @param verticesStart defines vertex index start
  95749. * @param verticesCount defines vertices count
  95750. * @param indexStart defines index start
  95751. * @param indexCount defines indices count
  95752. * @param mesh defines the parent mesh
  95753. * @param renderingMesh defines an optional rendering mesh
  95754. * @param createBoundingBox defines if bounding box should be created for this submesh
  95755. * @returns the new submesh
  95756. */
  95757. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  95758. if (createBoundingBox === void 0) { createBoundingBox = true; }
  95759. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  95760. };
  95761. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  95762. /**
  95763. * Returns true if this submesh covers the entire parent mesh
  95764. * @ignorenaming
  95765. */
  95766. get: function () {
  95767. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  95768. },
  95769. enumerable: true,
  95770. configurable: true
  95771. });
  95772. /**
  95773. * Returns the submesh BoudingInfo object
  95774. * @returns current bounding info (or mesh's one if the submesh is global)
  95775. */
  95776. SubMesh.prototype.getBoundingInfo = function () {
  95777. if (this.IsGlobal) {
  95778. return this._mesh.getBoundingInfo();
  95779. }
  95780. return this._boundingInfo;
  95781. };
  95782. /**
  95783. * Sets the submesh BoundingInfo
  95784. * @param boundingInfo defines the new bounding info to use
  95785. * @returns the SubMesh
  95786. */
  95787. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  95788. this._boundingInfo = boundingInfo;
  95789. return this;
  95790. };
  95791. /**
  95792. * Returns the mesh of the current submesh
  95793. * @return the parent mesh
  95794. */
  95795. SubMesh.prototype.getMesh = function () {
  95796. return this._mesh;
  95797. };
  95798. /**
  95799. * Returns the rendering mesh of the submesh
  95800. * @returns the rendering mesh (could be different from parent mesh)
  95801. */
  95802. SubMesh.prototype.getRenderingMesh = function () {
  95803. return this._renderingMesh;
  95804. };
  95805. /**
  95806. * Returns the submesh material
  95807. * @returns null or the current material
  95808. */
  95809. SubMesh.prototype.getMaterial = function () {
  95810. var rootMaterial = this._renderingMesh.material;
  95811. if (rootMaterial === null || rootMaterial === undefined) {
  95812. return this._mesh.getScene().defaultMaterial;
  95813. }
  95814. else if (rootMaterial.getSubMaterial) {
  95815. var multiMaterial = rootMaterial;
  95816. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  95817. if (this._currentMaterial !== effectiveMaterial) {
  95818. this._currentMaterial = effectiveMaterial;
  95819. this._materialDefines = null;
  95820. }
  95821. return effectiveMaterial;
  95822. }
  95823. return rootMaterial;
  95824. };
  95825. // Methods
  95826. /**
  95827. * Sets a new updated BoundingInfo object to the submesh
  95828. * @param data defines an optional position array to use to determine the bounding info
  95829. * @returns the SubMesh
  95830. */
  95831. SubMesh.prototype.refreshBoundingInfo = function (data) {
  95832. if (data === void 0) { data = null; }
  95833. this._lastColliderWorldVertices = null;
  95834. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  95835. return this;
  95836. }
  95837. if (!data) {
  95838. data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  95839. }
  95840. if (!data) {
  95841. this._boundingInfo = this._mesh.getBoundingInfo();
  95842. return this;
  95843. }
  95844. var indices = this._renderingMesh.getIndices();
  95845. var extend;
  95846. //is this the only submesh?
  95847. if (this.indexStart === 0 && this.indexCount === indices.length) {
  95848. var boundingInfo = this._renderingMesh.getBoundingInfo();
  95849. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  95850. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  95851. }
  95852. else {
  95853. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  95854. }
  95855. if (this._boundingInfo) {
  95856. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  95857. }
  95858. else {
  95859. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  95860. }
  95861. return this;
  95862. };
  95863. /** @hidden */
  95864. SubMesh.prototype._checkCollision = function (collider) {
  95865. var boundingInfo = this.getBoundingInfo();
  95866. return boundingInfo._checkCollision(collider);
  95867. };
  95868. /**
  95869. * Updates the submesh BoundingInfo
  95870. * @param world defines the world matrix to use to update the bounding info
  95871. * @returns the submesh
  95872. */
  95873. SubMesh.prototype.updateBoundingInfo = function (world) {
  95874. var boundingInfo = this.getBoundingInfo();
  95875. if (!boundingInfo) {
  95876. this.refreshBoundingInfo();
  95877. boundingInfo = this.getBoundingInfo();
  95878. }
  95879. boundingInfo.update(world);
  95880. return this;
  95881. };
  95882. /**
  95883. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  95884. * @param frustumPlanes defines the frustum planes
  95885. * @returns true if the submesh is intersecting with the frustum
  95886. */
  95887. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  95888. var boundingInfo = this.getBoundingInfo();
  95889. if (!boundingInfo) {
  95890. return false;
  95891. }
  95892. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  95893. };
  95894. /**
  95895. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  95896. * @param frustumPlanes defines the frustum planes
  95897. * @returns true if the submesh is inside the frustum
  95898. */
  95899. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  95900. var boundingInfo = this.getBoundingInfo();
  95901. if (!boundingInfo) {
  95902. return false;
  95903. }
  95904. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  95905. };
  95906. /**
  95907. * Renders the submesh
  95908. * @param enableAlphaMode defines if alpha needs to be used
  95909. * @returns the submesh
  95910. */
  95911. SubMesh.prototype.render = function (enableAlphaMode) {
  95912. this._renderingMesh.render(this, enableAlphaMode);
  95913. return this;
  95914. };
  95915. /**
  95916. * @hidden
  95917. */
  95918. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  95919. if (!this._linesIndexBuffer) {
  95920. var linesIndices = [];
  95921. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  95922. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  95923. }
  95924. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  95925. this._linesIndexCount = linesIndices.length;
  95926. }
  95927. return this._linesIndexBuffer;
  95928. };
  95929. /**
  95930. * Checks if the submesh intersects with a ray
  95931. * @param ray defines the ray to test
  95932. * @returns true is the passed ray intersects the submesh bounding box
  95933. */
  95934. SubMesh.prototype.canIntersects = function (ray) {
  95935. var boundingInfo = this.getBoundingInfo();
  95936. if (!boundingInfo) {
  95937. return false;
  95938. }
  95939. return ray.intersectsBox(boundingInfo.boundingBox);
  95940. };
  95941. /**
  95942. * Intersects current submesh with a ray
  95943. * @param ray defines the ray to test
  95944. * @param positions defines mesh's positions array
  95945. * @param indices defines mesh's indices array
  95946. * @param fastCheck defines if only bounding info should be used
  95947. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95948. * @returns intersection info or null if no intersection
  95949. */
  95950. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck, trianglePredicate) {
  95951. var material = this.getMaterial();
  95952. if (!material) {
  95953. return null;
  95954. }
  95955. switch (material.fillMode) {
  95956. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  95957. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  95958. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  95959. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  95960. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  95961. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  95962. return null;
  95963. }
  95964. // LineMesh first as it's also a Mesh...
  95965. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  95966. // Check if mesh is unindexed
  95967. if (!indices.length) {
  95968. return this._intersectUnIndexedLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  95969. }
  95970. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  95971. }
  95972. else {
  95973. // Check if mesh is unindexed
  95974. if (!indices.length && this._mesh._unIndexed) {
  95975. return this._intersectUnIndexedTriangles(ray, positions, indices, fastCheck, trianglePredicate);
  95976. }
  95977. return this._intersectTriangles(ray, positions, indices, fastCheck, trianglePredicate);
  95978. }
  95979. };
  95980. /** @hidden */
  95981. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  95982. var intersectInfo = null;
  95983. // Line test
  95984. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  95985. var p0 = positions[indices[index]];
  95986. var p1 = positions[indices[index + 1]];
  95987. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  95988. if (length < 0) {
  95989. continue;
  95990. }
  95991. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  95992. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  95993. intersectInfo.faceId = index / 2;
  95994. if (fastCheck) {
  95995. break;
  95996. }
  95997. }
  95998. }
  95999. return intersectInfo;
  96000. };
  96001. /** @hidden */
  96002. SubMesh.prototype._intersectUnIndexedLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  96003. var intersectInfo = null;
  96004. // Line test
  96005. for (var index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 2) {
  96006. var p0 = positions[index];
  96007. var p1 = positions[index + 1];
  96008. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  96009. if (length < 0) {
  96010. continue;
  96011. }
  96012. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  96013. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  96014. intersectInfo.faceId = index / 2;
  96015. if (fastCheck) {
  96016. break;
  96017. }
  96018. }
  96019. }
  96020. return intersectInfo;
  96021. };
  96022. /** @hidden */
  96023. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck, trianglePredicate) {
  96024. var intersectInfo = null;
  96025. // Triangles test
  96026. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  96027. var p0 = positions[indices[index]];
  96028. var p1 = positions[indices[index + 1]];
  96029. var p2 = positions[indices[index + 2]];
  96030. if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {
  96031. continue;
  96032. }
  96033. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  96034. if (currentIntersectInfo) {
  96035. if (currentIntersectInfo.distance < 0) {
  96036. continue;
  96037. }
  96038. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  96039. intersectInfo = currentIntersectInfo;
  96040. intersectInfo.faceId = index / 3;
  96041. if (fastCheck) {
  96042. break;
  96043. }
  96044. }
  96045. }
  96046. }
  96047. return intersectInfo;
  96048. };
  96049. /** @hidden */
  96050. SubMesh.prototype._intersectUnIndexedTriangles = function (ray, positions, indices, fastCheck, trianglePredicate) {
  96051. var intersectInfo = null;
  96052. // Triangles test
  96053. for (var index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 3) {
  96054. var p0 = positions[index];
  96055. var p1 = positions[index + 1];
  96056. var p2 = positions[index + 2];
  96057. if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {
  96058. continue;
  96059. }
  96060. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  96061. if (currentIntersectInfo) {
  96062. if (currentIntersectInfo.distance < 0) {
  96063. continue;
  96064. }
  96065. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  96066. intersectInfo = currentIntersectInfo;
  96067. intersectInfo.faceId = index / 3;
  96068. if (fastCheck) {
  96069. break;
  96070. }
  96071. }
  96072. }
  96073. }
  96074. return intersectInfo;
  96075. };
  96076. /** @hidden */
  96077. SubMesh.prototype._rebuild = function () {
  96078. if (this._linesIndexBuffer) {
  96079. this._linesIndexBuffer = null;
  96080. }
  96081. };
  96082. // Clone
  96083. /**
  96084. * Creates a new submesh from the passed mesh
  96085. * @param newMesh defines the new hosting mesh
  96086. * @param newRenderingMesh defines an optional rendering mesh
  96087. * @returns the new submesh
  96088. */
  96089. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  96090. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  96091. if (!this.IsGlobal) {
  96092. var boundingInfo = this.getBoundingInfo();
  96093. if (!boundingInfo) {
  96094. return result;
  96095. }
  96096. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  96097. }
  96098. return result;
  96099. };
  96100. // Dispose
  96101. /**
  96102. * Release associated resources
  96103. */
  96104. SubMesh.prototype.dispose = function () {
  96105. if (this._linesIndexBuffer) {
  96106. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  96107. this._linesIndexBuffer = null;
  96108. }
  96109. // Remove from mesh
  96110. var index = this._mesh.subMeshes.indexOf(this);
  96111. this._mesh.subMeshes.splice(index, 1);
  96112. };
  96113. /**
  96114. * Gets the class name
  96115. * @returns the string "SubMesh".
  96116. */
  96117. SubMesh.prototype.getClassName = function () {
  96118. return "SubMesh";
  96119. };
  96120. // Statics
  96121. /**
  96122. * Creates a new submesh from indices data
  96123. * @param materialIndex the index of the main mesh material
  96124. * @param startIndex the index where to start the copy in the mesh indices array
  96125. * @param indexCount the number of indices to copy then from the startIndex
  96126. * @param mesh the main mesh to create the submesh from
  96127. * @param renderingMesh the optional rendering mesh
  96128. * @returns a new submesh
  96129. */
  96130. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  96131. var minVertexIndex = Number.MAX_VALUE;
  96132. var maxVertexIndex = -Number.MAX_VALUE;
  96133. var whatWillRender = (renderingMesh || mesh);
  96134. var indices = whatWillRender.getIndices();
  96135. for (var index = startIndex; index < startIndex + indexCount; index++) {
  96136. var vertexIndex = indices[index];
  96137. if (vertexIndex < minVertexIndex) {
  96138. minVertexIndex = vertexIndex;
  96139. }
  96140. if (vertexIndex > maxVertexIndex) {
  96141. maxVertexIndex = vertexIndex;
  96142. }
  96143. }
  96144. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  96145. };
  96146. return SubMesh;
  96147. }(BaseSubMesh));
  96148. /***/ }),
  96149. /***/ "./Meshes/trailMesh.ts":
  96150. /*!*****************************!*\
  96151. !*** ./Meshes/trailMesh.ts ***!
  96152. \*****************************/
  96153. /*! exports provided: TrailMesh */
  96154. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96155. "use strict";
  96156. __webpack_require__.r(__webpack_exports__);
  96157. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return TrailMesh; });
  96158. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  96159. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  96160. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  96161. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  96162. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  96163. /**
  96164. * Class used to create a trail following a mesh
  96165. */
  96166. var TrailMesh = /** @class */ (function (_super) {
  96167. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TrailMesh, _super);
  96168. /**
  96169. * @constructor
  96170. * @param name The value used by scene.getMeshByName() to do a lookup.
  96171. * @param generator The mesh to generate a trail.
  96172. * @param scene The scene to add this mesh to.
  96173. * @param diameter Diameter of trailing mesh. Default is 1.
  96174. * @param length Length of trailing mesh. Default is 60.
  96175. * @param autoStart Automatically start trailing mesh. Default true.
  96176. */
  96177. function TrailMesh(name, generator, scene, diameter, length, autoStart) {
  96178. if (diameter === void 0) { diameter = 1; }
  96179. if (length === void 0) { length = 60; }
  96180. if (autoStart === void 0) { autoStart = true; }
  96181. var _this = _super.call(this, name, scene) || this;
  96182. _this._sectionPolygonPointsCount = 4;
  96183. _this._running = false;
  96184. _this._autoStart = autoStart;
  96185. _this._generator = generator;
  96186. _this._diameter = diameter;
  96187. _this._length = length;
  96188. _this._sectionVectors = [];
  96189. _this._sectionNormalVectors = [];
  96190. for (var i = 0; i < _this._sectionPolygonPointsCount; i++) {
  96191. _this._sectionVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  96192. _this._sectionNormalVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  96193. }
  96194. _this._createMesh();
  96195. return _this;
  96196. }
  96197. /**
  96198. * "TrailMesh"
  96199. * @returns "TrailMesh"
  96200. */
  96201. TrailMesh.prototype.getClassName = function () {
  96202. return "TrailMesh";
  96203. };
  96204. TrailMesh.prototype._createMesh = function () {
  96205. var data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"]();
  96206. var positions = [];
  96207. var normals = [];
  96208. var indices = [];
  96209. var meshCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  96210. if (this._generator._boundingInfo) {
  96211. meshCenter = this._generator._boundingInfo.boundingBox.centerWorld;
  96212. }
  96213. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  96214. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  96215. positions.push(meshCenter.x + Math.cos(i * alpha) * this._diameter, meshCenter.y + Math.sin(i * alpha) * this._diameter, meshCenter.z);
  96216. }
  96217. for (var i = 1; i <= this._length; i++) {
  96218. for (var j = 0; j < this._sectionPolygonPointsCount; j++) {
  96219. positions.push(meshCenter.x + Math.cos(j * alpha) * this._diameter, meshCenter.y + Math.sin(j * alpha) * this._diameter, meshCenter.z);
  96220. }
  96221. var l = positions.length / 3 - 2 * this._sectionPolygonPointsCount;
  96222. for (var j = 0; j < this._sectionPolygonPointsCount - 1; j++) {
  96223. indices.push(l + j, l + j + this._sectionPolygonPointsCount, l + j + this._sectionPolygonPointsCount + 1);
  96224. indices.push(l + j, l + j + this._sectionPolygonPointsCount + 1, l + j + 1);
  96225. }
  96226. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount);
  96227. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l);
  96228. }
  96229. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"].ComputeNormals(positions, indices, normals);
  96230. data.positions = positions;
  96231. data.normals = normals;
  96232. data.indices = indices;
  96233. data.applyToMesh(this, true);
  96234. if (this._autoStart) {
  96235. this.start();
  96236. }
  96237. };
  96238. /**
  96239. * Start trailing mesh.
  96240. */
  96241. TrailMesh.prototype.start = function () {
  96242. var _this = this;
  96243. if (!this._running) {
  96244. this._running = true;
  96245. this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(function () {
  96246. _this.update();
  96247. });
  96248. }
  96249. };
  96250. /**
  96251. * Stop trailing mesh.
  96252. */
  96253. TrailMesh.prototype.stop = function () {
  96254. if (this._beforeRenderObserver && this._running) {
  96255. this._running = false;
  96256. this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver);
  96257. }
  96258. };
  96259. /**
  96260. * Update trailing mesh geometry.
  96261. */
  96262. TrailMesh.prototype.update = function () {
  96263. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  96264. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind);
  96265. var wm = this._generator.getWorldMatrix();
  96266. if (positions && normals) {
  96267. for (var i = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {
  96268. positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - normals[i] / this._length * this._diameter;
  96269. }
  96270. for (var i = 3 * this._sectionPolygonPointsCount; i < normals.length; i++) {
  96271. normals[i - 3 * this._sectionPolygonPointsCount] = normals[i];
  96272. }
  96273. var l = positions.length - 3 * this._sectionPolygonPointsCount;
  96274. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  96275. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  96276. this._sectionVectors[i].copyFromFloats(Math.cos(i * alpha) * this._diameter, Math.sin(i * alpha) * this._diameter, 0);
  96277. this._sectionNormalVectors[i].copyFromFloats(Math.cos(i * alpha), Math.sin(i * alpha), 0);
  96278. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._sectionVectors[i], wm, this._sectionVectors[i]);
  96279. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this._sectionNormalVectors[i], wm, this._sectionNormalVectors[i]);
  96280. }
  96281. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  96282. positions[l + 3 * i] = this._sectionVectors[i].x;
  96283. positions[l + 3 * i + 1] = this._sectionVectors[i].y;
  96284. positions[l + 3 * i + 2] = this._sectionVectors[i].z;
  96285. normals[l + 3 * i] = this._sectionNormalVectors[i].x;
  96286. normals[l + 3 * i + 1] = this._sectionNormalVectors[i].y;
  96287. normals[l + 3 * i + 2] = this._sectionNormalVectors[i].z;
  96288. }
  96289. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, true, false);
  96290. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, true, false);
  96291. }
  96292. };
  96293. /**
  96294. * Returns a new TrailMesh object.
  96295. * @param name is a string, the name given to the new mesh
  96296. * @param newGenerator use new generator object for cloned trail mesh
  96297. * @returns a new mesh
  96298. */
  96299. TrailMesh.prototype.clone = function (name, newGenerator) {
  96300. if (name === void 0) { name = ""; }
  96301. return new TrailMesh(name, (newGenerator === undefined ? this._generator : newGenerator), this.getScene(), this._diameter, this._length, this._autoStart);
  96302. };
  96303. /**
  96304. * Serializes this trail mesh
  96305. * @param serializationObject object to write serialization to
  96306. */
  96307. TrailMesh.prototype.serialize = function (serializationObject) {
  96308. _super.prototype.serialize.call(this, serializationObject);
  96309. };
  96310. /**
  96311. * Parses a serialized trail mesh
  96312. * @param parsedMesh the serialized mesh
  96313. * @param scene the scene to create the trail mesh in
  96314. * @returns the created trail mesh
  96315. */
  96316. TrailMesh.Parse = function (parsedMesh, scene) {
  96317. return new TrailMesh(parsedMesh.name, parsedMesh._generator, scene, parsedMesh._diameter, parsedMesh._length, parsedMesh._autoStart);
  96318. };
  96319. return TrailMesh;
  96320. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]));
  96321. /***/ }),
  96322. /***/ "./Meshes/transformNode.ts":
  96323. /*!*********************************!*\
  96324. !*** ./Meshes/transformNode.ts ***!
  96325. \*********************************/
  96326. /*! exports provided: TransformNode */
  96327. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96328. "use strict";
  96329. __webpack_require__.r(__webpack_exports__);
  96330. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  96331. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  96332. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  96333. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  96334. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  96335. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  96336. /**
  96337. * 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.
  96338. * @see https://doc.babylonjs.com/how_to/transformnode
  96339. */
  96340. var TransformNode = /** @class */ (function (_super) {
  96341. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  96342. function TransformNode(name, scene, isPure) {
  96343. if (scene === void 0) { scene = null; }
  96344. if (isPure === void 0) { isPure = true; }
  96345. var _this = _super.call(this, name, scene) || this;
  96346. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  96347. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  96348. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  96349. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  96350. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  96351. // Properties
  96352. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  96353. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  96354. _this._rotationQuaternion = null;
  96355. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  96356. _this._isDirty = false;
  96357. _this._transformToBoneReferal = null;
  96358. _this._billboardMode = TransformNode.BILLBOARDMODE_NONE;
  96359. _this._preserveParentRotationForBillboard = false;
  96360. /**
  96361. * 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
  96362. */
  96363. _this.scalingDeterminant = 1;
  96364. _this._infiniteDistance = false;
  96365. /**
  96366. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  96367. * By default the system will update normals to compensate
  96368. */
  96369. _this.ignoreNonUniformScaling = false;
  96370. /**
  96371. * 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
  96372. */
  96373. _this.reIntegrateRotationIntoRotationQuaternion = false;
  96374. // Cache
  96375. /** @hidden */
  96376. _this._poseMatrix = null;
  96377. /** @hidden */
  96378. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  96379. _this._usePivotMatrix = false;
  96380. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  96381. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  96382. _this._postMultiplyPivotMatrix = false;
  96383. _this._isWorldMatrixFrozen = false;
  96384. /** @hidden */
  96385. _this._indexInSceneTransformNodesArray = -1;
  96386. /**
  96387. * An event triggered after the world matrix is updated
  96388. */
  96389. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  96390. _this._nonUniformScaling = false;
  96391. if (isPure) {
  96392. _this.getScene().addTransformNode(_this);
  96393. }
  96394. return _this;
  96395. }
  96396. Object.defineProperty(TransformNode.prototype, "billboardMode", {
  96397. /**
  96398. * Gets or sets the billboard mode. Default is 0.
  96399. *
  96400. * | Value | Type | Description |
  96401. * | --- | --- | --- |
  96402. * | 0 | BILLBOARDMODE_NONE | |
  96403. * | 1 | BILLBOARDMODE_X | |
  96404. * | 2 | BILLBOARDMODE_Y | |
  96405. * | 4 | BILLBOARDMODE_Z | |
  96406. * | 7 | BILLBOARDMODE_ALL | |
  96407. *
  96408. */
  96409. get: function () {
  96410. return this._billboardMode;
  96411. },
  96412. set: function (value) {
  96413. if (this._billboardMode === value) {
  96414. return;
  96415. }
  96416. this._billboardMode = value;
  96417. },
  96418. enumerable: true,
  96419. configurable: true
  96420. });
  96421. Object.defineProperty(TransformNode.prototype, "preserveParentRotationForBillboard", {
  96422. /**
  96423. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  96424. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  96425. */
  96426. get: function () {
  96427. return this._preserveParentRotationForBillboard;
  96428. },
  96429. set: function (value) {
  96430. if (value === this._preserveParentRotationForBillboard) {
  96431. return;
  96432. }
  96433. this._preserveParentRotationForBillboard = value;
  96434. },
  96435. enumerable: true,
  96436. configurable: true
  96437. });
  96438. Object.defineProperty(TransformNode.prototype, "infiniteDistance", {
  96439. /**
  96440. * Gets or sets the distance of the object to max, often used by skybox
  96441. */
  96442. get: function () {
  96443. return this._infiniteDistance;
  96444. },
  96445. set: function (value) {
  96446. if (this._infiniteDistance === value) {
  96447. return;
  96448. }
  96449. this._infiniteDistance = value;
  96450. },
  96451. enumerable: true,
  96452. configurable: true
  96453. });
  96454. /**
  96455. * Gets a string identifying the name of the class
  96456. * @returns "TransformNode" string
  96457. */
  96458. TransformNode.prototype.getClassName = function () {
  96459. return "TransformNode";
  96460. };
  96461. Object.defineProperty(TransformNode.prototype, "position", {
  96462. /**
  96463. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  96464. */
  96465. get: function () {
  96466. return this._position;
  96467. },
  96468. set: function (newPosition) {
  96469. this._position = newPosition;
  96470. this._isDirty = true;
  96471. },
  96472. enumerable: true,
  96473. configurable: true
  96474. });
  96475. Object.defineProperty(TransformNode.prototype, "rotation", {
  96476. /**
  96477. * 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)).
  96478. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  96479. */
  96480. get: function () {
  96481. return this._rotation;
  96482. },
  96483. set: function (newRotation) {
  96484. this._rotation = newRotation;
  96485. this._rotationQuaternion = null;
  96486. this._isDirty = true;
  96487. },
  96488. enumerable: true,
  96489. configurable: true
  96490. });
  96491. Object.defineProperty(TransformNode.prototype, "scaling", {
  96492. /**
  96493. * 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)).
  96494. */
  96495. get: function () {
  96496. return this._scaling;
  96497. },
  96498. set: function (newScaling) {
  96499. this._scaling = newScaling;
  96500. this._isDirty = true;
  96501. },
  96502. enumerable: true,
  96503. configurable: true
  96504. });
  96505. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  96506. /**
  96507. * 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).
  96508. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  96509. */
  96510. get: function () {
  96511. return this._rotationQuaternion;
  96512. },
  96513. set: function (quaternion) {
  96514. this._rotationQuaternion = quaternion;
  96515. //reset the rotation vector.
  96516. if (quaternion) {
  96517. this._rotation.setAll(0.0);
  96518. }
  96519. this._isDirty = true;
  96520. },
  96521. enumerable: true,
  96522. configurable: true
  96523. });
  96524. Object.defineProperty(TransformNode.prototype, "forward", {
  96525. /**
  96526. * The forward direction of that transform in world space.
  96527. */
  96528. get: function () {
  96529. 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()));
  96530. },
  96531. enumerable: true,
  96532. configurable: true
  96533. });
  96534. Object.defineProperty(TransformNode.prototype, "up", {
  96535. /**
  96536. * The up direction of that transform in world space.
  96537. */
  96538. get: function () {
  96539. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  96540. },
  96541. enumerable: true,
  96542. configurable: true
  96543. });
  96544. Object.defineProperty(TransformNode.prototype, "right", {
  96545. /**
  96546. * The right direction of that transform in world space.
  96547. */
  96548. get: function () {
  96549. 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()));
  96550. },
  96551. enumerable: true,
  96552. configurable: true
  96553. });
  96554. /**
  96555. * Copies the parameter passed Matrix into the mesh Pose matrix.
  96556. * @param matrix the matrix to copy the pose from
  96557. * @returns this TransformNode.
  96558. */
  96559. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  96560. if (!this._poseMatrix) {
  96561. this._poseMatrix = matrix.clone();
  96562. return this;
  96563. }
  96564. this._poseMatrix.copyFrom(matrix);
  96565. return this;
  96566. };
  96567. /**
  96568. * Returns the mesh Pose matrix.
  96569. * @returns the pose matrix
  96570. */
  96571. TransformNode.prototype.getPoseMatrix = function () {
  96572. if (!this._poseMatrix) {
  96573. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  96574. }
  96575. return this._poseMatrix;
  96576. };
  96577. /** @hidden */
  96578. TransformNode.prototype._isSynchronized = function () {
  96579. var cache = this._cache;
  96580. if (this.billboardMode !== cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  96581. return false;
  96582. }
  96583. if (cache.pivotMatrixUpdated) {
  96584. return false;
  96585. }
  96586. if (this.infiniteDistance) {
  96587. return false;
  96588. }
  96589. if (!cache.position.equals(this._position)) {
  96590. return false;
  96591. }
  96592. if (this._rotationQuaternion) {
  96593. if (!cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  96594. return false;
  96595. }
  96596. }
  96597. else if (!cache.rotation.equals(this._rotation)) {
  96598. return false;
  96599. }
  96600. if (!cache.scaling.equals(this._scaling)) {
  96601. return false;
  96602. }
  96603. return true;
  96604. };
  96605. /** @hidden */
  96606. TransformNode.prototype._initCache = function () {
  96607. _super.prototype._initCache.call(this);
  96608. var cache = this._cache;
  96609. cache.localMatrixUpdated = false;
  96610. cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  96611. cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  96612. cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  96613. cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  96614. cache.billboardMode = -1;
  96615. cache.infiniteDistance = false;
  96616. };
  96617. /**
  96618. * Flag the transform node as dirty (Forcing it to update everything)
  96619. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  96620. * @returns this transform node
  96621. */
  96622. TransformNode.prototype.markAsDirty = function (property) {
  96623. this._currentRenderId = Number.MAX_VALUE;
  96624. this._isDirty = true;
  96625. return this;
  96626. };
  96627. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  96628. /**
  96629. * Returns the current mesh absolute position.
  96630. * Returns a Vector3.
  96631. */
  96632. get: function () {
  96633. return this._absolutePosition;
  96634. },
  96635. enumerable: true,
  96636. configurable: true
  96637. });
  96638. /**
  96639. * Sets a new matrix to apply before all other transformation
  96640. * @param matrix defines the transform matrix
  96641. * @returns the current TransformNode
  96642. */
  96643. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  96644. return this.setPivotMatrix(matrix, false);
  96645. };
  96646. /**
  96647. * Sets a new pivot matrix to the current node
  96648. * @param matrix defines the new pivot matrix to use
  96649. * @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
  96650. * @returns the current TransformNode
  96651. */
  96652. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  96653. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  96654. this._pivotMatrix.copyFrom(matrix);
  96655. this._usePivotMatrix = !this._pivotMatrix.isIdentity();
  96656. this._cache.pivotMatrixUpdated = true;
  96657. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  96658. if (this._postMultiplyPivotMatrix) {
  96659. if (!this._pivotMatrixInverse) {
  96660. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  96661. }
  96662. else {
  96663. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  96664. }
  96665. }
  96666. return this;
  96667. };
  96668. /**
  96669. * Returns the mesh pivot matrix.
  96670. * Default : Identity.
  96671. * @returns the matrix
  96672. */
  96673. TransformNode.prototype.getPivotMatrix = function () {
  96674. return this._pivotMatrix;
  96675. };
  96676. /**
  96677. * Prevents the World matrix to be computed any longer.
  96678. * @returns the TransformNode.
  96679. */
  96680. TransformNode.prototype.freezeWorldMatrix = function () {
  96681. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  96682. this.computeWorldMatrix(true);
  96683. this._isWorldMatrixFrozen = true;
  96684. return this;
  96685. };
  96686. /**
  96687. * Allows back the World matrix computation.
  96688. * @returns the TransformNode.
  96689. */
  96690. TransformNode.prototype.unfreezeWorldMatrix = function () {
  96691. this._isWorldMatrixFrozen = false;
  96692. this.computeWorldMatrix(true);
  96693. return this;
  96694. };
  96695. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  96696. /**
  96697. * True if the World matrix has been frozen.
  96698. */
  96699. get: function () {
  96700. return this._isWorldMatrixFrozen;
  96701. },
  96702. enumerable: true,
  96703. configurable: true
  96704. });
  96705. /**
  96706. * Retuns the mesh absolute position in the World.
  96707. * @returns a Vector3.
  96708. */
  96709. TransformNode.prototype.getAbsolutePosition = function () {
  96710. this.computeWorldMatrix();
  96711. return this._absolutePosition;
  96712. };
  96713. /**
  96714. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  96715. * @param absolutePosition the absolute position to set
  96716. * @returns the TransformNode.
  96717. */
  96718. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  96719. if (!absolutePosition) {
  96720. return this;
  96721. }
  96722. var absolutePositionX;
  96723. var absolutePositionY;
  96724. var absolutePositionZ;
  96725. if (absolutePosition.x === undefined) {
  96726. if (arguments.length < 3) {
  96727. return this;
  96728. }
  96729. absolutePositionX = arguments[0];
  96730. absolutePositionY = arguments[1];
  96731. absolutePositionZ = arguments[2];
  96732. }
  96733. else {
  96734. absolutePositionX = absolutePosition.x;
  96735. absolutePositionY = absolutePosition.y;
  96736. absolutePositionZ = absolutePosition.z;
  96737. }
  96738. if (this.parent) {
  96739. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  96740. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  96741. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  96742. }
  96743. else {
  96744. this.position.x = absolutePositionX;
  96745. this.position.y = absolutePositionY;
  96746. this.position.z = absolutePositionZ;
  96747. }
  96748. return this;
  96749. };
  96750. /**
  96751. * Sets the mesh position in its local space.
  96752. * @param vector3 the position to set in localspace
  96753. * @returns the TransformNode.
  96754. */
  96755. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  96756. this.computeWorldMatrix();
  96757. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  96758. return this;
  96759. };
  96760. /**
  96761. * Returns the mesh position in the local space from the current World matrix values.
  96762. * @returns a new Vector3.
  96763. */
  96764. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  96765. this.computeWorldMatrix();
  96766. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  96767. this._localMatrix.invertToRef(invLocalWorldMatrix);
  96768. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  96769. };
  96770. /**
  96771. * Translates the mesh along the passed Vector3 in its local space.
  96772. * @param vector3 the distance to translate in localspace
  96773. * @returns the TransformNode.
  96774. */
  96775. TransformNode.prototype.locallyTranslate = function (vector3) {
  96776. this.computeWorldMatrix(true);
  96777. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  96778. return this;
  96779. };
  96780. /**
  96781. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  96782. * @param targetPoint the position (must be in same space as current mesh) to look at
  96783. * @param yawCor optional yaw (y-axis) correction in radians
  96784. * @param pitchCor optional pitch (x-axis) correction in radians
  96785. * @param rollCor optional roll (z-axis) correction in radians
  96786. * @param space the choosen space of the target
  96787. * @returns the TransformNode.
  96788. */
  96789. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  96790. if (yawCor === void 0) { yawCor = 0; }
  96791. if (pitchCor === void 0) { pitchCor = 0; }
  96792. if (rollCor === void 0) { rollCor = 0; }
  96793. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  96794. var dv = TransformNode._lookAtVectorCache;
  96795. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  96796. targetPoint.subtractToRef(pos, dv);
  96797. this.setDirection(dv, yawCor, pitchCor, rollCor);
  96798. // Correct for parent's rotation offset
  96799. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD && this.parent) {
  96800. if (this.rotationQuaternion) {
  96801. // Get local rotation matrix of the looking object
  96802. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  96803. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  96804. // Offset rotation by parent's inverted rotation matrix to correct in world space
  96805. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  96806. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  96807. parentRotationMatrix.invert();
  96808. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  96809. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  96810. }
  96811. else {
  96812. // Get local rotation matrix of the looking object
  96813. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  96814. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  96815. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  96816. quaternionRotation.toRotationMatrix(rotationMatrix);
  96817. // Offset rotation by parent's inverted rotation matrix to correct in world space
  96818. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  96819. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  96820. parentRotationMatrix.invert();
  96821. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  96822. quaternionRotation.fromRotationMatrix(rotationMatrix);
  96823. quaternionRotation.toEulerAnglesToRef(this.rotation);
  96824. }
  96825. }
  96826. return this;
  96827. };
  96828. /**
  96829. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  96830. * This Vector3 is expressed in the World space.
  96831. * @param localAxis axis to rotate
  96832. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  96833. */
  96834. TransformNode.prototype.getDirection = function (localAxis) {
  96835. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  96836. this.getDirectionToRef(localAxis, result);
  96837. return result;
  96838. };
  96839. /**
  96840. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  96841. * localAxis is expressed in the mesh local space.
  96842. * result is computed in the Wordl space from the mesh World matrix.
  96843. * @param localAxis axis to rotate
  96844. * @param result the resulting transformnode
  96845. * @returns this TransformNode.
  96846. */
  96847. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  96848. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  96849. return this;
  96850. };
  96851. /**
  96852. * Sets this transform node rotation to the given local axis.
  96853. * @param localAxis the axis in local space
  96854. * @param yawCor optional yaw (y-axis) correction in radians
  96855. * @param pitchCor optional pitch (x-axis) correction in radians
  96856. * @param rollCor optional roll (z-axis) correction in radians
  96857. * @returns this TransformNode
  96858. */
  96859. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  96860. if (yawCor === void 0) { yawCor = 0; }
  96861. if (pitchCor === void 0) { pitchCor = 0; }
  96862. if (rollCor === void 0) { rollCor = 0; }
  96863. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  96864. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  96865. var pitch = -Math.atan2(localAxis.y, len);
  96866. if (this.rotationQuaternion) {
  96867. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  96868. }
  96869. else {
  96870. this.rotation.x = pitch + pitchCor;
  96871. this.rotation.y = yaw + yawCor;
  96872. this.rotation.z = rollCor;
  96873. }
  96874. return this;
  96875. };
  96876. /**
  96877. * Sets a new pivot point to the current node
  96878. * @param point defines the new pivot point to use
  96879. * @param space defines if the point is in world or local space (local by default)
  96880. * @returns the current TransformNode
  96881. */
  96882. TransformNode.prototype.setPivotPoint = function (point, space) {
  96883. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  96884. if (this.getScene().getRenderId() == 0) {
  96885. this.computeWorldMatrix(true);
  96886. }
  96887. var wm = this.getWorldMatrix();
  96888. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD) {
  96889. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  96890. wm.invertToRef(tmat);
  96891. point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  96892. }
  96893. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  96894. };
  96895. /**
  96896. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  96897. * @returns the pivot point
  96898. */
  96899. TransformNode.prototype.getPivotPoint = function () {
  96900. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  96901. this.getPivotPointToRef(point);
  96902. return point;
  96903. };
  96904. /**
  96905. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  96906. * @param result the vector3 to store the result
  96907. * @returns this TransformNode.
  96908. */
  96909. TransformNode.prototype.getPivotPointToRef = function (result) {
  96910. result.x = -this._pivotMatrix.m[12];
  96911. result.y = -this._pivotMatrix.m[13];
  96912. result.z = -this._pivotMatrix.m[14];
  96913. return this;
  96914. };
  96915. /**
  96916. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  96917. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  96918. */
  96919. TransformNode.prototype.getAbsolutePivotPoint = function () {
  96920. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  96921. this.getAbsolutePivotPointToRef(point);
  96922. return point;
  96923. };
  96924. /**
  96925. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  96926. * @param result vector3 to store the result
  96927. * @returns this TransformNode.
  96928. */
  96929. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  96930. result.x = this._pivotMatrix.m[12];
  96931. result.y = this._pivotMatrix.m[13];
  96932. result.z = this._pivotMatrix.m[14];
  96933. this.getPivotPointToRef(result);
  96934. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  96935. return this;
  96936. };
  96937. /**
  96938. * Defines the passed node as the parent of the current node.
  96939. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  96940. * @see https://doc.babylonjs.com/how_to/parenting
  96941. * @param node the node ot set as the parent
  96942. * @returns this TransformNode.
  96943. */
  96944. TransformNode.prototype.setParent = function (node) {
  96945. if (!node && !this.parent) {
  96946. return this;
  96947. }
  96948. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  96949. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  96950. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  96951. if (!node) {
  96952. if (this.parent && this.parent.computeWorldMatrix) {
  96953. this.parent.computeWorldMatrix(true);
  96954. }
  96955. this.computeWorldMatrix(true);
  96956. this.getWorldMatrix().decompose(scale, quatRotation, position);
  96957. }
  96958. else {
  96959. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  96960. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  96961. this.computeWorldMatrix(true);
  96962. node.computeWorldMatrix(true);
  96963. node.getWorldMatrix().invertToRef(invParentMatrix);
  96964. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  96965. diffMatrix.decompose(scale, quatRotation, position);
  96966. }
  96967. if (this.rotationQuaternion) {
  96968. this.rotationQuaternion.copyFrom(quatRotation);
  96969. }
  96970. else {
  96971. quatRotation.toEulerAnglesToRef(this.rotation);
  96972. }
  96973. this.scaling.copyFrom(scale);
  96974. this.position.copyFrom(position);
  96975. this.parent = node;
  96976. return this;
  96977. };
  96978. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  96979. /**
  96980. * True if the scaling property of this object is non uniform eg. (1,2,1)
  96981. */
  96982. get: function () {
  96983. return this._nonUniformScaling;
  96984. },
  96985. enumerable: true,
  96986. configurable: true
  96987. });
  96988. /** @hidden */
  96989. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  96990. if (this._nonUniformScaling === value) {
  96991. return false;
  96992. }
  96993. this._nonUniformScaling = value;
  96994. return true;
  96995. };
  96996. /**
  96997. * Attach the current TransformNode to another TransformNode associated with a bone
  96998. * @param bone Bone affecting the TransformNode
  96999. * @param affectedTransformNode TransformNode associated with the bone
  97000. * @returns this object
  97001. */
  97002. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  97003. this._transformToBoneReferal = affectedTransformNode;
  97004. this.parent = bone;
  97005. if (bone.getWorldMatrix().determinant() < 0) {
  97006. this.scalingDeterminant *= -1;
  97007. }
  97008. return this;
  97009. };
  97010. /**
  97011. * Detach the transform node if its associated with a bone
  97012. * @returns this object
  97013. */
  97014. TransformNode.prototype.detachFromBone = function () {
  97015. if (!this.parent) {
  97016. return this;
  97017. }
  97018. if (this.parent.getWorldMatrix().determinant() < 0) {
  97019. this.scalingDeterminant *= -1;
  97020. }
  97021. this._transformToBoneReferal = null;
  97022. this.parent = null;
  97023. return this;
  97024. };
  97025. /**
  97026. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  97027. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  97028. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  97029. * The passed axis is also normalized.
  97030. * @param axis the axis to rotate around
  97031. * @param amount the amount to rotate in radians
  97032. * @param space Space to rotate in (Default: local)
  97033. * @returns the TransformNode.
  97034. */
  97035. TransformNode.prototype.rotate = function (axis, amount, space) {
  97036. axis.normalize();
  97037. if (!this.rotationQuaternion) {
  97038. this.rotationQuaternion = this.rotation.toQuaternion();
  97039. this.rotation.setAll(0);
  97040. }
  97041. var rotationQuaternion;
  97042. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  97043. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  97044. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  97045. }
  97046. else {
  97047. if (this.parent) {
  97048. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  97049. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  97050. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  97051. }
  97052. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  97053. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  97054. }
  97055. return this;
  97056. };
  97057. /**
  97058. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  97059. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  97060. * The passed axis is also normalized. .
  97061. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  97062. * @param point the point to rotate around
  97063. * @param axis the axis to rotate around
  97064. * @param amount the amount to rotate in radians
  97065. * @returns the TransformNode
  97066. */
  97067. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  97068. axis.normalize();
  97069. if (!this.rotationQuaternion) {
  97070. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  97071. this.rotation.setAll(0);
  97072. }
  97073. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  97074. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  97075. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[2];
  97076. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  97077. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]; // T
  97078. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]; // T'
  97079. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]; // R
  97080. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[3]; // T' x R x T
  97081. point.subtractToRef(this.position, tmpVector);
  97082. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  97083. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  97084. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  97085. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  97086. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  97087. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  97088. this.position.addInPlace(finalTranslation);
  97089. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  97090. return this;
  97091. };
  97092. /**
  97093. * Translates the mesh along the axis vector for the passed distance in the given space.
  97094. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  97095. * @param axis the axis to translate in
  97096. * @param distance the distance to translate
  97097. * @param space Space to rotate in (Default: local)
  97098. * @returns the TransformNode.
  97099. */
  97100. TransformNode.prototype.translate = function (axis, distance, space) {
  97101. var displacementVector = axis.scale(distance);
  97102. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  97103. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  97104. this.setPositionWithLocalVector(tempV3);
  97105. }
  97106. else {
  97107. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  97108. }
  97109. return this;
  97110. };
  97111. /**
  97112. * Adds a rotation step to the mesh current rotation.
  97113. * x, y, z are Euler angles expressed in radians.
  97114. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  97115. * This means this rotation is made in the mesh local space only.
  97116. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  97117. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  97118. * ```javascript
  97119. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  97120. * ```
  97121. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  97122. * 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.
  97123. * @param x Rotation to add
  97124. * @param y Rotation to add
  97125. * @param z Rotation to add
  97126. * @returns the TransformNode.
  97127. */
  97128. TransformNode.prototype.addRotation = function (x, y, z) {
  97129. var rotationQuaternion;
  97130. if (this.rotationQuaternion) {
  97131. rotationQuaternion = this.rotationQuaternion;
  97132. }
  97133. else {
  97134. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[1];
  97135. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  97136. }
  97137. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  97138. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  97139. rotationQuaternion.multiplyInPlace(accumulation);
  97140. if (!this.rotationQuaternion) {
  97141. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  97142. }
  97143. return this;
  97144. };
  97145. /**
  97146. * @hidden
  97147. */
  97148. TransformNode.prototype._getEffectiveParent = function () {
  97149. return this.parent;
  97150. };
  97151. /**
  97152. * Computes the world matrix of the node
  97153. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97154. * @returns the world matrix
  97155. */
  97156. TransformNode.prototype.computeWorldMatrix = function (force) {
  97157. if (this._isWorldMatrixFrozen && !this._isDirty) {
  97158. return this._worldMatrix;
  97159. }
  97160. var currentRenderId = this.getScene().getRenderId();
  97161. if (!this._isDirty && !force && this.isSynchronized()) {
  97162. this._currentRenderId = currentRenderId;
  97163. return this._worldMatrix;
  97164. }
  97165. this._updateCache();
  97166. var cache = this._cache;
  97167. cache.pivotMatrixUpdated = false;
  97168. cache.billboardMode = this.billboardMode;
  97169. cache.infiniteDistance = this.infiniteDistance;
  97170. this._currentRenderId = currentRenderId;
  97171. this._childUpdateId++;
  97172. this._isDirty = false;
  97173. var parent = this._getEffectiveParent();
  97174. var useBillboardPath = this._billboardMode !== TransformNode.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard;
  97175. var camera = this.getScene().activeCamera;
  97176. // Scaling
  97177. var scaling = cache.scaling;
  97178. var translation = cache.position;
  97179. // Translation
  97180. if (this._infiniteDistance) {
  97181. if (!this.parent && camera) {
  97182. var cameraWorldMatrix = camera.getWorldMatrix();
  97183. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  97184. translation.copyFromFloats(this._position.x + cameraGlobalPosition.x, this._position.y + cameraGlobalPosition.y, this._position.z + cameraGlobalPosition.z);
  97185. }
  97186. else {
  97187. translation.copyFrom(this._position);
  97188. }
  97189. }
  97190. else {
  97191. translation.copyFrom(this._position);
  97192. }
  97193. // Scaling
  97194. scaling.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant);
  97195. // Rotation
  97196. var rotation = cache.rotationQuaternion;
  97197. if (this._rotationQuaternion) {
  97198. if (this.reIntegrateRotationIntoRotationQuaternion) {
  97199. var len = this.rotation.lengthSquared();
  97200. if (len) {
  97201. this._rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z));
  97202. this._rotation.copyFromFloats(0, 0, 0);
  97203. }
  97204. }
  97205. rotation.copyFrom(this._rotationQuaternion);
  97206. }
  97207. else {
  97208. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, rotation);
  97209. cache.rotation.copyFrom(this._rotation);
  97210. }
  97211. // Compose
  97212. if (this._usePivotMatrix) {
  97213. var scaleMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  97214. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(scaling.x, scaling.y, scaling.z, scaleMatrix);
  97215. // Rotation
  97216. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  97217. rotation.toRotationMatrix(rotationMatrix);
  97218. // Composing transformations
  97219. this._pivotMatrix.multiplyToRef(scaleMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4]);
  97220. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4].multiplyToRef(rotationMatrix, this._localMatrix);
  97221. // Post multiply inverse of pivotMatrix
  97222. if (this._postMultiplyPivotMatrix) {
  97223. this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix);
  97224. }
  97225. this._localMatrix.addTranslationFromFloats(translation.x, translation.y, translation.z);
  97226. }
  97227. else {
  97228. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ComposeToRef(scaling, rotation, translation, this._localMatrix);
  97229. }
  97230. // Parent
  97231. if (parent && parent.getWorldMatrix) {
  97232. if (useBillboardPath) {
  97233. if (this._transformToBoneReferal) {
  97234. parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7]);
  97235. }
  97236. else {
  97237. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].copyFrom(parent.getWorldMatrix());
  97238. }
  97239. // Extract scaling and translation from parent
  97240. var translation_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5];
  97241. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[6];
  97242. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].decompose(scale, undefined, translation_1);
  97243. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(scale.x, scale.y, scale.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7]);
  97244. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].setTranslation(translation_1);
  97245. this._localMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7], this._worldMatrix);
  97246. }
  97247. else {
  97248. if (this._transformToBoneReferal) {
  97249. this._localMatrix.multiplyToRef(parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  97250. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  97251. }
  97252. else {
  97253. this._localMatrix.multiplyToRef(parent.getWorldMatrix(), this._worldMatrix);
  97254. }
  97255. }
  97256. this._markSyncedWithParent();
  97257. }
  97258. else {
  97259. this._worldMatrix.copyFrom(this._localMatrix);
  97260. }
  97261. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  97262. if (useBillboardPath && camera) {
  97263. var storedTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  97264. this._worldMatrix.getTranslationToRef(storedTranslation); // Save translation
  97265. // Cancel camera rotation
  97266. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  97267. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  97268. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  97269. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  97270. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0].decompose(undefined, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0], undefined);
  97271. var eulerAngles = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  97272. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0].toEulerAnglesToRef(eulerAngles);
  97273. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) !== TransformNode.BILLBOARDMODE_X) {
  97274. eulerAngles.x = 0;
  97275. }
  97276. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) !== TransformNode.BILLBOARDMODE_Y) {
  97277. eulerAngles.y = 0;
  97278. }
  97279. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) !== TransformNode.BILLBOARDMODE_Z) {
  97280. eulerAngles.z = 0;
  97281. }
  97282. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(eulerAngles.y, eulerAngles.x, eulerAngles.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  97283. }
  97284. this._worldMatrix.setTranslationFromFloats(0, 0, 0);
  97285. this._worldMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], this._worldMatrix);
  97286. // Restore translation
  97287. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  97288. }
  97289. // Normal matrix
  97290. if (!this.ignoreNonUniformScaling) {
  97291. if (this._scaling.isNonUniform) {
  97292. this._updateNonUniformScalingState(true);
  97293. }
  97294. else if (parent && parent._nonUniformScaling) {
  97295. this._updateNonUniformScalingState(parent._nonUniformScaling);
  97296. }
  97297. else {
  97298. this._updateNonUniformScalingState(false);
  97299. }
  97300. }
  97301. else {
  97302. this._updateNonUniformScalingState(false);
  97303. }
  97304. this._afterComputeWorldMatrix();
  97305. // Absolute position
  97306. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  97307. // Callbacks
  97308. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  97309. if (!this._poseMatrix) {
  97310. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  97311. }
  97312. // Cache the determinant
  97313. this._worldMatrixDeterminantIsDirty = true;
  97314. return this._worldMatrix;
  97315. };
  97316. TransformNode.prototype._afterComputeWorldMatrix = function () {
  97317. };
  97318. /**
  97319. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  97320. * @param func callback function to add
  97321. *
  97322. * @returns the TransformNode.
  97323. */
  97324. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  97325. this.onAfterWorldMatrixUpdateObservable.add(func);
  97326. return this;
  97327. };
  97328. /**
  97329. * Removes a registered callback function.
  97330. * @param func callback function to remove
  97331. * @returns the TransformNode.
  97332. */
  97333. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  97334. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  97335. return this;
  97336. };
  97337. /**
  97338. * Gets the position of the current mesh in camera space
  97339. * @param camera defines the camera to use
  97340. * @returns a position
  97341. */
  97342. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  97343. if (camera === void 0) { camera = null; }
  97344. if (!camera) {
  97345. camera = this.getScene().activeCamera;
  97346. }
  97347. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  97348. };
  97349. /**
  97350. * Returns the distance from the mesh to the active camera
  97351. * @param camera defines the camera to use
  97352. * @returns the distance
  97353. */
  97354. TransformNode.prototype.getDistanceToCamera = function (camera) {
  97355. if (camera === void 0) { camera = null; }
  97356. if (!camera) {
  97357. camera = this.getScene().activeCamera;
  97358. }
  97359. return this.absolutePosition.subtract(camera.globalPosition).length();
  97360. };
  97361. /**
  97362. * Clone the current transform node
  97363. * @param name Name of the new clone
  97364. * @param newParent New parent for the clone
  97365. * @param doNotCloneChildren Do not clone children hierarchy
  97366. * @returns the new transform node
  97367. */
  97368. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  97369. var _this = this;
  97370. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  97371. result.name = name;
  97372. result.id = name;
  97373. if (newParent) {
  97374. result.parent = newParent;
  97375. }
  97376. if (!doNotCloneChildren) {
  97377. // Children
  97378. var directDescendants = this.getDescendants(true);
  97379. for (var index = 0; index < directDescendants.length; index++) {
  97380. var child = directDescendants[index];
  97381. if (child.clone) {
  97382. child.clone(name + "." + child.name, result);
  97383. }
  97384. }
  97385. }
  97386. return result;
  97387. };
  97388. /**
  97389. * Serializes the objects information.
  97390. * @param currentSerializationObject defines the object to serialize in
  97391. * @returns the serialized object
  97392. */
  97393. TransformNode.prototype.serialize = function (currentSerializationObject) {
  97394. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  97395. serializationObject.type = this.getClassName();
  97396. // Parent
  97397. if (this.parent) {
  97398. serializationObject.parentId = this.parent.id;
  97399. }
  97400. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  97401. serializationObject.isEnabled = this.isEnabled();
  97402. // Parent
  97403. if (this.parent) {
  97404. serializationObject.parentId = this.parent.id;
  97405. }
  97406. return serializationObject;
  97407. };
  97408. // Statics
  97409. /**
  97410. * Returns a new TransformNode object parsed from the source provided.
  97411. * @param parsedTransformNode is the source.
  97412. * @param scene the scne the object belongs to
  97413. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  97414. * @returns a new TransformNode object parsed from the source provided.
  97415. */
  97416. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  97417. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  97418. if (parsedTransformNode.localMatrix) {
  97419. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  97420. }
  97421. else if (parsedTransformNode.pivotMatrix) {
  97422. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  97423. }
  97424. transformNode.setEnabled(parsedTransformNode.isEnabled);
  97425. // Parent
  97426. if (parsedTransformNode.parentId) {
  97427. transformNode._waitingParentId = parsedTransformNode.parentId;
  97428. }
  97429. return transformNode;
  97430. };
  97431. /**
  97432. * Get all child-transformNodes of this node
  97433. * @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
  97434. * @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
  97435. * @returns an array of TransformNode
  97436. */
  97437. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  97438. var results = [];
  97439. this._getDescendants(results, directDescendantsOnly, function (node) {
  97440. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  97441. });
  97442. return results;
  97443. };
  97444. /**
  97445. * Releases resources associated with this transform node.
  97446. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97447. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97448. */
  97449. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  97450. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  97451. // Animations
  97452. this.getScene().stopAnimation(this);
  97453. // Remove from scene
  97454. this.getScene().removeTransformNode(this);
  97455. this.onAfterWorldMatrixUpdateObservable.clear();
  97456. if (doNotRecurse) {
  97457. var transformNodes = this.getChildTransformNodes(true);
  97458. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  97459. var transformNode = transformNodes_1[_i];
  97460. transformNode.parent = null;
  97461. transformNode.computeWorldMatrix(true);
  97462. }
  97463. }
  97464. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  97465. };
  97466. // Statics
  97467. /**
  97468. * Object will not rotate to face the camera
  97469. */
  97470. TransformNode.BILLBOARDMODE_NONE = 0;
  97471. /**
  97472. * Object will rotate to face the camera but only on the x axis
  97473. */
  97474. TransformNode.BILLBOARDMODE_X = 1;
  97475. /**
  97476. * Object will rotate to face the camera but only on the y axis
  97477. */
  97478. TransformNode.BILLBOARDMODE_Y = 2;
  97479. /**
  97480. * Object will rotate to face the camera but only on the z axis
  97481. */
  97482. TransformNode.BILLBOARDMODE_Z = 4;
  97483. /**
  97484. * Object will rotate to face the camera
  97485. */
  97486. TransformNode.BILLBOARDMODE_ALL = 7;
  97487. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  97488. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  97489. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  97490. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  97491. ], TransformNode.prototype, "_position", void 0);
  97492. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  97493. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  97494. ], TransformNode.prototype, "_rotation", void 0);
  97495. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  97496. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  97497. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  97498. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  97499. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  97500. ], TransformNode.prototype, "_scaling", void 0);
  97501. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  97502. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("billboardMode")
  97503. ], TransformNode.prototype, "_billboardMode", void 0);
  97504. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  97505. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  97506. ], TransformNode.prototype, "scalingDeterminant", void 0);
  97507. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  97508. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("infiniteDistance")
  97509. ], TransformNode.prototype, "_infiniteDistance", void 0);
  97510. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  97511. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  97512. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  97513. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  97514. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  97515. ], TransformNode.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0);
  97516. return TransformNode;
  97517. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  97518. /***/ }),
  97519. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  97520. /*!***************************************************************!*\
  97521. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  97522. \***************************************************************/
  97523. /*! exports provided: CubeMapToSphericalPolynomialTools */
  97524. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97525. "use strict";
  97526. __webpack_require__.r(__webpack_exports__);
  97527. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  97528. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  97529. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  97530. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  97531. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  97532. var FileFaceOrientation = /** @class */ (function () {
  97533. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  97534. this.name = name;
  97535. this.worldAxisForNormal = worldAxisForNormal;
  97536. this.worldAxisForFileX = worldAxisForFileX;
  97537. this.worldAxisForFileY = worldAxisForFileY;
  97538. }
  97539. return FileFaceOrientation;
  97540. }());
  97541. /**
  97542. * Helper class dealing with the extraction of spherical polynomial dataArray
  97543. * from a cube map.
  97544. */
  97545. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  97546. function CubeMapToSphericalPolynomialTools() {
  97547. }
  97548. /**
  97549. * Converts a texture to the according Spherical Polynomial data.
  97550. * This extracts the first 3 orders only as they are the only one used in the lighting.
  97551. *
  97552. * @param texture The texture to extract the information from.
  97553. * @return The Spherical Polynomial data.
  97554. */
  97555. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  97556. if (!texture.isCube) {
  97557. // Only supports cube Textures currently.
  97558. return null;
  97559. }
  97560. var size = texture.getSize().width;
  97561. var right = texture.readPixels(0);
  97562. var left = texture.readPixels(1);
  97563. var up;
  97564. var down;
  97565. if (texture.isRenderTarget) {
  97566. up = texture.readPixels(3);
  97567. down = texture.readPixels(2);
  97568. }
  97569. else {
  97570. up = texture.readPixels(2);
  97571. down = texture.readPixels(3);
  97572. }
  97573. var front = texture.readPixels(4);
  97574. var back = texture.readPixels(5);
  97575. var gammaSpace = texture.gammaSpace;
  97576. // Always read as RGBA.
  97577. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  97578. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97579. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  97580. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  97581. }
  97582. var cubeInfo = {
  97583. size: size,
  97584. right: right,
  97585. left: left,
  97586. up: up,
  97587. down: down,
  97588. front: front,
  97589. back: back,
  97590. format: format,
  97591. type: type,
  97592. gammaSpace: gammaSpace,
  97593. };
  97594. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  97595. };
  97596. /**
  97597. * Converts a cubemap to the according Spherical Polynomial data.
  97598. * This extracts the first 3 orders only as they are the only one used in the lighting.
  97599. *
  97600. * @param cubeInfo The Cube map to extract the information from.
  97601. * @return The Spherical Polynomial data.
  97602. */
  97603. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  97604. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  97605. var totalSolidAngle = 0.0;
  97606. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  97607. var du = 2.0 / cubeInfo.size;
  97608. var dv = du;
  97609. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  97610. var minUV = du * 0.5 - 1.0;
  97611. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  97612. var fileFace = this.FileFaces[faceIndex];
  97613. var dataArray = cubeInfo[fileFace.name];
  97614. var v = minUV;
  97615. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  97616. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  97617. // Because SP is still linear, so summation is fine in that basis.
  97618. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  97619. for (var y = 0; y < cubeInfo.size; y++) {
  97620. var u = minUV;
  97621. for (var x = 0; x < cubeInfo.size; x++) {
  97622. // World direction (not normalised)
  97623. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  97624. worldDirection.normalize();
  97625. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  97626. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  97627. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  97628. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  97629. // Handle Integer types.
  97630. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  97631. r /= 255;
  97632. g /= 255;
  97633. b /= 255;
  97634. }
  97635. // Handle Gamma space textures.
  97636. if (cubeInfo.gammaSpace) {
  97637. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  97638. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  97639. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  97640. }
  97641. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  97642. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  97643. totalSolidAngle += deltaSolidAngle;
  97644. u += du;
  97645. }
  97646. v += dv;
  97647. }
  97648. }
  97649. // Solid angle for entire sphere is 4*pi
  97650. var sphereSolidAngle = 4.0 * Math.PI;
  97651. // Adjust the solid angle to allow for how many faces we processed.
  97652. var facesProcessed = 6.0;
  97653. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  97654. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  97655. // This is needed because the numerical integration over the cube uses a
  97656. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  97657. // and also to compensate for accumulative error due to float precision in the summation.
  97658. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  97659. sphericalHarmonics.scaleInPlace(correctionFactor);
  97660. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  97661. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  97662. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  97663. };
  97664. CubeMapToSphericalPolynomialTools.FileFaces = [
  97665. 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)),
  97666. 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)),
  97667. 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)),
  97668. 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)),
  97669. 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)),
  97670. 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
  97671. ];
  97672. return CubeMapToSphericalPolynomialTools;
  97673. }());
  97674. /***/ }),
  97675. /***/ "./Misc/HighDynamicRange/hdr.ts":
  97676. /*!**************************************!*\
  97677. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  97678. \**************************************/
  97679. /*! exports provided: HDRTools */
  97680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97681. "use strict";
  97682. __webpack_require__.r(__webpack_exports__);
  97683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  97684. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  97685. /**
  97686. * This groups tools to convert HDR texture to native colors array.
  97687. */
  97688. var HDRTools = /** @class */ (function () {
  97689. function HDRTools() {
  97690. }
  97691. HDRTools.Ldexp = function (mantissa, exponent) {
  97692. if (exponent > 1023) {
  97693. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  97694. }
  97695. if (exponent < -1074) {
  97696. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  97697. }
  97698. return mantissa * Math.pow(2, exponent);
  97699. };
  97700. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  97701. if (exponent > 0) { /*nonzero pixel*/
  97702. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  97703. float32array[index + 0] = red * exponent;
  97704. float32array[index + 1] = green * exponent;
  97705. float32array[index + 2] = blue * exponent;
  97706. }
  97707. else {
  97708. float32array[index + 0] = 0;
  97709. float32array[index + 1] = 0;
  97710. float32array[index + 2] = 0;
  97711. }
  97712. };
  97713. HDRTools.readStringLine = function (uint8array, startIndex) {
  97714. var line = "";
  97715. var character = "";
  97716. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  97717. character = String.fromCharCode(uint8array[i]);
  97718. if (character == "\n") {
  97719. break;
  97720. }
  97721. line += character;
  97722. }
  97723. return line;
  97724. };
  97725. /**
  97726. * Reads header information from an RGBE texture stored in a native array.
  97727. * More information on this format are available here:
  97728. * https://en.wikipedia.org/wiki/RGBE_image_format
  97729. *
  97730. * @param uint8array The binary file stored in native array.
  97731. * @return The header information.
  97732. */
  97733. HDRTools.RGBE_ReadHeader = function (uint8array) {
  97734. var height = 0;
  97735. var width = 0;
  97736. var line = this.readStringLine(uint8array, 0);
  97737. if (line[0] != '#' || line[1] != '?') {
  97738. throw "Bad HDR Format.";
  97739. }
  97740. var endOfHeader = false;
  97741. var findFormat = false;
  97742. var lineIndex = 0;
  97743. do {
  97744. lineIndex += (line.length + 1);
  97745. line = this.readStringLine(uint8array, lineIndex);
  97746. if (line == "FORMAT=32-bit_rle_rgbe") {
  97747. findFormat = true;
  97748. }
  97749. else if (line.length == 0) {
  97750. endOfHeader = true;
  97751. }
  97752. } while (!endOfHeader);
  97753. if (!findFormat) {
  97754. throw "HDR Bad header format, unsupported FORMAT";
  97755. }
  97756. lineIndex += (line.length + 1);
  97757. line = this.readStringLine(uint8array, lineIndex);
  97758. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  97759. var match = sizeRegexp.exec(line);
  97760. // TODO. Support +Y and -X if needed.
  97761. if (!match || match.length < 3) {
  97762. throw "HDR Bad header format, no size";
  97763. }
  97764. width = parseInt(match[2]);
  97765. height = parseInt(match[1]);
  97766. if (width < 8 || width > 0x7fff) {
  97767. throw "HDR Bad header format, unsupported size";
  97768. }
  97769. lineIndex += (line.length + 1);
  97770. return {
  97771. height: height,
  97772. width: width,
  97773. dataPosition: lineIndex
  97774. };
  97775. };
  97776. /**
  97777. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  97778. * This RGBE texture needs to store the information as a panorama.
  97779. *
  97780. * More information on this format are available here:
  97781. * https://en.wikipedia.org/wiki/RGBE_image_format
  97782. *
  97783. * @param buffer The binary file stored in an array buffer.
  97784. * @param size The expected size of the extracted cubemap.
  97785. * @return The Cube Map information.
  97786. */
  97787. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  97788. var uint8array = new Uint8Array(buffer);
  97789. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  97790. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  97791. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  97792. return cubeMapData;
  97793. };
  97794. /**
  97795. * Returns the pixels data extracted from an RGBE texture.
  97796. * This pixels will be stored left to right up to down in the R G B order in one array.
  97797. *
  97798. * More information on this format are available here:
  97799. * https://en.wikipedia.org/wiki/RGBE_image_format
  97800. *
  97801. * @param uint8array The binary file stored in an array buffer.
  97802. * @param hdrInfo The header information of the file.
  97803. * @return The pixels data in RGB right to left up to down order.
  97804. */
  97805. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  97806. // Keep for multi format supports.
  97807. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  97808. };
  97809. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  97810. var num_scanlines = hdrInfo.height;
  97811. var scanline_width = hdrInfo.width;
  97812. var a, b, c, d, count;
  97813. var dataIndex = hdrInfo.dataPosition;
  97814. var index = 0, endIndex = 0, i = 0;
  97815. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  97816. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  97817. // 3 channels of 4 bytes per pixel in float.
  97818. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  97819. var resultArray = new Float32Array(resultBuffer);
  97820. // read in each successive scanline
  97821. while (num_scanlines > 0) {
  97822. a = uint8array[dataIndex++];
  97823. b = uint8array[dataIndex++];
  97824. c = uint8array[dataIndex++];
  97825. d = uint8array[dataIndex++];
  97826. if (a != 2 || b != 2 || (c & 0x80)) {
  97827. // this file is not run length encoded
  97828. throw "HDR Bad header format, not RLE";
  97829. }
  97830. if (((c << 8) | d) != scanline_width) {
  97831. throw "HDR Bad header format, wrong scan line width";
  97832. }
  97833. index = 0;
  97834. // read each of the four channels for the scanline into the buffer
  97835. for (i = 0; i < 4; i++) {
  97836. endIndex = (i + 1) * scanline_width;
  97837. while (index < endIndex) {
  97838. a = uint8array[dataIndex++];
  97839. b = uint8array[dataIndex++];
  97840. if (a > 128) {
  97841. // a run of the same value
  97842. count = a - 128;
  97843. if ((count == 0) || (count > endIndex - index)) {
  97844. throw "HDR Bad Format, bad scanline data (run)";
  97845. }
  97846. while (count-- > 0) {
  97847. scanLineArray[index++] = b;
  97848. }
  97849. }
  97850. else {
  97851. // a non-run
  97852. count = a;
  97853. if ((count == 0) || (count > endIndex - index)) {
  97854. throw "HDR Bad Format, bad scanline data (non-run)";
  97855. }
  97856. scanLineArray[index++] = b;
  97857. if (--count > 0) {
  97858. for (var j = 0; j < count; j++) {
  97859. scanLineArray[index++] = uint8array[dataIndex++];
  97860. }
  97861. }
  97862. }
  97863. }
  97864. }
  97865. // now convert data from buffer into floats
  97866. for (i = 0; i < scanline_width; i++) {
  97867. a = scanLineArray[i];
  97868. b = scanLineArray[i + scanline_width];
  97869. c = scanLineArray[i + 2 * scanline_width];
  97870. d = scanLineArray[i + 3 * scanline_width];
  97871. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  97872. }
  97873. num_scanlines--;
  97874. }
  97875. return resultArray;
  97876. };
  97877. return HDRTools;
  97878. }());
  97879. /***/ }),
  97880. /***/ "./Misc/HighDynamicRange/index.ts":
  97881. /*!****************************************!*\
  97882. !*** ./Misc/HighDynamicRange/index.ts ***!
  97883. \****************************************/
  97884. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  97885. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97886. "use strict";
  97887. __webpack_require__.r(__webpack_exports__);
  97888. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  97889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  97890. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  97891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  97892. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  97893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  97894. /***/ }),
  97895. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  97896. /*!****************************************************!*\
  97897. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  97898. \****************************************************/
  97899. /*! exports provided: PanoramaToCubeMapTools */
  97900. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97901. "use strict";
  97902. __webpack_require__.r(__webpack_exports__);
  97903. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  97904. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  97905. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  97906. /**
  97907. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  97908. */
  97909. var PanoramaToCubeMapTools = /** @class */ (function () {
  97910. function PanoramaToCubeMapTools() {
  97911. }
  97912. /**
  97913. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  97914. *
  97915. * @param float32Array The source data.
  97916. * @param inputWidth The width of the input panorama.
  97917. * @param inputHeight The height of the input panorama.
  97918. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  97919. * @return The cubemap data
  97920. */
  97921. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  97922. if (!float32Array) {
  97923. throw "ConvertPanoramaToCubemap: input cannot be null";
  97924. }
  97925. if (float32Array.length != inputWidth * inputHeight * 3) {
  97926. throw "ConvertPanoramaToCubemap: input size is wrong";
  97927. }
  97928. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  97929. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  97930. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  97931. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  97932. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  97933. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  97934. return {
  97935. front: textureFront,
  97936. back: textureBack,
  97937. left: textureLeft,
  97938. right: textureRight,
  97939. up: textureUp,
  97940. down: textureDown,
  97941. size: size,
  97942. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  97943. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  97944. gammaSpace: false,
  97945. };
  97946. };
  97947. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  97948. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  97949. var textureArray = new Float32Array(buffer);
  97950. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  97951. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  97952. var dy = 1 / texSize;
  97953. var fy = 0;
  97954. for (var y = 0; y < texSize; y++) {
  97955. var xv1 = faceData[0];
  97956. var xv2 = faceData[2];
  97957. for (var x = 0; x < texSize; x++) {
  97958. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  97959. v.normalize();
  97960. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  97961. // 3 channels per pixels
  97962. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  97963. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  97964. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  97965. xv1 = xv1.add(rotDX1);
  97966. xv2 = xv2.add(rotDX2);
  97967. }
  97968. fy += dy;
  97969. }
  97970. return textureArray;
  97971. };
  97972. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  97973. var theta = Math.atan2(vDir.z, vDir.x);
  97974. var phi = Math.acos(vDir.y);
  97975. while (theta < -Math.PI) {
  97976. theta += 2 * Math.PI;
  97977. }
  97978. while (theta > Math.PI) {
  97979. theta -= 2 * Math.PI;
  97980. }
  97981. var dx = theta / Math.PI;
  97982. var dy = phi / Math.PI;
  97983. // recenter.
  97984. dx = dx * 0.5 + 0.5;
  97985. var px = Math.round(dx * inputWidth);
  97986. if (px < 0) {
  97987. px = 0;
  97988. }
  97989. else if (px >= inputWidth) {
  97990. px = inputWidth - 1;
  97991. }
  97992. var py = Math.round(dy * inputHeight);
  97993. if (py < 0) {
  97994. py = 0;
  97995. }
  97996. else if (py >= inputHeight) {
  97997. py = inputHeight - 1;
  97998. }
  97999. var inputY = (inputHeight - py - 1);
  98000. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  98001. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  98002. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  98003. return {
  98004. r: r,
  98005. g: g,
  98006. b: b
  98007. };
  98008. };
  98009. PanoramaToCubeMapTools.FACE_FRONT = [
  98010. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  98011. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  98012. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  98013. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  98014. ];
  98015. PanoramaToCubeMapTools.FACE_BACK = [
  98016. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  98017. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  98018. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  98019. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  98020. ];
  98021. PanoramaToCubeMapTools.FACE_RIGHT = [
  98022. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  98023. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  98024. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  98025. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  98026. ];
  98027. PanoramaToCubeMapTools.FACE_LEFT = [
  98028. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  98029. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  98030. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  98031. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  98032. ];
  98033. PanoramaToCubeMapTools.FACE_DOWN = [
  98034. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  98035. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  98036. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  98037. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  98038. ];
  98039. PanoramaToCubeMapTools.FACE_UP = [
  98040. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  98041. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  98042. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  98043. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  98044. ];
  98045. return PanoramaToCubeMapTools;
  98046. }());
  98047. /***/ }),
  98048. /***/ "./Misc/andOrNotEvaluator.ts":
  98049. /*!***********************************!*\
  98050. !*** ./Misc/andOrNotEvaluator.ts ***!
  98051. \***********************************/
  98052. /*! exports provided: AndOrNotEvaluator */
  98053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98054. "use strict";
  98055. __webpack_require__.r(__webpack_exports__);
  98056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  98057. /**
  98058. * Class used to evalaute queries containing `and` and `or` operators
  98059. */
  98060. var AndOrNotEvaluator = /** @class */ (function () {
  98061. function AndOrNotEvaluator() {
  98062. }
  98063. /**
  98064. * Evaluate a query
  98065. * @param query defines the query to evaluate
  98066. * @param evaluateCallback defines the callback used to filter result
  98067. * @returns true if the query matches
  98068. */
  98069. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  98070. if (!query.match(/\([^\(\)]*\)/g)) {
  98071. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  98072. }
  98073. else {
  98074. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  98075. // remove parenthesis
  98076. r = r.slice(1, r.length - 1);
  98077. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  98078. });
  98079. }
  98080. if (query === "true") {
  98081. return true;
  98082. }
  98083. if (query === "false") {
  98084. return false;
  98085. }
  98086. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  98087. };
  98088. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  98089. evaluateCallback = evaluateCallback || (function (r) {
  98090. return r === "true" ? true : false;
  98091. });
  98092. var result;
  98093. var or = parenthesisContent.split("||");
  98094. for (var i in or) {
  98095. if (or.hasOwnProperty(i)) {
  98096. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  98097. var and = ori.split("&&");
  98098. if (and.length > 1) {
  98099. for (var j = 0; j < and.length; ++j) {
  98100. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  98101. if (andj !== "true" && andj !== "false") {
  98102. if (andj[0] === "!") {
  98103. result = !evaluateCallback(andj.substring(1));
  98104. }
  98105. else {
  98106. result = evaluateCallback(andj);
  98107. }
  98108. }
  98109. else {
  98110. result = andj === "true" ? true : false;
  98111. }
  98112. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  98113. ori = "false";
  98114. break;
  98115. }
  98116. }
  98117. }
  98118. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  98119. result = true;
  98120. break;
  98121. }
  98122. // result equals false (or undefined)
  98123. if (ori !== "true" && ori !== "false") {
  98124. if (ori[0] === "!") {
  98125. result = !evaluateCallback(ori.substring(1));
  98126. }
  98127. else {
  98128. result = evaluateCallback(ori);
  98129. }
  98130. }
  98131. else {
  98132. result = ori === "true" ? true : false;
  98133. }
  98134. }
  98135. }
  98136. // the whole parenthesis scope is replaced by 'true' or 'false'
  98137. return result ? "true" : "false";
  98138. };
  98139. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  98140. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  98141. // remove whitespaces
  98142. r = r.replace(/[\s]/g, function () { return ""; });
  98143. return r.length % 2 ? "!" : "";
  98144. });
  98145. booleanString = booleanString.trim();
  98146. if (booleanString === "!true") {
  98147. booleanString = "false";
  98148. }
  98149. else if (booleanString === "!false") {
  98150. booleanString = "true";
  98151. }
  98152. return booleanString;
  98153. };
  98154. return AndOrNotEvaluator;
  98155. }());
  98156. /***/ }),
  98157. /***/ "./Misc/arrayTools.ts":
  98158. /*!****************************!*\
  98159. !*** ./Misc/arrayTools.ts ***!
  98160. \****************************/
  98161. /*! exports provided: ArrayTools */
  98162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98163. "use strict";
  98164. __webpack_require__.r(__webpack_exports__);
  98165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  98166. /**
  98167. * Class containing a set of static utilities functions for arrays.
  98168. */
  98169. var ArrayTools = /** @class */ (function () {
  98170. function ArrayTools() {
  98171. }
  98172. /**
  98173. * Returns an array of the given size filled with element built from the given constructor and the paramters
  98174. * @param size the number of element to construct and put in the array
  98175. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  98176. * @returns a new array filled with new objects
  98177. */
  98178. ArrayTools.BuildArray = function (size, itemBuilder) {
  98179. var a = [];
  98180. for (var i = 0; i < size; ++i) {
  98181. a.push(itemBuilder());
  98182. }
  98183. return a;
  98184. };
  98185. return ArrayTools;
  98186. }());
  98187. /***/ }),
  98188. /***/ "./Misc/assetsManager.ts":
  98189. /*!*******************************!*\
  98190. !*** ./Misc/assetsManager.ts ***!
  98191. \*******************************/
  98192. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager */
  98193. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98194. "use strict";
  98195. __webpack_require__.r(__webpack_exports__);
  98196. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  98197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  98198. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  98199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  98200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  98201. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  98202. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  98203. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  98204. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  98205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  98206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return EquiRectangularCubeTextureAssetTask; });
  98207. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  98208. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  98209. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  98210. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  98211. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  98212. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  98213. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  98214. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  98215. /* harmony import */ var _Materials_Textures_equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/equiRectangularCubeTexture */ "./Materials/Textures/equiRectangularCubeTexture.ts");
  98216. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  98217. /**
  98218. * Defines the list of states available for a task inside a AssetsManager
  98219. */
  98220. var AssetTaskState;
  98221. (function (AssetTaskState) {
  98222. /**
  98223. * Initialization
  98224. */
  98225. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  98226. /**
  98227. * Running
  98228. */
  98229. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  98230. /**
  98231. * Done
  98232. */
  98233. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  98234. /**
  98235. * Error
  98236. */
  98237. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  98238. })(AssetTaskState || (AssetTaskState = {}));
  98239. /**
  98240. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  98241. */
  98242. var AbstractAssetTask = /** @class */ (function () {
  98243. /**
  98244. * Creates a new AssetsManager
  98245. * @param name defines the name of the task
  98246. */
  98247. function AbstractAssetTask(
  98248. /**
  98249. * Task name
  98250. */ name) {
  98251. this.name = name;
  98252. this._isCompleted = false;
  98253. this._taskState = AssetTaskState.INIT;
  98254. }
  98255. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  98256. /**
  98257. * Get if the task is completed
  98258. */
  98259. get: function () {
  98260. return this._isCompleted;
  98261. },
  98262. enumerable: true,
  98263. configurable: true
  98264. });
  98265. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  98266. /**
  98267. * Gets the current state of the task
  98268. */
  98269. get: function () {
  98270. return this._taskState;
  98271. },
  98272. enumerable: true,
  98273. configurable: true
  98274. });
  98275. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  98276. /**
  98277. * Gets the current error object (if task is in error)
  98278. */
  98279. get: function () {
  98280. return this._errorObject;
  98281. },
  98282. enumerable: true,
  98283. configurable: true
  98284. });
  98285. /**
  98286. * Internal only
  98287. * @hidden
  98288. */
  98289. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  98290. if (this._errorObject) {
  98291. return;
  98292. }
  98293. this._errorObject = {
  98294. message: message,
  98295. exception: exception
  98296. };
  98297. };
  98298. /**
  98299. * Execute the current task
  98300. * @param scene defines the scene where you want your assets to be loaded
  98301. * @param onSuccess is a callback called when the task is successfully executed
  98302. * @param onError is a callback called if an error occurs
  98303. */
  98304. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  98305. var _this = this;
  98306. this._taskState = AssetTaskState.RUNNING;
  98307. this.runTask(scene, function () {
  98308. _this.onDoneCallback(onSuccess, onError);
  98309. }, function (msg, exception) {
  98310. _this.onErrorCallback(onError, msg, exception);
  98311. });
  98312. };
  98313. /**
  98314. * Execute the current task
  98315. * @param scene defines the scene where you want your assets to be loaded
  98316. * @param onSuccess is a callback called when the task is successfully executed
  98317. * @param onError is a callback called if an error occurs
  98318. */
  98319. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  98320. throw new Error("runTask is not implemented");
  98321. };
  98322. /**
  98323. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  98324. * This can be used with failed tasks that have the reason for failure fixed.
  98325. */
  98326. AbstractAssetTask.prototype.reset = function () {
  98327. this._taskState = AssetTaskState.INIT;
  98328. };
  98329. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  98330. this._taskState = AssetTaskState.ERROR;
  98331. this._errorObject = {
  98332. message: message,
  98333. exception: exception
  98334. };
  98335. if (this.onError) {
  98336. this.onError(this, message, exception);
  98337. }
  98338. onError();
  98339. };
  98340. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  98341. try {
  98342. this._taskState = AssetTaskState.DONE;
  98343. this._isCompleted = true;
  98344. if (this.onSuccess) {
  98345. this.onSuccess(this);
  98346. }
  98347. onSuccess();
  98348. }
  98349. catch (e) {
  98350. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  98351. }
  98352. };
  98353. return AbstractAssetTask;
  98354. }());
  98355. /**
  98356. * Class used to share progress information about assets loading
  98357. */
  98358. var AssetsProgressEvent = /** @class */ (function () {
  98359. /**
  98360. * Creates a AssetsProgressEvent
  98361. * @param remainingCount defines the number of remaining tasks to process
  98362. * @param totalCount defines the total number of tasks
  98363. * @param task defines the task that was just processed
  98364. */
  98365. function AssetsProgressEvent(remainingCount, totalCount, task) {
  98366. this.remainingCount = remainingCount;
  98367. this.totalCount = totalCount;
  98368. this.task = task;
  98369. }
  98370. return AssetsProgressEvent;
  98371. }());
  98372. /**
  98373. * Define a task used by AssetsManager to load meshes
  98374. */
  98375. var MeshAssetTask = /** @class */ (function (_super) {
  98376. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  98377. /**
  98378. * Creates a new MeshAssetTask
  98379. * @param name defines the name of the task
  98380. * @param meshesNames defines the list of mesh's names you want to load
  98381. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  98382. * @param sceneFilename defines the filename of the scene to load from
  98383. */
  98384. function MeshAssetTask(
  98385. /**
  98386. * Defines the name of the task
  98387. */
  98388. name,
  98389. /**
  98390. * Defines the list of mesh's names you want to load
  98391. */
  98392. meshesNames,
  98393. /**
  98394. * Defines the root url to use as a base to load your meshes and associated resources
  98395. */
  98396. rootUrl,
  98397. /**
  98398. * Defines the filename of the scene to load from
  98399. */
  98400. sceneFilename) {
  98401. var _this = _super.call(this, name) || this;
  98402. _this.name = name;
  98403. _this.meshesNames = meshesNames;
  98404. _this.rootUrl = rootUrl;
  98405. _this.sceneFilename = sceneFilename;
  98406. return _this;
  98407. }
  98408. /**
  98409. * Execute the current task
  98410. * @param scene defines the scene where you want your assets to be loaded
  98411. * @param onSuccess is a callback called when the task is successfully executed
  98412. * @param onError is a callback called if an error occurs
  98413. */
  98414. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  98415. var _this = this;
  98416. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  98417. _this.loadedMeshes = meshes;
  98418. _this.loadedParticleSystems = particleSystems;
  98419. _this.loadedSkeletons = skeletons;
  98420. _this.loadedAnimationGroups = animationGroups;
  98421. onSuccess();
  98422. }, null, function (scene, message, exception) {
  98423. onError(message, exception);
  98424. });
  98425. };
  98426. return MeshAssetTask;
  98427. }(AbstractAssetTask));
  98428. /**
  98429. * Define a task used by AssetsManager to load text content
  98430. */
  98431. var TextFileAssetTask = /** @class */ (function (_super) {
  98432. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  98433. /**
  98434. * Creates a new TextFileAssetTask object
  98435. * @param name defines the name of the task
  98436. * @param url defines the location of the file to load
  98437. */
  98438. function TextFileAssetTask(
  98439. /**
  98440. * Defines the name of the task
  98441. */
  98442. name,
  98443. /**
  98444. * Defines the location of the file to load
  98445. */
  98446. url) {
  98447. var _this = _super.call(this, name) || this;
  98448. _this.name = name;
  98449. _this.url = url;
  98450. return _this;
  98451. }
  98452. /**
  98453. * Execute the current task
  98454. * @param scene defines the scene where you want your assets to be loaded
  98455. * @param onSuccess is a callback called when the task is successfully executed
  98456. * @param onError is a callback called if an error occurs
  98457. */
  98458. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  98459. var _this = this;
  98460. scene._loadFile(this.url, function (data) {
  98461. _this.text = data;
  98462. onSuccess();
  98463. }, undefined, false, false, function (request, exception) {
  98464. if (request) {
  98465. onError(request.status + " " + request.statusText, exception);
  98466. }
  98467. });
  98468. };
  98469. return TextFileAssetTask;
  98470. }(AbstractAssetTask));
  98471. /**
  98472. * Define a task used by AssetsManager to load binary data
  98473. */
  98474. var BinaryFileAssetTask = /** @class */ (function (_super) {
  98475. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  98476. /**
  98477. * Creates a new BinaryFileAssetTask object
  98478. * @param name defines the name of the new task
  98479. * @param url defines the location of the file to load
  98480. */
  98481. function BinaryFileAssetTask(
  98482. /**
  98483. * Defines the name of the task
  98484. */
  98485. name,
  98486. /**
  98487. * Defines the location of the file to load
  98488. */
  98489. url) {
  98490. var _this = _super.call(this, name) || this;
  98491. _this.name = name;
  98492. _this.url = url;
  98493. return _this;
  98494. }
  98495. /**
  98496. * Execute the current task
  98497. * @param scene defines the scene where you want your assets to be loaded
  98498. * @param onSuccess is a callback called when the task is successfully executed
  98499. * @param onError is a callback called if an error occurs
  98500. */
  98501. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  98502. var _this = this;
  98503. scene._loadFile(this.url, function (data) {
  98504. _this.data = data;
  98505. onSuccess();
  98506. }, undefined, true, true, function (request, exception) {
  98507. if (request) {
  98508. onError(request.status + " " + request.statusText, exception);
  98509. }
  98510. });
  98511. };
  98512. return BinaryFileAssetTask;
  98513. }(AbstractAssetTask));
  98514. /**
  98515. * Define a task used by AssetsManager to load images
  98516. */
  98517. var ImageAssetTask = /** @class */ (function (_super) {
  98518. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  98519. /**
  98520. * Creates a new ImageAssetTask
  98521. * @param name defines the name of the task
  98522. * @param url defines the location of the image to load
  98523. */
  98524. function ImageAssetTask(
  98525. /**
  98526. * Defines the name of the task
  98527. */
  98528. name,
  98529. /**
  98530. * Defines the location of the image to load
  98531. */
  98532. url) {
  98533. var _this = _super.call(this, name) || this;
  98534. _this.name = name;
  98535. _this.url = url;
  98536. return _this;
  98537. }
  98538. /**
  98539. * Execute the current task
  98540. * @param scene defines the scene where you want your assets to be loaded
  98541. * @param onSuccess is a callback called when the task is successfully executed
  98542. * @param onError is a callback called if an error occurs
  98543. */
  98544. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  98545. var _this = this;
  98546. var img = new Image();
  98547. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  98548. img.onload = function () {
  98549. _this.image = img;
  98550. onSuccess();
  98551. };
  98552. img.onerror = function (err) {
  98553. onError("Error loading image", err);
  98554. };
  98555. img.src = this.url;
  98556. };
  98557. return ImageAssetTask;
  98558. }(AbstractAssetTask));
  98559. /**
  98560. * Define a task used by AssetsManager to load 2D textures
  98561. */
  98562. var TextureAssetTask = /** @class */ (function (_super) {
  98563. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  98564. /**
  98565. * Creates a new TextureAssetTask object
  98566. * @param name defines the name of the task
  98567. * @param url defines the location of the file to load
  98568. * @param noMipmap defines if mipmap should not be generated (default is false)
  98569. * @param invertY defines if texture must be inverted on Y axis (default is false)
  98570. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  98571. */
  98572. function TextureAssetTask(
  98573. /**
  98574. * Defines the name of the task
  98575. */
  98576. name,
  98577. /**
  98578. * Defines the location of the file to load
  98579. */
  98580. url,
  98581. /**
  98582. * Defines if mipmap should not be generated (default is false)
  98583. */
  98584. noMipmap,
  98585. /**
  98586. * Defines if texture must be inverted on Y axis (default is false)
  98587. */
  98588. invertY,
  98589. /**
  98590. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  98591. */
  98592. samplingMode) {
  98593. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  98594. var _this = _super.call(this, name) || this;
  98595. _this.name = name;
  98596. _this.url = url;
  98597. _this.noMipmap = noMipmap;
  98598. _this.invertY = invertY;
  98599. _this.samplingMode = samplingMode;
  98600. return _this;
  98601. }
  98602. /**
  98603. * Execute the current task
  98604. * @param scene defines the scene where you want your assets to be loaded
  98605. * @param onSuccess is a callback called when the task is successfully executed
  98606. * @param onError is a callback called if an error occurs
  98607. */
  98608. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  98609. var onload = function () {
  98610. onSuccess();
  98611. };
  98612. var onerror = function (message, exception) {
  98613. onError(message, exception);
  98614. };
  98615. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  98616. };
  98617. return TextureAssetTask;
  98618. }(AbstractAssetTask));
  98619. /**
  98620. * Define a task used by AssetsManager to load cube textures
  98621. */
  98622. var CubeTextureAssetTask = /** @class */ (function (_super) {
  98623. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  98624. /**
  98625. * Creates a new CubeTextureAssetTask
  98626. * @param name defines the name of the task
  98627. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  98628. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  98629. * @param noMipmap defines if mipmaps should not be generated (default is false)
  98630. * @param files defines the explicit list of files (undefined by default)
  98631. */
  98632. function CubeTextureAssetTask(
  98633. /**
  98634. * Defines the name of the task
  98635. */
  98636. name,
  98637. /**
  98638. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  98639. */
  98640. url,
  98641. /**
  98642. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  98643. */
  98644. extensions,
  98645. /**
  98646. * Defines if mipmaps should not be generated (default is false)
  98647. */
  98648. noMipmap,
  98649. /**
  98650. * Defines the explicit list of files (undefined by default)
  98651. */
  98652. files) {
  98653. var _this = _super.call(this, name) || this;
  98654. _this.name = name;
  98655. _this.url = url;
  98656. _this.extensions = extensions;
  98657. _this.noMipmap = noMipmap;
  98658. _this.files = files;
  98659. return _this;
  98660. }
  98661. /**
  98662. * Execute the current task
  98663. * @param scene defines the scene where you want your assets to be loaded
  98664. * @param onSuccess is a callback called when the task is successfully executed
  98665. * @param onError is a callback called if an error occurs
  98666. */
  98667. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  98668. var onload = function () {
  98669. onSuccess();
  98670. };
  98671. var onerror = function (message, exception) {
  98672. onError(message, exception);
  98673. };
  98674. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  98675. };
  98676. return CubeTextureAssetTask;
  98677. }(AbstractAssetTask));
  98678. /**
  98679. * Define a task used by AssetsManager to load HDR cube textures
  98680. */
  98681. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  98682. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  98683. /**
  98684. * Creates a new HDRCubeTextureAssetTask object
  98685. * @param name defines the name of the task
  98686. * @param url defines the location of the file to load
  98687. * @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.
  98688. * @param noMipmap defines if mipmaps should not be generated (default is false)
  98689. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  98690. * @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)
  98691. * @param reserved Internal use only
  98692. */
  98693. function HDRCubeTextureAssetTask(
  98694. /**
  98695. * Defines the name of the task
  98696. */
  98697. name,
  98698. /**
  98699. * Defines the location of the file to load
  98700. */
  98701. url,
  98702. /**
  98703. * Defines the desired size (the more it increases the longer the generation will be)
  98704. */
  98705. size,
  98706. /**
  98707. * Defines if mipmaps should not be generated (default is false)
  98708. */
  98709. noMipmap,
  98710. /**
  98711. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  98712. */
  98713. generateHarmonics,
  98714. /**
  98715. * 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)
  98716. */
  98717. gammaSpace,
  98718. /**
  98719. * Internal Use Only
  98720. */
  98721. reserved) {
  98722. if (noMipmap === void 0) { noMipmap = false; }
  98723. if (generateHarmonics === void 0) { generateHarmonics = true; }
  98724. if (gammaSpace === void 0) { gammaSpace = false; }
  98725. if (reserved === void 0) { reserved = false; }
  98726. var _this = _super.call(this, name) || this;
  98727. _this.name = name;
  98728. _this.url = url;
  98729. _this.size = size;
  98730. _this.noMipmap = noMipmap;
  98731. _this.generateHarmonics = generateHarmonics;
  98732. _this.gammaSpace = gammaSpace;
  98733. _this.reserved = reserved;
  98734. return _this;
  98735. }
  98736. /**
  98737. * Execute the current task
  98738. * @param scene defines the scene where you want your assets to be loaded
  98739. * @param onSuccess is a callback called when the task is successfully executed
  98740. * @param onError is a callback called if an error occurs
  98741. */
  98742. HDRCubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  98743. var onload = function () {
  98744. onSuccess();
  98745. };
  98746. var onerror = function (message, exception) {
  98747. onError(message, exception);
  98748. };
  98749. 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);
  98750. };
  98751. return HDRCubeTextureAssetTask;
  98752. }(AbstractAssetTask));
  98753. /**
  98754. * Define a task used by AssetsManager to load Equirectangular cube textures
  98755. */
  98756. var EquiRectangularCubeTextureAssetTask = /** @class */ (function (_super) {
  98757. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](EquiRectangularCubeTextureAssetTask, _super);
  98758. /**
  98759. * Creates a new EquiRectangularCubeTextureAssetTask object
  98760. * @param name defines the name of the task
  98761. * @param url defines the location of the file to load
  98762. * @param size defines the desired size (the more it increases the longer the generation will be)
  98763. * If the size is omitted this implies you are using a preprocessed cubemap.
  98764. * @param noMipmap defines if mipmaps should not be generated (default is false)
  98765. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  98766. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  98767. * (default is true)
  98768. */
  98769. function EquiRectangularCubeTextureAssetTask(
  98770. /**
  98771. * Defines the name of the task
  98772. */
  98773. name,
  98774. /**
  98775. * Defines the location of the file to load
  98776. */
  98777. url,
  98778. /**
  98779. * Defines the desired size (the more it increases the longer the generation will be)
  98780. */
  98781. size,
  98782. /**
  98783. * Defines if mipmaps should not be generated (default is false)
  98784. */
  98785. noMipmap,
  98786. /**
  98787. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  98788. * but the standard material would require them in Gamma space) (default is true)
  98789. */
  98790. gammaSpace) {
  98791. if (noMipmap === void 0) { noMipmap = false; }
  98792. if (gammaSpace === void 0) { gammaSpace = true; }
  98793. var _this = _super.call(this, name) || this;
  98794. _this.name = name;
  98795. _this.url = url;
  98796. _this.size = size;
  98797. _this.noMipmap = noMipmap;
  98798. _this.gammaSpace = gammaSpace;
  98799. return _this;
  98800. }
  98801. /**
  98802. * Execute the current task
  98803. * @param scene defines the scene where you want your assets to be loaded
  98804. * @param onSuccess is a callback called when the task is successfully executed
  98805. * @param onError is a callback called if an error occurs
  98806. */
  98807. EquiRectangularCubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  98808. var onload = function () {
  98809. onSuccess();
  98810. };
  98811. var onerror = function (message, exception) {
  98812. onError(message, exception);
  98813. };
  98814. this.texture = new _Materials_Textures_equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_7__["EquiRectangularCubeTexture"](this.url, scene, this.size, this.noMipmap, this.gammaSpace, onload, onerror);
  98815. };
  98816. return EquiRectangularCubeTextureAssetTask;
  98817. }(AbstractAssetTask));
  98818. /**
  98819. * This class can be used to easily import assets into a scene
  98820. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  98821. */
  98822. var AssetsManager = /** @class */ (function () {
  98823. /**
  98824. * Creates a new AssetsManager
  98825. * @param scene defines the scene to work on
  98826. */
  98827. function AssetsManager(scene) {
  98828. this._isLoading = false;
  98829. this._tasks = new Array();
  98830. this._waitingTasksCount = 0;
  98831. this._totalTasksCount = 0;
  98832. /**
  98833. * Observable called when all tasks are processed
  98834. */
  98835. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  98836. /**
  98837. * Observable called when a task had an error
  98838. */
  98839. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  98840. /**
  98841. * Observable called when all tasks were executed
  98842. */
  98843. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  98844. /**
  98845. * Observable called when a task is done (whatever the result is)
  98846. */
  98847. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  98848. /**
  98849. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  98850. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98851. */
  98852. this.useDefaultLoadingScreen = true;
  98853. this._scene = scene;
  98854. }
  98855. /**
  98856. * Add a MeshAssetTask to the list of active tasks
  98857. * @param taskName defines the name of the new task
  98858. * @param meshesNames defines the name of meshes to load
  98859. * @param rootUrl defines the root url to use to locate files
  98860. * @param sceneFilename defines the filename of the scene file
  98861. * @returns a new MeshAssetTask object
  98862. */
  98863. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  98864. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  98865. this._tasks.push(task);
  98866. return task;
  98867. };
  98868. /**
  98869. * Add a TextFileAssetTask to the list of active tasks
  98870. * @param taskName defines the name of the new task
  98871. * @param url defines the url of the file to load
  98872. * @returns a new TextFileAssetTask object
  98873. */
  98874. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  98875. var task = new TextFileAssetTask(taskName, url);
  98876. this._tasks.push(task);
  98877. return task;
  98878. };
  98879. /**
  98880. * Add a BinaryFileAssetTask to the list of active tasks
  98881. * @param taskName defines the name of the new task
  98882. * @param url defines the url of the file to load
  98883. * @returns a new BinaryFileAssetTask object
  98884. */
  98885. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  98886. var task = new BinaryFileAssetTask(taskName, url);
  98887. this._tasks.push(task);
  98888. return task;
  98889. };
  98890. /**
  98891. * Add a ImageAssetTask to the list of active tasks
  98892. * @param taskName defines the name of the new task
  98893. * @param url defines the url of the file to load
  98894. * @returns a new ImageAssetTask object
  98895. */
  98896. AssetsManager.prototype.addImageTask = function (taskName, url) {
  98897. var task = new ImageAssetTask(taskName, url);
  98898. this._tasks.push(task);
  98899. return task;
  98900. };
  98901. /**
  98902. * Add a TextureAssetTask to the list of active tasks
  98903. * @param taskName defines the name of the new task
  98904. * @param url defines the url of the file to load
  98905. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  98906. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  98907. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  98908. * @returns a new TextureAssetTask object
  98909. */
  98910. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  98911. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  98912. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  98913. this._tasks.push(task);
  98914. return task;
  98915. };
  98916. /**
  98917. * Add a CubeTextureAssetTask to the list of active tasks
  98918. * @param taskName defines the name of the new task
  98919. * @param url defines the url of the file to load
  98920. * @param extensions defines the extension to use to load the cube map (can be null)
  98921. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  98922. * @param files defines the list of files to load (can be null)
  98923. * @returns a new CubeTextureAssetTask object
  98924. */
  98925. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  98926. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  98927. this._tasks.push(task);
  98928. return task;
  98929. };
  98930. /**
  98931. *
  98932. * Add a HDRCubeTextureAssetTask to the list of active tasks
  98933. * @param taskName defines the name of the new task
  98934. * @param url defines the url of the file to load
  98935. * @param size defines the size you want for the cubemap (can be null)
  98936. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  98937. * @param generateHarmonics defines if you want to automatically generate (true by default)
  98938. * @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)
  98939. * @param reserved Internal use only
  98940. * @returns a new HDRCubeTextureAssetTask object
  98941. */
  98942. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  98943. if (noMipmap === void 0) { noMipmap = false; }
  98944. if (generateHarmonics === void 0) { generateHarmonics = true; }
  98945. if (gammaSpace === void 0) { gammaSpace = false; }
  98946. if (reserved === void 0) { reserved = false; }
  98947. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  98948. this._tasks.push(task);
  98949. return task;
  98950. };
  98951. /**
  98952. *
  98953. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  98954. * @param taskName defines the name of the new task
  98955. * @param url defines the url of the file to load
  98956. * @param size defines the size you want for the cubemap (can be null)
  98957. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  98958. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  98959. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  98960. * @returns a new EquiRectangularCubeTextureAssetTask object
  98961. */
  98962. AssetsManager.prototype.addEquiRectangularCubeTextureAssetTask = function (taskName, url, size, noMipmap, gammaSpace) {
  98963. if (noMipmap === void 0) { noMipmap = false; }
  98964. if (gammaSpace === void 0) { gammaSpace = true; }
  98965. var task = new EquiRectangularCubeTextureAssetTask(taskName, url, size, noMipmap, gammaSpace);
  98966. this._tasks.push(task);
  98967. return task;
  98968. };
  98969. /**
  98970. * Remove a task from the assets manager.
  98971. * @param task the task to remove
  98972. */
  98973. AssetsManager.prototype.removeTask = function (task) {
  98974. var index = this._tasks.indexOf(task);
  98975. if (index > -1) {
  98976. this._tasks.splice(index, 1);
  98977. }
  98978. };
  98979. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  98980. this._waitingTasksCount--;
  98981. try {
  98982. if (this.onProgress) {
  98983. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  98984. }
  98985. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  98986. }
  98987. catch (e) {
  98988. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("Error running progress callbacks.");
  98989. console.log(e);
  98990. }
  98991. if (this._waitingTasksCount === 0) {
  98992. try {
  98993. if (this.onFinish) {
  98994. this.onFinish(this._tasks);
  98995. }
  98996. // Let's remove successfull tasks
  98997. var currentTasks = this._tasks.slice();
  98998. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  98999. var task = currentTasks_1[_i];
  99000. if (task.taskState === AssetTaskState.DONE) {
  99001. var index = this._tasks.indexOf(task);
  99002. if (index > -1) {
  99003. this._tasks.splice(index, 1);
  99004. }
  99005. }
  99006. }
  99007. this.onTasksDoneObservable.notifyObservers(this._tasks);
  99008. }
  99009. catch (e) {
  99010. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("Error running tasks-done callbacks.");
  99011. console.log(e);
  99012. }
  99013. this._isLoading = false;
  99014. this._scene.getEngine().hideLoadingUI();
  99015. }
  99016. };
  99017. AssetsManager.prototype._runTask = function (task) {
  99018. var _this = this;
  99019. var done = function () {
  99020. try {
  99021. if (_this.onTaskSuccess) {
  99022. _this.onTaskSuccess(task);
  99023. }
  99024. _this.onTaskSuccessObservable.notifyObservers(task);
  99025. _this._decreaseWaitingTasksCount(task);
  99026. }
  99027. catch (e) {
  99028. error("Error executing task success callbacks", e);
  99029. }
  99030. };
  99031. var error = function (message, exception) {
  99032. task._setErrorObject(message, exception);
  99033. if (_this.onTaskError) {
  99034. _this.onTaskError(task);
  99035. }
  99036. _this.onTaskErrorObservable.notifyObservers(task);
  99037. _this._decreaseWaitingTasksCount(task);
  99038. };
  99039. task.run(this._scene, done, error);
  99040. };
  99041. /**
  99042. * Reset the AssetsManager and remove all tasks
  99043. * @return the current instance of the AssetsManager
  99044. */
  99045. AssetsManager.prototype.reset = function () {
  99046. this._isLoading = false;
  99047. this._tasks = new Array();
  99048. return this;
  99049. };
  99050. /**
  99051. * Start the loading process
  99052. * @return the current instance of the AssetsManager
  99053. */
  99054. AssetsManager.prototype.load = function () {
  99055. if (this._isLoading) {
  99056. return this;
  99057. }
  99058. this._isLoading = true;
  99059. this._waitingTasksCount = this._tasks.length;
  99060. this._totalTasksCount = this._tasks.length;
  99061. if (this._waitingTasksCount === 0) {
  99062. this._isLoading = false;
  99063. if (this.onFinish) {
  99064. this.onFinish(this._tasks);
  99065. }
  99066. this.onTasksDoneObservable.notifyObservers(this._tasks);
  99067. return this;
  99068. }
  99069. if (this.useDefaultLoadingScreen) {
  99070. this._scene.getEngine().displayLoadingUI();
  99071. }
  99072. for (var index = 0; index < this._tasks.length; index++) {
  99073. var task = this._tasks[index];
  99074. if (task.taskState === AssetTaskState.INIT) {
  99075. this._runTask(task);
  99076. }
  99077. }
  99078. return this;
  99079. };
  99080. /**
  99081. * Start the loading process as an async operation
  99082. * @return a promise returning the list of failed tasks
  99083. */
  99084. AssetsManager.prototype.loadAsync = function () {
  99085. var _this = this;
  99086. return new Promise(function (resolve, reject) {
  99087. _this.onTasksDoneObservable.addOnce(function (remainingTasks) {
  99088. if (remainingTasks && remainingTasks.length) {
  99089. reject(remainingTasks);
  99090. }
  99091. else {
  99092. resolve();
  99093. }
  99094. });
  99095. });
  99096. };
  99097. return AssetsManager;
  99098. }());
  99099. /***/ }),
  99100. /***/ "./Misc/brdfTextureTools.ts":
  99101. /*!**********************************!*\
  99102. !*** ./Misc/brdfTextureTools.ts ***!
  99103. \**********************************/
  99104. /*! exports provided: BRDFTextureTools */
  99105. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99106. "use strict";
  99107. __webpack_require__.r(__webpack_exports__);
  99108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BRDFTextureTools", function() { return BRDFTextureTools; });
  99109. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  99110. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  99111. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  99112. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  99113. /**
  99114. * Class used to host texture specific utilities
  99115. */
  99116. var BRDFTextureTools = /** @class */ (function () {
  99117. function BRDFTextureTools() {
  99118. }
  99119. /**
  99120. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  99121. * @param texture the texture to expand.
  99122. */
  99123. BRDFTextureTools._ExpandDefaultBRDFTexture = function (texture) {
  99124. // Gets everything ready.
  99125. var engine = texture.getEngine();
  99126. var caps = engine.getCaps();
  99127. var expandTexture = false;
  99128. // If half float available we can uncompress the texture
  99129. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  99130. expandTexture = true;
  99131. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_HALF_FLOAT;
  99132. }
  99133. // If full float available we can uncompress the texture
  99134. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  99135. expandTexture = true;
  99136. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT;
  99137. }
  99138. // Expand the texture if possible
  99139. if (expandTexture) {
  99140. // Do not use during decode.
  99141. texture.isReady = false;
  99142. // Simply run through the decode PP.
  99143. 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);
  99144. texture._isRGBD = false;
  99145. texture.invertY = false;
  99146. // Hold the output of the decoding.
  99147. var expandedTexture_1 = engine.createRenderTargetTexture(texture.width, {
  99148. generateDepthBuffer: false,
  99149. generateMipMaps: false,
  99150. generateStencilBuffer: false,
  99151. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  99152. type: texture.type,
  99153. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA
  99154. });
  99155. rgbdPostProcess_1.getEffect().executeWhenCompiled(function () {
  99156. // PP Render Pass
  99157. rgbdPostProcess_1.onApply = function (effect) {
  99158. effect._bindTexture("textureSampler", texture);
  99159. effect.setFloat2("scale", 1, 1);
  99160. };
  99161. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess_1], expandedTexture_1, true);
  99162. // Cleanup
  99163. engine.restoreDefaultFramebuffer();
  99164. engine._releaseTexture(texture);
  99165. engine._releaseFramebufferObjects(expandedTexture_1);
  99166. if (rgbdPostProcess_1) {
  99167. rgbdPostProcess_1.dispose();
  99168. }
  99169. // Internal Swap
  99170. expandedTexture_1._swapAndDie(texture);
  99171. // Ready to get rolling again.
  99172. texture.isReady = true;
  99173. });
  99174. }
  99175. };
  99176. /**
  99177. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  99178. * @param scene defines the hosting scene
  99179. * @returns the environment BRDF texture
  99180. */
  99181. BRDFTextureTools.GetEnvironmentBRDFTexture = function (scene) {
  99182. var _this = this;
  99183. if (!scene.environmentBRDFTexture) {
  99184. // Forces Delayed Texture Loading to prevent undefined error whilst setting RGBD values.
  99185. var useDelayedTextureLoading = scene.useDelayedTextureLoading;
  99186. scene.useDelayedTextureLoading = false;
  99187. 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);
  99188. texture._texture._isRGBD = true;
  99189. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  99190. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  99191. scene.environmentBRDFTexture = texture;
  99192. scene.useDelayedTextureLoading = useDelayedTextureLoading;
  99193. texture.onLoadObservable.addOnce(function () {
  99194. _this._ExpandDefaultBRDFTexture(texture._texture);
  99195. });
  99196. }
  99197. return scene.environmentBRDFTexture;
  99198. };
  99199. 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==";
  99200. return BRDFTextureTools;
  99201. }());
  99202. /***/ }),
  99203. /***/ "./Misc/dds.ts":
  99204. /*!*********************!*\
  99205. !*** ./Misc/dds.ts ***!
  99206. \*********************/
  99207. /*! exports provided: DDSTools */
  99208. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99209. "use strict";
  99210. __webpack_require__.r(__webpack_exports__);
  99211. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  99212. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  99213. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  99214. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  99215. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  99216. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  99217. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  99218. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  99219. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  99220. /* harmony import */ var _Engines_Extensions_engine_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/Extensions/engine.cubeTexture */ "./Engines/Extensions/engine.cubeTexture.ts");
  99221. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  99222. // All values and structures referenced from:
  99223. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  99224. var DDS_MAGIC = 0x20534444;
  99225. var
  99226. //DDSD_CAPS = 0x1,
  99227. //DDSD_HEIGHT = 0x2,
  99228. //DDSD_WIDTH = 0x4,
  99229. //DDSD_PITCH = 0x8,
  99230. //DDSD_PIXELFORMAT = 0x1000,
  99231. DDSD_MIPMAPCOUNT = 0x20000;
  99232. //DDSD_LINEARSIZE = 0x80000,
  99233. //DDSD_DEPTH = 0x800000;
  99234. // var DDSCAPS_COMPLEX = 0x8,
  99235. // DDSCAPS_MIPMAP = 0x400000,
  99236. // DDSCAPS_TEXTURE = 0x1000;
  99237. var DDSCAPS2_CUBEMAP = 0x200;
  99238. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  99239. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  99240. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  99241. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  99242. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  99243. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  99244. // DDSCAPS2_VOLUME = 0x200000;
  99245. var
  99246. //DDPF_ALPHAPIXELS = 0x1,
  99247. //DDPF_ALPHA = 0x2,
  99248. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  99249. //DDPF_YUV = 0x200,
  99250. DDPF_LUMINANCE = 0x20000;
  99251. function FourCCToInt32(value) {
  99252. return value.charCodeAt(0) +
  99253. (value.charCodeAt(1) << 8) +
  99254. (value.charCodeAt(2) << 16) +
  99255. (value.charCodeAt(3) << 24);
  99256. }
  99257. function Int32ToFourCC(value) {
  99258. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  99259. }
  99260. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  99261. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  99262. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  99263. var FOURCC_DX10 = FourCCToInt32("DX10");
  99264. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  99265. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  99266. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  99267. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  99268. var headerLengthInt = 31; // The header length in 32 bit ints
  99269. // Offsets into the header array
  99270. var off_magic = 0;
  99271. var off_size = 1;
  99272. var off_flags = 2;
  99273. var off_height = 3;
  99274. var off_width = 4;
  99275. var off_mipmapCount = 7;
  99276. var off_pfFlags = 20;
  99277. var off_pfFourCC = 21;
  99278. var off_RGBbpp = 22;
  99279. var off_RMask = 23;
  99280. var off_GMask = 24;
  99281. var off_BMask = 25;
  99282. var off_AMask = 26;
  99283. // var off_caps1 = 27;
  99284. var off_caps2 = 28;
  99285. // var off_caps3 = 29;
  99286. // var off_caps4 = 30;
  99287. var off_dxgiFormat = 32;
  99288. /**
  99289. * Class used to provide DDS decompression tools
  99290. */
  99291. var DDSTools = /** @class */ (function () {
  99292. function DDSTools() {
  99293. }
  99294. /**
  99295. * Gets DDS information from an array buffer
  99296. * @param arrayBuffer defines the array buffer to read data from
  99297. * @returns the DDS information
  99298. */
  99299. DDSTools.GetDDSInfo = function (arrayBuffer) {
  99300. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  99301. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  99302. var mipmapCount = 1;
  99303. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  99304. mipmapCount = Math.max(1, header[off_mipmapCount]);
  99305. }
  99306. var fourCC = header[off_pfFourCC];
  99307. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  99308. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  99309. switch (fourCC) {
  99310. case FOURCC_D3DFMT_R16G16B16A16F:
  99311. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  99312. break;
  99313. case FOURCC_D3DFMT_R32G32B32A32F:
  99314. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  99315. break;
  99316. case FOURCC_DX10:
  99317. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  99318. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  99319. break;
  99320. }
  99321. }
  99322. return {
  99323. width: header[off_width],
  99324. height: header[off_height],
  99325. mipmapCount: mipmapCount,
  99326. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  99327. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  99328. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  99329. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  99330. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  99331. dxgiFormat: dxgiFormat,
  99332. textureType: textureType
  99333. };
  99334. };
  99335. DDSTools._ToHalfFloat = function (value) {
  99336. if (!DDSTools._FloatView) {
  99337. DDSTools._FloatView = new Float32Array(1);
  99338. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  99339. }
  99340. DDSTools._FloatView[0] = value;
  99341. var x = DDSTools._Int32View[0];
  99342. var bits = (x >> 16) & 0x8000; /* Get the sign */
  99343. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  99344. var e = (x >> 23) & 0xff; /* Using int is faster here */
  99345. /* If zero, or denormal, or exponent underflows too much for a denormal
  99346. * half, return signed zero. */
  99347. if (e < 103) {
  99348. return bits;
  99349. }
  99350. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  99351. if (e > 142) {
  99352. bits |= 0x7c00;
  99353. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  99354. * not Inf, so make sure we set one mantissa bit too. */
  99355. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  99356. return bits;
  99357. }
  99358. /* If exponent underflows but not too much, return a denormal */
  99359. if (e < 113) {
  99360. m |= 0x0800;
  99361. /* Extra rounding may overflow and set mantissa to 0 and exponent
  99362. * to 1, which is OK. */
  99363. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  99364. return bits;
  99365. }
  99366. bits |= ((e - 112) << 10) | (m >> 1);
  99367. bits += m & 1;
  99368. return bits;
  99369. };
  99370. DDSTools._FromHalfFloat = function (value) {
  99371. var s = (value & 0x8000) >> 15;
  99372. var e = (value & 0x7C00) >> 10;
  99373. var f = value & 0x03FF;
  99374. if (e === 0) {
  99375. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  99376. }
  99377. else if (e == 0x1F) {
  99378. return f ? NaN : ((s ? -1 : 1) * Infinity);
  99379. }
  99380. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  99381. };
  99382. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  99383. var destArray = new Float32Array(dataLength);
  99384. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  99385. var index = 0;
  99386. for (var y = 0; y < height; y++) {
  99387. for (var x = 0; x < width; x++) {
  99388. var srcPos = (x + y * width) * 4;
  99389. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  99390. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  99391. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  99392. if (DDSTools.StoreLODInAlphaChannel) {
  99393. destArray[index + 3] = lod;
  99394. }
  99395. else {
  99396. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  99397. }
  99398. index += 4;
  99399. }
  99400. }
  99401. return destArray;
  99402. };
  99403. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  99404. if (DDSTools.StoreLODInAlphaChannel) {
  99405. var destArray = new Uint16Array(dataLength);
  99406. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  99407. var index = 0;
  99408. for (var y = 0; y < height; y++) {
  99409. for (var x = 0; x < width; x++) {
  99410. var srcPos = (x + y * width) * 4;
  99411. destArray[index] = srcData[srcPos];
  99412. destArray[index + 1] = srcData[srcPos + 1];
  99413. destArray[index + 2] = srcData[srcPos + 2];
  99414. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  99415. index += 4;
  99416. }
  99417. }
  99418. return destArray;
  99419. }
  99420. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  99421. };
  99422. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  99423. if (DDSTools.StoreLODInAlphaChannel) {
  99424. var destArray = new Float32Array(dataLength);
  99425. var srcData = new Float32Array(arrayBuffer, dataOffset);
  99426. var index = 0;
  99427. for (var y = 0; y < height; y++) {
  99428. for (var x = 0; x < width; x++) {
  99429. var srcPos = (x + y * width) * 4;
  99430. destArray[index] = srcData[srcPos];
  99431. destArray[index + 1] = srcData[srcPos + 1];
  99432. destArray[index + 2] = srcData[srcPos + 2];
  99433. destArray[index + 3] = lod;
  99434. index += 4;
  99435. }
  99436. }
  99437. return destArray;
  99438. }
  99439. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  99440. };
  99441. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  99442. var destArray = new Uint8Array(dataLength);
  99443. var srcData = new Float32Array(arrayBuffer, dataOffset);
  99444. var index = 0;
  99445. for (var y = 0; y < height; y++) {
  99446. for (var x = 0; x < width; x++) {
  99447. var srcPos = (x + y * width) * 4;
  99448. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  99449. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  99450. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  99451. if (DDSTools.StoreLODInAlphaChannel) {
  99452. destArray[index + 3] = lod;
  99453. }
  99454. else {
  99455. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  99456. }
  99457. index += 4;
  99458. }
  99459. }
  99460. return destArray;
  99461. };
  99462. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  99463. var destArray = new Uint8Array(dataLength);
  99464. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  99465. var index = 0;
  99466. for (var y = 0; y < height; y++) {
  99467. for (var x = 0; x < width; x++) {
  99468. var srcPos = (x + y * width) * 4;
  99469. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  99470. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  99471. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  99472. if (DDSTools.StoreLODInAlphaChannel) {
  99473. destArray[index + 3] = lod;
  99474. }
  99475. else {
  99476. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  99477. }
  99478. index += 4;
  99479. }
  99480. }
  99481. return destArray;
  99482. };
  99483. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  99484. var byteArray = new Uint8Array(dataLength);
  99485. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  99486. var index = 0;
  99487. for (var y = 0; y < height; y++) {
  99488. for (var x = 0; x < width; x++) {
  99489. var srcPos = (x + y * width) * 4;
  99490. byteArray[index] = srcData[srcPos + rOffset];
  99491. byteArray[index + 1] = srcData[srcPos + gOffset];
  99492. byteArray[index + 2] = srcData[srcPos + bOffset];
  99493. byteArray[index + 3] = srcData[srcPos + aOffset];
  99494. index += 4;
  99495. }
  99496. }
  99497. return byteArray;
  99498. };
  99499. DDSTools._ExtractLongWordOrder = function (value) {
  99500. if (value === 0 || value === 255 || value === -16777216) {
  99501. return 0;
  99502. }
  99503. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  99504. };
  99505. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  99506. var byteArray = new Uint8Array(dataLength);
  99507. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  99508. var index = 0;
  99509. for (var y = 0; y < height; y++) {
  99510. for (var x = 0; x < width; x++) {
  99511. var srcPos = (x + y * width) * 3;
  99512. byteArray[index] = srcData[srcPos + rOffset];
  99513. byteArray[index + 1] = srcData[srcPos + gOffset];
  99514. byteArray[index + 2] = srcData[srcPos + bOffset];
  99515. index += 3;
  99516. }
  99517. }
  99518. return byteArray;
  99519. };
  99520. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  99521. var byteArray = new Uint8Array(dataLength);
  99522. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  99523. var index = 0;
  99524. for (var y = 0; y < height; y++) {
  99525. for (var x = 0; x < width; x++) {
  99526. var srcPos = (x + y * width);
  99527. byteArray[index] = srcData[srcPos];
  99528. index++;
  99529. }
  99530. }
  99531. return byteArray;
  99532. };
  99533. /**
  99534. * Uploads DDS Levels to a Babylon Texture
  99535. * @hidden
  99536. */
  99537. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  99538. if (lodIndex === void 0) { lodIndex = -1; }
  99539. var sphericalPolynomialFaces = null;
  99540. if (info.sphericalPolynomial) {
  99541. sphericalPolynomialFaces = new Array();
  99542. }
  99543. var ext = engine.getCaps().s3tc;
  99544. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  99545. var fourCC, width, height, dataLength = 0, dataOffset;
  99546. var byteArray, mipmapCount, mip;
  99547. var internalCompressedFormat = 0;
  99548. var blockBytes = 1;
  99549. if (header[off_magic] !== DDS_MAGIC) {
  99550. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  99551. return;
  99552. }
  99553. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  99554. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  99555. return;
  99556. }
  99557. if (info.isCompressed && !ext) {
  99558. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  99559. return;
  99560. }
  99561. var bpp = header[off_RGBbpp];
  99562. dataOffset = header[off_size] + 4;
  99563. var computeFormats = false;
  99564. if (info.isFourCC) {
  99565. fourCC = header[off_pfFourCC];
  99566. switch (fourCC) {
  99567. case FOURCC_DXT1:
  99568. blockBytes = 8;
  99569. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  99570. break;
  99571. case FOURCC_DXT3:
  99572. blockBytes = 16;
  99573. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  99574. break;
  99575. case FOURCC_DXT5:
  99576. blockBytes = 16;
  99577. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  99578. break;
  99579. case FOURCC_D3DFMT_R16G16B16A16F:
  99580. computeFormats = true;
  99581. break;
  99582. case FOURCC_D3DFMT_R32G32B32A32F:
  99583. computeFormats = true;
  99584. break;
  99585. case FOURCC_DX10:
  99586. // There is an additionnal header so dataOffset need to be changed
  99587. dataOffset += 5 * 4; // 5 uints
  99588. var supported = false;
  99589. switch (info.dxgiFormat) {
  99590. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  99591. computeFormats = true;
  99592. supported = true;
  99593. break;
  99594. case DXGI_FORMAT_B8G8R8X8_UNORM:
  99595. info.isRGB = true;
  99596. info.isFourCC = false;
  99597. bpp = 32;
  99598. supported = true;
  99599. break;
  99600. }
  99601. if (supported) {
  99602. break;
  99603. }
  99604. default:
  99605. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  99606. return;
  99607. }
  99608. }
  99609. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  99610. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  99611. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  99612. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  99613. if (computeFormats) {
  99614. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  99615. }
  99616. mipmapCount = 1;
  99617. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  99618. mipmapCount = Math.max(1, header[off_mipmapCount]);
  99619. }
  99620. var startFace = currentFace || 0;
  99621. for (var face = startFace; face < faces; face++) {
  99622. width = header[off_width];
  99623. height = header[off_height];
  99624. for (mip = 0; mip < mipmapCount; ++mip) {
  99625. if (lodIndex === -1 || lodIndex === mip) {
  99626. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  99627. var i = (lodIndex === -1) ? mip : 0;
  99628. if (!info.isCompressed && info.isFourCC) {
  99629. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  99630. dataLength = width * height * 4;
  99631. var floatArray = null;
  99632. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  99633. if (bpp === 128) {
  99634. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  99635. if (sphericalPolynomialFaces && i == 0) {
  99636. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  99637. }
  99638. }
  99639. else if (bpp === 64) {
  99640. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  99641. if (sphericalPolynomialFaces && i == 0) {
  99642. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  99643. }
  99644. }
  99645. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  99646. }
  99647. else {
  99648. if (bpp === 128) {
  99649. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  99650. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  99651. if (sphericalPolynomialFaces && i == 0) {
  99652. sphericalPolynomialFaces.push(floatArray);
  99653. }
  99654. }
  99655. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  99656. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  99657. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  99658. if (sphericalPolynomialFaces && i == 0) {
  99659. sphericalPolynomialFaces.push(floatArray);
  99660. }
  99661. }
  99662. else { // 64
  99663. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  99664. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  99665. if (sphericalPolynomialFaces && i == 0) {
  99666. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  99667. }
  99668. }
  99669. }
  99670. if (floatArray) {
  99671. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  99672. }
  99673. }
  99674. else if (info.isRGB) {
  99675. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  99676. if (bpp === 24) {
  99677. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  99678. dataLength = width * height * 3;
  99679. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  99680. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  99681. }
  99682. else { // 32
  99683. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  99684. dataLength = width * height * 4;
  99685. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  99686. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  99687. }
  99688. }
  99689. else if (info.isLuminance) {
  99690. var unpackAlignment = engine._getUnpackAlignement();
  99691. var unpaddedRowSize = width;
  99692. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  99693. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  99694. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  99695. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  99696. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  99697. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  99698. }
  99699. else {
  99700. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  99701. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  99702. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  99703. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  99704. }
  99705. }
  99706. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  99707. width *= 0.5;
  99708. height *= 0.5;
  99709. width = Math.max(1.0, width);
  99710. height = Math.max(1.0, height);
  99711. }
  99712. if (currentFace !== undefined) {
  99713. // Loading a single face
  99714. break;
  99715. }
  99716. }
  99717. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  99718. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  99719. size: header[off_width],
  99720. right: sphericalPolynomialFaces[0],
  99721. left: sphericalPolynomialFaces[1],
  99722. up: sphericalPolynomialFaces[2],
  99723. down: sphericalPolynomialFaces[3],
  99724. front: sphericalPolynomialFaces[4],
  99725. back: sphericalPolynomialFaces[5],
  99726. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  99727. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  99728. gammaSpace: false,
  99729. });
  99730. }
  99731. else {
  99732. info.sphericalPolynomial = undefined;
  99733. }
  99734. };
  99735. /**
  99736. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  99737. */
  99738. DDSTools.StoreLODInAlphaChannel = false;
  99739. return DDSTools;
  99740. }());
  99741. /**
  99742. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  99743. * @param rootUrl defines the url where the file to load is located
  99744. * @param scene defines the current scene
  99745. * @param lodScale defines scale to apply to the mip map selection
  99746. * @param lodOffset defines offset to apply to the mip map selection
  99747. * @param onLoad defines an optional callback raised when the texture is loaded
  99748. * @param onError defines an optional callback raised if there is an issue to load the texture
  99749. * @param format defines the format of the data
  99750. * @param forcedExtension defines the extension to use to pick the right loader
  99751. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  99752. * @returns the cube texture as an InternalTexture
  99753. */
  99754. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  99755. var _this = this;
  99756. if (onLoad === void 0) { onLoad = null; }
  99757. if (onError === void 0) { onError = null; }
  99758. if (forcedExtension === void 0) { forcedExtension = null; }
  99759. if (createPolynomials === void 0) { createPolynomials = true; }
  99760. var callback = function (loadData) {
  99761. if (!loadData) {
  99762. if (onLoad) {
  99763. onLoad(null);
  99764. }
  99765. return;
  99766. }
  99767. var texture = loadData.texture;
  99768. if (!createPolynomials) {
  99769. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  99770. }
  99771. else if (loadData.info.sphericalPolynomial) {
  99772. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  99773. }
  99774. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  99775. if (_this.getCaps().textureLOD) {
  99776. // Do not add extra process if texture lod is supported.
  99777. if (onLoad) {
  99778. onLoad(texture);
  99779. }
  99780. return;
  99781. }
  99782. var mipSlices = 3;
  99783. var gl = _this._gl;
  99784. var width = loadData.width;
  99785. if (!width) {
  99786. return;
  99787. }
  99788. var textures = [];
  99789. for (var i = 0; i < mipSlices; i++) {
  99790. //compute LOD from even spacing in smoothness (matching shader calculation)
  99791. var smoothness = i / (mipSlices - 1);
  99792. var roughness = 1 - smoothness;
  99793. var minLODIndex = lodOffset; // roughness = 0
  99794. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  99795. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  99796. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  99797. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  99798. glTextureFromLod.type = texture.type;
  99799. glTextureFromLod.format = texture.format;
  99800. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  99801. glTextureFromLod.height = glTextureFromLod.width;
  99802. glTextureFromLod.isCube = true;
  99803. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  99804. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  99805. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  99806. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  99807. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  99808. if (loadData.isDDS) {
  99809. var info = loadData.info;
  99810. var data = loadData.data;
  99811. _this._unpackFlipY(info.isCompressed);
  99812. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  99813. }
  99814. else {
  99815. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  99816. }
  99817. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  99818. // Wrap in a base texture for easy binding.
  99819. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  99820. lodTexture.isCube = true;
  99821. lodTexture._texture = glTextureFromLod;
  99822. glTextureFromLod.isReady = true;
  99823. textures.push(lodTexture);
  99824. }
  99825. texture._lodTextureHigh = textures[2];
  99826. texture._lodTextureMid = textures[1];
  99827. texture._lodTextureLow = textures[0];
  99828. if (onLoad) {
  99829. onLoad(texture);
  99830. }
  99831. };
  99832. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  99833. };
  99834. /***/ }),
  99835. /***/ "./Misc/decorators.ts":
  99836. /*!****************************!*\
  99837. !*** ./Misc/decorators.ts ***!
  99838. \****************************/
  99839. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper */
  99840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99841. "use strict";
  99842. __webpack_require__.r(__webpack_exports__);
  99843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  99844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  99845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  99846. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  99847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  99848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  99849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  99850. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  99851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  99852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  99853. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  99854. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  99855. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return serializeAsMatrix; });
  99856. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  99857. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  99858. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  99859. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  99860. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  99861. var __decoratorInitialStore = {};
  99862. var __mergedStore = {};
  99863. var _copySource = function (creationFunction, source, instanciate) {
  99864. var destination = creationFunction();
  99865. // Tags
  99866. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  99867. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  99868. }
  99869. var classStore = getMergedStore(destination);
  99870. // Properties
  99871. for (var property in classStore) {
  99872. var propertyDescriptor = classStore[property];
  99873. var sourceProperty = source[property];
  99874. var propertyType = propertyDescriptor.type;
  99875. if (sourceProperty !== undefined && sourceProperty !== null && property !== "uniqueId") {
  99876. switch (propertyType) {
  99877. case 0: // Value
  99878. case 6: // Mesh reference
  99879. case 11: // Camera reference
  99880. destination[property] = sourceProperty;
  99881. break;
  99882. case 1: // Texture
  99883. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  99884. break;
  99885. case 2: // Color3
  99886. case 3: // FresnelParameters
  99887. case 4: // Vector2
  99888. case 5: // Vector3
  99889. case 7: // Color Curves
  99890. case 10: // Quaternion
  99891. case 12: // Matrix
  99892. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  99893. break;
  99894. }
  99895. }
  99896. }
  99897. return destination;
  99898. };
  99899. function getDirectStore(target) {
  99900. var classKey = target.getClassName();
  99901. if (!__decoratorInitialStore[classKey]) {
  99902. __decoratorInitialStore[classKey] = {};
  99903. }
  99904. return __decoratorInitialStore[classKey];
  99905. }
  99906. /**
  99907. * Return the list of properties flagged as serializable
  99908. * @param target: host object
  99909. */
  99910. function getMergedStore(target) {
  99911. var classKey = target.getClassName();
  99912. if (__mergedStore[classKey]) {
  99913. return __mergedStore[classKey];
  99914. }
  99915. __mergedStore[classKey] = {};
  99916. var store = __mergedStore[classKey];
  99917. var currentTarget = target;
  99918. var currentKey = classKey;
  99919. while (currentKey) {
  99920. var initialStore = __decoratorInitialStore[currentKey];
  99921. for (var property in initialStore) {
  99922. store[property] = initialStore[property];
  99923. }
  99924. var parent_1 = void 0;
  99925. var done = false;
  99926. do {
  99927. parent_1 = Object.getPrototypeOf(currentTarget);
  99928. if (!parent_1.getClassName) {
  99929. done = true;
  99930. break;
  99931. }
  99932. if (parent_1.getClassName() !== currentKey) {
  99933. break;
  99934. }
  99935. currentTarget = parent_1;
  99936. } while (parent_1);
  99937. if (done) {
  99938. break;
  99939. }
  99940. currentKey = parent_1.getClassName();
  99941. currentTarget = parent_1;
  99942. }
  99943. return store;
  99944. }
  99945. function generateSerializableMember(type, sourceName) {
  99946. return function (target, propertyKey) {
  99947. var classStore = getDirectStore(target);
  99948. if (!classStore[propertyKey]) {
  99949. classStore[propertyKey] = { type: type, sourceName: sourceName };
  99950. }
  99951. };
  99952. }
  99953. function generateExpandMember(setCallback, targetKey) {
  99954. if (targetKey === void 0) { targetKey = null; }
  99955. return function (target, propertyKey) {
  99956. var key = targetKey || ("_" + propertyKey);
  99957. Object.defineProperty(target, propertyKey, {
  99958. get: function () {
  99959. return this[key];
  99960. },
  99961. set: function (value) {
  99962. if (this[key] === value) {
  99963. return;
  99964. }
  99965. this[key] = value;
  99966. target[setCallback].apply(this);
  99967. },
  99968. enumerable: true,
  99969. configurable: true
  99970. });
  99971. };
  99972. }
  99973. function expandToProperty(callback, targetKey) {
  99974. if (targetKey === void 0) { targetKey = null; }
  99975. return generateExpandMember(callback, targetKey);
  99976. }
  99977. function serialize(sourceName) {
  99978. return generateSerializableMember(0, sourceName); // value member
  99979. }
  99980. function serializeAsTexture(sourceName) {
  99981. return generateSerializableMember(1, sourceName); // texture member
  99982. }
  99983. function serializeAsColor3(sourceName) {
  99984. return generateSerializableMember(2, sourceName); // color3 member
  99985. }
  99986. function serializeAsFresnelParameters(sourceName) {
  99987. return generateSerializableMember(3, sourceName); // fresnel parameters member
  99988. }
  99989. function serializeAsVector2(sourceName) {
  99990. return generateSerializableMember(4, sourceName); // vector2 member
  99991. }
  99992. function serializeAsVector3(sourceName) {
  99993. return generateSerializableMember(5, sourceName); // vector3 member
  99994. }
  99995. function serializeAsMeshReference(sourceName) {
  99996. return generateSerializableMember(6, sourceName); // mesh reference member
  99997. }
  99998. function serializeAsColorCurves(sourceName) {
  99999. return generateSerializableMember(7, sourceName); // color curves
  100000. }
  100001. function serializeAsColor4(sourceName) {
  100002. return generateSerializableMember(8, sourceName); // color 4
  100003. }
  100004. function serializeAsImageProcessingConfiguration(sourceName) {
  100005. return generateSerializableMember(9, sourceName); // image processing
  100006. }
  100007. function serializeAsQuaternion(sourceName) {
  100008. return generateSerializableMember(10, sourceName); // quaternion member
  100009. }
  100010. function serializeAsMatrix(sourceName) {
  100011. return generateSerializableMember(12, sourceName); // matrix member
  100012. }
  100013. /**
  100014. * Decorator used to define property that can be serialized as reference to a camera
  100015. * @param sourceName defines the name of the property to decorate
  100016. */
  100017. function serializeAsCameraReference(sourceName) {
  100018. return generateSerializableMember(11, sourceName); // camera reference member
  100019. }
  100020. /**
  100021. * Class used to help serialization objects
  100022. */
  100023. var SerializationHelper = /** @class */ (function () {
  100024. function SerializationHelper() {
  100025. }
  100026. /**
  100027. * Appends the serialized animations from the source animations
  100028. * @param source Source containing the animations
  100029. * @param destination Target to store the animations
  100030. */
  100031. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  100032. if (source.animations) {
  100033. destination.animations = [];
  100034. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  100035. var animation = source.animations[animationIndex];
  100036. destination.animations.push(animation.serialize());
  100037. }
  100038. }
  100039. };
  100040. /**
  100041. * Static function used to serialized a specific entity
  100042. * @param entity defines the entity to serialize
  100043. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  100044. * @returns a JSON compatible object representing the serialization of the entity
  100045. */
  100046. SerializationHelper.Serialize = function (entity, serializationObject) {
  100047. if (!serializationObject) {
  100048. serializationObject = {};
  100049. }
  100050. // Tags
  100051. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  100052. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  100053. }
  100054. var serializedProperties = getMergedStore(entity);
  100055. // Properties
  100056. for (var property in serializedProperties) {
  100057. var propertyDescriptor = serializedProperties[property];
  100058. var targetPropertyName = propertyDescriptor.sourceName || property;
  100059. var propertyType = propertyDescriptor.type;
  100060. var sourceProperty = entity[property];
  100061. if (sourceProperty !== undefined && sourceProperty !== null) {
  100062. switch (propertyType) {
  100063. case 0: // Value
  100064. serializationObject[targetPropertyName] = sourceProperty;
  100065. break;
  100066. case 1: // Texture
  100067. serializationObject[targetPropertyName] = sourceProperty.serialize();
  100068. break;
  100069. case 2: // Color3
  100070. serializationObject[targetPropertyName] = sourceProperty.asArray();
  100071. break;
  100072. case 3: // FresnelParameters
  100073. serializationObject[targetPropertyName] = sourceProperty.serialize();
  100074. break;
  100075. case 4: // Vector2
  100076. serializationObject[targetPropertyName] = sourceProperty.asArray();
  100077. break;
  100078. case 5: // Vector3
  100079. serializationObject[targetPropertyName] = sourceProperty.asArray();
  100080. break;
  100081. case 6: // Mesh reference
  100082. serializationObject[targetPropertyName] = sourceProperty.id;
  100083. break;
  100084. case 7: // Color Curves
  100085. serializationObject[targetPropertyName] = sourceProperty.serialize();
  100086. break;
  100087. case 8: // Color 4
  100088. serializationObject[targetPropertyName] = sourceProperty.asArray();
  100089. break;
  100090. case 9: // Image Processing
  100091. serializationObject[targetPropertyName] = sourceProperty.serialize();
  100092. break;
  100093. case 10: // Quaternion
  100094. serializationObject[targetPropertyName] = sourceProperty.asArray();
  100095. break;
  100096. case 11: // Camera reference
  100097. serializationObject[targetPropertyName] = sourceProperty.id;
  100098. case 12: // Matrix
  100099. serializationObject[targetPropertyName] = sourceProperty.asArray();
  100100. break;
  100101. }
  100102. }
  100103. }
  100104. return serializationObject;
  100105. };
  100106. /**
  100107. * Creates a new entity from a serialization data object
  100108. * @param creationFunction defines a function used to instanciated the new entity
  100109. * @param source defines the source serialization data
  100110. * @param scene defines the hosting scene
  100111. * @param rootUrl defines the root url for resources
  100112. * @returns a new entity
  100113. */
  100114. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  100115. if (rootUrl === void 0) { rootUrl = null; }
  100116. var destination = creationFunction();
  100117. if (!rootUrl) {
  100118. rootUrl = "";
  100119. }
  100120. // Tags
  100121. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  100122. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  100123. }
  100124. var classStore = getMergedStore(destination);
  100125. // Properties
  100126. for (var property in classStore) {
  100127. var propertyDescriptor = classStore[property];
  100128. var sourceProperty = source[propertyDescriptor.sourceName || property];
  100129. var propertyType = propertyDescriptor.type;
  100130. if (sourceProperty !== undefined && sourceProperty !== null) {
  100131. var dest = destination;
  100132. switch (propertyType) {
  100133. case 0: // Value
  100134. dest[property] = sourceProperty;
  100135. break;
  100136. case 1: // Texture
  100137. if (scene) {
  100138. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  100139. }
  100140. break;
  100141. case 2: // Color3
  100142. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  100143. break;
  100144. case 3: // FresnelParameters
  100145. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  100146. break;
  100147. case 4: // Vector2
  100148. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  100149. break;
  100150. case 5: // Vector3
  100151. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  100152. break;
  100153. case 6: // Mesh reference
  100154. if (scene) {
  100155. dest[property] = scene.getLastMeshByID(sourceProperty);
  100156. }
  100157. break;
  100158. case 7: // Color Curves
  100159. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  100160. break;
  100161. case 8: // Color 4
  100162. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  100163. break;
  100164. case 9: // Image Processing
  100165. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  100166. break;
  100167. case 10: // Quaternion
  100168. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  100169. break;
  100170. case 11: // Camera reference
  100171. if (scene) {
  100172. dest[property] = scene.getCameraByID(sourceProperty);
  100173. }
  100174. case 12: // Matrix
  100175. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromArray(sourceProperty);
  100176. break;
  100177. }
  100178. }
  100179. }
  100180. return destination;
  100181. };
  100182. /**
  100183. * Clones an object
  100184. * @param creationFunction defines the function used to instanciate the new object
  100185. * @param source defines the source object
  100186. * @returns the cloned object
  100187. */
  100188. SerializationHelper.Clone = function (creationFunction, source) {
  100189. return _copySource(creationFunction, source, false);
  100190. };
  100191. /**
  100192. * Instanciates a new object based on a source one (some data will be shared between both object)
  100193. * @param creationFunction defines the function used to instanciate the new object
  100194. * @param source defines the source object
  100195. * @returns the new object
  100196. */
  100197. SerializationHelper.Instanciate = function (creationFunction, source) {
  100198. return _copySource(creationFunction, source, true);
  100199. };
  100200. /** hidden */
  100201. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  100202. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  100203. };
  100204. /** hidden */
  100205. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  100206. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  100207. };
  100208. /** hidden */
  100209. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  100210. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  100211. };
  100212. /** hidden */
  100213. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  100214. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  100215. };
  100216. return SerializationHelper;
  100217. }());
  100218. /***/ }),
  100219. /***/ "./Misc/deepCopier.ts":
  100220. /*!****************************!*\
  100221. !*** ./Misc/deepCopier.ts ***!
  100222. \****************************/
  100223. /*! exports provided: DeepCopier */
  100224. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100225. "use strict";
  100226. __webpack_require__.r(__webpack_exports__);
  100227. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  100228. var cloneValue = function (source, destinationObject) {
  100229. if (!source) {
  100230. return null;
  100231. }
  100232. if (source.getClassName && source.getClassName() === "Mesh") {
  100233. return null;
  100234. }
  100235. if (source.getClassName && source.getClassName() === "SubMesh") {
  100236. return source.clone(destinationObject);
  100237. }
  100238. else if (source.clone) {
  100239. return source.clone();
  100240. }
  100241. return null;
  100242. };
  100243. /**
  100244. * Class containing a set of static utilities functions for deep copy.
  100245. */
  100246. var DeepCopier = /** @class */ (function () {
  100247. function DeepCopier() {
  100248. }
  100249. /**
  100250. * Tries to copy an object by duplicating every property
  100251. * @param source defines the source object
  100252. * @param destination defines the target object
  100253. * @param doNotCopyList defines a list of properties to avoid
  100254. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  100255. */
  100256. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  100257. for (var prop in source) {
  100258. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  100259. continue;
  100260. }
  100261. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  100262. continue;
  100263. }
  100264. var sourceValue = source[prop];
  100265. var typeOfSourceValue = typeof sourceValue;
  100266. if (typeOfSourceValue === "function") {
  100267. continue;
  100268. }
  100269. try {
  100270. if (typeOfSourceValue === "object") {
  100271. if (sourceValue instanceof Array) {
  100272. destination[prop] = [];
  100273. if (sourceValue.length > 0) {
  100274. if (typeof sourceValue[0] == "object") {
  100275. for (var index = 0; index < sourceValue.length; index++) {
  100276. var clonedValue = cloneValue(sourceValue[index], destination);
  100277. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  100278. destination[prop].push(clonedValue);
  100279. }
  100280. }
  100281. }
  100282. else {
  100283. destination[prop] = sourceValue.slice(0);
  100284. }
  100285. }
  100286. }
  100287. else {
  100288. destination[prop] = cloneValue(sourceValue, destination);
  100289. }
  100290. }
  100291. else {
  100292. destination[prop] = sourceValue;
  100293. }
  100294. }
  100295. catch (e) {
  100296. // Just ignore error (it could be because of a read-only property)
  100297. }
  100298. }
  100299. };
  100300. return DeepCopier;
  100301. }());
  100302. /***/ }),
  100303. /***/ "./Misc/deferred.ts":
  100304. /*!**************************!*\
  100305. !*** ./Misc/deferred.ts ***!
  100306. \**************************/
  100307. /*! exports provided: Deferred */
  100308. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100309. "use strict";
  100310. __webpack_require__.r(__webpack_exports__);
  100311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  100312. /**
  100313. * Wrapper class for promise with external resolve and reject.
  100314. */
  100315. var Deferred = /** @class */ (function () {
  100316. /**
  100317. * Constructor for this deferred object.
  100318. */
  100319. function Deferred() {
  100320. var _this = this;
  100321. this.promise = new Promise(function (resolve, reject) {
  100322. _this._resolve = resolve;
  100323. _this._reject = reject;
  100324. });
  100325. }
  100326. Object.defineProperty(Deferred.prototype, "resolve", {
  100327. /**
  100328. * The resolve method of the promise associated with this deferred object.
  100329. */
  100330. get: function () {
  100331. return this._resolve;
  100332. },
  100333. enumerable: true,
  100334. configurable: true
  100335. });
  100336. Object.defineProperty(Deferred.prototype, "reject", {
  100337. /**
  100338. * The reject method of the promise associated with this deferred object.
  100339. */
  100340. get: function () {
  100341. return this._reject;
  100342. },
  100343. enumerable: true,
  100344. configurable: true
  100345. });
  100346. return Deferred;
  100347. }());
  100348. /***/ }),
  100349. /***/ "./Misc/devTools.ts":
  100350. /*!**************************!*\
  100351. !*** ./Misc/devTools.ts ***!
  100352. \**************************/
  100353. /*! exports provided: _DevTools */
  100354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100355. "use strict";
  100356. __webpack_require__.r(__webpack_exports__);
  100357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  100358. /** @hidden */
  100359. var _DevTools = /** @class */ (function () {
  100360. function _DevTools() {
  100361. }
  100362. _DevTools.WarnImport = function (name) {
  100363. return name + " needs to be imported before as it contains a side-effect required by your code.";
  100364. };
  100365. return _DevTools;
  100366. }());
  100367. /***/ }),
  100368. /***/ "./Misc/domManagement.ts":
  100369. /*!*******************************!*\
  100370. !*** ./Misc/domManagement.ts ***!
  100371. \*******************************/
  100372. /*! exports provided: DomManagement */
  100373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100374. "use strict";
  100375. __webpack_require__.r(__webpack_exports__);
  100376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  100377. /**
  100378. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  100379. * Babylon.js
  100380. */
  100381. var DomManagement = /** @class */ (function () {
  100382. function DomManagement() {
  100383. }
  100384. /**
  100385. * Checks if the window object exists
  100386. * @returns true if the window object exists
  100387. */
  100388. DomManagement.IsWindowObjectExist = function () {
  100389. return (typeof window) !== "undefined";
  100390. };
  100391. /**
  100392. * Extracts text content from a DOM element hierarchy
  100393. * @param element defines the root element
  100394. * @returns a string
  100395. */
  100396. DomManagement.GetDOMTextContent = function (element) {
  100397. var result = "";
  100398. var child = element.firstChild;
  100399. while (child) {
  100400. if (child.nodeType === 3) {
  100401. result += child.textContent;
  100402. }
  100403. child = (child.nextSibling);
  100404. }
  100405. return result;
  100406. };
  100407. return DomManagement;
  100408. }());
  100409. /***/ }),
  100410. /***/ "./Misc/environmentTextureTools.ts":
  100411. /*!*****************************************!*\
  100412. !*** ./Misc/environmentTextureTools.ts ***!
  100413. \*****************************************/
  100414. /*! exports provided: EnvironmentTextureTools */
  100415. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100416. "use strict";
  100417. __webpack_require__.r(__webpack_exports__);
  100418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  100419. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  100420. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  100421. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  100422. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  100423. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  100424. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  100425. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  100426. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  100427. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  100428. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  100429. /* harmony import */ var _Engines_Extensions_engine_renderTarget__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/Extensions/engine.renderTarget */ "./Engines/Extensions/engine.renderTarget.ts");
  100430. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  100431. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  100432. /**
  100433. * Sets of helpers addressing the serialization and deserialization of environment texture
  100434. * stored in a BabylonJS env file.
  100435. * Those files are usually stored as .env files.
  100436. */
  100437. var EnvironmentTextureTools = /** @class */ (function () {
  100438. function EnvironmentTextureTools() {
  100439. }
  100440. /**
  100441. * Gets the environment info from an env file.
  100442. * @param data The array buffer containing the .env bytes.
  100443. * @returns the environment file info (the json header) if successfully parsed.
  100444. */
  100445. EnvironmentTextureTools.GetEnvInfo = function (data) {
  100446. var dataView = new DataView(data);
  100447. var pos = 0;
  100448. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  100449. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  100450. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  100451. return null;
  100452. }
  100453. }
  100454. // Read json manifest - collect characters up to null terminator
  100455. var manifestString = '';
  100456. var charCode = 0x00;
  100457. while ((charCode = dataView.getUint8(pos++))) {
  100458. manifestString += String.fromCharCode(charCode);
  100459. }
  100460. var manifest = JSON.parse(manifestString);
  100461. if (manifest.specular) {
  100462. // Extend the header with the position of the payload.
  100463. manifest.specular.specularDataPosition = pos;
  100464. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  100465. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  100466. }
  100467. return manifest;
  100468. };
  100469. /**
  100470. * Creates an environment texture from a loaded cube texture.
  100471. * @param texture defines the cube texture to convert in env file
  100472. * @return a promise containing the environment data if succesfull.
  100473. */
  100474. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  100475. var _this = this;
  100476. var internalTexture = texture.getInternalTexture();
  100477. if (!internalTexture) {
  100478. return Promise.reject("The cube texture is invalid.");
  100479. }
  100480. if (!texture._prefiltered) {
  100481. return Promise.reject("The cube texture is invalid (not prefiltered).");
  100482. }
  100483. var engine = internalTexture.getEngine();
  100484. if (engine && engine.premultipliedAlpha) {
  100485. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  100486. }
  100487. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  100488. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  100489. }
  100490. var canvas = engine.getRenderingCanvas();
  100491. if (!canvas) {
  100492. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  100493. }
  100494. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  100495. if (!engine.getCaps().textureFloatRender) {
  100496. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  100497. if (!engine.getCaps().textureHalfFloatRender) {
  100498. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  100499. }
  100500. }
  100501. var cubeWidth = internalTexture.width;
  100502. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  100503. var specularTextures = {};
  100504. var promises = [];
  100505. // Read and collect all mipmaps data from the cube.
  100506. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  100507. mipmapsCount = Math.round(mipmapsCount);
  100508. var _loop_1 = function (i) {
  100509. var faceWidth = Math.pow(2, mipmapsCount - i);
  100510. var _loop_2 = function (face) {
  100511. var data = texture.readPixels(face, i);
  100512. // Creates a temp texture with the face data.
  100513. 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);
  100514. // And rgbdEncode them.
  100515. var promise = new Promise(function (resolve, reject) {
  100516. 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);
  100517. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  100518. rgbdPostProcess.onApply = function (effect) {
  100519. effect._bindTexture("textureSampler", tempTexture);
  100520. };
  100521. // As the process needs to happen on the main canvas, keep track of the current size
  100522. var currentW = engine.getRenderWidth();
  100523. var currentH = engine.getRenderHeight();
  100524. // Set the desired size for the texture
  100525. engine.setSize(faceWidth, faceWidth);
  100526. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  100527. // Reading datas from WebGL
  100528. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  100529. var fileReader = new FileReader();
  100530. fileReader.onload = function (event) {
  100531. var arrayBuffer = event.target.result;
  100532. specularTextures[i * 6 + face] = arrayBuffer;
  100533. resolve();
  100534. };
  100535. fileReader.readAsArrayBuffer(blob);
  100536. });
  100537. // Reapply the previous canvas size
  100538. engine.setSize(currentW, currentH);
  100539. });
  100540. });
  100541. promises.push(promise);
  100542. };
  100543. // All faces of the cube.
  100544. for (var face = 0; face < 6; face++) {
  100545. _loop_2(face);
  100546. }
  100547. };
  100548. for (var i = 0; i <= mipmapsCount; i++) {
  100549. _loop_1(i);
  100550. }
  100551. // Once all the textures haves been collected as RGBD stored in PNGs
  100552. return Promise.all(promises).then(function () {
  100553. // We can delete the hosting scene keeping track of all the creation objects
  100554. hostingScene.dispose();
  100555. // Creates the json header for the env texture
  100556. var info = {
  100557. version: 1,
  100558. width: cubeWidth,
  100559. irradiance: _this._CreateEnvTextureIrradiance(texture),
  100560. specular: {
  100561. mipmaps: [],
  100562. lodGenerationScale: texture.lodGenerationScale
  100563. }
  100564. };
  100565. // Sets the specular image data information
  100566. var position = 0;
  100567. for (var i = 0; i <= mipmapsCount; i++) {
  100568. for (var face = 0; face < 6; face++) {
  100569. var byteLength = specularTextures[i * 6 + face].byteLength;
  100570. info.specular.mipmaps.push({
  100571. length: byteLength,
  100572. position: position
  100573. });
  100574. position += byteLength;
  100575. }
  100576. }
  100577. // Encode the JSON as an array buffer
  100578. var infoString = JSON.stringify(info);
  100579. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  100580. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  100581. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  100582. infoView[i] = infoString.charCodeAt(i);
  100583. }
  100584. // Ends up with a null terminator for easier parsing
  100585. infoView[infoString.length] = 0x00;
  100586. // Computes the final required size and creates the storage
  100587. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  100588. var finalBuffer = new ArrayBuffer(totalSize);
  100589. var finalBufferView = new Uint8Array(finalBuffer);
  100590. var dataView = new DataView(finalBuffer);
  100591. // Copy the magic bytes identifying the file in
  100592. var pos = 0;
  100593. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  100594. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  100595. }
  100596. // Add the json info
  100597. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  100598. pos += infoBuffer.byteLength;
  100599. // Finally inserts the texture data
  100600. for (var i = 0; i <= mipmapsCount; i++) {
  100601. for (var face = 0; face < 6; face++) {
  100602. var dataBuffer = specularTextures[i * 6 + face];
  100603. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  100604. pos += dataBuffer.byteLength;
  100605. }
  100606. }
  100607. // Voila
  100608. return finalBuffer;
  100609. });
  100610. };
  100611. /**
  100612. * Creates a JSON representation of the spherical data.
  100613. * @param texture defines the texture containing the polynomials
  100614. * @return the JSON representation of the spherical info
  100615. */
  100616. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  100617. var polynmials = texture.sphericalPolynomial;
  100618. if (polynmials == null) {
  100619. return null;
  100620. }
  100621. return {
  100622. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  100623. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  100624. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  100625. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  100626. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  100627. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  100628. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  100629. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  100630. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  100631. };
  100632. };
  100633. /**
  100634. * Uploads the texture info contained in the env file to the GPU.
  100635. * @param texture defines the internal texture to upload to
  100636. * @param arrayBuffer defines the buffer cotaining the data to load
  100637. * @param info defines the texture info retrieved through the GetEnvInfo method
  100638. * @returns a promise
  100639. */
  100640. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  100641. if (info.version !== 1) {
  100642. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  100643. }
  100644. var specularInfo = info.specular;
  100645. if (!specularInfo) {
  100646. // Nothing else parsed so far
  100647. return Promise.resolve();
  100648. }
  100649. // Double checks the enclosed info
  100650. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  100651. mipmapsCount = Math.round(mipmapsCount) + 1;
  100652. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  100653. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  100654. }
  100655. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  100656. var imageData = new Array(mipmapsCount);
  100657. for (var i = 0; i < mipmapsCount; i++) {
  100658. imageData[i] = new Array(6);
  100659. for (var face = 0; face < 6; face++) {
  100660. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  100661. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  100662. }
  100663. }
  100664. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  100665. };
  100666. /**
  100667. * Uploads the levels of image data to the GPU.
  100668. * @param texture defines the internal texture to upload to
  100669. * @param imageData defines the array buffer views of image data [mipmap][face]
  100670. * @returns a promise
  100671. */
  100672. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  100673. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  100674. throw new Error("Texture size must be a power of two");
  100675. }
  100676. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  100677. // Gets everything ready.
  100678. var engine = texture.getEngine();
  100679. var expandTexture = false;
  100680. var generateNonLODTextures = false;
  100681. var rgbdPostProcess = null;
  100682. var cubeRtt = null;
  100683. var lodTextures = null;
  100684. var caps = engine.getCaps();
  100685. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  100686. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  100687. texture.generateMipMaps = true;
  100688. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  100689. // Add extra process if texture lod is not supported
  100690. if (!caps.textureLOD) {
  100691. expandTexture = false;
  100692. generateNonLODTextures = true;
  100693. lodTextures = {};
  100694. }
  100695. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  100696. else if (engine.webGLVersion < 2) {
  100697. expandTexture = false;
  100698. }
  100699. // If half float available we can uncompress the texture
  100700. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  100701. expandTexture = true;
  100702. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  100703. }
  100704. // If full float available we can uncompress the texture
  100705. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  100706. expandTexture = true;
  100707. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  100708. }
  100709. // Expand the texture if possible
  100710. if (expandTexture) {
  100711. // Simply run through the decode PP
  100712. 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);
  100713. texture._isRGBD = false;
  100714. texture.invertY = false;
  100715. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  100716. generateDepthBuffer: false,
  100717. generateMipMaps: true,
  100718. generateStencilBuffer: false,
  100719. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  100720. type: texture.type,
  100721. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  100722. });
  100723. }
  100724. else {
  100725. texture._isRGBD = true;
  100726. texture.invertY = true;
  100727. // In case of missing support, applies the same patch than DDS files.
  100728. if (generateNonLODTextures) {
  100729. var mipSlices = 3;
  100730. var scale = texture._lodGenerationScale;
  100731. var offset = texture._lodGenerationOffset;
  100732. for (var i = 0; i < mipSlices; i++) {
  100733. //compute LOD from even spacing in smoothness (matching shader calculation)
  100734. var smoothness = i / (mipSlices - 1);
  100735. var roughness = 1 - smoothness;
  100736. var minLODIndex = offset; // roughness = 0
  100737. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  100738. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  100739. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  100740. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  100741. glTextureFromLod.isCube = true;
  100742. glTextureFromLod.invertY = true;
  100743. glTextureFromLod.generateMipMaps = false;
  100744. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  100745. // Wrap in a base texture for easy binding.
  100746. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  100747. lodTexture.isCube = true;
  100748. lodTexture._texture = glTextureFromLod;
  100749. lodTextures[mipmapIndex] = lodTexture;
  100750. switch (i) {
  100751. case 0:
  100752. texture._lodTextureLow = lodTexture;
  100753. break;
  100754. case 1:
  100755. texture._lodTextureMid = lodTexture;
  100756. break;
  100757. case 2:
  100758. texture._lodTextureHigh = lodTexture;
  100759. break;
  100760. }
  100761. }
  100762. }
  100763. }
  100764. var promises = [];
  100765. var _loop_3 = function (i) {
  100766. var _loop_4 = function (face) {
  100767. // Constructs an image element from image data
  100768. var bytes = imageData[i][face];
  100769. var blob = new Blob([bytes], { type: 'image/png' });
  100770. var url = URL.createObjectURL(blob);
  100771. var image = new Image();
  100772. image.src = url;
  100773. // Enqueue promise to upload to the texture.
  100774. var promise = new Promise(function (resolve, reject) {
  100775. image.onload = function () {
  100776. if (expandTexture) {
  100777. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  100778. reject(message);
  100779. }, image);
  100780. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  100781. // Uncompress the data to a RTT
  100782. rgbdPostProcess.onApply = function (effect) {
  100783. effect._bindTexture("textureSampler", tempTexture_1);
  100784. effect.setFloat2("scale", 1, 1);
  100785. };
  100786. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  100787. // Cleanup
  100788. engine.restoreDefaultFramebuffer();
  100789. tempTexture_1.dispose();
  100790. window.URL.revokeObjectURL(url);
  100791. resolve();
  100792. });
  100793. }
  100794. else {
  100795. engine._uploadImageToTexture(texture, image, face, i);
  100796. // Upload the face to the non lod texture support
  100797. if (generateNonLODTextures) {
  100798. var lodTexture = lodTextures[i];
  100799. if (lodTexture) {
  100800. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  100801. }
  100802. }
  100803. resolve();
  100804. }
  100805. };
  100806. image.onerror = function (error) {
  100807. reject(error);
  100808. };
  100809. });
  100810. promises.push(promise);
  100811. };
  100812. // All faces
  100813. for (var face = 0; face < 6; face++) {
  100814. _loop_4(face);
  100815. }
  100816. };
  100817. // All mipmaps up to provided number of images
  100818. for (var i = 0; i < imageData.length; i++) {
  100819. _loop_3(i);
  100820. }
  100821. // Fill remaining mipmaps with black textures.
  100822. if (imageData.length < mipmapsCount) {
  100823. var data = void 0;
  100824. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  100825. var dataLength = size * size * 4;
  100826. switch (texture.type) {
  100827. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  100828. data = new Uint8Array(dataLength);
  100829. break;
  100830. }
  100831. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  100832. data = new Uint16Array(dataLength);
  100833. break;
  100834. }
  100835. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  100836. data = new Float32Array(dataLength);
  100837. break;
  100838. }
  100839. }
  100840. for (var i = imageData.length; i < mipmapsCount; i++) {
  100841. for (var face = 0; face < 6; face++) {
  100842. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  100843. }
  100844. }
  100845. }
  100846. // Once all done, finishes the cleanup and return
  100847. return Promise.all(promises).then(function () {
  100848. // Release temp RTT.
  100849. if (cubeRtt) {
  100850. engine._releaseFramebufferObjects(cubeRtt);
  100851. cubeRtt._swapAndDie(texture);
  100852. }
  100853. // Release temp Post Process.
  100854. if (rgbdPostProcess) {
  100855. rgbdPostProcess.dispose();
  100856. }
  100857. // Flag internal texture as ready in case they are in use.
  100858. if (generateNonLODTextures) {
  100859. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  100860. texture._lodTextureHigh._texture.isReady = true;
  100861. }
  100862. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  100863. texture._lodTextureMid._texture.isReady = true;
  100864. }
  100865. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  100866. texture._lodTextureLow._texture.isReady = true;
  100867. }
  100868. }
  100869. });
  100870. };
  100871. /**
  100872. * Uploads spherical polynomials information to the texture.
  100873. * @param texture defines the texture we are trying to upload the information to
  100874. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  100875. */
  100876. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  100877. if (info.version !== 1) {
  100878. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  100879. }
  100880. var irradianceInfo = info.irradiance;
  100881. if (!irradianceInfo) {
  100882. return;
  100883. }
  100884. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  100885. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  100886. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  100887. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  100888. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  100889. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  100890. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  100891. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  100892. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  100893. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  100894. texture._sphericalPolynomial = sp;
  100895. };
  100896. /** @hidden */
  100897. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  100898. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  100899. internalTexture._bufferViewArrayArray = data;
  100900. internalTexture._lodGenerationScale = lodScale;
  100901. internalTexture._lodGenerationOffset = lodOffset;
  100902. internalTexture._sphericalPolynomial = sphericalPolynomial;
  100903. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  100904. internalTexture.isReady = true;
  100905. });
  100906. };
  100907. /**
  100908. * Magic number identifying the env file.
  100909. */
  100910. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  100911. return EnvironmentTextureTools;
  100912. }());
  100913. // References the dependencies.
  100914. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  100915. /***/ }),
  100916. /***/ "./Misc/filesInput.ts":
  100917. /*!****************************!*\
  100918. !*** ./Misc/filesInput.ts ***!
  100919. \****************************/
  100920. /*! exports provided: FilesInput */
  100921. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100922. "use strict";
  100923. __webpack_require__.r(__webpack_exports__);
  100924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  100925. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  100926. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  100927. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  100928. /**
  100929. * Class used to help managing file picking and drag'n'drop
  100930. */
  100931. var FilesInput = /** @class */ (function () {
  100932. /**
  100933. * Creates a new FilesInput
  100934. * @param engine defines the rendering engine
  100935. * @param scene defines the hosting scene
  100936. * @param sceneLoadedCallback callback called when scene is loaded
  100937. * @param progressCallback callback called to track progress
  100938. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  100939. * @param textureLoadingCallback callback called when a texture is loading
  100940. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  100941. * @param onReloadCallback callback called when a reload is requested
  100942. * @param errorCallback callback call if an error occurs
  100943. */
  100944. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  100945. /**
  100946. * Callback called when a file is processed
  100947. */
  100948. this.onProcessFileCallback = function () { return true; };
  100949. this._engine = engine;
  100950. this._currentScene = scene;
  100951. this._sceneLoadedCallback = sceneLoadedCallback;
  100952. this._progressCallback = progressCallback;
  100953. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  100954. this._textureLoadingCallback = textureLoadingCallback;
  100955. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  100956. this._onReloadCallback = onReloadCallback;
  100957. this._errorCallback = errorCallback;
  100958. }
  100959. Object.defineProperty(FilesInput, "FilesToLoad", {
  100960. /**
  100961. * List of files ready to be loaded
  100962. */
  100963. get: function () {
  100964. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  100965. },
  100966. enumerable: true,
  100967. configurable: true
  100968. });
  100969. /**
  100970. * Calls this function to listen to drag'n'drop events on a specific DOM element
  100971. * @param elementToMonitor defines the DOM element to track
  100972. */
  100973. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  100974. var _this = this;
  100975. if (elementToMonitor) {
  100976. this._elementToMonitor = elementToMonitor;
  100977. this._dragEnterHandler = function (e) { _this.drag(e); };
  100978. this._dragOverHandler = function (e) { _this.drag(e); };
  100979. this._dropHandler = function (e) { _this.drop(e); };
  100980. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  100981. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  100982. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  100983. }
  100984. };
  100985. /**
  100986. * Release all associated resources
  100987. */
  100988. FilesInput.prototype.dispose = function () {
  100989. if (!this._elementToMonitor) {
  100990. return;
  100991. }
  100992. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  100993. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  100994. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  100995. };
  100996. FilesInput.prototype.renderFunction = function () {
  100997. if (this._additionalRenderLoopLogicCallback) {
  100998. this._additionalRenderLoopLogicCallback();
  100999. }
  101000. if (this._currentScene) {
  101001. if (this._textureLoadingCallback) {
  101002. var remaining = this._currentScene.getWaitingItemsCount();
  101003. if (remaining > 0) {
  101004. this._textureLoadingCallback(remaining);
  101005. }
  101006. }
  101007. this._currentScene.render();
  101008. }
  101009. };
  101010. FilesInput.prototype.drag = function (e) {
  101011. e.stopPropagation();
  101012. e.preventDefault();
  101013. };
  101014. FilesInput.prototype.drop = function (eventDrop) {
  101015. eventDrop.stopPropagation();
  101016. eventDrop.preventDefault();
  101017. this.loadFiles(eventDrop);
  101018. };
  101019. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  101020. var _this = this;
  101021. var reader = folder.createReader();
  101022. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  101023. reader.readEntries(function (entries) {
  101024. remaining.count += entries.length;
  101025. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  101026. var entry = entries_1[_i];
  101027. if (entry.isFile) {
  101028. entry.file(function (file) {
  101029. file.correctName = relativePath + file.name;
  101030. files.push(file);
  101031. if (--remaining.count === 0) {
  101032. callback();
  101033. }
  101034. });
  101035. }
  101036. else if (entry.isDirectory) {
  101037. _this._traverseFolder(entry, files, remaining, callback);
  101038. }
  101039. }
  101040. if (--remaining.count) {
  101041. callback();
  101042. }
  101043. });
  101044. };
  101045. FilesInput.prototype._processFiles = function (files) {
  101046. for (var i = 0; i < files.length; i++) {
  101047. var name = files[i].correctName.toLowerCase();
  101048. var extension = name.split('.').pop();
  101049. if (!this.onProcessFileCallback(files[i], name, extension)) {
  101050. continue;
  101051. }
  101052. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  101053. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  101054. this._sceneFileToLoad = files[i];
  101055. }
  101056. FilesInput.FilesToLoad[name] = files[i];
  101057. }
  101058. };
  101059. /**
  101060. * Load files from a drop event
  101061. * @param event defines the drop event to use as source
  101062. */
  101063. FilesInput.prototype.loadFiles = function (event) {
  101064. var _this = this;
  101065. // Handling data transfer via drag'n'drop
  101066. if (event && event.dataTransfer && event.dataTransfer.files) {
  101067. this._filesToLoad = event.dataTransfer.files;
  101068. }
  101069. // Handling files from input files
  101070. if (event && event.target && event.target.files) {
  101071. this._filesToLoad = event.target.files;
  101072. }
  101073. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  101074. return;
  101075. }
  101076. if (this._startingProcessingFilesCallback) {
  101077. this._startingProcessingFilesCallback(this._filesToLoad);
  101078. }
  101079. if (this._filesToLoad && this._filesToLoad.length > 0) {
  101080. var files_1 = new Array();
  101081. var folders = [];
  101082. var items = event.dataTransfer ? event.dataTransfer.items : null;
  101083. for (var i = 0; i < this._filesToLoad.length; i++) {
  101084. var fileToLoad = this._filesToLoad[i];
  101085. var name_1 = fileToLoad.name.toLowerCase();
  101086. var entry = void 0;
  101087. fileToLoad.correctName = name_1;
  101088. if (items) {
  101089. var item = items[i];
  101090. if (item.getAsEntry) {
  101091. entry = item.getAsEntry();
  101092. }
  101093. else if (item.webkitGetAsEntry) {
  101094. entry = item.webkitGetAsEntry();
  101095. }
  101096. }
  101097. if (!entry) {
  101098. files_1.push(fileToLoad);
  101099. }
  101100. else {
  101101. if (entry.isDirectory) {
  101102. folders.push(entry);
  101103. }
  101104. else {
  101105. files_1.push(fileToLoad);
  101106. }
  101107. }
  101108. }
  101109. if (folders.length === 0) {
  101110. this._processFiles(files_1);
  101111. this._processReload();
  101112. }
  101113. else {
  101114. var remaining = { count: folders.length };
  101115. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  101116. var folder = folders_1[_i];
  101117. this._traverseFolder(folder, files_1, remaining, function () {
  101118. _this._processFiles(files_1);
  101119. if (remaining.count === 0) {
  101120. _this._processReload();
  101121. }
  101122. });
  101123. }
  101124. }
  101125. }
  101126. };
  101127. FilesInput.prototype._processReload = function () {
  101128. if (this._onReloadCallback) {
  101129. this._onReloadCallback(this._sceneFileToLoad);
  101130. }
  101131. else {
  101132. this.reload();
  101133. }
  101134. };
  101135. /**
  101136. * Reload the current scene from the loaded files
  101137. */
  101138. FilesInput.prototype.reload = function () {
  101139. var _this = this;
  101140. // If a scene file has been provided
  101141. if (this._sceneFileToLoad) {
  101142. if (this._currentScene) {
  101143. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  101144. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  101145. }
  101146. this._engine.stopRenderLoop();
  101147. }
  101148. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  101149. if (_this._progressCallback) {
  101150. _this._progressCallback(progress);
  101151. }
  101152. }).then(function (scene) {
  101153. if (_this._currentScene) {
  101154. _this._currentScene.dispose();
  101155. }
  101156. _this._currentScene = scene;
  101157. if (_this._sceneLoadedCallback) {
  101158. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  101159. }
  101160. // Wait for textures and shaders to be ready
  101161. _this._currentScene.executeWhenReady(function () {
  101162. _this._engine.runRenderLoop(function () {
  101163. _this.renderFunction();
  101164. });
  101165. });
  101166. }).catch(function (error) {
  101167. if (_this._errorCallback) {
  101168. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  101169. }
  101170. });
  101171. }
  101172. else {
  101173. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  101174. }
  101175. };
  101176. return FilesInput;
  101177. }());
  101178. /***/ }),
  101179. /***/ "./Misc/filesInputStore.ts":
  101180. /*!*********************************!*\
  101181. !*** ./Misc/filesInputStore.ts ***!
  101182. \*********************************/
  101183. /*! exports provided: FilesInputStore */
  101184. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101185. "use strict";
  101186. __webpack_require__.r(__webpack_exports__);
  101187. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  101188. /**
  101189. * Class used to help managing file picking and drag'n'drop
  101190. * File Storage
  101191. */
  101192. var FilesInputStore = /** @class */ (function () {
  101193. function FilesInputStore() {
  101194. }
  101195. /**
  101196. * List of files ready to be loaded
  101197. */
  101198. FilesInputStore.FilesToLoad = {};
  101199. return FilesInputStore;
  101200. }());
  101201. /***/ }),
  101202. /***/ "./Misc/iInspectable.ts":
  101203. /*!******************************!*\
  101204. !*** ./Misc/iInspectable.ts ***!
  101205. \******************************/
  101206. /*! exports provided: InspectableType */
  101207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101208. "use strict";
  101209. __webpack_require__.r(__webpack_exports__);
  101210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return InspectableType; });
  101211. /**
  101212. * Enum that determines the text-wrapping mode to use.
  101213. */
  101214. var InspectableType;
  101215. (function (InspectableType) {
  101216. /**
  101217. * Checkbox for booleans
  101218. */
  101219. InspectableType[InspectableType["Checkbox"] = 0] = "Checkbox";
  101220. /**
  101221. * Sliders for numbers
  101222. */
  101223. InspectableType[InspectableType["Slider"] = 1] = "Slider";
  101224. /**
  101225. * Vector3
  101226. */
  101227. InspectableType[InspectableType["Vector3"] = 2] = "Vector3";
  101228. /**
  101229. * Quaternions
  101230. */
  101231. InspectableType[InspectableType["Quaternion"] = 3] = "Quaternion";
  101232. /**
  101233. * Color3
  101234. */
  101235. InspectableType[InspectableType["Color3"] = 4] = "Color3";
  101236. })(InspectableType || (InspectableType = {}));
  101237. /***/ }),
  101238. /***/ "./Misc/index.ts":
  101239. /*!***********************!*\
  101240. !*** ./Misc/index.ts ***!
  101241. \***********************/
  101242. /*! 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 */
  101243. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101244. "use strict";
  101245. __webpack_require__.r(__webpack_exports__);
  101246. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  101247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  101248. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  101249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  101250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  101251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  101252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  101253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  101254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  101255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  101256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  101257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  101258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  101259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["EquiRectangularCubeTextureAssetTask"]; });
  101260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  101261. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  101262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  101263. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  101264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  101265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  101266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  101267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  101268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  101269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  101270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  101271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  101272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  101273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  101274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  101275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  101276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMatrix"]; });
  101277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  101278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  101279. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  101280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  101281. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  101282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  101283. /* harmony import */ var _meshExploder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshExploder */ "./Misc/meshExploder.ts");
  101284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _meshExploder__WEBPACK_IMPORTED_MODULE_6__["MeshExploder"]; });
  101285. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  101286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_7__["FilesInput"]; });
  101287. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  101288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["CubeMapToSphericalPolynomialTools"]; });
  101289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["HDRTools"]; });
  101290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["PanoramaToCubeMapTools"]; });
  101291. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  101292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__["KhronosTextureContainer"]; });
  101293. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  101294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["EventState"]; });
  101295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observer"]; });
  101296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["MultiObserver"]; });
  101297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observable"]; });
  101298. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  101299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["PerformanceMonitor"]; });
  101300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["RollingAverage"]; });
  101301. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  101302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_12__["PromisePolyfill"]; });
  101303. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  101304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimization"]; });
  101305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["TextureOptimization"]; });
  101306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["HardwareScalingOptimization"]; });
  101307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ShadowsOptimization"]; });
  101308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["PostProcessesOptimization"]; });
  101309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["LensFlaresOptimization"]; });
  101310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["CustomOptimization"]; });
  101311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ParticlesOptimization"]; });
  101312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["RenderTargetsOptimization"]; });
  101313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["MergeMeshesOptimization"]; });
  101314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizerOptions"]; });
  101315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizer"]; });
  101316. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  101317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__["SceneSerializer"]; });
  101318. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  101319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArray"]; });
  101320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArrayNoDuplicate"]; });
  101321. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  101322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_16__["StringDictionary"]; });
  101323. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  101324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_17__["Tags"]; });
  101325. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  101326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_18__["TextureTools"]; });
  101327. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  101328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_19__["TGATools"]; });
  101329. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  101330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["ColorGradient"]; });
  101331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Color3Gradient"]; });
  101332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["FactorGradient"]; });
  101333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["LoadFileError"]; });
  101334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["RetryStrategy"]; });
  101335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Tools"]; });
  101336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["PerfCounter"]; });
  101337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["className"]; });
  101338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["AsyncLoop"]; });
  101339. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  101340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_21__["VideoRecorder"]; });
  101341. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  101342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["JoystickAxis"]; });
  101343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["VirtualJoystick"]; });
  101344. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  101345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_23__["WorkerPool"]; });
  101346. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  101347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_24__["Logger"]; });
  101348. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  101349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_25__["_TypeStore"]; });
  101350. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  101351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_26__["FilesInputStore"]; });
  101352. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  101353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_27__["DeepCopier"]; });
  101354. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  101355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_28__["PivotTools"]; });
  101356. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  101357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_29__["PrecisionDate"]; });
  101358. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  101359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_30__["ScreenshotTools"]; });
  101360. /* empty/unused harmony star reexport *//* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  101361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _webRequest__WEBPACK_IMPORTED_MODULE_31__["WebRequest"]; });
  101362. /* harmony import */ var _iInspectable__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./iInspectable */ "./Misc/iInspectable.ts");
  101363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _iInspectable__WEBPACK_IMPORTED_MODULE_32__["InspectableType"]; });
  101364. /***/ }),
  101365. /***/ "./Misc/khronosTextureContainer.ts":
  101366. /*!*****************************************!*\
  101367. !*** ./Misc/khronosTextureContainer.ts ***!
  101368. \*****************************************/
  101369. /*! exports provided: KhronosTextureContainer */
  101370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101371. "use strict";
  101372. __webpack_require__.r(__webpack_exports__);
  101373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  101374. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  101375. /**
  101376. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  101377. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  101378. */
  101379. var KhronosTextureContainer = /** @class */ (function () {
  101380. /**
  101381. * Creates a new KhronosTextureContainer
  101382. * @param arrayBuffer contents of the KTX container file
  101383. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  101384. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  101385. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  101386. */
  101387. function KhronosTextureContainer(
  101388. /** contents of the KTX container file */
  101389. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  101390. this.arrayBuffer = arrayBuffer;
  101391. /**
  101392. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  101393. */
  101394. this.isInvalid = false;
  101395. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  101396. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  101397. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  101398. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  101399. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  101400. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  101401. this.isInvalid = true;
  101402. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  101403. return;
  101404. }
  101405. // load the reset of the header in native 32 bit uint
  101406. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  101407. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  101408. var endianness = headerDataView.getUint32(0, true);
  101409. var littleEndian = endianness === 0x04030201;
  101410. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  101411. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  101412. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  101413. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  101414. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  101415. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  101416. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  101417. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  101418. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  101419. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  101420. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  101421. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  101422. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  101423. if (this.glType !== 0) {
  101424. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  101425. return;
  101426. }
  101427. else {
  101428. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  101429. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  101430. }
  101431. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  101432. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  101433. return;
  101434. }
  101435. if (this.numberOfArrayElements !== 0) {
  101436. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  101437. return;
  101438. }
  101439. if (this.numberOfFaces !== facesExpected) {
  101440. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  101441. return;
  101442. }
  101443. // we now have a completely validated file, so could use existence of loadType as success
  101444. // would need to make this more elaborate & adjust checks above to support more than one load type
  101445. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  101446. }
  101447. /**
  101448. * Uploads KTX content to a Babylon Texture.
  101449. * It is assumed that the texture has already been created & is currently bound
  101450. * @hidden
  101451. */
  101452. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  101453. switch (this.loadType) {
  101454. case KhronosTextureContainer.COMPRESSED_2D:
  101455. this._upload2DCompressedLevels(texture, loadMipmaps);
  101456. break;
  101457. case KhronosTextureContainer.TEX_2D:
  101458. case KhronosTextureContainer.COMPRESSED_3D:
  101459. case KhronosTextureContainer.TEX_3D:
  101460. }
  101461. };
  101462. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  101463. // initialize width & height for level 1
  101464. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  101465. var width = this.pixelWidth;
  101466. var height = this.pixelHeight;
  101467. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  101468. for (var level = 0; level < mipmapCount; level++) {
  101469. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  101470. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  101471. for (var face = 0; face < this.numberOfFaces; face++) {
  101472. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  101473. var engine = texture.getEngine();
  101474. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  101475. dataOffset += imageSize; // add size of the image for the next face/mipmap
  101476. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  101477. }
  101478. width = Math.max(1.0, width * 0.5);
  101479. height = Math.max(1.0, height * 0.5);
  101480. }
  101481. };
  101482. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  101483. // load types
  101484. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  101485. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  101486. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  101487. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  101488. return KhronosTextureContainer;
  101489. }());
  101490. /***/ }),
  101491. /***/ "./Misc/logger.ts":
  101492. /*!************************!*\
  101493. !*** ./Misc/logger.ts ***!
  101494. \************************/
  101495. /*! exports provided: Logger */
  101496. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101497. "use strict";
  101498. __webpack_require__.r(__webpack_exports__);
  101499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  101500. /**
  101501. * Logger used througouht the application to allow configuration of
  101502. * the log level required for the messages.
  101503. */
  101504. var Logger = /** @class */ (function () {
  101505. function Logger() {
  101506. }
  101507. Logger._AddLogEntry = function (entry) {
  101508. Logger._LogCache = entry + Logger._LogCache;
  101509. if (Logger.OnNewCacheEntry) {
  101510. Logger.OnNewCacheEntry(entry);
  101511. }
  101512. };
  101513. Logger._FormatMessage = function (message) {
  101514. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  101515. var date = new Date();
  101516. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  101517. };
  101518. Logger._LogDisabled = function (message) {
  101519. // nothing to do
  101520. };
  101521. Logger._LogEnabled = function (message) {
  101522. var formattedMessage = Logger._FormatMessage(message);
  101523. console.log("BJS - " + formattedMessage);
  101524. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  101525. Logger._AddLogEntry(entry);
  101526. };
  101527. Logger._WarnDisabled = function (message) {
  101528. // nothing to do
  101529. };
  101530. Logger._WarnEnabled = function (message) {
  101531. var formattedMessage = Logger._FormatMessage(message);
  101532. console.warn("BJS - " + formattedMessage);
  101533. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  101534. Logger._AddLogEntry(entry);
  101535. };
  101536. Logger._ErrorDisabled = function (message) {
  101537. // nothing to do
  101538. };
  101539. Logger._ErrorEnabled = function (message) {
  101540. Logger.errorsCount++;
  101541. var formattedMessage = Logger._FormatMessage(message);
  101542. console.error("BJS - " + formattedMessage);
  101543. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  101544. Logger._AddLogEntry(entry);
  101545. };
  101546. Object.defineProperty(Logger, "LogCache", {
  101547. /**
  101548. * Gets current log cache (list of logs)
  101549. */
  101550. get: function () {
  101551. return Logger._LogCache;
  101552. },
  101553. enumerable: true,
  101554. configurable: true
  101555. });
  101556. /**
  101557. * Clears the log cache
  101558. */
  101559. Logger.ClearLogCache = function () {
  101560. Logger._LogCache = "";
  101561. Logger.errorsCount = 0;
  101562. };
  101563. Object.defineProperty(Logger, "LogLevels", {
  101564. /**
  101565. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  101566. */
  101567. set: function (level) {
  101568. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  101569. Logger.Log = Logger._LogEnabled;
  101570. }
  101571. else {
  101572. Logger.Log = Logger._LogDisabled;
  101573. }
  101574. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  101575. Logger.Warn = Logger._WarnEnabled;
  101576. }
  101577. else {
  101578. Logger.Warn = Logger._WarnDisabled;
  101579. }
  101580. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  101581. Logger.Error = Logger._ErrorEnabled;
  101582. }
  101583. else {
  101584. Logger.Error = Logger._ErrorDisabled;
  101585. }
  101586. },
  101587. enumerable: true,
  101588. configurable: true
  101589. });
  101590. /**
  101591. * No log
  101592. */
  101593. Logger.NoneLogLevel = 0;
  101594. /**
  101595. * Only message logs
  101596. */
  101597. Logger.MessageLogLevel = 1;
  101598. /**
  101599. * Only warning logs
  101600. */
  101601. Logger.WarningLogLevel = 2;
  101602. /**
  101603. * Only error logs
  101604. */
  101605. Logger.ErrorLogLevel = 4;
  101606. /**
  101607. * All logs
  101608. */
  101609. Logger.AllLogLevel = 7;
  101610. Logger._LogCache = "";
  101611. /**
  101612. * Gets a value indicating the number of loading errors
  101613. * @ignorenaming
  101614. */
  101615. Logger.errorsCount = 0;
  101616. /**
  101617. * Log a message to the console
  101618. */
  101619. Logger.Log = Logger._LogEnabled;
  101620. /**
  101621. * Write a warning message to the console
  101622. */
  101623. Logger.Warn = Logger._WarnEnabled;
  101624. /**
  101625. * Write an error message to the console
  101626. */
  101627. Logger.Error = Logger._ErrorEnabled;
  101628. return Logger;
  101629. }());
  101630. /***/ }),
  101631. /***/ "./Misc/meshExploder.ts":
  101632. /*!******************************!*\
  101633. !*** ./Misc/meshExploder.ts ***!
  101634. \******************************/
  101635. /*! exports provided: MeshExploder */
  101636. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101637. "use strict";
  101638. __webpack_require__.r(__webpack_exports__);
  101639. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return MeshExploder; });
  101640. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  101641. /**
  101642. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  101643. */
  101644. var MeshExploder = /** @class */ (function () {
  101645. /**
  101646. * Explodes meshes from a center mesh.
  101647. * @param meshes The meshes to explode.
  101648. * @param centerMesh The mesh to be center of explosion.
  101649. */
  101650. function MeshExploder(meshes, centerMesh) {
  101651. this._meshesOrigins = [];
  101652. this._toCenterVectors = [];
  101653. this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101654. this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101655. this._centerPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101656. this._meshes = meshes.slice();
  101657. if (centerMesh) {
  101658. this._centerMesh = centerMesh;
  101659. }
  101660. else {
  101661. this._setCenterMesh();
  101662. }
  101663. var centerMeshIndex = this._meshes.indexOf(this._centerMesh);
  101664. if (centerMeshIndex >= 0) {
  101665. this._meshes.splice(centerMeshIndex, 1);
  101666. }
  101667. this._centerPosition = this._centerMesh.getAbsolutePosition().clone();
  101668. for (var index = 0; index < this._meshes.length; index++) {
  101669. if (this._meshes[index]) {
  101670. var mesh = this._meshes[index];
  101671. this._meshesOrigins[index] = mesh.getAbsolutePosition().clone();
  101672. this._toCenterVectors[index] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101673. if (mesh._boundingInfo && this._centerMesh._boundingInfo) {
  101674. mesh._boundingInfo.boundingBox.centerWorld.subtractToRef(this._centerMesh._boundingInfo.boundingBox.centerWorld, this._toCenterVectors[index]);
  101675. }
  101676. }
  101677. }
  101678. }
  101679. MeshExploder.prototype._setCenterMesh = function () {
  101680. var averageCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101681. var totalCenters = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101682. var shortestToCenter = Number.MAX_VALUE;
  101683. for (var index = 0; index < this._meshes.length; index++) {
  101684. if (this._meshes[index]) {
  101685. var mesh = this._meshes[index];
  101686. var boundingInfo = mesh.getBoundingInfo();
  101687. if (boundingInfo) {
  101688. totalCenters.addInPlace(boundingInfo.boundingBox.centerWorld);
  101689. }
  101690. }
  101691. }
  101692. averageCenter = totalCenters.scale(1 / this._meshes.length);
  101693. for (var index = 0; index < this._meshes.length; index++) {
  101694. if (this._meshes[index]) {
  101695. var mesh = this._meshes[index];
  101696. var boundingInfo = mesh.getBoundingInfo();
  101697. if (boundingInfo) {
  101698. var distanceToCenter = boundingInfo.boundingBox.centerWorld.subtract(averageCenter).lengthSquared();
  101699. if (distanceToCenter < shortestToCenter) {
  101700. this._centerMesh = mesh;
  101701. shortestToCenter = distanceToCenter;
  101702. }
  101703. }
  101704. }
  101705. }
  101706. };
  101707. /**
  101708. * Get class name
  101709. * @returns "MeshExploder"
  101710. */
  101711. MeshExploder.prototype.getClassName = function () {
  101712. return "MeshExploder";
  101713. };
  101714. /**
  101715. * "Exploded meshes"
  101716. * @returns Array of meshes with the centerMesh at index 0.
  101717. */
  101718. MeshExploder.prototype.getMeshes = function () {
  101719. var meshArray = this._meshes.slice();
  101720. meshArray.unshift(this._centerMesh);
  101721. return meshArray;
  101722. };
  101723. /**
  101724. * Explodes meshes giving a specific direction
  101725. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  101726. */
  101727. MeshExploder.prototype.explode = function (direction) {
  101728. if (direction === void 0) { direction = 1.0; }
  101729. for (var index = 0; index < this._meshes.length; index++) {
  101730. if (this._meshes[index] && this._meshesOrigins[index] && this._toCenterVectors[index]) {
  101731. this._toCenterVectors[index].scaleToRef(direction, this._scaledDirection);
  101732. this._meshesOrigins[index].addToRef(this._scaledDirection, this._newPosition);
  101733. this._meshes[index].setAbsolutePosition(this._newPosition);
  101734. }
  101735. }
  101736. this._centerMesh.setAbsolutePosition(this._centerPosition);
  101737. };
  101738. return MeshExploder;
  101739. }());
  101740. /***/ }),
  101741. /***/ "./Misc/observable.ts":
  101742. /*!****************************!*\
  101743. !*** ./Misc/observable.ts ***!
  101744. \****************************/
  101745. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  101746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101747. "use strict";
  101748. __webpack_require__.r(__webpack_exports__);
  101749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  101750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  101751. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  101752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  101753. /**
  101754. * A class serves as a medium between the observable and its observers
  101755. */
  101756. var EventState = /** @class */ (function () {
  101757. /**
  101758. * Create a new EventState
  101759. * @param mask defines the mask associated with this state
  101760. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  101761. * @param target defines the original target of the state
  101762. * @param currentTarget defines the current target of the state
  101763. */
  101764. function EventState(mask, skipNextObservers, target, currentTarget) {
  101765. if (skipNextObservers === void 0) { skipNextObservers = false; }
  101766. this.initalize(mask, skipNextObservers, target, currentTarget);
  101767. }
  101768. /**
  101769. * Initialize the current event state
  101770. * @param mask defines the mask associated with this state
  101771. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  101772. * @param target defines the original target of the state
  101773. * @param currentTarget defines the current target of the state
  101774. * @returns the current event state
  101775. */
  101776. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  101777. if (skipNextObservers === void 0) { skipNextObservers = false; }
  101778. this.mask = mask;
  101779. this.skipNextObservers = skipNextObservers;
  101780. this.target = target;
  101781. this.currentTarget = currentTarget;
  101782. return this;
  101783. };
  101784. return EventState;
  101785. }());
  101786. /**
  101787. * Represent an Observer registered to a given Observable object.
  101788. */
  101789. var Observer = /** @class */ (function () {
  101790. /**
  101791. * Creates a new observer
  101792. * @param callback defines the callback to call when the observer is notified
  101793. * @param mask defines the mask of the observer (used to filter notifications)
  101794. * @param scope defines the current scope used to restore the JS context
  101795. */
  101796. function Observer(
  101797. /**
  101798. * Defines the callback to call when the observer is notified
  101799. */
  101800. callback,
  101801. /**
  101802. * Defines the mask of the observer (used to filter notifications)
  101803. */
  101804. mask,
  101805. /**
  101806. * Defines the current scope used to restore the JS context
  101807. */
  101808. scope) {
  101809. if (scope === void 0) { scope = null; }
  101810. this.callback = callback;
  101811. this.mask = mask;
  101812. this.scope = scope;
  101813. /** @hidden */
  101814. this._willBeUnregistered = false;
  101815. /**
  101816. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  101817. */
  101818. this.unregisterOnNextCall = false;
  101819. }
  101820. return Observer;
  101821. }());
  101822. /**
  101823. * Represent a list of observers registered to multiple Observables object.
  101824. */
  101825. var MultiObserver = /** @class */ (function () {
  101826. function MultiObserver() {
  101827. }
  101828. /**
  101829. * Release associated resources
  101830. */
  101831. MultiObserver.prototype.dispose = function () {
  101832. if (this._observers && this._observables) {
  101833. for (var index = 0; index < this._observers.length; index++) {
  101834. this._observables[index].remove(this._observers[index]);
  101835. }
  101836. }
  101837. this._observers = null;
  101838. this._observables = null;
  101839. };
  101840. /**
  101841. * Raise a callback when one of the observable will notify
  101842. * @param observables defines a list of observables to watch
  101843. * @param callback defines the callback to call on notification
  101844. * @param mask defines the mask used to filter notifications
  101845. * @param scope defines the current scope used to restore the JS context
  101846. * @returns the new MultiObserver
  101847. */
  101848. MultiObserver.Watch = function (observables, callback, mask, scope) {
  101849. if (mask === void 0) { mask = -1; }
  101850. if (scope === void 0) { scope = null; }
  101851. var result = new MultiObserver();
  101852. result._observers = new Array();
  101853. result._observables = observables;
  101854. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  101855. var observable = observables_1[_i];
  101856. var observer = observable.add(callback, mask, false, scope);
  101857. if (observer) {
  101858. result._observers.push(observer);
  101859. }
  101860. }
  101861. return result;
  101862. };
  101863. return MultiObserver;
  101864. }());
  101865. /**
  101866. * The Observable class is a simple implementation of the Observable pattern.
  101867. *
  101868. * 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.
  101869. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  101870. * 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).
  101871. * 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.
  101872. */
  101873. var Observable = /** @class */ (function () {
  101874. /**
  101875. * Creates a new observable
  101876. * @param onObserverAdded defines a callback to call when a new observer is added
  101877. */
  101878. function Observable(onObserverAdded) {
  101879. this._observers = new Array();
  101880. this._eventState = new EventState(0);
  101881. if (onObserverAdded) {
  101882. this._onObserverAdded = onObserverAdded;
  101883. }
  101884. }
  101885. /**
  101886. * Create a new Observer with the specified callback
  101887. * @param callback the callback that will be executed for that Observer
  101888. * @param mask the mask used to filter observers
  101889. * @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.
  101890. * @param scope optional scope for the callback to be called from
  101891. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  101892. * @returns the new observer created for the callback
  101893. */
  101894. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  101895. if (mask === void 0) { mask = -1; }
  101896. if (insertFirst === void 0) { insertFirst = false; }
  101897. if (scope === void 0) { scope = null; }
  101898. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  101899. if (!callback) {
  101900. return null;
  101901. }
  101902. var observer = new Observer(callback, mask, scope);
  101903. observer.unregisterOnNextCall = unregisterOnFirstCall;
  101904. if (insertFirst) {
  101905. this._observers.unshift(observer);
  101906. }
  101907. else {
  101908. this._observers.push(observer);
  101909. }
  101910. if (this._onObserverAdded) {
  101911. this._onObserverAdded(observer);
  101912. }
  101913. return observer;
  101914. };
  101915. /**
  101916. * Create a new Observer with the specified callback and unregisters after the next notification
  101917. * @param callback the callback that will be executed for that Observer
  101918. * @returns the new observer created for the callback
  101919. */
  101920. Observable.prototype.addOnce = function (callback) {
  101921. return this.add(callback, undefined, undefined, undefined, true);
  101922. };
  101923. /**
  101924. * Remove an Observer from the Observable object
  101925. * @param observer the instance of the Observer to remove
  101926. * @returns false if it doesn't belong to this Observable
  101927. */
  101928. Observable.prototype.remove = function (observer) {
  101929. if (!observer) {
  101930. return false;
  101931. }
  101932. var index = this._observers.indexOf(observer);
  101933. if (index !== -1) {
  101934. this._deferUnregister(observer);
  101935. return true;
  101936. }
  101937. return false;
  101938. };
  101939. /**
  101940. * Remove a callback from the Observable object
  101941. * @param callback the callback to remove
  101942. * @param scope optional scope. If used only the callbacks with this scope will be removed
  101943. * @returns false if it doesn't belong to this Observable
  101944. */
  101945. Observable.prototype.removeCallback = function (callback, scope) {
  101946. for (var index = 0; index < this._observers.length; index++) {
  101947. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  101948. this._deferUnregister(this._observers[index]);
  101949. return true;
  101950. }
  101951. }
  101952. return false;
  101953. };
  101954. Observable.prototype._deferUnregister = function (observer) {
  101955. var _this = this;
  101956. observer.unregisterOnNextCall = false;
  101957. observer._willBeUnregistered = true;
  101958. setTimeout(function () {
  101959. _this._remove(observer);
  101960. }, 0);
  101961. };
  101962. // This should only be called when not iterating over _observers to avoid callback skipping.
  101963. // Removes an observer from the _observer Array.
  101964. Observable.prototype._remove = function (observer) {
  101965. if (!observer) {
  101966. return false;
  101967. }
  101968. var index = this._observers.indexOf(observer);
  101969. if (index !== -1) {
  101970. this._observers.splice(index, 1);
  101971. return true;
  101972. }
  101973. return false;
  101974. };
  101975. /**
  101976. * Moves the observable to the top of the observer list making it get called first when notified
  101977. * @param observer the observer to move
  101978. */
  101979. Observable.prototype.makeObserverTopPriority = function (observer) {
  101980. this._remove(observer);
  101981. this._observers.unshift(observer);
  101982. };
  101983. /**
  101984. * Moves the observable to the bottom of the observer list making it get called last when notified
  101985. * @param observer the observer to move
  101986. */
  101987. Observable.prototype.makeObserverBottomPriority = function (observer) {
  101988. this._remove(observer);
  101989. this._observers.push(observer);
  101990. };
  101991. /**
  101992. * Notify all Observers by calling their respective callback with the given data
  101993. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  101994. * @param eventData defines the data to send to all observers
  101995. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  101996. * @param target defines the original target of the state
  101997. * @param currentTarget defines the current target of the state
  101998. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  101999. */
  102000. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  102001. if (mask === void 0) { mask = -1; }
  102002. if (!this._observers.length) {
  102003. return true;
  102004. }
  102005. var state = this._eventState;
  102006. state.mask = mask;
  102007. state.target = target;
  102008. state.currentTarget = currentTarget;
  102009. state.skipNextObservers = false;
  102010. state.lastReturnValue = eventData;
  102011. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  102012. var obs = _a[_i];
  102013. if (obs._willBeUnregistered) {
  102014. continue;
  102015. }
  102016. if (obs.mask & mask) {
  102017. if (obs.scope) {
  102018. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  102019. }
  102020. else {
  102021. state.lastReturnValue = obs.callback(eventData, state);
  102022. }
  102023. if (obs.unregisterOnNextCall) {
  102024. this._deferUnregister(obs);
  102025. }
  102026. }
  102027. if (state.skipNextObservers) {
  102028. return false;
  102029. }
  102030. }
  102031. return true;
  102032. };
  102033. /**
  102034. * Calling this will execute each callback, expecting it to be a promise or return a value.
  102035. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  102036. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  102037. * and it is crucial that all callbacks will be executed.
  102038. * The order of the callbacks is kept, callbacks are not executed parallel.
  102039. *
  102040. * @param eventData The data to be sent to each callback
  102041. * @param mask is used to filter observers defaults to -1
  102042. * @param target defines the callback target (see EventState)
  102043. * @param currentTarget defines he current object in the bubbling phase
  102044. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  102045. */
  102046. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  102047. var _this = this;
  102048. if (mask === void 0) { mask = -1; }
  102049. // create an empty promise
  102050. var p = Promise.resolve(eventData);
  102051. // no observers? return this promise.
  102052. if (!this._observers.length) {
  102053. return p;
  102054. }
  102055. var state = this._eventState;
  102056. state.mask = mask;
  102057. state.target = target;
  102058. state.currentTarget = currentTarget;
  102059. state.skipNextObservers = false;
  102060. // execute one callback after another (not using Promise.all, the order is important)
  102061. this._observers.forEach(function (obs) {
  102062. if (state.skipNextObservers) {
  102063. return;
  102064. }
  102065. if (obs._willBeUnregistered) {
  102066. return;
  102067. }
  102068. if (obs.mask & mask) {
  102069. if (obs.scope) {
  102070. p = p.then(function (lastReturnedValue) {
  102071. state.lastReturnValue = lastReturnedValue;
  102072. return obs.callback.apply(obs.scope, [eventData, state]);
  102073. });
  102074. }
  102075. else {
  102076. p = p.then(function (lastReturnedValue) {
  102077. state.lastReturnValue = lastReturnedValue;
  102078. return obs.callback(eventData, state);
  102079. });
  102080. }
  102081. if (obs.unregisterOnNextCall) {
  102082. _this._deferUnregister(obs);
  102083. }
  102084. }
  102085. });
  102086. // return the eventData
  102087. return p.then(function () { return eventData; });
  102088. };
  102089. /**
  102090. * Notify a specific observer
  102091. * @param observer defines the observer to notify
  102092. * @param eventData defines the data to be sent to each callback
  102093. * @param mask is used to filter observers defaults to -1
  102094. */
  102095. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  102096. if (mask === void 0) { mask = -1; }
  102097. var state = this._eventState;
  102098. state.mask = mask;
  102099. state.skipNextObservers = false;
  102100. observer.callback(eventData, state);
  102101. };
  102102. /**
  102103. * Gets a boolean indicating if the observable has at least one observer
  102104. * @returns true is the Observable has at least one Observer registered
  102105. */
  102106. Observable.prototype.hasObservers = function () {
  102107. return this._observers.length > 0;
  102108. };
  102109. /**
  102110. * Clear the list of observers
  102111. */
  102112. Observable.prototype.clear = function () {
  102113. this._observers = new Array();
  102114. this._onObserverAdded = null;
  102115. };
  102116. /**
  102117. * Clone the current observable
  102118. * @returns a new observable
  102119. */
  102120. Observable.prototype.clone = function () {
  102121. var result = new Observable();
  102122. result._observers = this._observers.slice(0);
  102123. return result;
  102124. };
  102125. /**
  102126. * Does this observable handles observer registered with a given mask
  102127. * @param mask defines the mask to be tested
  102128. * @return whether or not one observer registered with the given mask is handeled
  102129. **/
  102130. Observable.prototype.hasSpecificMask = function (mask) {
  102131. if (mask === void 0) { mask = -1; }
  102132. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  102133. var obs = _a[_i];
  102134. if (obs.mask & mask || obs.mask === mask) {
  102135. return true;
  102136. }
  102137. }
  102138. return false;
  102139. };
  102140. return Observable;
  102141. }());
  102142. /***/ }),
  102143. /***/ "./Misc/performanceMonitor.ts":
  102144. /*!************************************!*\
  102145. !*** ./Misc/performanceMonitor.ts ***!
  102146. \************************************/
  102147. /*! exports provided: PerformanceMonitor, RollingAverage */
  102148. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102149. "use strict";
  102150. __webpack_require__.r(__webpack_exports__);
  102151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  102152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  102153. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  102154. /**
  102155. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  102156. */
  102157. var PerformanceMonitor = /** @class */ (function () {
  102158. /**
  102159. * constructor
  102160. * @param frameSampleSize The number of samples required to saturate the sliding window
  102161. */
  102162. function PerformanceMonitor(frameSampleSize) {
  102163. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  102164. this._enabled = true;
  102165. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  102166. }
  102167. /**
  102168. * Samples current frame
  102169. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  102170. */
  102171. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  102172. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  102173. if (!this._enabled) {
  102174. return;
  102175. }
  102176. if (this._lastFrameTimeMs != null) {
  102177. var dt = timeMs - this._lastFrameTimeMs;
  102178. this._rollingFrameTime.add(dt);
  102179. }
  102180. this._lastFrameTimeMs = timeMs;
  102181. };
  102182. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  102183. /**
  102184. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  102185. */
  102186. get: function () {
  102187. return this._rollingFrameTime.average;
  102188. },
  102189. enumerable: true,
  102190. configurable: true
  102191. });
  102192. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  102193. /**
  102194. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  102195. */
  102196. get: function () {
  102197. return this._rollingFrameTime.variance;
  102198. },
  102199. enumerable: true,
  102200. configurable: true
  102201. });
  102202. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  102203. /**
  102204. * Returns the frame time of the most recent frame
  102205. */
  102206. get: function () {
  102207. return this._rollingFrameTime.history(0);
  102208. },
  102209. enumerable: true,
  102210. configurable: true
  102211. });
  102212. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  102213. /**
  102214. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  102215. */
  102216. get: function () {
  102217. return 1000.0 / this._rollingFrameTime.average;
  102218. },
  102219. enumerable: true,
  102220. configurable: true
  102221. });
  102222. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  102223. /**
  102224. * Returns the average framerate in frames per second using the most recent frame time
  102225. */
  102226. get: function () {
  102227. var history = this._rollingFrameTime.history(0);
  102228. if (history === 0) {
  102229. return 0;
  102230. }
  102231. return 1000.0 / history;
  102232. },
  102233. enumerable: true,
  102234. configurable: true
  102235. });
  102236. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  102237. /**
  102238. * Returns true if enough samples have been taken to completely fill the sliding window
  102239. */
  102240. get: function () {
  102241. return this._rollingFrameTime.isSaturated();
  102242. },
  102243. enumerable: true,
  102244. configurable: true
  102245. });
  102246. /**
  102247. * Enables contributions to the sliding window sample set
  102248. */
  102249. PerformanceMonitor.prototype.enable = function () {
  102250. this._enabled = true;
  102251. };
  102252. /**
  102253. * Disables contributions to the sliding window sample set
  102254. * Samples will not be interpolated over the disabled period
  102255. */
  102256. PerformanceMonitor.prototype.disable = function () {
  102257. this._enabled = false;
  102258. //clear last sample to avoid interpolating over the disabled period when next enabled
  102259. this._lastFrameTimeMs = null;
  102260. };
  102261. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  102262. /**
  102263. * Returns true if sampling is enabled
  102264. */
  102265. get: function () {
  102266. return this._enabled;
  102267. },
  102268. enumerable: true,
  102269. configurable: true
  102270. });
  102271. /**
  102272. * Resets performance monitor
  102273. */
  102274. PerformanceMonitor.prototype.reset = function () {
  102275. //clear last sample to avoid interpolating over the disabled period when next enabled
  102276. this._lastFrameTimeMs = null;
  102277. //wipe record
  102278. this._rollingFrameTime.reset();
  102279. };
  102280. return PerformanceMonitor;
  102281. }());
  102282. /**
  102283. * RollingAverage
  102284. *
  102285. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  102286. */
  102287. var RollingAverage = /** @class */ (function () {
  102288. /**
  102289. * constructor
  102290. * @param length The number of samples required to saturate the sliding window
  102291. */
  102292. function RollingAverage(length) {
  102293. this._samples = new Array(length);
  102294. this.reset();
  102295. }
  102296. /**
  102297. * Adds a sample to the sample set
  102298. * @param v The sample value
  102299. */
  102300. RollingAverage.prototype.add = function (v) {
  102301. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  102302. var delta;
  102303. //we need to check if we've already wrapped round
  102304. if (this.isSaturated()) {
  102305. //remove bottom of stack from mean
  102306. var bottomValue = this._samples[this._pos];
  102307. delta = bottomValue - this.average;
  102308. this.average -= delta / (this._sampleCount - 1);
  102309. this._m2 -= delta * (bottomValue - this.average);
  102310. }
  102311. else {
  102312. this._sampleCount++;
  102313. }
  102314. //add new value to mean
  102315. delta = v - this.average;
  102316. this.average += delta / (this._sampleCount);
  102317. this._m2 += delta * (v - this.average);
  102318. //set the new variance
  102319. this.variance = this._m2 / (this._sampleCount - 1);
  102320. this._samples[this._pos] = v;
  102321. this._pos++;
  102322. this._pos %= this._samples.length; //positive wrap around
  102323. };
  102324. /**
  102325. * Returns previously added values or null if outside of history or outside the sliding window domain
  102326. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  102327. * @return Value previously recorded with add() or null if outside of range
  102328. */
  102329. RollingAverage.prototype.history = function (i) {
  102330. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  102331. return 0;
  102332. }
  102333. var i0 = this._wrapPosition(this._pos - 1.0);
  102334. return this._samples[this._wrapPosition(i0 - i)];
  102335. };
  102336. /**
  102337. * Returns true if enough samples have been taken to completely fill the sliding window
  102338. * @return true if sample-set saturated
  102339. */
  102340. RollingAverage.prototype.isSaturated = function () {
  102341. return this._sampleCount >= this._samples.length;
  102342. };
  102343. /**
  102344. * Resets the rolling average (equivalent to 0 samples taken so far)
  102345. */
  102346. RollingAverage.prototype.reset = function () {
  102347. this.average = 0;
  102348. this.variance = 0;
  102349. this._sampleCount = 0;
  102350. this._pos = 0;
  102351. this._m2 = 0;
  102352. };
  102353. /**
  102354. * Wraps a value around the sample range boundaries
  102355. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  102356. * @return Wrapped position in sample range
  102357. */
  102358. RollingAverage.prototype._wrapPosition = function (i) {
  102359. var max = this._samples.length;
  102360. return ((i % max) + max) % max;
  102361. };
  102362. return RollingAverage;
  102363. }());
  102364. /***/ }),
  102365. /***/ "./Misc/pivotTools.ts":
  102366. /*!****************************!*\
  102367. !*** ./Misc/pivotTools.ts ***!
  102368. \****************************/
  102369. /*! exports provided: PivotTools */
  102370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102371. "use strict";
  102372. __webpack_require__.r(__webpack_exports__);
  102373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  102374. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  102375. /**
  102376. * Class containing a set of static utilities functions for managing Pivots
  102377. * @hidden
  102378. */
  102379. var PivotTools = /** @class */ (function () {
  102380. function PivotTools() {
  102381. }
  102382. /** @hidden */
  102383. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  102384. if (mesh && PivotTools._PivotCached === 0) {
  102385. // Save old pivot and set pivot to 0,0,0
  102386. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  102387. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  102388. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  102389. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  102390. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  102391. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  102392. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  102393. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  102394. }
  102395. }
  102396. PivotTools._PivotCached++;
  102397. };
  102398. /** @hidden */
  102399. PivotTools._RestorePivotPoint = function (mesh) {
  102400. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  102401. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  102402. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  102403. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  102404. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  102405. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  102406. }
  102407. this._PivotCached--;
  102408. };
  102409. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  102410. // store/remove pivot point should only be applied during their outermost calls
  102411. PivotTools._PivotCached = 0;
  102412. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  102413. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  102414. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  102415. return PivotTools;
  102416. }());
  102417. /***/ }),
  102418. /***/ "./Misc/precisionDate.ts":
  102419. /*!*******************************!*\
  102420. !*** ./Misc/precisionDate.ts ***!
  102421. \*******************************/
  102422. /*! exports provided: PrecisionDate */
  102423. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102424. "use strict";
  102425. __webpack_require__.r(__webpack_exports__);
  102426. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  102427. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  102428. /**
  102429. * Class containing a set of static utilities functions for precision date
  102430. */
  102431. var PrecisionDate = /** @class */ (function () {
  102432. function PrecisionDate() {
  102433. }
  102434. Object.defineProperty(PrecisionDate, "Now", {
  102435. /**
  102436. * Gets either window.performance.now() if supported or Date.now() else
  102437. */
  102438. get: function () {
  102439. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  102440. return window.performance.now();
  102441. }
  102442. return Date.now();
  102443. },
  102444. enumerable: true,
  102445. configurable: true
  102446. });
  102447. return PrecisionDate;
  102448. }());
  102449. /***/ }),
  102450. /***/ "./Misc/promise.ts":
  102451. /*!*************************!*\
  102452. !*** ./Misc/promise.ts ***!
  102453. \*************************/
  102454. /*! exports provided: PromisePolyfill */
  102455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102456. "use strict";
  102457. __webpack_require__.r(__webpack_exports__);
  102458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  102459. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  102460. var PromiseStates;
  102461. (function (PromiseStates) {
  102462. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  102463. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  102464. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  102465. })(PromiseStates || (PromiseStates = {}));
  102466. var FulFillmentAgregator = /** @class */ (function () {
  102467. function FulFillmentAgregator() {
  102468. this.count = 0;
  102469. this.target = 0;
  102470. this.results = [];
  102471. }
  102472. return FulFillmentAgregator;
  102473. }());
  102474. var InternalPromise = /** @class */ (function () {
  102475. function InternalPromise(resolver) {
  102476. var _this = this;
  102477. this._state = PromiseStates.Pending;
  102478. this._children = new Array();
  102479. this._rejectWasConsumed = false;
  102480. if (!resolver) {
  102481. return;
  102482. }
  102483. try {
  102484. resolver(function (value) {
  102485. _this._resolve(value);
  102486. }, function (reason) {
  102487. _this._reject(reason);
  102488. });
  102489. }
  102490. catch (e) {
  102491. this._reject(e);
  102492. }
  102493. }
  102494. Object.defineProperty(InternalPromise.prototype, "_result", {
  102495. get: function () {
  102496. return this._resultValue;
  102497. },
  102498. set: function (value) {
  102499. this._resultValue = value;
  102500. if (this._parent && this._parent._result === undefined) {
  102501. this._parent._result = value;
  102502. }
  102503. },
  102504. enumerable: true,
  102505. configurable: true
  102506. });
  102507. InternalPromise.prototype.catch = function (onRejected) {
  102508. return this.then(undefined, onRejected);
  102509. };
  102510. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  102511. var _this = this;
  102512. var newPromise = new InternalPromise();
  102513. newPromise._onFulfilled = onFulfilled;
  102514. newPromise._onRejected = onRejected;
  102515. // Composition
  102516. this._children.push(newPromise);
  102517. newPromise._parent = this;
  102518. if (this._state !== PromiseStates.Pending) {
  102519. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  102520. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  102521. var returnedValue = newPromise._resolve(_this._result);
  102522. if (returnedValue !== undefined && returnedValue !== null) {
  102523. if (returnedValue._state !== undefined) {
  102524. var returnedPromise = returnedValue;
  102525. newPromise._children.push(returnedPromise);
  102526. returnedPromise._parent = newPromise;
  102527. newPromise = returnedPromise;
  102528. }
  102529. else {
  102530. newPromise._result = returnedValue;
  102531. }
  102532. }
  102533. }
  102534. else {
  102535. newPromise._reject(_this._reason);
  102536. }
  102537. });
  102538. }
  102539. return newPromise;
  102540. };
  102541. InternalPromise.prototype._moveChildren = function (children) {
  102542. var _this = this;
  102543. var _a;
  102544. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  102545. this._children.forEach(function (child) {
  102546. child._parent = _this;
  102547. });
  102548. if (this._state === PromiseStates.Fulfilled) {
  102549. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  102550. var child = _b[_i];
  102551. child._resolve(this._result);
  102552. }
  102553. }
  102554. else if (this._state === PromiseStates.Rejected) {
  102555. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  102556. var child = _d[_c];
  102557. child._reject(this._reason);
  102558. }
  102559. }
  102560. };
  102561. InternalPromise.prototype._resolve = function (value) {
  102562. try {
  102563. this._state = PromiseStates.Fulfilled;
  102564. var returnedValue = null;
  102565. if (this._onFulfilled) {
  102566. returnedValue = this._onFulfilled(value);
  102567. }
  102568. if (returnedValue !== undefined && returnedValue !== null) {
  102569. if (returnedValue._state !== undefined) {
  102570. // Transmit children
  102571. var returnedPromise = returnedValue;
  102572. returnedPromise._parent = this;
  102573. returnedPromise._moveChildren(this._children);
  102574. value = returnedPromise._result;
  102575. }
  102576. else {
  102577. value = returnedValue;
  102578. }
  102579. }
  102580. this._result = value;
  102581. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  102582. var child = _a[_i];
  102583. child._resolve(value);
  102584. }
  102585. this._children.length = 0;
  102586. delete this._onFulfilled;
  102587. delete this._onRejected;
  102588. }
  102589. catch (e) {
  102590. this._reject(e, true);
  102591. }
  102592. };
  102593. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  102594. if (onLocalThrow === void 0) { onLocalThrow = false; }
  102595. this._state = PromiseStates.Rejected;
  102596. this._reason = reason;
  102597. if (this._onRejected && !onLocalThrow) {
  102598. try {
  102599. this._onRejected(reason);
  102600. this._rejectWasConsumed = true;
  102601. }
  102602. catch (e) {
  102603. reason = e;
  102604. }
  102605. }
  102606. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  102607. var child = _a[_i];
  102608. if (this._rejectWasConsumed) {
  102609. child._resolve(null);
  102610. }
  102611. else {
  102612. child._reject(reason);
  102613. }
  102614. }
  102615. this._children.length = 0;
  102616. delete this._onFulfilled;
  102617. delete this._onRejected;
  102618. };
  102619. InternalPromise.resolve = function (value) {
  102620. var newPromise = new InternalPromise();
  102621. newPromise._resolve(value);
  102622. return newPromise;
  102623. };
  102624. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  102625. promise.then(function (value) {
  102626. agregator.results[index] = value;
  102627. agregator.count++;
  102628. if (agregator.count === agregator.target) {
  102629. agregator.rootPromise._resolve(agregator.results);
  102630. }
  102631. return null;
  102632. }, function (reason) {
  102633. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  102634. agregator.rootPromise._reject(reason);
  102635. }
  102636. });
  102637. };
  102638. InternalPromise.all = function (promises) {
  102639. var newPromise = new InternalPromise();
  102640. var agregator = new FulFillmentAgregator();
  102641. agregator.target = promises.length;
  102642. agregator.rootPromise = newPromise;
  102643. if (promises.length) {
  102644. for (var index = 0; index < promises.length; index++) {
  102645. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  102646. }
  102647. }
  102648. else {
  102649. newPromise._resolve([]);
  102650. }
  102651. return newPromise;
  102652. };
  102653. InternalPromise.race = function (promises) {
  102654. var newPromise = new InternalPromise();
  102655. if (promises.length) {
  102656. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  102657. var promise = promises_1[_i];
  102658. promise.then(function (value) {
  102659. if (newPromise) {
  102660. newPromise._resolve(value);
  102661. newPromise = null;
  102662. }
  102663. return null;
  102664. }, function (reason) {
  102665. if (newPromise) {
  102666. newPromise._reject(reason);
  102667. newPromise = null;
  102668. }
  102669. });
  102670. }
  102671. }
  102672. return newPromise;
  102673. };
  102674. return InternalPromise;
  102675. }());
  102676. /**
  102677. * Helper class that provides a small promise polyfill
  102678. */
  102679. var PromisePolyfill = /** @class */ (function () {
  102680. function PromisePolyfill() {
  102681. }
  102682. /**
  102683. * Static function used to check if the polyfill is required
  102684. * If this is the case then the function will inject the polyfill to window.Promise
  102685. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  102686. */
  102687. PromisePolyfill.Apply = function (force) {
  102688. if (force === void 0) { force = false; }
  102689. if (force || typeof Promise === 'undefined') {
  102690. var root = window;
  102691. root.Promise = InternalPromise;
  102692. }
  102693. };
  102694. return PromisePolyfill;
  102695. }());
  102696. /***/ }),
  102697. /***/ "./Misc/sceneOptimizer.ts":
  102698. /*!********************************!*\
  102699. !*** ./Misc/sceneOptimizer.ts ***!
  102700. \********************************/
  102701. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  102702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102703. "use strict";
  102704. __webpack_require__.r(__webpack_exports__);
  102705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  102706. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  102707. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  102708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  102709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  102710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  102711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  102712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  102713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  102714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  102715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  102716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  102717. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102718. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  102719. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  102720. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  102721. /**
  102722. * Defines the root class used to create scene optimization to use with SceneOptimizer
  102723. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  102724. */
  102725. var SceneOptimization = /** @class */ (function () {
  102726. /**
  102727. * Creates the SceneOptimization object
  102728. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  102729. * @param desc defines the description associated with the optimization
  102730. */
  102731. function SceneOptimization(
  102732. /**
  102733. * Defines the priority of this optimization (0 by default which means first in the list)
  102734. */
  102735. priority) {
  102736. if (priority === void 0) { priority = 0; }
  102737. this.priority = priority;
  102738. }
  102739. /**
  102740. * Gets a string describing the action executed by the current optimization
  102741. * @returns description string
  102742. */
  102743. SceneOptimization.prototype.getDescription = function () {
  102744. return "";
  102745. };
  102746. /**
  102747. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  102748. * @param scene defines the current scene where to apply this optimization
  102749. * @param optimizer defines the current optimizer
  102750. * @returns true if everything that can be done was applied
  102751. */
  102752. SceneOptimization.prototype.apply = function (scene, optimizer) {
  102753. return true;
  102754. };
  102755. return SceneOptimization;
  102756. }());
  102757. /**
  102758. * Defines an optimization used to reduce the size of render target textures
  102759. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  102760. */
  102761. var TextureOptimization = /** @class */ (function (_super) {
  102762. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  102763. /**
  102764. * Creates the TextureOptimization object
  102765. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  102766. * @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
  102767. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  102768. */
  102769. function TextureOptimization(
  102770. /**
  102771. * Defines the priority of this optimization (0 by default which means first in the list)
  102772. */
  102773. priority,
  102774. /**
  102775. * 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
  102776. */
  102777. maximumSize,
  102778. /**
  102779. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  102780. */
  102781. step) {
  102782. if (priority === void 0) { priority = 0; }
  102783. if (maximumSize === void 0) { maximumSize = 1024; }
  102784. if (step === void 0) { step = 0.5; }
  102785. var _this = _super.call(this, priority) || this;
  102786. _this.priority = priority;
  102787. _this.maximumSize = maximumSize;
  102788. _this.step = step;
  102789. return _this;
  102790. }
  102791. /**
  102792. * Gets a string describing the action executed by the current optimization
  102793. * @returns description string
  102794. */
  102795. TextureOptimization.prototype.getDescription = function () {
  102796. return "Reducing render target texture size to " + this.maximumSize;
  102797. };
  102798. /**
  102799. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  102800. * @param scene defines the current scene where to apply this optimization
  102801. * @param optimizer defines the current optimizer
  102802. * @returns true if everything that can be done was applied
  102803. */
  102804. TextureOptimization.prototype.apply = function (scene, optimizer) {
  102805. var allDone = true;
  102806. for (var index = 0; index < scene.textures.length; index++) {
  102807. var texture = scene.textures[index];
  102808. if (!texture.canRescale || texture.getContext) {
  102809. continue;
  102810. }
  102811. var currentSize = texture.getSize();
  102812. var maxDimension = Math.max(currentSize.width, currentSize.height);
  102813. if (maxDimension > this.maximumSize) {
  102814. texture.scale(this.step);
  102815. allDone = false;
  102816. }
  102817. }
  102818. return allDone;
  102819. };
  102820. return TextureOptimization;
  102821. }(SceneOptimization));
  102822. /**
  102823. * Defines an optimization used to increase or decrease the rendering resolution
  102824. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  102825. */
  102826. var HardwareScalingOptimization = /** @class */ (function (_super) {
  102827. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  102828. /**
  102829. * Creates the HardwareScalingOptimization object
  102830. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  102831. * @param maximumScale defines the maximum scale to use (2 by default)
  102832. * @param step defines the step to use between two passes (0.5 by default)
  102833. */
  102834. function HardwareScalingOptimization(
  102835. /**
  102836. * Defines the priority of this optimization (0 by default which means first in the list)
  102837. */
  102838. priority,
  102839. /**
  102840. * Defines the maximum scale to use (2 by default)
  102841. */
  102842. maximumScale,
  102843. /**
  102844. * Defines the step to use between two passes (0.5 by default)
  102845. */
  102846. step) {
  102847. if (priority === void 0) { priority = 0; }
  102848. if (maximumScale === void 0) { maximumScale = 2; }
  102849. if (step === void 0) { step = 0.25; }
  102850. var _this = _super.call(this, priority) || this;
  102851. _this.priority = priority;
  102852. _this.maximumScale = maximumScale;
  102853. _this.step = step;
  102854. _this._currentScale = -1;
  102855. _this._directionOffset = 1;
  102856. return _this;
  102857. }
  102858. /**
  102859. * Gets a string describing the action executed by the current optimization
  102860. * @return description string
  102861. */
  102862. HardwareScalingOptimization.prototype.getDescription = function () {
  102863. return "Setting hardware scaling level to " + this._currentScale;
  102864. };
  102865. /**
  102866. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  102867. * @param scene defines the current scene where to apply this optimization
  102868. * @param optimizer defines the current optimizer
  102869. * @returns true if everything that can be done was applied
  102870. */
  102871. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  102872. if (this._currentScale === -1) {
  102873. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  102874. if (this._currentScale > this.maximumScale) {
  102875. this._directionOffset = -1;
  102876. }
  102877. }
  102878. this._currentScale += this._directionOffset * this.step;
  102879. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  102880. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  102881. };
  102882. return HardwareScalingOptimization;
  102883. }(SceneOptimization));
  102884. /**
  102885. * Defines an optimization used to remove shadows
  102886. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  102887. */
  102888. var ShadowsOptimization = /** @class */ (function (_super) {
  102889. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  102890. function ShadowsOptimization() {
  102891. return _super !== null && _super.apply(this, arguments) || this;
  102892. }
  102893. /**
  102894. * Gets a string describing the action executed by the current optimization
  102895. * @return description string
  102896. */
  102897. ShadowsOptimization.prototype.getDescription = function () {
  102898. return "Turning shadows on/off";
  102899. };
  102900. /**
  102901. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  102902. * @param scene defines the current scene where to apply this optimization
  102903. * @param optimizer defines the current optimizer
  102904. * @returns true if everything that can be done was applied
  102905. */
  102906. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  102907. scene.shadowsEnabled = optimizer.isInImprovementMode;
  102908. return true;
  102909. };
  102910. return ShadowsOptimization;
  102911. }(SceneOptimization));
  102912. /**
  102913. * Defines an optimization used to turn post-processes off
  102914. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  102915. */
  102916. var PostProcessesOptimization = /** @class */ (function (_super) {
  102917. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  102918. function PostProcessesOptimization() {
  102919. return _super !== null && _super.apply(this, arguments) || this;
  102920. }
  102921. /**
  102922. * Gets a string describing the action executed by the current optimization
  102923. * @return description string
  102924. */
  102925. PostProcessesOptimization.prototype.getDescription = function () {
  102926. return "Turning post-processes on/off";
  102927. };
  102928. /**
  102929. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  102930. * @param scene defines the current scene where to apply this optimization
  102931. * @param optimizer defines the current optimizer
  102932. * @returns true if everything that can be done was applied
  102933. */
  102934. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  102935. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  102936. return true;
  102937. };
  102938. return PostProcessesOptimization;
  102939. }(SceneOptimization));
  102940. /**
  102941. * Defines an optimization used to turn lens flares off
  102942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  102943. */
  102944. var LensFlaresOptimization = /** @class */ (function (_super) {
  102945. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  102946. function LensFlaresOptimization() {
  102947. return _super !== null && _super.apply(this, arguments) || this;
  102948. }
  102949. /**
  102950. * Gets a string describing the action executed by the current optimization
  102951. * @return description string
  102952. */
  102953. LensFlaresOptimization.prototype.getDescription = function () {
  102954. return "Turning lens flares on/off";
  102955. };
  102956. /**
  102957. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  102958. * @param scene defines the current scene where to apply this optimization
  102959. * @param optimizer defines the current optimizer
  102960. * @returns true if everything that can be done was applied
  102961. */
  102962. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  102963. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  102964. return true;
  102965. };
  102966. return LensFlaresOptimization;
  102967. }(SceneOptimization));
  102968. /**
  102969. * Defines an optimization based on user defined callback.
  102970. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  102971. */
  102972. var CustomOptimization = /** @class */ (function (_super) {
  102973. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  102974. function CustomOptimization() {
  102975. return _super !== null && _super.apply(this, arguments) || this;
  102976. }
  102977. /**
  102978. * Gets a string describing the action executed by the current optimization
  102979. * @returns description string
  102980. */
  102981. CustomOptimization.prototype.getDescription = function () {
  102982. if (this.onGetDescription) {
  102983. return this.onGetDescription();
  102984. }
  102985. return "Running user defined callback";
  102986. };
  102987. /**
  102988. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  102989. * @param scene defines the current scene where to apply this optimization
  102990. * @param optimizer defines the current optimizer
  102991. * @returns true if everything that can be done was applied
  102992. */
  102993. CustomOptimization.prototype.apply = function (scene, optimizer) {
  102994. if (this.onApply) {
  102995. return this.onApply(scene, optimizer);
  102996. }
  102997. return true;
  102998. };
  102999. return CustomOptimization;
  103000. }(SceneOptimization));
  103001. /**
  103002. * Defines an optimization used to turn particles off
  103003. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  103004. */
  103005. var ParticlesOptimization = /** @class */ (function (_super) {
  103006. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  103007. function ParticlesOptimization() {
  103008. return _super !== null && _super.apply(this, arguments) || this;
  103009. }
  103010. /**
  103011. * Gets a string describing the action executed by the current optimization
  103012. * @return description string
  103013. */
  103014. ParticlesOptimization.prototype.getDescription = function () {
  103015. return "Turning particles on/off";
  103016. };
  103017. /**
  103018. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  103019. * @param scene defines the current scene where to apply this optimization
  103020. * @param optimizer defines the current optimizer
  103021. * @returns true if everything that can be done was applied
  103022. */
  103023. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  103024. scene.particlesEnabled = optimizer.isInImprovementMode;
  103025. return true;
  103026. };
  103027. return ParticlesOptimization;
  103028. }(SceneOptimization));
  103029. /**
  103030. * Defines an optimization used to turn render targets off
  103031. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  103032. */
  103033. var RenderTargetsOptimization = /** @class */ (function (_super) {
  103034. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  103035. function RenderTargetsOptimization() {
  103036. return _super !== null && _super.apply(this, arguments) || this;
  103037. }
  103038. /**
  103039. * Gets a string describing the action executed by the current optimization
  103040. * @return description string
  103041. */
  103042. RenderTargetsOptimization.prototype.getDescription = function () {
  103043. return "Turning render targets off";
  103044. };
  103045. /**
  103046. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  103047. * @param scene defines the current scene where to apply this optimization
  103048. * @param optimizer defines the current optimizer
  103049. * @returns true if everything that can be done was applied
  103050. */
  103051. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  103052. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  103053. return true;
  103054. };
  103055. return RenderTargetsOptimization;
  103056. }(SceneOptimization));
  103057. /**
  103058. * Defines an optimization used to merge meshes with compatible materials
  103059. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  103060. */
  103061. var MergeMeshesOptimization = /** @class */ (function (_super) {
  103062. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  103063. function MergeMeshesOptimization() {
  103064. var _this = _super !== null && _super.apply(this, arguments) || this;
  103065. _this._canBeMerged = function (abstractMesh) {
  103066. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  103067. return false;
  103068. }
  103069. var mesh = abstractMesh;
  103070. if (mesh.isDisposed()) {
  103071. return false;
  103072. }
  103073. if (!mesh.isVisible || !mesh.isEnabled()) {
  103074. return false;
  103075. }
  103076. if (mesh.instances.length > 0) {
  103077. return false;
  103078. }
  103079. if (mesh.skeleton || mesh.hasLODLevels) {
  103080. return false;
  103081. }
  103082. return true;
  103083. };
  103084. return _this;
  103085. }
  103086. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  103087. /**
  103088. * Gets or sets a boolean which defines if optimization octree has to be updated
  103089. */
  103090. get: function () {
  103091. return MergeMeshesOptimization._UpdateSelectionTree;
  103092. },
  103093. /**
  103094. * Gets or sets a boolean which defines if optimization octree has to be updated
  103095. */
  103096. set: function (value) {
  103097. MergeMeshesOptimization._UpdateSelectionTree = value;
  103098. },
  103099. enumerable: true,
  103100. configurable: true
  103101. });
  103102. /**
  103103. * Gets a string describing the action executed by the current optimization
  103104. * @return description string
  103105. */
  103106. MergeMeshesOptimization.prototype.getDescription = function () {
  103107. return "Merging similar meshes together";
  103108. };
  103109. /**
  103110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  103111. * @param scene defines the current scene where to apply this optimization
  103112. * @param optimizer defines the current optimizer
  103113. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  103114. * @returns true if everything that can be done was applied
  103115. */
  103116. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  103117. var globalPool = scene.meshes.slice(0);
  103118. var globalLength = globalPool.length;
  103119. for (var index = 0; index < globalLength; index++) {
  103120. var currentPool = new Array();
  103121. var current = globalPool[index];
  103122. // Checks
  103123. if (!this._canBeMerged(current)) {
  103124. continue;
  103125. }
  103126. currentPool.push(current);
  103127. // Find compatible meshes
  103128. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  103129. var otherMesh = globalPool[subIndex];
  103130. if (!this._canBeMerged(otherMesh)) {
  103131. continue;
  103132. }
  103133. if (otherMesh.material !== current.material) {
  103134. continue;
  103135. }
  103136. if (otherMesh.checkCollisions !== current.checkCollisions) {
  103137. continue;
  103138. }
  103139. currentPool.push(otherMesh);
  103140. globalLength--;
  103141. globalPool.splice(subIndex, 1);
  103142. subIndex--;
  103143. }
  103144. if (currentPool.length < 2) {
  103145. continue;
  103146. }
  103147. // Merge meshes
  103148. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  103149. }
  103150. // Call the octree system optimization if it is defined.
  103151. var sceneAsAny = scene;
  103152. if (sceneAsAny.createOrUpdateSelectionOctree) {
  103153. if (updateSelectionTree != undefined) {
  103154. if (updateSelectionTree) {
  103155. sceneAsAny.createOrUpdateSelectionOctree();
  103156. }
  103157. }
  103158. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  103159. sceneAsAny.createOrUpdateSelectionOctree();
  103160. }
  103161. }
  103162. return true;
  103163. };
  103164. MergeMeshesOptimization._UpdateSelectionTree = false;
  103165. return MergeMeshesOptimization;
  103166. }(SceneOptimization));
  103167. /**
  103168. * Defines a list of options used by SceneOptimizer
  103169. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  103170. */
  103171. var SceneOptimizerOptions = /** @class */ (function () {
  103172. /**
  103173. * Creates a new list of options used by SceneOptimizer
  103174. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  103175. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  103176. */
  103177. function SceneOptimizerOptions(
  103178. /**
  103179. * Defines the target frame rate to reach (60 by default)
  103180. */
  103181. targetFrameRate,
  103182. /**
  103183. * Defines the interval between two checkes (2000ms by default)
  103184. */
  103185. trackerDuration) {
  103186. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  103187. if (trackerDuration === void 0) { trackerDuration = 2000; }
  103188. this.targetFrameRate = targetFrameRate;
  103189. this.trackerDuration = trackerDuration;
  103190. /**
  103191. * Gets the list of optimizations to apply
  103192. */
  103193. this.optimizations = new Array();
  103194. }
  103195. /**
  103196. * Add a new optimization
  103197. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  103198. * @returns the current SceneOptimizerOptions
  103199. */
  103200. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  103201. this.optimizations.push(optimization);
  103202. return this;
  103203. };
  103204. /**
  103205. * Add a new custom optimization
  103206. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  103207. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  103208. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  103209. * @returns the current SceneOptimizerOptions
  103210. */
  103211. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  103212. if (priority === void 0) { priority = 0; }
  103213. var optimization = new CustomOptimization(priority);
  103214. optimization.onApply = onApply;
  103215. optimization.onGetDescription = onGetDescription;
  103216. this.optimizations.push(optimization);
  103217. return this;
  103218. };
  103219. /**
  103220. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  103221. * @param targetFrameRate defines the target frame rate (60 by default)
  103222. * @returns a SceneOptimizerOptions object
  103223. */
  103224. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  103225. var result = new SceneOptimizerOptions(targetFrameRate);
  103226. var priority = 0;
  103227. result.addOptimization(new MergeMeshesOptimization(priority));
  103228. result.addOptimization(new ShadowsOptimization(priority));
  103229. result.addOptimization(new LensFlaresOptimization(priority));
  103230. // Next priority
  103231. priority++;
  103232. result.addOptimization(new PostProcessesOptimization(priority));
  103233. result.addOptimization(new ParticlesOptimization(priority));
  103234. // Next priority
  103235. priority++;
  103236. result.addOptimization(new TextureOptimization(priority, 1024));
  103237. return result;
  103238. };
  103239. /**
  103240. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  103241. * @param targetFrameRate defines the target frame rate (60 by default)
  103242. * @returns a SceneOptimizerOptions object
  103243. */
  103244. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  103245. var result = new SceneOptimizerOptions(targetFrameRate);
  103246. var priority = 0;
  103247. result.addOptimization(new MergeMeshesOptimization(priority));
  103248. result.addOptimization(new ShadowsOptimization(priority));
  103249. result.addOptimization(new LensFlaresOptimization(priority));
  103250. // Next priority
  103251. priority++;
  103252. result.addOptimization(new PostProcessesOptimization(priority));
  103253. result.addOptimization(new ParticlesOptimization(priority));
  103254. // Next priority
  103255. priority++;
  103256. result.addOptimization(new TextureOptimization(priority, 512));
  103257. // Next priority
  103258. priority++;
  103259. result.addOptimization(new RenderTargetsOptimization(priority));
  103260. // Next priority
  103261. priority++;
  103262. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  103263. return result;
  103264. };
  103265. /**
  103266. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  103267. * @param targetFrameRate defines the target frame rate (60 by default)
  103268. * @returns a SceneOptimizerOptions object
  103269. */
  103270. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  103271. var result = new SceneOptimizerOptions(targetFrameRate);
  103272. var priority = 0;
  103273. result.addOptimization(new MergeMeshesOptimization(priority));
  103274. result.addOptimization(new ShadowsOptimization(priority));
  103275. result.addOptimization(new LensFlaresOptimization(priority));
  103276. // Next priority
  103277. priority++;
  103278. result.addOptimization(new PostProcessesOptimization(priority));
  103279. result.addOptimization(new ParticlesOptimization(priority));
  103280. // Next priority
  103281. priority++;
  103282. result.addOptimization(new TextureOptimization(priority, 256));
  103283. // Next priority
  103284. priority++;
  103285. result.addOptimization(new RenderTargetsOptimization(priority));
  103286. // Next priority
  103287. priority++;
  103288. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  103289. return result;
  103290. };
  103291. return SceneOptimizerOptions;
  103292. }());
  103293. /**
  103294. * Class used to run optimizations in order to reach a target frame rate
  103295. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  103296. */
  103297. var SceneOptimizer = /** @class */ (function () {
  103298. /**
  103299. * Creates a new SceneOptimizer
  103300. * @param scene defines the scene to work on
  103301. * @param options defines the options to use with the SceneOptimizer
  103302. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  103303. * @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)
  103304. */
  103305. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  103306. var _this = this;
  103307. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  103308. if (improvementMode === void 0) { improvementMode = false; }
  103309. this._isRunning = false;
  103310. this._currentPriorityLevel = 0;
  103311. this._targetFrameRate = 60;
  103312. this._trackerDuration = 2000;
  103313. this._currentFrameRate = 0;
  103314. this._improvementMode = false;
  103315. /**
  103316. * Defines an observable called when the optimizer reaches the target frame rate
  103317. */
  103318. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  103319. /**
  103320. * Defines an observable called when the optimizer enables an optimization
  103321. */
  103322. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  103323. /**
  103324. * Defines an observable called when the optimizer is not able to reach the target frame rate
  103325. */
  103326. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  103327. if (!options) {
  103328. this._options = new SceneOptimizerOptions();
  103329. }
  103330. else {
  103331. this._options = options;
  103332. }
  103333. if (this._options.targetFrameRate) {
  103334. this._targetFrameRate = this._options.targetFrameRate;
  103335. }
  103336. if (this._options.trackerDuration) {
  103337. this._trackerDuration = this._options.trackerDuration;
  103338. }
  103339. if (autoGeneratePriorities) {
  103340. var priority = 0;
  103341. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  103342. var optim = _a[_i];
  103343. optim.priority = priority++;
  103344. }
  103345. }
  103346. this._improvementMode = improvementMode;
  103347. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  103348. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  103349. _this._sceneDisposeObserver = null;
  103350. _this.dispose();
  103351. });
  103352. }
  103353. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  103354. /**
  103355. * Gets a boolean indicating if the optimizer is in improvement mode
  103356. */
  103357. get: function () {
  103358. return this._improvementMode;
  103359. },
  103360. enumerable: true,
  103361. configurable: true
  103362. });
  103363. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  103364. /**
  103365. * Gets the current priority level (0 at start)
  103366. */
  103367. get: function () {
  103368. return this._currentPriorityLevel;
  103369. },
  103370. enumerable: true,
  103371. configurable: true
  103372. });
  103373. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  103374. /**
  103375. * Gets the current frame rate checked by the SceneOptimizer
  103376. */
  103377. get: function () {
  103378. return this._currentFrameRate;
  103379. },
  103380. enumerable: true,
  103381. configurable: true
  103382. });
  103383. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  103384. /**
  103385. * Gets or sets the current target frame rate (60 by default)
  103386. */
  103387. get: function () {
  103388. return this._targetFrameRate;
  103389. },
  103390. /**
  103391. * Gets or sets the current target frame rate (60 by default)
  103392. */
  103393. set: function (value) {
  103394. this._targetFrameRate = value;
  103395. },
  103396. enumerable: true,
  103397. configurable: true
  103398. });
  103399. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  103400. /**
  103401. * Gets or sets the current interval between two checks (every 2000ms by default)
  103402. */
  103403. get: function () {
  103404. return this._trackerDuration;
  103405. },
  103406. /**
  103407. * Gets or sets the current interval between two checks (every 2000ms by default)
  103408. */
  103409. set: function (value) {
  103410. this._trackerDuration = value;
  103411. },
  103412. enumerable: true,
  103413. configurable: true
  103414. });
  103415. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  103416. /**
  103417. * Gets the list of active optimizations
  103418. */
  103419. get: function () {
  103420. return this._options.optimizations;
  103421. },
  103422. enumerable: true,
  103423. configurable: true
  103424. });
  103425. /**
  103426. * Stops the current optimizer
  103427. */
  103428. SceneOptimizer.prototype.stop = function () {
  103429. this._isRunning = false;
  103430. };
  103431. /**
  103432. * Reset the optimizer to initial step (current priority level = 0)
  103433. */
  103434. SceneOptimizer.prototype.reset = function () {
  103435. this._currentPriorityLevel = 0;
  103436. };
  103437. /**
  103438. * Start the optimizer. By default it will try to reach a specific framerate
  103439. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  103440. */
  103441. SceneOptimizer.prototype.start = function () {
  103442. var _this = this;
  103443. if (this._isRunning) {
  103444. return;
  103445. }
  103446. this._isRunning = true;
  103447. // Let's wait for the scene to be ready before running our check
  103448. this._scene.executeWhenReady(function () {
  103449. setTimeout(function () {
  103450. _this._checkCurrentState();
  103451. }, _this._trackerDuration);
  103452. });
  103453. };
  103454. SceneOptimizer.prototype._checkCurrentState = function () {
  103455. var _this = this;
  103456. if (!this._isRunning) {
  103457. return;
  103458. }
  103459. var scene = this._scene;
  103460. var options = this._options;
  103461. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  103462. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  103463. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  103464. this._isRunning = false;
  103465. this.onSuccessObservable.notifyObservers(this);
  103466. return;
  103467. }
  103468. // Apply current level of optimizations
  103469. var allDone = true;
  103470. var noOptimizationApplied = true;
  103471. for (var index = 0; index < options.optimizations.length; index++) {
  103472. var optimization = options.optimizations[index];
  103473. if (optimization.priority === this._currentPriorityLevel) {
  103474. noOptimizationApplied = false;
  103475. allDone = allDone && optimization.apply(scene, this);
  103476. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  103477. }
  103478. }
  103479. // If no optimization was applied, this is a failure :(
  103480. if (noOptimizationApplied) {
  103481. this._isRunning = false;
  103482. this.onFailureObservable.notifyObservers(this);
  103483. return;
  103484. }
  103485. // If all optimizations were done, move to next level
  103486. if (allDone) {
  103487. this._currentPriorityLevel++;
  103488. }
  103489. // Let's the system running for a specific amount of time before checking FPS
  103490. scene.executeWhenReady(function () {
  103491. setTimeout(function () {
  103492. _this._checkCurrentState();
  103493. }, _this._trackerDuration);
  103494. });
  103495. };
  103496. /**
  103497. * Release all resources
  103498. */
  103499. SceneOptimizer.prototype.dispose = function () {
  103500. this.stop();
  103501. this.onSuccessObservable.clear();
  103502. this.onFailureObservable.clear();
  103503. this.onNewOptimizationAppliedObservable.clear();
  103504. if (this._sceneDisposeObserver) {
  103505. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  103506. }
  103507. };
  103508. /**
  103509. * Helper function to create a SceneOptimizer with one single line of code
  103510. * @param scene defines the scene to work on
  103511. * @param options defines the options to use with the SceneOptimizer
  103512. * @param onSuccess defines a callback to call on success
  103513. * @param onFailure defines a callback to call on failure
  103514. * @returns the new SceneOptimizer object
  103515. */
  103516. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  103517. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  103518. if (onSuccess) {
  103519. optimizer.onSuccessObservable.add(function () {
  103520. onSuccess();
  103521. });
  103522. }
  103523. if (onFailure) {
  103524. optimizer.onFailureObservable.add(function () {
  103525. onFailure();
  103526. });
  103527. }
  103528. optimizer.start();
  103529. return optimizer;
  103530. };
  103531. return SceneOptimizer;
  103532. }());
  103533. /***/ }),
  103534. /***/ "./Misc/sceneSerializer.ts":
  103535. /*!*********************************!*\
  103536. !*** ./Misc/sceneSerializer.ts ***!
  103537. \*********************************/
  103538. /*! exports provided: SceneSerializer */
  103539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103540. "use strict";
  103541. __webpack_require__.r(__webpack_exports__);
  103542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  103543. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  103544. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  103545. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  103546. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  103547. var serializedGeometries = [];
  103548. var serializeGeometry = function (geometry, serializationGeometries) {
  103549. if (serializedGeometries[geometry.id]) {
  103550. return;
  103551. }
  103552. if (geometry.doNotSerialize) {
  103553. return;
  103554. }
  103555. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  103556. serializedGeometries[geometry.id] = true;
  103557. };
  103558. var serializeMesh = function (mesh, serializationScene) {
  103559. var serializationObject = {};
  103560. // Geometry
  103561. var geometry = mesh._geometry;
  103562. if (geometry) {
  103563. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  103564. // 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
  103565. serializeGeometry(geometry, serializationScene.geometries);
  103566. }
  103567. }
  103568. // Custom
  103569. if (mesh.serialize) {
  103570. mesh.serialize(serializationObject);
  103571. }
  103572. return serializationObject;
  103573. };
  103574. var finalizeSingleMesh = function (mesh, serializationObject) {
  103575. //only works if the mesh is already loaded
  103576. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  103577. //serialize material
  103578. if (mesh.material) {
  103579. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  103580. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  103581. serializationObject.materials = serializationObject.materials || [];
  103582. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  103583. serializationObject.multiMaterials.push(mesh.material.serialize());
  103584. var _loop_1 = function (submaterial) {
  103585. if (submaterial) {
  103586. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  103587. serializationObject.materials.push(submaterial.serialize());
  103588. }
  103589. }
  103590. };
  103591. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  103592. var submaterial = _a[_i];
  103593. _loop_1(submaterial);
  103594. }
  103595. }
  103596. }
  103597. else {
  103598. serializationObject.materials = serializationObject.materials || [];
  103599. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  103600. serializationObject.materials.push(mesh.material.serialize());
  103601. }
  103602. }
  103603. }
  103604. //serialize geometry
  103605. var geometry = mesh._geometry;
  103606. if (geometry) {
  103607. if (!serializationObject.geometries) {
  103608. serializationObject.geometries = {};
  103609. serializationObject.geometries.boxes = [];
  103610. serializationObject.geometries.spheres = [];
  103611. serializationObject.geometries.cylinders = [];
  103612. serializationObject.geometries.toruses = [];
  103613. serializationObject.geometries.grounds = [];
  103614. serializationObject.geometries.planes = [];
  103615. serializationObject.geometries.torusKnots = [];
  103616. serializationObject.geometries.vertexData = [];
  103617. }
  103618. serializeGeometry(geometry, serializationObject.geometries);
  103619. }
  103620. // Skeletons
  103621. if (mesh.skeleton) {
  103622. serializationObject.skeletons = serializationObject.skeletons || [];
  103623. serializationObject.skeletons.push(mesh.skeleton.serialize());
  103624. }
  103625. //serialize the actual mesh
  103626. serializationObject.meshes = serializationObject.meshes || [];
  103627. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  103628. }
  103629. };
  103630. /**
  103631. * Class used to serialize a scene into a string
  103632. */
  103633. var SceneSerializer = /** @class */ (function () {
  103634. function SceneSerializer() {
  103635. }
  103636. /**
  103637. * Clear cache used by a previous serialization
  103638. */
  103639. SceneSerializer.ClearCache = function () {
  103640. serializedGeometries = [];
  103641. };
  103642. /**
  103643. * Serialize a scene into a JSON compatible object
  103644. * @param scene defines the scene to serialize
  103645. * @returns a JSON compatible object
  103646. */
  103647. SceneSerializer.Serialize = function (scene) {
  103648. var serializationObject = {};
  103649. SceneSerializer.ClearCache();
  103650. // Scene
  103651. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  103652. serializationObject.autoClear = scene.autoClear;
  103653. serializationObject.clearColor = scene.clearColor.asArray();
  103654. serializationObject.ambientColor = scene.ambientColor.asArray();
  103655. serializationObject.gravity = scene.gravity.asArray();
  103656. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  103657. // Fog
  103658. if (scene.fogMode && scene.fogMode !== 0) {
  103659. serializationObject.fogMode = scene.fogMode;
  103660. serializationObject.fogColor = scene.fogColor.asArray();
  103661. serializationObject.fogStart = scene.fogStart;
  103662. serializationObject.fogEnd = scene.fogEnd;
  103663. serializationObject.fogDensity = scene.fogDensity;
  103664. }
  103665. //Physics
  103666. if (scene.isPhysicsEnabled()) {
  103667. var physicEngine = scene.getPhysicsEngine();
  103668. if (physicEngine) {
  103669. serializationObject.physicsEnabled = true;
  103670. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  103671. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  103672. }
  103673. }
  103674. // Metadata
  103675. if (scene.metadata) {
  103676. serializationObject.metadata = scene.metadata;
  103677. }
  103678. // Morph targets
  103679. serializationObject.morphTargetManagers = [];
  103680. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  103681. var abstractMesh = _a[_i];
  103682. var manager = abstractMesh.morphTargetManager;
  103683. if (manager) {
  103684. serializationObject.morphTargetManagers.push(manager.serialize());
  103685. }
  103686. }
  103687. // Lights
  103688. serializationObject.lights = [];
  103689. var index;
  103690. var light;
  103691. for (index = 0; index < scene.lights.length; index++) {
  103692. light = scene.lights[index];
  103693. if (!light.doNotSerialize) {
  103694. serializationObject.lights.push(light.serialize());
  103695. }
  103696. }
  103697. // Cameras
  103698. serializationObject.cameras = [];
  103699. for (index = 0; index < scene.cameras.length; index++) {
  103700. var camera = scene.cameras[index];
  103701. if (!camera.doNotSerialize) {
  103702. serializationObject.cameras.push(camera.serialize());
  103703. }
  103704. }
  103705. if (scene.activeCamera) {
  103706. serializationObject.activeCameraID = scene.activeCamera.id;
  103707. }
  103708. // Animations
  103709. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  103710. // Reflection probes
  103711. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  103712. serializationObject.reflectionProbes = [];
  103713. for (index = 0; index < scene.reflectionProbes.length; index++) {
  103714. var reflectionProbe = scene.reflectionProbes[index];
  103715. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  103716. }
  103717. }
  103718. // Materials
  103719. serializationObject.materials = [];
  103720. serializationObject.multiMaterials = [];
  103721. var material;
  103722. for (index = 0; index < scene.materials.length; index++) {
  103723. material = scene.materials[index];
  103724. if (!material.doNotSerialize) {
  103725. serializationObject.materials.push(material.serialize());
  103726. }
  103727. }
  103728. // MultiMaterials
  103729. serializationObject.multiMaterials = [];
  103730. for (index = 0; index < scene.multiMaterials.length; index++) {
  103731. var multiMaterial = scene.multiMaterials[index];
  103732. serializationObject.multiMaterials.push(multiMaterial.serialize());
  103733. }
  103734. // Environment texture
  103735. if (scene.environmentTexture) {
  103736. serializationObject.environmentTexture = scene.environmentTexture.name;
  103737. }
  103738. // Skeletons
  103739. serializationObject.skeletons = [];
  103740. for (index = 0; index < scene.skeletons.length; index++) {
  103741. var skeleton = scene.skeletons[index];
  103742. if (!skeleton.doNotSerialize) {
  103743. serializationObject.skeletons.push(skeleton.serialize());
  103744. }
  103745. }
  103746. // Transform nodes
  103747. serializationObject.transformNodes = [];
  103748. for (index = 0; index < scene.transformNodes.length; index++) {
  103749. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  103750. }
  103751. // Geometries
  103752. serializationObject.geometries = {};
  103753. serializationObject.geometries.boxes = [];
  103754. serializationObject.geometries.spheres = [];
  103755. serializationObject.geometries.cylinders = [];
  103756. serializationObject.geometries.toruses = [];
  103757. serializationObject.geometries.grounds = [];
  103758. serializationObject.geometries.planes = [];
  103759. serializationObject.geometries.torusKnots = [];
  103760. serializationObject.geometries.vertexData = [];
  103761. serializedGeometries = [];
  103762. var geometries = scene.getGeometries();
  103763. for (index = 0; index < geometries.length; index++) {
  103764. var geometry = geometries[index];
  103765. if (geometry.isReady()) {
  103766. serializeGeometry(geometry, serializationObject.geometries);
  103767. }
  103768. }
  103769. // Meshes
  103770. serializationObject.meshes = [];
  103771. for (index = 0; index < scene.meshes.length; index++) {
  103772. var abstractMesh = scene.meshes[index];
  103773. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  103774. var mesh = abstractMesh;
  103775. if (!mesh.doNotSerialize) {
  103776. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  103777. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  103778. }
  103779. }
  103780. }
  103781. }
  103782. // Particles Systems
  103783. serializationObject.particleSystems = [];
  103784. for (index = 0; index < scene.particleSystems.length; index++) {
  103785. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  103786. }
  103787. // Action Manager
  103788. if (scene.actionManager) {
  103789. serializationObject.actions = scene.actionManager.serialize("scene");
  103790. }
  103791. // Components
  103792. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  103793. var component = _c[_b];
  103794. component.serialize(serializationObject);
  103795. }
  103796. return serializationObject;
  103797. };
  103798. /**
  103799. * Serialize a mesh into a JSON compatible object
  103800. * @param toSerialize defines the mesh to serialize
  103801. * @param withParents defines if parents must be serialized as well
  103802. * @param withChildren defines if children must be serialized as well
  103803. * @returns a JSON compatible object
  103804. */
  103805. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  103806. if (withParents === void 0) { withParents = false; }
  103807. if (withChildren === void 0) { withChildren = false; }
  103808. var serializationObject = {};
  103809. SceneSerializer.ClearCache();
  103810. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  103811. if (withParents || withChildren) {
  103812. //deliberate for loop! not for each, appended should be processed as well.
  103813. for (var i = 0; i < toSerialize.length; ++i) {
  103814. if (withChildren) {
  103815. toSerialize[i].getDescendants().forEach(function (node) {
  103816. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  103817. toSerialize.push(node);
  103818. }
  103819. });
  103820. }
  103821. //make sure the array doesn't contain the object already
  103822. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  103823. toSerialize.push(toSerialize[i].parent);
  103824. }
  103825. }
  103826. }
  103827. toSerialize.forEach(function (mesh) {
  103828. finalizeSingleMesh(mesh, serializationObject);
  103829. });
  103830. return serializationObject;
  103831. };
  103832. return SceneSerializer;
  103833. }());
  103834. /***/ }),
  103835. /***/ "./Misc/screenshotTools.ts":
  103836. /*!*********************************!*\
  103837. !*** ./Misc/screenshotTools.ts ***!
  103838. \*********************************/
  103839. /*! exports provided: ScreenshotTools */
  103840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103841. "use strict";
  103842. __webpack_require__.r(__webpack_exports__);
  103843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  103844. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  103845. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  103846. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  103847. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  103848. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  103849. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  103850. /**
  103851. * Class containing a set of static utilities functions for screenshots
  103852. */
  103853. var ScreenshotTools = /** @class */ (function () {
  103854. function ScreenshotTools() {
  103855. }
  103856. /**
  103857. * Captures a screenshot of the current rendering
  103858. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103859. * @param engine defines the rendering engine
  103860. * @param camera defines the source camera
  103861. * @param size This parameter can be set to a single number or to an object with the
  103862. * following (optional) properties: precision, width, height. If a single number is passed,
  103863. * it will be used for both width and height. If an object is passed, the screenshot size
  103864. * will be derived from the parameters. The precision property is a multiplier allowing
  103865. * rendering at a higher or lower resolution
  103866. * @param successCallback defines the callback receives a single parameter which contains the
  103867. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  103868. * src parameter of an <img> to display it
  103869. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  103870. * Check your browser for supported MIME types
  103871. */
  103872. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  103873. if (mimeType === void 0) { mimeType = "image/png"; }
  103874. var width;
  103875. var height;
  103876. // If a precision value is specified
  103877. if (size.precision) {
  103878. width = Math.round(engine.getRenderWidth() * size.precision);
  103879. height = Math.round(width / engine.getAspectRatio(camera));
  103880. }
  103881. else if (size.width && size.height) {
  103882. width = size.width;
  103883. height = size.height;
  103884. }
  103885. //If passing only width, computing height to keep display canvas ratio.
  103886. else if (size.width && !size.height) {
  103887. width = size.width;
  103888. height = Math.round(width / engine.getAspectRatio(camera));
  103889. }
  103890. //If passing only height, computing width to keep display canvas ratio.
  103891. else if (size.height && !size.width) {
  103892. height = size.height;
  103893. width = Math.round(height * engine.getAspectRatio(camera));
  103894. }
  103895. //Assuming here that "size" parameter is a number
  103896. else if (!isNaN(size)) {
  103897. height = size;
  103898. width = size;
  103899. }
  103900. else {
  103901. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  103902. return;
  103903. }
  103904. if (!_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas) {
  103905. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas = document.createElement('canvas');
  103906. }
  103907. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.width = width;
  103908. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.height = height;
  103909. var renderContext = _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.getContext("2d");
  103910. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  103911. var newWidth = width;
  103912. var newHeight = newWidth / ratio;
  103913. if (newHeight > height) {
  103914. newHeight = height;
  103915. newWidth = newHeight * ratio;
  103916. }
  103917. var offsetX = Math.max(0, width - newWidth) / 2;
  103918. var offsetY = Math.max(0, height - newHeight) / 2;
  103919. var renderingCanvas = engine.getRenderingCanvas();
  103920. if (renderContext && renderingCanvas) {
  103921. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  103922. }
  103923. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  103924. };
  103925. /**
  103926. * Generates an image screenshot from the specified camera.
  103927. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103928. * @param engine The engine to use for rendering
  103929. * @param camera The camera to use for rendering
  103930. * @param size This parameter can be set to a single number or to an object with the
  103931. * following (optional) properties: precision, width, height. If a single number is passed,
  103932. * it will be used for both width and height. If an object is passed, the screenshot size
  103933. * will be derived from the parameters. The precision property is a multiplier allowing
  103934. * rendering at a higher or lower resolution
  103935. * @param successCallback The callback receives a single parameter which contains the
  103936. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  103937. * src parameter of an <img> to display it
  103938. * @param mimeType The MIME type of the screenshot image (default: image/png).
  103939. * Check your browser for supported MIME types
  103940. * @param samples Texture samples (default: 1)
  103941. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  103942. * @param fileName A name for for the downloaded file.
  103943. */
  103944. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  103945. if (mimeType === void 0) { mimeType = "image/png"; }
  103946. if (samples === void 0) { samples = 1; }
  103947. if (antialiasing === void 0) { antialiasing = false; }
  103948. var width;
  103949. var height;
  103950. //If a precision value is specified
  103951. if (size.precision) {
  103952. width = Math.round(engine.getRenderWidth() * size.precision);
  103953. height = Math.round(width / engine.getAspectRatio(camera));
  103954. size = { width: width, height: height };
  103955. }
  103956. else if (size.width && size.height) {
  103957. width = size.width;
  103958. height = size.height;
  103959. }
  103960. //If passing only width, computing height to keep display canvas ratio.
  103961. else if (size.width && !size.height) {
  103962. width = size.width;
  103963. height = Math.round(width / engine.getAspectRatio(camera));
  103964. size = { width: width, height: height };
  103965. }
  103966. //If passing only height, computing width to keep display canvas ratio.
  103967. else if (size.height && !size.width) {
  103968. height = size.height;
  103969. width = Math.round(height * engine.getAspectRatio(camera));
  103970. size = { width: width, height: height };
  103971. }
  103972. //Assuming here that "size" parameter is a number
  103973. else if (!isNaN(size)) {
  103974. height = size;
  103975. width = size;
  103976. }
  103977. else {
  103978. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  103979. return;
  103980. }
  103981. var scene = camera.getScene();
  103982. var previousCamera = null;
  103983. if (scene.activeCamera !== camera) {
  103984. previousCamera = scene.activeCamera;
  103985. scene.activeCamera = camera;
  103986. }
  103987. var renderCanvas = engine.getRenderingCanvas();
  103988. if (!renderCanvas) {
  103989. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  103990. return;
  103991. }
  103992. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  103993. engine.setSize(width, height);
  103994. scene.render();
  103995. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  103996. 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);
  103997. texture.renderList = null;
  103998. texture.samples = samples;
  103999. if (antialiasing) {
  104000. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  104001. }
  104002. texture.onAfterRenderObservable.add(function () {
  104003. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  104004. });
  104005. scene.incrementRenderId();
  104006. scene.resetCachedMaterial();
  104007. texture.render(true);
  104008. texture.dispose();
  104009. if (previousCamera) {
  104010. scene.activeCamera = previousCamera;
  104011. }
  104012. engine.setSize(originalSize.width, originalSize.height);
  104013. camera.getProjectionMatrix(true); // Force cache refresh;
  104014. };
  104015. return ScreenshotTools;
  104016. }());
  104017. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  104018. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  104019. /***/ }),
  104020. /***/ "./Misc/smartArray.ts":
  104021. /*!****************************!*\
  104022. !*** ./Misc/smartArray.ts ***!
  104023. \****************************/
  104024. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  104025. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104026. "use strict";
  104027. __webpack_require__.r(__webpack_exports__);
  104028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  104029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  104030. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104031. /**
  104032. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  104033. */
  104034. var SmartArray = /** @class */ (function () {
  104035. /**
  104036. * Instantiates a Smart Array.
  104037. * @param capacity defines the default capacity of the array.
  104038. */
  104039. function SmartArray(capacity) {
  104040. /**
  104041. * The active length of the array.
  104042. */
  104043. this.length = 0;
  104044. this.data = new Array(capacity);
  104045. this._id = SmartArray._GlobalId++;
  104046. }
  104047. /**
  104048. * Pushes a value at the end of the active data.
  104049. * @param value defines the object to push in the array.
  104050. */
  104051. SmartArray.prototype.push = function (value) {
  104052. this.data[this.length++] = value;
  104053. if (this.length > this.data.length) {
  104054. this.data.length *= 2;
  104055. }
  104056. };
  104057. /**
  104058. * Iterates over the active data and apply the lambda to them.
  104059. * @param func defines the action to apply on each value.
  104060. */
  104061. SmartArray.prototype.forEach = function (func) {
  104062. for (var index = 0; index < this.length; index++) {
  104063. func(this.data[index]);
  104064. }
  104065. };
  104066. /**
  104067. * Sorts the full sets of data.
  104068. * @param compareFn defines the comparison function to apply.
  104069. */
  104070. SmartArray.prototype.sort = function (compareFn) {
  104071. this.data.sort(compareFn);
  104072. };
  104073. /**
  104074. * Resets the active data to an empty array.
  104075. */
  104076. SmartArray.prototype.reset = function () {
  104077. this.length = 0;
  104078. };
  104079. /**
  104080. * Releases all the data from the array as well as the array.
  104081. */
  104082. SmartArray.prototype.dispose = function () {
  104083. this.reset();
  104084. if (this.data) {
  104085. this.data.length = 0;
  104086. this.data = [];
  104087. }
  104088. };
  104089. /**
  104090. * Concats the active data with a given array.
  104091. * @param array defines the data to concatenate with.
  104092. */
  104093. SmartArray.prototype.concat = function (array) {
  104094. if (array.length === 0) {
  104095. return;
  104096. }
  104097. if (this.length + array.length > this.data.length) {
  104098. this.data.length = (this.length + array.length) * 2;
  104099. }
  104100. for (var index = 0; index < array.length; index++) {
  104101. this.data[this.length++] = (array.data || array)[index];
  104102. }
  104103. };
  104104. /**
  104105. * Returns the position of a value in the active data.
  104106. * @param value defines the value to find the index for
  104107. * @returns the index if found in the active data otherwise -1
  104108. */
  104109. SmartArray.prototype.indexOf = function (value) {
  104110. var position = this.data.indexOf(value);
  104111. if (position >= this.length) {
  104112. return -1;
  104113. }
  104114. return position;
  104115. };
  104116. /**
  104117. * Returns whether an element is part of the active data.
  104118. * @param value defines the value to look for
  104119. * @returns true if found in the active data otherwise false
  104120. */
  104121. SmartArray.prototype.contains = function (value) {
  104122. return this.indexOf(value) !== -1;
  104123. };
  104124. // Statics
  104125. SmartArray._GlobalId = 0;
  104126. return SmartArray;
  104127. }());
  104128. /**
  104129. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  104130. * The data in this array can only be present once
  104131. */
  104132. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  104133. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  104134. function SmartArrayNoDuplicate() {
  104135. var _this = _super !== null && _super.apply(this, arguments) || this;
  104136. _this._duplicateId = 0;
  104137. return _this;
  104138. }
  104139. /**
  104140. * Pushes a value at the end of the active data.
  104141. * THIS DOES NOT PREVENT DUPPLICATE DATA
  104142. * @param value defines the object to push in the array.
  104143. */
  104144. SmartArrayNoDuplicate.prototype.push = function (value) {
  104145. _super.prototype.push.call(this, value);
  104146. if (!value.__smartArrayFlags) {
  104147. value.__smartArrayFlags = {};
  104148. }
  104149. value.__smartArrayFlags[this._id] = this._duplicateId;
  104150. };
  104151. /**
  104152. * Pushes a value at the end of the active data.
  104153. * If the data is already present, it won t be added again
  104154. * @param value defines the object to push in the array.
  104155. * @returns true if added false if it was already present
  104156. */
  104157. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  104158. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  104159. return false;
  104160. }
  104161. this.push(value);
  104162. return true;
  104163. };
  104164. /**
  104165. * Resets the active data to an empty array.
  104166. */
  104167. SmartArrayNoDuplicate.prototype.reset = function () {
  104168. _super.prototype.reset.call(this);
  104169. this._duplicateId++;
  104170. };
  104171. /**
  104172. * Concats the active data with a given array.
  104173. * This ensures no dupplicate will be present in the result.
  104174. * @param array defines the data to concatenate with.
  104175. */
  104176. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  104177. if (array.length === 0) {
  104178. return;
  104179. }
  104180. if (this.length + array.length > this.data.length) {
  104181. this.data.length = (this.length + array.length) * 2;
  104182. }
  104183. for (var index = 0; index < array.length; index++) {
  104184. var item = (array.data || array)[index];
  104185. this.pushNoDuplicate(item);
  104186. }
  104187. };
  104188. return SmartArrayNoDuplicate;
  104189. }(SmartArray));
  104190. /***/ }),
  104191. /***/ "./Misc/stringDictionary.ts":
  104192. /*!**********************************!*\
  104193. !*** ./Misc/stringDictionary.ts ***!
  104194. \**********************************/
  104195. /*! exports provided: StringDictionary */
  104196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104197. "use strict";
  104198. __webpack_require__.r(__webpack_exports__);
  104199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  104200. /**
  104201. * This class implement a typical dictionary using a string as key and the generic type T as value.
  104202. * The underlying implementation relies on an associative array to ensure the best performances.
  104203. * The value can be anything including 'null' but except 'undefined'
  104204. */
  104205. var StringDictionary = /** @class */ (function () {
  104206. function StringDictionary() {
  104207. this._count = 0;
  104208. this._data = {};
  104209. }
  104210. /**
  104211. * This will clear this dictionary and copy the content from the 'source' one.
  104212. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  104213. * @param source the dictionary to take the content from and copy to this dictionary
  104214. */
  104215. StringDictionary.prototype.copyFrom = function (source) {
  104216. var _this = this;
  104217. this.clear();
  104218. source.forEach(function (t, v) { return _this.add(t, v); });
  104219. };
  104220. /**
  104221. * Get a value based from its key
  104222. * @param key the given key to get the matching value from
  104223. * @return the value if found, otherwise undefined is returned
  104224. */
  104225. StringDictionary.prototype.get = function (key) {
  104226. var val = this._data[key];
  104227. if (val !== undefined) {
  104228. return val;
  104229. }
  104230. return undefined;
  104231. };
  104232. /**
  104233. * Get a value from its key or add it if it doesn't exist.
  104234. * This method will ensure you that a given key/data will be present in the dictionary.
  104235. * @param key the given key to get the matching value from
  104236. * @param factory the factory that will create the value if the key is not present in the dictionary.
  104237. * The factory will only be invoked if there's no data for the given key.
  104238. * @return the value corresponding to the key.
  104239. */
  104240. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  104241. var val = this.get(key);
  104242. if (val !== undefined) {
  104243. return val;
  104244. }
  104245. val = factory(key);
  104246. if (val) {
  104247. this.add(key, val);
  104248. }
  104249. return val;
  104250. };
  104251. /**
  104252. * Get a value from its key if present in the dictionary otherwise add it
  104253. * @param key the key to get the value from
  104254. * @param val if there's no such key/value pair in the dictionary add it with this value
  104255. * @return the value corresponding to the key
  104256. */
  104257. StringDictionary.prototype.getOrAdd = function (key, val) {
  104258. var curVal = this.get(key);
  104259. if (curVal !== undefined) {
  104260. return curVal;
  104261. }
  104262. this.add(key, val);
  104263. return val;
  104264. };
  104265. /**
  104266. * Check if there's a given key in the dictionary
  104267. * @param key the key to check for
  104268. * @return true if the key is present, false otherwise
  104269. */
  104270. StringDictionary.prototype.contains = function (key) {
  104271. return this._data[key] !== undefined;
  104272. };
  104273. /**
  104274. * Add a new key and its corresponding value
  104275. * @param key the key to add
  104276. * @param value the value corresponding to the key
  104277. * @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
  104278. */
  104279. StringDictionary.prototype.add = function (key, value) {
  104280. if (this._data[key] !== undefined) {
  104281. return false;
  104282. }
  104283. this._data[key] = value;
  104284. ++this._count;
  104285. return true;
  104286. };
  104287. /**
  104288. * Update a specific value associated to a key
  104289. * @param key defines the key to use
  104290. * @param value defines the value to store
  104291. * @returns true if the value was updated (or false if the key was not found)
  104292. */
  104293. StringDictionary.prototype.set = function (key, value) {
  104294. if (this._data[key] === undefined) {
  104295. return false;
  104296. }
  104297. this._data[key] = value;
  104298. return true;
  104299. };
  104300. /**
  104301. * Get the element of the given key and remove it from the dictionary
  104302. * @param key defines the key to search
  104303. * @returns the value associated with the key or null if not found
  104304. */
  104305. StringDictionary.prototype.getAndRemove = function (key) {
  104306. var val = this.get(key);
  104307. if (val !== undefined) {
  104308. delete this._data[key];
  104309. --this._count;
  104310. return val;
  104311. }
  104312. return null;
  104313. };
  104314. /**
  104315. * Remove a key/value from the dictionary.
  104316. * @param key the key to remove
  104317. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  104318. */
  104319. StringDictionary.prototype.remove = function (key) {
  104320. if (this.contains(key)) {
  104321. delete this._data[key];
  104322. --this._count;
  104323. return true;
  104324. }
  104325. return false;
  104326. };
  104327. /**
  104328. * Clear the whole content of the dictionary
  104329. */
  104330. StringDictionary.prototype.clear = function () {
  104331. this._data = {};
  104332. this._count = 0;
  104333. };
  104334. Object.defineProperty(StringDictionary.prototype, "count", {
  104335. /**
  104336. * Gets the current count
  104337. */
  104338. get: function () {
  104339. return this._count;
  104340. },
  104341. enumerable: true,
  104342. configurable: true
  104343. });
  104344. /**
  104345. * Execute a callback on each key/val of the dictionary.
  104346. * Note that you can remove any element in this dictionary in the callback implementation
  104347. * @param callback the callback to execute on a given key/value pair
  104348. */
  104349. StringDictionary.prototype.forEach = function (callback) {
  104350. for (var cur in this._data) {
  104351. var val = this._data[cur];
  104352. callback(cur, val);
  104353. }
  104354. };
  104355. /**
  104356. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  104357. * If the callback returns null or undefined the method will iterate to the next key/value pair
  104358. * Note that you can remove any element in this dictionary in the callback implementation
  104359. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  104360. * @returns the first item
  104361. */
  104362. StringDictionary.prototype.first = function (callback) {
  104363. for (var cur in this._data) {
  104364. var val = this._data[cur];
  104365. var res = callback(cur, val);
  104366. if (res) {
  104367. return res;
  104368. }
  104369. }
  104370. return null;
  104371. };
  104372. return StringDictionary;
  104373. }());
  104374. /***/ }),
  104375. /***/ "./Misc/tags.ts":
  104376. /*!**********************!*\
  104377. !*** ./Misc/tags.ts ***!
  104378. \**********************/
  104379. /*! exports provided: Tags */
  104380. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104381. "use strict";
  104382. __webpack_require__.r(__webpack_exports__);
  104383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  104384. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  104385. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  104386. /**
  104387. * Class used to store custom tags
  104388. */
  104389. var Tags = /** @class */ (function () {
  104390. function Tags() {
  104391. }
  104392. /**
  104393. * Adds support for tags on the given object
  104394. * @param obj defines the object to use
  104395. */
  104396. Tags.EnableFor = function (obj) {
  104397. obj._tags = obj._tags || {};
  104398. obj.hasTags = function () {
  104399. return Tags.HasTags(obj);
  104400. };
  104401. obj.addTags = function (tagsString) {
  104402. return Tags.AddTagsTo(obj, tagsString);
  104403. };
  104404. obj.removeTags = function (tagsString) {
  104405. return Tags.RemoveTagsFrom(obj, tagsString);
  104406. };
  104407. obj.matchesTagsQuery = function (tagsQuery) {
  104408. return Tags.MatchesQuery(obj, tagsQuery);
  104409. };
  104410. };
  104411. /**
  104412. * Removes tags support
  104413. * @param obj defines the object to use
  104414. */
  104415. Tags.DisableFor = function (obj) {
  104416. delete obj._tags;
  104417. delete obj.hasTags;
  104418. delete obj.addTags;
  104419. delete obj.removeTags;
  104420. delete obj.matchesTagsQuery;
  104421. };
  104422. /**
  104423. * Gets a boolean indicating if the given object has tags
  104424. * @param obj defines the object to use
  104425. * @returns a boolean
  104426. */
  104427. Tags.HasTags = function (obj) {
  104428. if (!obj._tags) {
  104429. return false;
  104430. }
  104431. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  104432. };
  104433. /**
  104434. * Gets the tags available on a given object
  104435. * @param obj defines the object to use
  104436. * @param asString defines if the tags must be returned as a string instead of an array of strings
  104437. * @returns the tags
  104438. */
  104439. Tags.GetTags = function (obj, asString) {
  104440. if (asString === void 0) { asString = true; }
  104441. if (!obj._tags) {
  104442. return null;
  104443. }
  104444. if (asString) {
  104445. var tagsArray = [];
  104446. for (var tag in obj._tags) {
  104447. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  104448. tagsArray.push(tag);
  104449. }
  104450. }
  104451. return tagsArray.join(" ");
  104452. }
  104453. else {
  104454. return obj._tags;
  104455. }
  104456. };
  104457. /**
  104458. * Adds tags to an object
  104459. * @param obj defines the object to use
  104460. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  104461. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  104462. */
  104463. Tags.AddTagsTo = function (obj, tagsString) {
  104464. if (!tagsString) {
  104465. return;
  104466. }
  104467. if (typeof tagsString !== "string") {
  104468. return;
  104469. }
  104470. var tags = tagsString.split(" ");
  104471. tags.forEach(function (tag, index, array) {
  104472. Tags._AddTagTo(obj, tag);
  104473. });
  104474. };
  104475. /**
  104476. * @hidden
  104477. */
  104478. Tags._AddTagTo = function (obj, tag) {
  104479. tag = tag.trim();
  104480. if (tag === "" || tag === "true" || tag === "false") {
  104481. return;
  104482. }
  104483. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  104484. return;
  104485. }
  104486. Tags.EnableFor(obj);
  104487. obj._tags[tag] = true;
  104488. };
  104489. /**
  104490. * Removes specific tags from a specific object
  104491. * @param obj defines the object to use
  104492. * @param tagsString defines the tags to remove
  104493. */
  104494. Tags.RemoveTagsFrom = function (obj, tagsString) {
  104495. if (!Tags.HasTags(obj)) {
  104496. return;
  104497. }
  104498. var tags = tagsString.split(" ");
  104499. for (var t in tags) {
  104500. Tags._RemoveTagFrom(obj, tags[t]);
  104501. }
  104502. };
  104503. /**
  104504. * @hidden
  104505. */
  104506. Tags._RemoveTagFrom = function (obj, tag) {
  104507. delete obj._tags[tag];
  104508. };
  104509. /**
  104510. * Defines if tags hosted on an object match a given query
  104511. * @param obj defines the object to use
  104512. * @param tagsQuery defines the tag query
  104513. * @returns a boolean
  104514. */
  104515. Tags.MatchesQuery = function (obj, tagsQuery) {
  104516. if (tagsQuery === undefined) {
  104517. return true;
  104518. }
  104519. if (tagsQuery === "") {
  104520. return Tags.HasTags(obj);
  104521. }
  104522. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  104523. };
  104524. return Tags;
  104525. }());
  104526. /***/ }),
  104527. /***/ "./Misc/textureTools.ts":
  104528. /*!******************************!*\
  104529. !*** ./Misc/textureTools.ts ***!
  104530. \******************************/
  104531. /*! exports provided: TextureTools */
  104532. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104533. "use strict";
  104534. __webpack_require__.r(__webpack_exports__);
  104535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  104536. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  104537. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  104538. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  104539. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  104540. /**
  104541. * Class used to host texture specific utilities
  104542. */
  104543. var TextureTools = /** @class */ (function () {
  104544. function TextureTools() {
  104545. }
  104546. /**
  104547. * Uses the GPU to create a copy texture rescaled at a given size
  104548. * @param texture Texture to copy from
  104549. * @param width defines the desired width
  104550. * @param height defines the desired height
  104551. * @param useBilinearMode defines if bilinear mode has to be used
  104552. * @return the generated texture
  104553. */
  104554. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  104555. if (useBilinearMode === void 0) { useBilinearMode = true; }
  104556. var scene = texture.getScene();
  104557. var engine = scene.getEngine();
  104558. 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);
  104559. rtt.wrapU = texture.wrapU;
  104560. rtt.wrapV = texture.wrapV;
  104561. rtt.uOffset = texture.uOffset;
  104562. rtt.vOffset = texture.vOffset;
  104563. rtt.uScale = texture.uScale;
  104564. rtt.vScale = texture.vScale;
  104565. rtt.uAng = texture.uAng;
  104566. rtt.vAng = texture.vAng;
  104567. rtt.wAng = texture.wAng;
  104568. rtt.coordinatesIndex = texture.coordinatesIndex;
  104569. rtt.level = texture.level;
  104570. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  104571. rtt._texture.isReady = false;
  104572. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  104573. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  104574. 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);
  104575. passPostProcess.getEffect().executeWhenCompiled(function () {
  104576. passPostProcess.onApply = function (effect) {
  104577. effect.setTexture("textureSampler", texture);
  104578. };
  104579. var internalTexture = rtt.getInternalTexture();
  104580. if (internalTexture) {
  104581. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  104582. engine.unBindFramebuffer(internalTexture);
  104583. rtt.disposeFramebufferObjects();
  104584. passPostProcess.dispose();
  104585. internalTexture.isReady = true;
  104586. }
  104587. });
  104588. return rtt;
  104589. };
  104590. return TextureTools;
  104591. }());
  104592. /***/ }),
  104593. /***/ "./Misc/tga.ts":
  104594. /*!*********************!*\
  104595. !*** ./Misc/tga.ts ***!
  104596. \*********************/
  104597. /*! exports provided: TGATools */
  104598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104599. "use strict";
  104600. __webpack_require__.r(__webpack_exports__);
  104601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  104602. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  104603. /**
  104604. * Based on jsTGALoader - Javascript loader for TGA file
  104605. * By Vincent Thibault
  104606. * @see http://blog.robrowser.com/javascript-tga-loader.html
  104607. */
  104608. var TGATools = /** @class */ (function () {
  104609. function TGATools() {
  104610. }
  104611. /**
  104612. * Gets the header of a TGA file
  104613. * @param data defines the TGA data
  104614. * @returns the header
  104615. */
  104616. TGATools.GetTGAHeader = function (data) {
  104617. var offset = 0;
  104618. var header = {
  104619. id_length: data[offset++],
  104620. colormap_type: data[offset++],
  104621. image_type: data[offset++],
  104622. colormap_index: data[offset++] | data[offset++] << 8,
  104623. colormap_length: data[offset++] | data[offset++] << 8,
  104624. colormap_size: data[offset++],
  104625. origin: [
  104626. data[offset++] | data[offset++] << 8,
  104627. data[offset++] | data[offset++] << 8
  104628. ],
  104629. width: data[offset++] | data[offset++] << 8,
  104630. height: data[offset++] | data[offset++] << 8,
  104631. pixel_size: data[offset++],
  104632. flags: data[offset++]
  104633. };
  104634. return header;
  104635. };
  104636. /**
  104637. * Uploads TGA content to a Babylon Texture
  104638. * @hidden
  104639. */
  104640. TGATools.UploadContent = function (texture, data) {
  104641. // Not enough data to contain header ?
  104642. if (data.length < 19) {
  104643. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  104644. return;
  104645. }
  104646. // Read Header
  104647. var offset = 18;
  104648. var header = TGATools.GetTGAHeader(data);
  104649. // Assume it's a valid Targa file.
  104650. if (header.id_length + offset > data.length) {
  104651. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  104652. return;
  104653. }
  104654. // Skip not needed data
  104655. offset += header.id_length;
  104656. var use_rle = false;
  104657. var use_pal = false;
  104658. var use_grey = false;
  104659. // Get some informations.
  104660. switch (header.image_type) {
  104661. case TGATools._TYPE_RLE_INDEXED:
  104662. use_rle = true;
  104663. case TGATools._TYPE_INDEXED:
  104664. use_pal = true;
  104665. break;
  104666. case TGATools._TYPE_RLE_RGB:
  104667. use_rle = true;
  104668. case TGATools._TYPE_RGB:
  104669. // use_rgb = true;
  104670. break;
  104671. case TGATools._TYPE_RLE_GREY:
  104672. use_rle = true;
  104673. case TGATools._TYPE_GREY:
  104674. use_grey = true;
  104675. break;
  104676. }
  104677. var pixel_data;
  104678. // var numAlphaBits = header.flags & 0xf;
  104679. var pixel_size = header.pixel_size >> 3;
  104680. var pixel_total = header.width * header.height * pixel_size;
  104681. // Read palettes
  104682. var palettes;
  104683. if (use_pal) {
  104684. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  104685. }
  104686. // Read LRE
  104687. if (use_rle) {
  104688. pixel_data = new Uint8Array(pixel_total);
  104689. var c, count, i;
  104690. var localOffset = 0;
  104691. var pixels = new Uint8Array(pixel_size);
  104692. while (offset < pixel_total && localOffset < pixel_total) {
  104693. c = data[offset++];
  104694. count = (c & 0x7f) + 1;
  104695. // RLE pixels
  104696. if (c & 0x80) {
  104697. // Bind pixel tmp array
  104698. for (i = 0; i < pixel_size; ++i) {
  104699. pixels[i] = data[offset++];
  104700. }
  104701. // Copy pixel array
  104702. for (i = 0; i < count; ++i) {
  104703. pixel_data.set(pixels, localOffset + i * pixel_size);
  104704. }
  104705. localOffset += pixel_size * count;
  104706. }
  104707. // Raw pixels
  104708. else {
  104709. count *= pixel_size;
  104710. for (i = 0; i < count; ++i) {
  104711. pixel_data[localOffset + i] = data[offset++];
  104712. }
  104713. localOffset += count;
  104714. }
  104715. }
  104716. }
  104717. // RAW Pixels
  104718. else {
  104719. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  104720. }
  104721. // Load to texture
  104722. var x_start, y_start, x_step, y_step, y_end, x_end;
  104723. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  104724. default:
  104725. case TGATools._ORIGIN_UL:
  104726. x_start = 0;
  104727. x_step = 1;
  104728. x_end = header.width;
  104729. y_start = 0;
  104730. y_step = 1;
  104731. y_end = header.height;
  104732. break;
  104733. case TGATools._ORIGIN_BL:
  104734. x_start = 0;
  104735. x_step = 1;
  104736. x_end = header.width;
  104737. y_start = header.height - 1;
  104738. y_step = -1;
  104739. y_end = -1;
  104740. break;
  104741. case TGATools._ORIGIN_UR:
  104742. x_start = header.width - 1;
  104743. x_step = -1;
  104744. x_end = -1;
  104745. y_start = 0;
  104746. y_step = 1;
  104747. y_end = header.height;
  104748. break;
  104749. case TGATools._ORIGIN_BR:
  104750. x_start = header.width - 1;
  104751. x_step = -1;
  104752. x_end = -1;
  104753. y_start = header.height - 1;
  104754. y_step = -1;
  104755. y_end = -1;
  104756. break;
  104757. }
  104758. // Load the specify method
  104759. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  104760. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  104761. var engine = texture.getEngine();
  104762. engine._uploadDataToTextureDirectly(texture, imageData);
  104763. };
  104764. /** @hidden */
  104765. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  104766. var image = pixel_data, colormap = palettes;
  104767. var width = header.width, height = header.height;
  104768. var color, i = 0, x, y;
  104769. var imageData = new Uint8Array(width * height * 4);
  104770. for (y = y_start; y !== y_end; y += y_step) {
  104771. for (x = x_start; x !== x_end; x += x_step, i++) {
  104772. color = image[i];
  104773. imageData[(x + width * y) * 4 + 3] = 255;
  104774. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  104775. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  104776. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  104777. }
  104778. }
  104779. return imageData;
  104780. };
  104781. /** @hidden */
  104782. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  104783. var image = pixel_data;
  104784. var width = header.width, height = header.height;
  104785. var color, i = 0, x, y;
  104786. var imageData = new Uint8Array(width * height * 4);
  104787. for (y = y_start; y !== y_end; y += y_step) {
  104788. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  104789. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  104790. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  104791. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  104792. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  104793. imageData[(x + width * y) * 4 + 0] = r;
  104794. imageData[(x + width * y) * 4 + 1] = g;
  104795. imageData[(x + width * y) * 4 + 2] = b;
  104796. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  104797. }
  104798. }
  104799. return imageData;
  104800. };
  104801. /** @hidden */
  104802. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  104803. var image = pixel_data;
  104804. var width = header.width, height = header.height;
  104805. var i = 0, x, y;
  104806. var imageData = new Uint8Array(width * height * 4);
  104807. for (y = y_start; y !== y_end; y += y_step) {
  104808. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  104809. imageData[(x + width * y) * 4 + 3] = 255;
  104810. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  104811. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  104812. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  104813. }
  104814. }
  104815. return imageData;
  104816. };
  104817. /** @hidden */
  104818. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  104819. var image = pixel_data;
  104820. var width = header.width, height = header.height;
  104821. var i = 0, x, y;
  104822. var imageData = new Uint8Array(width * height * 4);
  104823. for (y = y_start; y !== y_end; y += y_step) {
  104824. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  104825. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  104826. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  104827. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  104828. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  104829. }
  104830. }
  104831. return imageData;
  104832. };
  104833. /** @hidden */
  104834. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  104835. var image = pixel_data;
  104836. var width = header.width, height = header.height;
  104837. var color, i = 0, x, y;
  104838. var imageData = new Uint8Array(width * height * 4);
  104839. for (y = y_start; y !== y_end; y += y_step) {
  104840. for (x = x_start; x !== x_end; x += x_step, i++) {
  104841. color = image[i];
  104842. imageData[(x + width * y) * 4 + 0] = color;
  104843. imageData[(x + width * y) * 4 + 1] = color;
  104844. imageData[(x + width * y) * 4 + 2] = color;
  104845. imageData[(x + width * y) * 4 + 3] = 255;
  104846. }
  104847. }
  104848. return imageData;
  104849. };
  104850. /** @hidden */
  104851. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  104852. var image = pixel_data;
  104853. var width = header.width, height = header.height;
  104854. var i = 0, x, y;
  104855. var imageData = new Uint8Array(width * height * 4);
  104856. for (y = y_start; y !== y_end; y += y_step) {
  104857. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  104858. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  104859. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  104860. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  104861. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  104862. }
  104863. }
  104864. return imageData;
  104865. };
  104866. //private static _TYPE_NO_DATA = 0;
  104867. TGATools._TYPE_INDEXED = 1;
  104868. TGATools._TYPE_RGB = 2;
  104869. TGATools._TYPE_GREY = 3;
  104870. TGATools._TYPE_RLE_INDEXED = 9;
  104871. TGATools._TYPE_RLE_RGB = 10;
  104872. TGATools._TYPE_RLE_GREY = 11;
  104873. TGATools._ORIGIN_MASK = 0x30;
  104874. TGATools._ORIGIN_SHIFT = 0x04;
  104875. TGATools._ORIGIN_BL = 0x00;
  104876. TGATools._ORIGIN_BR = 0x01;
  104877. TGATools._ORIGIN_UL = 0x02;
  104878. TGATools._ORIGIN_UR = 0x03;
  104879. return TGATools;
  104880. }());
  104881. /***/ }),
  104882. /***/ "./Misc/tools.ts":
  104883. /*!***********************!*\
  104884. !*** ./Misc/tools.ts ***!
  104885. \***********************/
  104886. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  104887. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104888. "use strict";
  104889. __webpack_require__.r(__webpack_exports__);
  104890. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  104891. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  104892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  104893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  104894. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  104895. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  104896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  104897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  104898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  104899. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104900. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104901. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104902. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  104903. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  104904. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  104905. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  104906. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  104907. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  104908. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  104909. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  104910. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  104911. /* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  104912. /** Class used to store color4 gradient */
  104913. var ColorGradient = /** @class */ (function () {
  104914. function ColorGradient() {
  104915. }
  104916. /**
  104917. * Will get a color picked randomly between color1 and color2.
  104918. * If color2 is undefined then color1 will be used
  104919. * @param result defines the target Color4 to store the result in
  104920. */
  104921. ColorGradient.prototype.getColorToRef = function (result) {
  104922. if (!this.color2) {
  104923. result.copyFrom(this.color1);
  104924. return;
  104925. }
  104926. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  104927. };
  104928. return ColorGradient;
  104929. }());
  104930. /** Class used to store color 3 gradient */
  104931. var Color3Gradient = /** @class */ (function () {
  104932. function Color3Gradient() {
  104933. }
  104934. return Color3Gradient;
  104935. }());
  104936. /** Class used to store factor gradient */
  104937. var FactorGradient = /** @class */ (function () {
  104938. function FactorGradient() {
  104939. }
  104940. /**
  104941. * Will get a number picked randomly between factor1 and factor2.
  104942. * If factor2 is undefined then factor1 will be used
  104943. * @returns the picked number
  104944. */
  104945. FactorGradient.prototype.getFactor = function () {
  104946. if (this.factor2 === undefined) {
  104947. return this.factor1;
  104948. }
  104949. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  104950. };
  104951. return FactorGradient;
  104952. }());
  104953. /**
  104954. * @ignore
  104955. * Application error to support additional information when loading a file
  104956. */
  104957. var LoadFileError = /** @class */ (function (_super) {
  104958. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  104959. /**
  104960. * Creates a new LoadFileError
  104961. * @param message defines the message of the error
  104962. * @param request defines the optional web request
  104963. */
  104964. function LoadFileError(message,
  104965. /** defines the optional web request */
  104966. request) {
  104967. var _this = _super.call(this, message) || this;
  104968. _this.request = request;
  104969. _this.name = "LoadFileError";
  104970. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  104971. return _this;
  104972. }
  104973. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  104974. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  104975. // Polyfill for Object.setPrototypeOf if necessary.
  104976. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  104977. return LoadFileError;
  104978. }(Error));
  104979. /**
  104980. * Class used to define a retry strategy when error happens while loading assets
  104981. */
  104982. var RetryStrategy = /** @class */ (function () {
  104983. function RetryStrategy() {
  104984. }
  104985. /**
  104986. * Function used to defines an exponential back off strategy
  104987. * @param maxRetries defines the maximum number of retries (3 by default)
  104988. * @param baseInterval defines the interval between retries
  104989. * @returns the strategy function to use
  104990. */
  104991. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  104992. if (maxRetries === void 0) { maxRetries = 3; }
  104993. if (baseInterval === void 0) { baseInterval = 500; }
  104994. return function (url, request, retryIndex) {
  104995. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  104996. return -1;
  104997. }
  104998. return Math.pow(2, retryIndex) * baseInterval;
  104999. };
  105000. };
  105001. return RetryStrategy;
  105002. }());
  105003. /**
  105004. * Class containing a set of static utilities functions
  105005. */
  105006. var Tools = /** @class */ (function () {
  105007. function Tools() {
  105008. }
  105009. /**
  105010. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  105011. * @param u defines the coordinate on X axis
  105012. * @param v defines the coordinate on Y axis
  105013. * @param width defines the width of the source data
  105014. * @param height defines the height of the source data
  105015. * @param pixels defines the source byte array
  105016. * @param color defines the output color
  105017. */
  105018. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  105019. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  105020. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  105021. var position = (wrappedU + wrappedV * width) * 4;
  105022. color.r = pixels[position] / 255;
  105023. color.g = pixels[position + 1] / 255;
  105024. color.b = pixels[position + 2] / 255;
  105025. color.a = pixels[position + 3] / 255;
  105026. };
  105027. /**
  105028. * Interpolates between a and b via alpha
  105029. * @param a The lower value (returned when alpha = 0)
  105030. * @param b The upper value (returned when alpha = 1)
  105031. * @param alpha The interpolation-factor
  105032. * @return The mixed value
  105033. */
  105034. Tools.Mix = function (a, b, alpha) {
  105035. return a * (1 - alpha) + b * alpha;
  105036. };
  105037. /**
  105038. * Tries to instantiate a new object from a given class name
  105039. * @param className defines the class name to instantiate
  105040. * @returns the new object or null if the system was not able to do the instantiation
  105041. */
  105042. Tools.Instantiate = function (className) {
  105043. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  105044. return Tools.RegisteredExternalClasses[className];
  105045. }
  105046. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  105047. if (internalClass) {
  105048. return internalClass;
  105049. }
  105050. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  105051. var arr = className.split(".");
  105052. var fn = (window || this);
  105053. for (var i = 0, len = arr.length; i < len; i++) {
  105054. fn = fn[arr[i]];
  105055. }
  105056. if (typeof fn !== "function") {
  105057. return null;
  105058. }
  105059. return fn;
  105060. };
  105061. /**
  105062. * Provides a slice function that will work even on IE
  105063. * @param data defines the array to slice
  105064. * @param start defines the start of the data (optional)
  105065. * @param end defines the end of the data (optional)
  105066. * @returns the new sliced array
  105067. */
  105068. Tools.Slice = function (data, start, end) {
  105069. if (data.slice) {
  105070. return data.slice(start, end);
  105071. }
  105072. return Array.prototype.slice.call(data, start, end);
  105073. };
  105074. /**
  105075. * Polyfill for setImmediate
  105076. * @param action defines the action to execute after the current execution block
  105077. */
  105078. Tools.SetImmediate = function (action) {
  105079. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  105080. window.setImmediate(action);
  105081. }
  105082. else {
  105083. setTimeout(action, 1);
  105084. }
  105085. };
  105086. /**
  105087. * Function indicating if a number is an exponent of 2
  105088. * @param value defines the value to test
  105089. * @returns true if the value is an exponent of 2
  105090. */
  105091. Tools.IsExponentOfTwo = function (value) {
  105092. var count = 1;
  105093. do {
  105094. count *= 2;
  105095. } while (count < value);
  105096. return count === value;
  105097. };
  105098. /**
  105099. * Returns the nearest 32-bit single precision float representation of a Number
  105100. * @param value A Number. If the parameter is of a different type, it will get converted
  105101. * to a number or to NaN if it cannot be converted
  105102. * @returns number
  105103. */
  105104. Tools.FloatRound = function (value) {
  105105. if (Math.fround) {
  105106. return Math.fround(value);
  105107. }
  105108. return (Tools._tmpFloatArray[0] = value);
  105109. };
  105110. /**
  105111. * Find the next highest power of two.
  105112. * @param x Number to start search from.
  105113. * @return Next highest power of two.
  105114. */
  105115. Tools.CeilingPOT = function (x) {
  105116. x--;
  105117. x |= x >> 1;
  105118. x |= x >> 2;
  105119. x |= x >> 4;
  105120. x |= x >> 8;
  105121. x |= x >> 16;
  105122. x++;
  105123. return x;
  105124. };
  105125. /**
  105126. * Find the next lowest power of two.
  105127. * @param x Number to start search from.
  105128. * @return Next lowest power of two.
  105129. */
  105130. Tools.FloorPOT = function (x) {
  105131. x = x | (x >> 1);
  105132. x = x | (x >> 2);
  105133. x = x | (x >> 4);
  105134. x = x | (x >> 8);
  105135. x = x | (x >> 16);
  105136. return x - (x >> 1);
  105137. };
  105138. /**
  105139. * Find the nearest power of two.
  105140. * @param x Number to start search from.
  105141. * @return Next nearest power of two.
  105142. */
  105143. Tools.NearestPOT = function (x) {
  105144. var c = Tools.CeilingPOT(x);
  105145. var f = Tools.FloorPOT(x);
  105146. return (c - x) > (x - f) ? f : c;
  105147. };
  105148. /**
  105149. * Get the closest exponent of two
  105150. * @param value defines the value to approximate
  105151. * @param max defines the maximum value to return
  105152. * @param mode defines how to define the closest value
  105153. * @returns closest exponent of two of the given value
  105154. */
  105155. Tools.GetExponentOfTwo = function (value, max, mode) {
  105156. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  105157. var pot;
  105158. switch (mode) {
  105159. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  105160. pot = Tools.FloorPOT(value);
  105161. break;
  105162. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  105163. pot = Tools.NearestPOT(value);
  105164. break;
  105165. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  105166. default:
  105167. pot = Tools.CeilingPOT(value);
  105168. break;
  105169. }
  105170. return Math.min(pot, max);
  105171. };
  105172. /**
  105173. * Extracts the filename from a path
  105174. * @param path defines the path to use
  105175. * @returns the filename
  105176. */
  105177. Tools.GetFilename = function (path) {
  105178. var index = path.lastIndexOf("/");
  105179. if (index < 0) {
  105180. return path;
  105181. }
  105182. return path.substring(index + 1);
  105183. };
  105184. /**
  105185. * Extracts the "folder" part of a path (everything before the filename).
  105186. * @param uri The URI to extract the info from
  105187. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  105188. * @returns The "folder" part of the path
  105189. */
  105190. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  105191. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  105192. var index = uri.lastIndexOf("/");
  105193. if (index < 0) {
  105194. if (returnUnchangedIfNoSlash) {
  105195. return uri;
  105196. }
  105197. return "";
  105198. }
  105199. return uri.substring(0, index + 1);
  105200. };
  105201. /**
  105202. * Convert an angle in radians to degrees
  105203. * @param angle defines the angle to convert
  105204. * @returns the angle in degrees
  105205. */
  105206. Tools.ToDegrees = function (angle) {
  105207. return angle * 180 / Math.PI;
  105208. };
  105209. /**
  105210. * Convert an angle in degrees to radians
  105211. * @param angle defines the angle to convert
  105212. * @returns the angle in radians
  105213. */
  105214. Tools.ToRadians = function (angle) {
  105215. return angle * Math.PI / 180;
  105216. };
  105217. /**
  105218. * Encode a buffer to a base64 string
  105219. * @param buffer defines the buffer to encode
  105220. * @returns the encoded string
  105221. */
  105222. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  105223. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  105224. var output = "";
  105225. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  105226. var i = 0;
  105227. var bytes = new Uint8Array(buffer);
  105228. while (i < bytes.length) {
  105229. chr1 = bytes[i++];
  105230. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  105231. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  105232. enc1 = chr1 >> 2;
  105233. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  105234. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  105235. enc4 = chr3 & 63;
  105236. if (isNaN(chr2)) {
  105237. enc3 = enc4 = 64;
  105238. }
  105239. else if (isNaN(chr3)) {
  105240. enc4 = 64;
  105241. }
  105242. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  105243. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  105244. }
  105245. return "data:image/png;base64," + output;
  105246. };
  105247. /**
  105248. * Extracts minimum and maximum values from a list of indexed positions
  105249. * @param positions defines the positions to use
  105250. * @param indices defines the indices to the positions
  105251. * @param indexStart defines the start index
  105252. * @param indexCount defines the end index
  105253. * @param bias defines bias value to add to the result
  105254. * @return minimum and maximum values
  105255. */
  105256. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  105257. if (bias === void 0) { bias = null; }
  105258. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  105259. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  105260. for (var index = indexStart; index < indexStart + indexCount; index++) {
  105261. var offset = indices[index] * 3;
  105262. var x = positions[offset];
  105263. var y = positions[offset + 1];
  105264. var z = positions[offset + 2];
  105265. minimum.minimizeInPlaceFromFloats(x, y, z);
  105266. maximum.maximizeInPlaceFromFloats(x, y, z);
  105267. }
  105268. if (bias) {
  105269. minimum.x -= minimum.x * bias.x + bias.y;
  105270. minimum.y -= minimum.y * bias.x + bias.y;
  105271. minimum.z -= minimum.z * bias.x + bias.y;
  105272. maximum.x += maximum.x * bias.x + bias.y;
  105273. maximum.y += maximum.y * bias.x + bias.y;
  105274. maximum.z += maximum.z * bias.x + bias.y;
  105275. }
  105276. return {
  105277. minimum: minimum,
  105278. maximum: maximum
  105279. };
  105280. };
  105281. /**
  105282. * Extracts minimum and maximum values from a list of positions
  105283. * @param positions defines the positions to use
  105284. * @param start defines the start index in the positions array
  105285. * @param count defines the number of positions to handle
  105286. * @param bias defines bias value to add to the result
  105287. * @param stride defines the stride size to use (distance between two positions in the positions array)
  105288. * @return minimum and maximum values
  105289. */
  105290. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  105291. if (bias === void 0) { bias = null; }
  105292. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  105293. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  105294. if (!stride) {
  105295. stride = 3;
  105296. }
  105297. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  105298. var x = positions[offset];
  105299. var y = positions[offset + 1];
  105300. var z = positions[offset + 2];
  105301. minimum.minimizeInPlaceFromFloats(x, y, z);
  105302. maximum.maximizeInPlaceFromFloats(x, y, z);
  105303. }
  105304. if (bias) {
  105305. minimum.x -= minimum.x * bias.x + bias.y;
  105306. minimum.y -= minimum.y * bias.x + bias.y;
  105307. minimum.z -= minimum.z * bias.x + bias.y;
  105308. maximum.x += maximum.x * bias.x + bias.y;
  105309. maximum.y += maximum.y * bias.x + bias.y;
  105310. maximum.z += maximum.z * bias.x + bias.y;
  105311. }
  105312. return {
  105313. minimum: minimum,
  105314. maximum: maximum
  105315. };
  105316. };
  105317. /**
  105318. * Returns an array if obj is not an array
  105319. * @param obj defines the object to evaluate as an array
  105320. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  105321. * @returns either obj directly if obj is an array or a new array containing obj
  105322. */
  105323. Tools.MakeArray = function (obj, allowsNullUndefined) {
  105324. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  105325. return null;
  105326. }
  105327. return Array.isArray(obj) ? obj : [obj];
  105328. };
  105329. /**
  105330. * Gets the pointer prefix to use
  105331. * @returns "pointer" if touch is enabled. Else returns "mouse"
  105332. */
  105333. Tools.GetPointerPrefix = function () {
  105334. var eventPrefix = "pointer";
  105335. // Check if pointer events are supported
  105336. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  105337. eventPrefix = "mouse";
  105338. }
  105339. return eventPrefix;
  105340. };
  105341. /**
  105342. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105343. * @param func - the function to be called
  105344. * @param requester - the object that will request the next frame. Falls back to window.
  105345. * @returns frame number
  105346. */
  105347. Tools.QueueNewFrame = function (func, requester) {
  105348. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  105349. return setTimeout(func, 16);
  105350. }
  105351. if (!requester) {
  105352. requester = window;
  105353. }
  105354. if (requester.requestAnimationFrame) {
  105355. return requester.requestAnimationFrame(func);
  105356. }
  105357. else if (requester.msRequestAnimationFrame) {
  105358. return requester.msRequestAnimationFrame(func);
  105359. }
  105360. else if (requester.webkitRequestAnimationFrame) {
  105361. return requester.webkitRequestAnimationFrame(func);
  105362. }
  105363. else if (requester.mozRequestAnimationFrame) {
  105364. return requester.mozRequestAnimationFrame(func);
  105365. }
  105366. else if (requester.oRequestAnimationFrame) {
  105367. return requester.oRequestAnimationFrame(func);
  105368. }
  105369. else {
  105370. return window.setTimeout(func, 16);
  105371. }
  105372. };
  105373. /**
  105374. * Ask the browser to promote the current element to fullscreen rendering mode
  105375. * @param element defines the DOM element to promote
  105376. */
  105377. Tools.RequestFullscreen = function (element) {
  105378. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  105379. if (!requestFunction) {
  105380. return;
  105381. }
  105382. requestFunction.call(element);
  105383. };
  105384. /**
  105385. * Asks the browser to exit fullscreen mode
  105386. */
  105387. Tools.ExitFullscreen = function () {
  105388. var anyDoc = document;
  105389. if (document.exitFullscreen) {
  105390. document.exitFullscreen();
  105391. }
  105392. else if (anyDoc.mozCancelFullScreen) {
  105393. anyDoc.mozCancelFullScreen();
  105394. }
  105395. else if (anyDoc.webkitCancelFullScreen) {
  105396. anyDoc.webkitCancelFullScreen();
  105397. }
  105398. else if (anyDoc.msCancelFullScreen) {
  105399. anyDoc.msCancelFullScreen();
  105400. }
  105401. };
  105402. /**
  105403. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  105404. * @param url define the url we are trying
  105405. * @param element define the dom element where to configure the cors policy
  105406. */
  105407. Tools.SetCorsBehavior = function (url, element) {
  105408. if (url && url.indexOf("data:") === 0) {
  105409. return;
  105410. }
  105411. if (Tools.CorsBehavior) {
  105412. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  105413. element.crossOrigin = Tools.CorsBehavior;
  105414. }
  105415. else {
  105416. var result = Tools.CorsBehavior(url);
  105417. if (result) {
  105418. element.crossOrigin = result;
  105419. }
  105420. }
  105421. }
  105422. };
  105423. // External files
  105424. /**
  105425. * Removes unwanted characters from an url
  105426. * @param url defines the url to clean
  105427. * @returns the cleaned url
  105428. */
  105429. Tools.CleanUrl = function (url) {
  105430. url = url.replace(/#/mg, "%23");
  105431. return url;
  105432. };
  105433. /**
  105434. * Loads an image as an HTMLImageElement.
  105435. * @param input url string, ArrayBuffer, or Blob to load
  105436. * @param onLoad callback called when the image successfully loads
  105437. * @param onError callback called when the image fails to load
  105438. * @param offlineProvider offline provider for caching
  105439. * @returns the HTMLImageElement of the loaded image
  105440. */
  105441. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  105442. var url;
  105443. var usingObjectURL = false;
  105444. if (input instanceof ArrayBuffer) {
  105445. url = URL.createObjectURL(new Blob([input]));
  105446. usingObjectURL = true;
  105447. }
  105448. else if (input instanceof Blob) {
  105449. url = URL.createObjectURL(input);
  105450. usingObjectURL = true;
  105451. }
  105452. else {
  105453. url = Tools.CleanUrl(input);
  105454. url = Tools.PreprocessUrl(input);
  105455. }
  105456. var img = new Image();
  105457. Tools.SetCorsBehavior(url, img);
  105458. var loadHandler = function () {
  105459. img.removeEventListener("load", loadHandler);
  105460. img.removeEventListener("error", errorHandler);
  105461. onLoad(img);
  105462. // Must revoke the URL after calling onLoad to avoid security exceptions in
  105463. // certain scenarios (e.g. when hosted in vscode).
  105464. if (usingObjectURL && img.src) {
  105465. URL.revokeObjectURL(img.src);
  105466. }
  105467. };
  105468. var errorHandler = function (err) {
  105469. img.removeEventListener("load", loadHandler);
  105470. img.removeEventListener("error", errorHandler);
  105471. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  105472. if (onError) {
  105473. onError("Error while trying to load image: " + input, err);
  105474. }
  105475. if (usingObjectURL && img.src) {
  105476. URL.revokeObjectURL(img.src);
  105477. }
  105478. };
  105479. img.addEventListener("load", loadHandler);
  105480. img.addEventListener("error", errorHandler);
  105481. var noOfflineSupport = function () {
  105482. img.src = url;
  105483. };
  105484. var loadFromOfflineSupport = function () {
  105485. if (offlineProvider) {
  105486. offlineProvider.loadImage(url, img);
  105487. }
  105488. };
  105489. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  105490. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  105491. }
  105492. else {
  105493. if (url.indexOf("file:") !== -1) {
  105494. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  105495. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  105496. try {
  105497. var blobURL;
  105498. try {
  105499. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  105500. }
  105501. catch (ex) {
  105502. // Chrome doesn't support oneTimeOnly parameter
  105503. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  105504. }
  105505. img.src = blobURL;
  105506. usingObjectURL = true;
  105507. }
  105508. catch (e) {
  105509. img.src = "";
  105510. }
  105511. return img;
  105512. }
  105513. }
  105514. noOfflineSupport();
  105515. }
  105516. return img;
  105517. };
  105518. /**
  105519. * Loads a file
  105520. * @param url url string, ArrayBuffer, or Blob to load
  105521. * @param onSuccess callback called when the file successfully loads
  105522. * @param onProgress callback called while file is loading (if the server supports this mode)
  105523. * @param offlineProvider defines the offline provider for caching
  105524. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105525. * @param onError callback called when the file fails to load
  105526. * @returns a file request object
  105527. */
  105528. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  105529. url = Tools.CleanUrl(url);
  105530. url = Tools.PreprocessUrl(url);
  105531. // If file and file input are set
  105532. if (url.indexOf("file:") !== -1) {
  105533. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  105534. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  105535. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  105536. }
  105537. }
  105538. var loadUrl = Tools.BaseUrl + url;
  105539. var aborted = false;
  105540. var fileRequest = {
  105541. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  105542. abort: function () { return aborted = true; },
  105543. };
  105544. var requestFile = function () {
  105545. var request = new _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"]();
  105546. var retryHandle = null;
  105547. fileRequest.abort = function () {
  105548. aborted = true;
  105549. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  105550. request.abort();
  105551. }
  105552. if (retryHandle !== null) {
  105553. clearTimeout(retryHandle);
  105554. retryHandle = null;
  105555. }
  105556. };
  105557. var retryLoop = function (retryIndex) {
  105558. request.open('GET', loadUrl);
  105559. if (useArrayBuffer) {
  105560. request.responseType = "arraybuffer";
  105561. }
  105562. if (onProgress) {
  105563. request.addEventListener("progress", onProgress);
  105564. }
  105565. var onLoadEnd = function () {
  105566. request.removeEventListener("loadend", onLoadEnd);
  105567. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  105568. fileRequest.onCompleteObservable.clear();
  105569. };
  105570. request.addEventListener("loadend", onLoadEnd);
  105571. var onReadyStateChange = function () {
  105572. if (aborted) {
  105573. return;
  105574. }
  105575. // In case of undefined state in some browsers.
  105576. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  105577. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  105578. request.removeEventListener("readystatechange", onReadyStateChange);
  105579. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  105580. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  105581. return;
  105582. }
  105583. var retryStrategy = Tools.DefaultRetryStrategy;
  105584. if (retryStrategy) {
  105585. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  105586. if (waitTime !== -1) {
  105587. // Prevent the request from completing for retry.
  105588. request.removeEventListener("loadend", onLoadEnd);
  105589. request = new _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"]();
  105590. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  105591. return;
  105592. }
  105593. }
  105594. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  105595. if (onError) {
  105596. onError(request, e);
  105597. }
  105598. else {
  105599. throw e;
  105600. }
  105601. }
  105602. };
  105603. request.addEventListener("readystatechange", onReadyStateChange);
  105604. request.send();
  105605. };
  105606. retryLoop(0);
  105607. };
  105608. // Caching all files
  105609. if (offlineProvider && offlineProvider.enableSceneOffline) {
  105610. var noOfflineSupport_1 = function (request) {
  105611. if (request && request.status > 400) {
  105612. if (onError) {
  105613. onError(request);
  105614. }
  105615. }
  105616. else {
  105617. if (!aborted) {
  105618. requestFile();
  105619. }
  105620. }
  105621. };
  105622. var loadFromOfflineSupport = function () {
  105623. // TODO: database needs to support aborting and should return a IFileRequest
  105624. if (aborted) {
  105625. return;
  105626. }
  105627. if (offlineProvider) {
  105628. offlineProvider.loadFile(url, function (data) {
  105629. if (!aborted) {
  105630. onSuccess(data);
  105631. }
  105632. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  105633. }, onProgress ? function (event) {
  105634. if (!aborted) {
  105635. onProgress(event);
  105636. }
  105637. } : undefined, noOfflineSupport_1, useArrayBuffer);
  105638. }
  105639. };
  105640. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  105641. }
  105642. else {
  105643. requestFile();
  105644. }
  105645. return fileRequest;
  105646. };
  105647. /**
  105648. * Load a script (identified by an url). When the url returns, the
  105649. * content of this file is added into a new script element, attached to the DOM (body element)
  105650. * @param scriptUrl defines the url of the script to laod
  105651. * @param onSuccess defines the callback called when the script is loaded
  105652. * @param onError defines the callback to call if an error occurs
  105653. * @param scriptId defines the id of the script element
  105654. */
  105655. Tools.LoadScript = function (scriptUrl, onSuccess, onError, scriptId) {
  105656. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  105657. return;
  105658. }
  105659. var head = document.getElementsByTagName('head')[0];
  105660. var script = document.createElement('script');
  105661. script.setAttribute('type', 'text/javascript');
  105662. script.setAttribute('src', scriptUrl);
  105663. if (scriptId) {
  105664. script.id = scriptId;
  105665. }
  105666. script.onload = function () {
  105667. if (onSuccess) {
  105668. onSuccess();
  105669. }
  105670. };
  105671. script.onerror = function (e) {
  105672. if (onError) {
  105673. onError("Unable to load script '" + scriptUrl + "'", e);
  105674. }
  105675. };
  105676. head.appendChild(script);
  105677. };
  105678. /**
  105679. * Load an asynchronous script (identified by an url). When the url returns, the
  105680. * content of this file is added into a new script element, attached to the DOM (body element)
  105681. * @param scriptUrl defines the url of the script to laod
  105682. * @param scriptId defines the id of the script element
  105683. * @returns a promise request object
  105684. */
  105685. Tools.LoadScriptAsync = function (scriptUrl, scriptId) {
  105686. return new Promise(function (resolve, reject) {
  105687. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  105688. resolve(false);
  105689. return;
  105690. }
  105691. var head = document.getElementsByTagName('head')[0];
  105692. var script = document.createElement('script');
  105693. script.setAttribute('type', 'text/javascript');
  105694. script.setAttribute('src', scriptUrl);
  105695. if (scriptId) {
  105696. script.id = scriptId;
  105697. }
  105698. script.onload = function () {
  105699. resolve(true);
  105700. };
  105701. script.onerror = function (e) {
  105702. resolve(false);
  105703. };
  105704. head.appendChild(script);
  105705. });
  105706. };
  105707. /**
  105708. * Loads a file from a blob
  105709. * @param fileToLoad defines the blob to use
  105710. * @param callback defines the callback to call when data is loaded
  105711. * @param progressCallback defines the callback to call during loading process
  105712. * @returns a file request object
  105713. */
  105714. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  105715. var reader = new FileReader();
  105716. var request = {
  105717. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  105718. abort: function () { return reader.abort(); },
  105719. };
  105720. reader.onloadend = function (e) {
  105721. request.onCompleteObservable.notifyObservers(request);
  105722. };
  105723. reader.onload = function (e) {
  105724. //target doesn't have result from ts 1.3
  105725. callback(e.target['result']);
  105726. };
  105727. reader.onprogress = progressCallback;
  105728. reader.readAsDataURL(fileToLoad);
  105729. return request;
  105730. };
  105731. /**
  105732. * Loads a file
  105733. * @param fileToLoad defines the file to load
  105734. * @param callback defines the callback to call when data is loaded
  105735. * @param progressCallBack defines the callback to call during loading process
  105736. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  105737. * @returns a file request object
  105738. */
  105739. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  105740. var reader = new FileReader();
  105741. var request = {
  105742. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  105743. abort: function () { return reader.abort(); },
  105744. };
  105745. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  105746. reader.onerror = function (e) {
  105747. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  105748. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  105749. };
  105750. reader.onload = function (e) {
  105751. //target doesn't have result from ts 1.3
  105752. callback(e.target['result']);
  105753. };
  105754. if (progressCallBack) {
  105755. reader.onprogress = progressCallBack;
  105756. }
  105757. if (!useArrayBuffer) {
  105758. // Asynchronous read
  105759. reader.readAsText(fileToLoad);
  105760. }
  105761. else {
  105762. reader.readAsArrayBuffer(fileToLoad);
  105763. }
  105764. return request;
  105765. };
  105766. /**
  105767. * Creates a data url from a given string content
  105768. * @param content defines the content to convert
  105769. * @returns the new data url link
  105770. */
  105771. Tools.FileAsURL = function (content) {
  105772. var fileBlob = new Blob([content]);
  105773. var url = window.URL || window.webkitURL;
  105774. var link = url.createObjectURL(fileBlob);
  105775. return link;
  105776. };
  105777. /**
  105778. * Format the given number to a specific decimal format
  105779. * @param value defines the number to format
  105780. * @param decimals defines the number of decimals to use
  105781. * @returns the formatted string
  105782. */
  105783. Tools.Format = function (value, decimals) {
  105784. if (decimals === void 0) { decimals = 2; }
  105785. return value.toFixed(decimals);
  105786. };
  105787. /**
  105788. * Checks if a given vector is inside a specific range
  105789. * @param v defines the vector to test
  105790. * @param min defines the minimum range
  105791. * @param max defines the maximum range
  105792. */
  105793. Tools.CheckExtends = function (v, min, max) {
  105794. min.minimizeInPlace(v);
  105795. max.maximizeInPlace(v);
  105796. };
  105797. /**
  105798. * Tries to copy an object by duplicating every property
  105799. * @param source defines the source object
  105800. * @param destination defines the target object
  105801. * @param doNotCopyList defines a list of properties to avoid
  105802. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  105803. */
  105804. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  105805. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  105806. };
  105807. /**
  105808. * Gets a boolean indicating if the given object has no own property
  105809. * @param obj defines the object to test
  105810. * @returns true if object has no own property
  105811. */
  105812. Tools.IsEmpty = function (obj) {
  105813. for (var i in obj) {
  105814. if (obj.hasOwnProperty(i)) {
  105815. return false;
  105816. }
  105817. }
  105818. return true;
  105819. };
  105820. /**
  105821. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  105822. * @param str Source string
  105823. * @param suffix Suffix to search for in the source string
  105824. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  105825. */
  105826. Tools.EndsWith = function (str, suffix) {
  105827. return str.indexOf(suffix, str.length - suffix.length) !== -1;
  105828. };
  105829. /**
  105830. * Function used to register events at window level
  105831. * @param events defines the events to register
  105832. */
  105833. Tools.RegisterTopRootEvents = function (events) {
  105834. for (var index = 0; index < events.length; index++) {
  105835. var event = events[index];
  105836. window.addEventListener(event.name, event.handler, false);
  105837. try {
  105838. if (window.parent) {
  105839. window.parent.addEventListener(event.name, event.handler, false);
  105840. }
  105841. }
  105842. catch (e) {
  105843. // Silently fails...
  105844. }
  105845. }
  105846. };
  105847. /**
  105848. * Function used to unregister events from window level
  105849. * @param events defines the events to unregister
  105850. */
  105851. Tools.UnregisterTopRootEvents = function (events) {
  105852. for (var index = 0; index < events.length; index++) {
  105853. var event = events[index];
  105854. window.removeEventListener(event.name, event.handler);
  105855. try {
  105856. if (window.parent) {
  105857. window.parent.removeEventListener(event.name, event.handler);
  105858. }
  105859. }
  105860. catch (e) {
  105861. // Silently fails...
  105862. }
  105863. }
  105864. };
  105865. /**
  105866. * Dumps the current bound framebuffer
  105867. * @param width defines the rendering width
  105868. * @param height defines the rendering height
  105869. * @param engine defines the hosting engine
  105870. * @param successCallback defines the callback triggered once the data are available
  105871. * @param mimeType defines the mime type of the result
  105872. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  105873. */
  105874. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  105875. if (mimeType === void 0) { mimeType = "image/png"; }
  105876. // Read the contents of the framebuffer
  105877. var numberOfChannelsByLine = width * 4;
  105878. var halfHeight = height / 2;
  105879. //Reading datas from WebGL
  105880. var data = engine.readPixels(0, 0, width, height);
  105881. //To flip image on Y axis.
  105882. for (var i = 0; i < halfHeight; i++) {
  105883. for (var j = 0; j < numberOfChannelsByLine; j++) {
  105884. var currentCell = j + i * numberOfChannelsByLine;
  105885. var targetLine = height - i - 1;
  105886. var targetCell = j + targetLine * numberOfChannelsByLine;
  105887. var temp = data[currentCell];
  105888. data[currentCell] = data[targetCell];
  105889. data[targetCell] = temp;
  105890. }
  105891. }
  105892. // Create a 2D canvas to store the result
  105893. if (!Tools._ScreenshotCanvas) {
  105894. Tools._ScreenshotCanvas = document.createElement('canvas');
  105895. }
  105896. Tools._ScreenshotCanvas.width = width;
  105897. Tools._ScreenshotCanvas.height = height;
  105898. var context = Tools._ScreenshotCanvas.getContext('2d');
  105899. if (context) {
  105900. // Copy the pixels to a 2D canvas
  105901. var imageData = context.createImageData(width, height);
  105902. var castData = (imageData.data);
  105903. castData.set(data);
  105904. context.putImageData(imageData, 0, 0);
  105905. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  105906. }
  105907. };
  105908. /**
  105909. * Converts the canvas data to blob.
  105910. * This acts as a polyfill for browsers not supporting the to blob function.
  105911. * @param canvas Defines the canvas to extract the data from
  105912. * @param successCallback Defines the callback triggered once the data are available
  105913. * @param mimeType Defines the mime type of the result
  105914. */
  105915. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  105916. if (mimeType === void 0) { mimeType = "image/png"; }
  105917. // We need HTMLCanvasElement.toBlob for HD screenshots
  105918. if (!canvas.toBlob) {
  105919. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  105920. canvas.toBlob = function (callback, type, quality) {
  105921. var _this = this;
  105922. setTimeout(function () {
  105923. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  105924. for (var i = 0; i < len; i++) {
  105925. arr[i] = binStr.charCodeAt(i);
  105926. }
  105927. callback(new Blob([arr]));
  105928. });
  105929. };
  105930. }
  105931. canvas.toBlob(function (blob) {
  105932. successCallback(blob);
  105933. }, mimeType);
  105934. };
  105935. /**
  105936. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  105937. * @param successCallback defines the callback triggered once the data are available
  105938. * @param mimeType defines the mime type of the result
  105939. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  105940. */
  105941. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  105942. if (mimeType === void 0) { mimeType = "image/png"; }
  105943. if (successCallback) {
  105944. var base64Image = Tools._ScreenshotCanvas.toDataURL(mimeType);
  105945. successCallback(base64Image);
  105946. }
  105947. else {
  105948. this.ToBlob(Tools._ScreenshotCanvas, function (blob) {
  105949. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  105950. if (("download" in document.createElement("a"))) {
  105951. if (!fileName) {
  105952. var date = new Date();
  105953. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  105954. fileName = "screenshot_" + stringDate + ".png";
  105955. }
  105956. Tools.Download(blob, fileName);
  105957. }
  105958. else {
  105959. var url = URL.createObjectURL(blob);
  105960. var newWindow = window.open("");
  105961. if (!newWindow) {
  105962. return;
  105963. }
  105964. var img = newWindow.document.createElement("img");
  105965. img.onload = function () {
  105966. // no longer need to read the blob so it's revoked
  105967. URL.revokeObjectURL(url);
  105968. };
  105969. img.src = url;
  105970. newWindow.document.body.appendChild(img);
  105971. }
  105972. }, mimeType);
  105973. }
  105974. };
  105975. /**
  105976. * Downloads a blob in the browser
  105977. * @param blob defines the blob to download
  105978. * @param fileName defines the name of the downloaded file
  105979. */
  105980. Tools.Download = function (blob, fileName) {
  105981. if (navigator && navigator.msSaveBlob) {
  105982. navigator.msSaveBlob(blob, fileName);
  105983. return;
  105984. }
  105985. var url = window.URL.createObjectURL(blob);
  105986. var a = document.createElement("a");
  105987. document.body.appendChild(a);
  105988. a.style.display = "none";
  105989. a.href = url;
  105990. a.download = fileName;
  105991. a.addEventListener("click", function () {
  105992. if (a.parentElement) {
  105993. a.parentElement.removeChild(a);
  105994. }
  105995. });
  105996. a.click();
  105997. window.URL.revokeObjectURL(url);
  105998. };
  105999. /**
  106000. * Captures a screenshot of the current rendering
  106001. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106002. * @param engine defines the rendering engine
  106003. * @param camera defines the source camera
  106004. * @param size This parameter can be set to a single number or to an object with the
  106005. * following (optional) properties: precision, width, height. If a single number is passed,
  106006. * it will be used for both width and height. If an object is passed, the screenshot size
  106007. * will be derived from the parameters. The precision property is a multiplier allowing
  106008. * rendering at a higher or lower resolution
  106009. * @param successCallback defines the callback receives a single parameter which contains the
  106010. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  106011. * src parameter of an <img> to display it
  106012. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  106013. * Check your browser for supported MIME types
  106014. */
  106015. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  106016. if (mimeType === void 0) { mimeType = "image/png"; }
  106017. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  106018. };
  106019. /**
  106020. * Generates an image screenshot from the specified camera.
  106021. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106022. * @param engine The engine to use for rendering
  106023. * @param camera The camera to use for rendering
  106024. * @param size This parameter can be set to a single number or to an object with the
  106025. * following (optional) properties: precision, width, height. If a single number is passed,
  106026. * it will be used for both width and height. If an object is passed, the screenshot size
  106027. * will be derived from the parameters. The precision property is a multiplier allowing
  106028. * rendering at a higher or lower resolution
  106029. * @param successCallback The callback receives a single parameter which contains the
  106030. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  106031. * src parameter of an <img> to display it
  106032. * @param mimeType The MIME type of the screenshot image (default: image/png).
  106033. * Check your browser for supported MIME types
  106034. * @param samples Texture samples (default: 1)
  106035. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  106036. * @param fileName A name for for the downloaded file.
  106037. */
  106038. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  106039. if (mimeType === void 0) { mimeType = "image/png"; }
  106040. if (samples === void 0) { samples = 1; }
  106041. if (antialiasing === void 0) { antialiasing = false; }
  106042. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  106043. };
  106044. /**
  106045. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106046. * Be aware Math.random() could cause collisions, but:
  106047. * "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"
  106048. * @returns a pseudo random id
  106049. */
  106050. Tools.RandomId = function () {
  106051. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  106052. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  106053. return v.toString(16);
  106054. });
  106055. };
  106056. /**
  106057. * Test if the given uri is a base64 string
  106058. * @param uri The uri to test
  106059. * @return True if the uri is a base64 string or false otherwise
  106060. */
  106061. Tools.IsBase64 = function (uri) {
  106062. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  106063. };
  106064. /**
  106065. * Decode the given base64 uri.
  106066. * @param uri The uri to decode
  106067. * @return The decoded base64 data.
  106068. */
  106069. Tools.DecodeBase64 = function (uri) {
  106070. var decodedString = atob(uri.split(",")[1]);
  106071. var bufferLength = decodedString.length;
  106072. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  106073. for (var i = 0; i < bufferLength; i++) {
  106074. bufferView[i] = decodedString.charCodeAt(i);
  106075. }
  106076. return bufferView.buffer;
  106077. };
  106078. /**
  106079. * Gets the absolute url.
  106080. * @param url the input url
  106081. * @return the absolute url
  106082. */
  106083. Tools.GetAbsoluteUrl = function (url) {
  106084. var a = document.createElement("a");
  106085. a.href = url;
  106086. return a.href;
  106087. };
  106088. Object.defineProperty(Tools, "errorsCount", {
  106089. /**
  106090. * Gets a value indicating the number of loading errors
  106091. * @ignorenaming
  106092. */
  106093. get: function () {
  106094. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  106095. },
  106096. enumerable: true,
  106097. configurable: true
  106098. });
  106099. /**
  106100. * Log a message to the console
  106101. * @param message defines the message to log
  106102. */
  106103. Tools.Log = function (message) {
  106104. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  106105. };
  106106. /**
  106107. * Write a warning message to the console
  106108. * @param message defines the message to log
  106109. */
  106110. Tools.Warn = function (message) {
  106111. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  106112. };
  106113. /**
  106114. * Write an error message to the console
  106115. * @param message defines the message to log
  106116. */
  106117. Tools.Error = function (message) {
  106118. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  106119. };
  106120. Object.defineProperty(Tools, "LogCache", {
  106121. /**
  106122. * Gets current log cache (list of logs)
  106123. */
  106124. get: function () {
  106125. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  106126. },
  106127. enumerable: true,
  106128. configurable: true
  106129. });
  106130. /**
  106131. * Clears the log cache
  106132. */
  106133. Tools.ClearLogCache = function () {
  106134. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  106135. };
  106136. Object.defineProperty(Tools, "LogLevels", {
  106137. /**
  106138. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  106139. */
  106140. set: function (level) {
  106141. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  106142. },
  106143. enumerable: true,
  106144. configurable: true
  106145. });
  106146. /**
  106147. * Checks if the loaded document was accessed via `file:`-Protocol.
  106148. * @returns boolean
  106149. */
  106150. Tools.IsFileURL = function () {
  106151. return location.protocol === "file:";
  106152. };
  106153. Object.defineProperty(Tools, "PerformanceLogLevel", {
  106154. /**
  106155. * Sets the current performance log level
  106156. */
  106157. set: function (level) {
  106158. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  106159. Tools.StartPerformanceCounter = Tools._StartUserMark;
  106160. Tools.EndPerformanceCounter = Tools._EndUserMark;
  106161. return;
  106162. }
  106163. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  106164. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  106165. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  106166. return;
  106167. }
  106168. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  106169. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  106170. },
  106171. enumerable: true,
  106172. configurable: true
  106173. });
  106174. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  106175. };
  106176. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  106177. };
  106178. Tools._StartUserMark = function (counterName, condition) {
  106179. if (condition === void 0) { condition = true; }
  106180. if (!Tools._performance) {
  106181. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  106182. return;
  106183. }
  106184. Tools._performance = window.performance;
  106185. }
  106186. if (!condition || !Tools._performance.mark) {
  106187. return;
  106188. }
  106189. Tools._performance.mark(counterName + "-Begin");
  106190. };
  106191. Tools._EndUserMark = function (counterName, condition) {
  106192. if (condition === void 0) { condition = true; }
  106193. if (!condition || !Tools._performance.mark) {
  106194. return;
  106195. }
  106196. Tools._performance.mark(counterName + "-End");
  106197. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  106198. };
  106199. Tools._StartPerformanceConsole = function (counterName, condition) {
  106200. if (condition === void 0) { condition = true; }
  106201. if (!condition) {
  106202. return;
  106203. }
  106204. Tools._StartUserMark(counterName, condition);
  106205. if (console.time) {
  106206. console.time(counterName);
  106207. }
  106208. };
  106209. Tools._EndPerformanceConsole = function (counterName, condition) {
  106210. if (condition === void 0) { condition = true; }
  106211. if (!condition) {
  106212. return;
  106213. }
  106214. Tools._EndUserMark(counterName, condition);
  106215. if (console.time) {
  106216. console.timeEnd(counterName);
  106217. }
  106218. };
  106219. Object.defineProperty(Tools, "Now", {
  106220. /**
  106221. * Gets either window.performance.now() if supported or Date.now() else
  106222. */
  106223. get: function () {
  106224. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  106225. },
  106226. enumerable: true,
  106227. configurable: true
  106228. });
  106229. /**
  106230. * This method will return the name of the class used to create the instance of the given object.
  106231. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  106232. * @param object the object to get the class name from
  106233. * @param isType defines if the object is actually a type
  106234. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  106235. */
  106236. Tools.GetClassName = function (object, isType) {
  106237. if (isType === void 0) { isType = false; }
  106238. var name = null;
  106239. if (!isType && object.getClassName) {
  106240. name = object.getClassName();
  106241. }
  106242. else {
  106243. if (object instanceof Object) {
  106244. var classObj = isType ? object : Object.getPrototypeOf(object);
  106245. name = classObj.constructor["__bjsclassName__"];
  106246. }
  106247. if (!name) {
  106248. name = typeof object;
  106249. }
  106250. }
  106251. return name;
  106252. };
  106253. /**
  106254. * Gets the first element of an array satisfying a given predicate
  106255. * @param array defines the array to browse
  106256. * @param predicate defines the predicate to use
  106257. * @returns null if not found or the element
  106258. */
  106259. Tools.First = function (array, predicate) {
  106260. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  106261. var el = array_1[_i];
  106262. if (predicate(el)) {
  106263. return el;
  106264. }
  106265. }
  106266. return null;
  106267. };
  106268. /**
  106269. * This method will return the name of the full name of the class, including its owning module (if any).
  106270. * 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).
  106271. * @param object the object to get the class name from
  106272. * @param isType defines if the object is actually a type
  106273. * @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.
  106274. * @ignorenaming
  106275. */
  106276. Tools.getFullClassName = function (object, isType) {
  106277. if (isType === void 0) { isType = false; }
  106278. var className = null;
  106279. var moduleName = null;
  106280. if (!isType && object.getClassName) {
  106281. className = object.getClassName();
  106282. }
  106283. else {
  106284. if (object instanceof Object) {
  106285. var classObj = isType ? object : Object.getPrototypeOf(object);
  106286. className = classObj.constructor["__bjsclassName__"];
  106287. moduleName = classObj.constructor["__bjsmoduleName__"];
  106288. }
  106289. if (!className) {
  106290. className = typeof object;
  106291. }
  106292. }
  106293. if (!className) {
  106294. return null;
  106295. }
  106296. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  106297. };
  106298. /**
  106299. * Returns a promise that resolves after the given amount of time.
  106300. * @param delay Number of milliseconds to delay
  106301. * @returns Promise that resolves after the given amount of time
  106302. */
  106303. Tools.DelayAsync = function (delay) {
  106304. return new Promise(function (resolve) {
  106305. setTimeout(function () {
  106306. resolve();
  106307. }, delay);
  106308. });
  106309. };
  106310. /**
  106311. * Gets the current gradient from an array of IValueGradient
  106312. * @param ratio defines the current ratio to get
  106313. * @param gradients defines the array of IValueGradient
  106314. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  106315. */
  106316. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  106317. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  106318. var currentGradient = gradients[gradientIndex];
  106319. var nextGradient = gradients[gradientIndex + 1];
  106320. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  106321. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  106322. updateFunc(currentGradient, nextGradient, scale);
  106323. return;
  106324. }
  106325. }
  106326. // Use last index if over
  106327. var lastIndex = gradients.length - 1;
  106328. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  106329. };
  106330. /**
  106331. * Gets or sets the base URL to use to load assets
  106332. */
  106333. Tools.BaseUrl = "";
  106334. /**
  106335. * Enable/Disable Custom HTTP Request Headers globally.
  106336. * default = false
  106337. * @see CustomRequestHeaders
  106338. */
  106339. Tools.UseCustomRequestHeaders = false;
  106340. /**
  106341. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  106342. * i.e. when loading files, where the server/service expects an Authorization header
  106343. */
  106344. Tools.CustomRequestHeaders = _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"].CustomRequestHeaders;
  106345. /**
  106346. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  106347. */
  106348. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  106349. /**
  106350. * Default behaviour for cors in the application.
  106351. * It can be a string if the expected behavior is identical in the entire app.
  106352. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  106353. */
  106354. Tools.CorsBehavior = "anonymous";
  106355. /**
  106356. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  106357. * @ignorenaming
  106358. */
  106359. Tools.UseFallbackTexture = true;
  106360. /**
  106361. * Use this object to register external classes like custom textures or material
  106362. * to allow the laoders to instantiate them
  106363. */
  106364. Tools.RegisteredExternalClasses = {};
  106365. /**
  106366. * Texture content used if a texture cannot loaded
  106367. * @ignorenaming
  106368. */
  106369. 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";
  106370. Tools._tmpFloatArray = new Float32Array(1);
  106371. /**
  106372. * Extracts text content from a DOM element hierarchy
  106373. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  106374. */
  106375. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  106376. /**
  106377. * Gets or sets a function used to pre-process url before using them to load assets
  106378. */
  106379. Tools.PreprocessUrl = function (url) {
  106380. return url;
  106381. };
  106382. // Logs
  106383. /**
  106384. * No log
  106385. */
  106386. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  106387. /**
  106388. * Only message logs
  106389. */
  106390. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  106391. /**
  106392. * Only warning logs
  106393. */
  106394. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  106395. /**
  106396. * Only error logs
  106397. */
  106398. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  106399. /**
  106400. * All logs
  106401. */
  106402. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  106403. /**
  106404. * Checks if the window object exists
  106405. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  106406. */
  106407. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  106408. // Performances
  106409. /**
  106410. * No performance log
  106411. */
  106412. Tools.PerformanceNoneLogLevel = 0;
  106413. /**
  106414. * Use user marks to log performance
  106415. */
  106416. Tools.PerformanceUserMarkLogLevel = 1;
  106417. /**
  106418. * Log performance to the console
  106419. */
  106420. Tools.PerformanceConsoleLogLevel = 2;
  106421. /**
  106422. * Starts a performance counter
  106423. */
  106424. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  106425. /**
  106426. * Ends a specific performance coutner
  106427. */
  106428. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  106429. return Tools;
  106430. }());
  106431. /**
  106432. * This class is used to track a performance counter which is number based.
  106433. * The user has access to many properties which give statistics of different nature.
  106434. *
  106435. * The implementer can track two kinds of Performance Counter: time and count.
  106436. * 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.
  106437. * 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.
  106438. */
  106439. var PerfCounter = /** @class */ (function () {
  106440. /**
  106441. * Creates a new counter
  106442. */
  106443. function PerfCounter() {
  106444. this._startMonitoringTime = 0;
  106445. this._min = 0;
  106446. this._max = 0;
  106447. this._average = 0;
  106448. this._lastSecAverage = 0;
  106449. this._current = 0;
  106450. this._totalValueCount = 0;
  106451. this._totalAccumulated = 0;
  106452. this._lastSecAccumulated = 0;
  106453. this._lastSecTime = 0;
  106454. this._lastSecValueCount = 0;
  106455. }
  106456. Object.defineProperty(PerfCounter.prototype, "min", {
  106457. /**
  106458. * Returns the smallest value ever
  106459. */
  106460. get: function () {
  106461. return this._min;
  106462. },
  106463. enumerable: true,
  106464. configurable: true
  106465. });
  106466. Object.defineProperty(PerfCounter.prototype, "max", {
  106467. /**
  106468. * Returns the biggest value ever
  106469. */
  106470. get: function () {
  106471. return this._max;
  106472. },
  106473. enumerable: true,
  106474. configurable: true
  106475. });
  106476. Object.defineProperty(PerfCounter.prototype, "average", {
  106477. /**
  106478. * Returns the average value since the performance counter is running
  106479. */
  106480. get: function () {
  106481. return this._average;
  106482. },
  106483. enumerable: true,
  106484. configurable: true
  106485. });
  106486. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  106487. /**
  106488. * Returns the average value of the last second the counter was monitored
  106489. */
  106490. get: function () {
  106491. return this._lastSecAverage;
  106492. },
  106493. enumerable: true,
  106494. configurable: true
  106495. });
  106496. Object.defineProperty(PerfCounter.prototype, "current", {
  106497. /**
  106498. * Returns the current value
  106499. */
  106500. get: function () {
  106501. return this._current;
  106502. },
  106503. enumerable: true,
  106504. configurable: true
  106505. });
  106506. Object.defineProperty(PerfCounter.prototype, "total", {
  106507. /**
  106508. * Gets the accumulated total
  106509. */
  106510. get: function () {
  106511. return this._totalAccumulated;
  106512. },
  106513. enumerable: true,
  106514. configurable: true
  106515. });
  106516. Object.defineProperty(PerfCounter.prototype, "count", {
  106517. /**
  106518. * Gets the total value count
  106519. */
  106520. get: function () {
  106521. return this._totalValueCount;
  106522. },
  106523. enumerable: true,
  106524. configurable: true
  106525. });
  106526. /**
  106527. * Call this method to start monitoring a new frame.
  106528. * 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.
  106529. */
  106530. PerfCounter.prototype.fetchNewFrame = function () {
  106531. this._totalValueCount++;
  106532. this._current = 0;
  106533. this._lastSecValueCount++;
  106534. };
  106535. /**
  106536. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106537. * @param newCount the count value to add to the monitored count
  106538. * @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.
  106539. */
  106540. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  106541. if (!PerfCounter.Enabled) {
  106542. return;
  106543. }
  106544. this._current += newCount;
  106545. if (fetchResult) {
  106546. this._fetchResult();
  106547. }
  106548. };
  106549. /**
  106550. * Start monitoring this performance counter
  106551. */
  106552. PerfCounter.prototype.beginMonitoring = function () {
  106553. if (!PerfCounter.Enabled) {
  106554. return;
  106555. }
  106556. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  106557. };
  106558. /**
  106559. * Compute the time lapsed since the previous beginMonitoring() call.
  106560. * @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
  106561. */
  106562. PerfCounter.prototype.endMonitoring = function (newFrame) {
  106563. if (newFrame === void 0) { newFrame = true; }
  106564. if (!PerfCounter.Enabled) {
  106565. return;
  106566. }
  106567. if (newFrame) {
  106568. this.fetchNewFrame();
  106569. }
  106570. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  106571. this._current = currentTime - this._startMonitoringTime;
  106572. if (newFrame) {
  106573. this._fetchResult();
  106574. }
  106575. };
  106576. PerfCounter.prototype._fetchResult = function () {
  106577. this._totalAccumulated += this._current;
  106578. this._lastSecAccumulated += this._current;
  106579. // Min/Max update
  106580. this._min = Math.min(this._min, this._current);
  106581. this._max = Math.max(this._max, this._current);
  106582. this._average = this._totalAccumulated / this._totalValueCount;
  106583. // Reset last sec?
  106584. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  106585. if ((now - this._lastSecTime) > 1000) {
  106586. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  106587. this._lastSecTime = now;
  106588. this._lastSecAccumulated = 0;
  106589. this._lastSecValueCount = 0;
  106590. }
  106591. };
  106592. /**
  106593. * Gets or sets a global boolean to turn on and off all the counters
  106594. */
  106595. PerfCounter.Enabled = true;
  106596. return PerfCounter;
  106597. }());
  106598. /**
  106599. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  106600. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  106601. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  106602. * @param name The name of the class, case should be preserved
  106603. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  106604. */
  106605. function className(name, module) {
  106606. return function (target) {
  106607. target["__bjsclassName__"] = name;
  106608. target["__bjsmoduleName__"] = (module != null) ? module : null;
  106609. };
  106610. }
  106611. /**
  106612. * An implementation of a loop for asynchronous functions.
  106613. */
  106614. var AsyncLoop = /** @class */ (function () {
  106615. /**
  106616. * Constructor.
  106617. * @param iterations the number of iterations.
  106618. * @param func the function to run each iteration
  106619. * @param successCallback the callback that will be called upon succesful execution
  106620. * @param offset starting offset.
  106621. */
  106622. function AsyncLoop(
  106623. /**
  106624. * Defines the number of iterations for the loop
  106625. */
  106626. iterations, func, successCallback, offset) {
  106627. if (offset === void 0) { offset = 0; }
  106628. this.iterations = iterations;
  106629. this.index = offset - 1;
  106630. this._done = false;
  106631. this._fn = func;
  106632. this._successCallback = successCallback;
  106633. }
  106634. /**
  106635. * Execute the next iteration. Must be called after the last iteration was finished.
  106636. */
  106637. AsyncLoop.prototype.executeNext = function () {
  106638. if (!this._done) {
  106639. if (this.index + 1 < this.iterations) {
  106640. ++this.index;
  106641. this._fn(this);
  106642. }
  106643. else {
  106644. this.breakLoop();
  106645. }
  106646. }
  106647. };
  106648. /**
  106649. * Break the loop and run the success callback.
  106650. */
  106651. AsyncLoop.prototype.breakLoop = function () {
  106652. this._done = true;
  106653. this._successCallback();
  106654. };
  106655. /**
  106656. * Create and run an async loop.
  106657. * @param iterations the number of iterations.
  106658. * @param fn the function to run each iteration
  106659. * @param successCallback the callback that will be called upon succesful execution
  106660. * @param offset starting offset.
  106661. * @returns the created async loop object
  106662. */
  106663. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  106664. if (offset === void 0) { offset = 0; }
  106665. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  106666. loop.executeNext();
  106667. return loop;
  106668. };
  106669. /**
  106670. * A for-loop that will run a given number of iterations synchronous and the rest async.
  106671. * @param iterations total number of iterations
  106672. * @param syncedIterations number of synchronous iterations in each async iteration.
  106673. * @param fn the function to call each iteration.
  106674. * @param callback a success call back that will be called when iterating stops.
  106675. * @param breakFunction a break condition (optional)
  106676. * @param timeout timeout settings for the setTimeout function. default - 0.
  106677. * @returns the created async loop object
  106678. */
  106679. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  106680. if (timeout === void 0) { timeout = 0; }
  106681. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  106682. if (breakFunction && breakFunction()) {
  106683. loop.breakLoop();
  106684. }
  106685. else {
  106686. setTimeout(function () {
  106687. for (var i = 0; i < syncedIterations; ++i) {
  106688. var iteration = (loop.index * syncedIterations) + i;
  106689. if (iteration >= iterations) {
  106690. break;
  106691. }
  106692. fn(iteration);
  106693. if (breakFunction && breakFunction()) {
  106694. loop.breakLoop();
  106695. break;
  106696. }
  106697. }
  106698. loop.executeNext();
  106699. }, timeout);
  106700. }
  106701. }, callback);
  106702. };
  106703. return AsyncLoop;
  106704. }());
  106705. /***/ }),
  106706. /***/ "./Misc/typeStore.ts":
  106707. /*!***************************!*\
  106708. !*** ./Misc/typeStore.ts ***!
  106709. \***************************/
  106710. /*! exports provided: _TypeStore */
  106711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106712. "use strict";
  106713. __webpack_require__.r(__webpack_exports__);
  106714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  106715. /** @hidden */
  106716. var _TypeStore = /** @class */ (function () {
  106717. function _TypeStore() {
  106718. }
  106719. /** @hidden */
  106720. _TypeStore.GetClass = function (fqdn) {
  106721. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  106722. return this.RegisteredTypes[fqdn];
  106723. }
  106724. return null;
  106725. };
  106726. /** @hidden */
  106727. _TypeStore.RegisteredTypes = {};
  106728. return _TypeStore;
  106729. }());
  106730. /***/ }),
  106731. /***/ "./Misc/videoRecorder.ts":
  106732. /*!*******************************!*\
  106733. !*** ./Misc/videoRecorder.ts ***!
  106734. \*******************************/
  106735. /*! exports provided: VideoRecorder */
  106736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106737. "use strict";
  106738. __webpack_require__.r(__webpack_exports__);
  106739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  106740. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  106741. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  106742. /**
  106743. * This can helps recording videos from BabylonJS.
  106744. * This is based on the available WebRTC functionalities of the browser.
  106745. *
  106746. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  106747. */
  106748. var VideoRecorder = /** @class */ (function () {
  106749. /**
  106750. * Create a new VideoCapture object which can help converting what you see in Babylon to
  106751. * a video file.
  106752. * @param engine Defines the BabylonJS Engine you wish to record
  106753. * @param options Defines options that can be used to customized the capture
  106754. */
  106755. function VideoRecorder(engine, options) {
  106756. if (options === void 0) { options = null; }
  106757. if (!VideoRecorder.IsSupported(engine)) {
  106758. throw "Your browser does not support recording so far.";
  106759. }
  106760. var canvas = engine.getRenderingCanvas();
  106761. if (!canvas) {
  106762. throw "The babylon engine must have a canvas to be recorded";
  106763. }
  106764. this._canvas = canvas;
  106765. this._canvas.isRecording = false;
  106766. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  106767. var stream = this._canvas.captureStream(this._options.fps);
  106768. if (this._options.audioTracks) {
  106769. for (var _i = 0, _a = this._options.audioTracks; _i < _a.length; _i++) {
  106770. var track = _a[_i];
  106771. stream.addTrack(track);
  106772. }
  106773. }
  106774. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  106775. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  106776. this._mediaRecorder.onerror = this._handleError.bind(this);
  106777. this._mediaRecorder.onstop = this._handleStop.bind(this);
  106778. }
  106779. /**
  106780. * Returns wehther or not the VideoRecorder is available in your browser.
  106781. * @param engine Defines the Babylon Engine to check the support for
  106782. * @returns true if supported otherwise false
  106783. */
  106784. VideoRecorder.IsSupported = function (engine) {
  106785. var canvas = engine.getRenderingCanvas();
  106786. return (!!canvas && typeof canvas.captureStream === "function");
  106787. };
  106788. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  106789. /**
  106790. * True wether a recording is already in progress.
  106791. */
  106792. get: function () {
  106793. return !!this._canvas && this._canvas.isRecording;
  106794. },
  106795. enumerable: true,
  106796. configurable: true
  106797. });
  106798. /**
  106799. * Stops the current recording before the default capture timeout passed in the startRecording
  106800. * functions.
  106801. */
  106802. VideoRecorder.prototype.stopRecording = function () {
  106803. if (!this._canvas || !this._mediaRecorder) {
  106804. return;
  106805. }
  106806. if (!this.isRecording) {
  106807. return;
  106808. }
  106809. this._canvas.isRecording = false;
  106810. this._mediaRecorder.stop();
  106811. };
  106812. /**
  106813. * Starts recording the canvas for a max duration specified in parameters.
  106814. * @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.
  106815. * @param maxDuration Defines the maximum recording time in seconds.
  106816. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  106817. * @return a promise callback at the end of the recording with the video data in Blob.
  106818. */
  106819. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  106820. var _this = this;
  106821. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  106822. if (maxDuration === void 0) { maxDuration = 7; }
  106823. if (!this._canvas || !this._mediaRecorder) {
  106824. throw "Recorder has already been disposed";
  106825. }
  106826. if (this.isRecording) {
  106827. throw "Recording already in progress";
  106828. }
  106829. if (maxDuration > 0) {
  106830. setTimeout(function () {
  106831. _this.stopRecording();
  106832. }, maxDuration * 1000);
  106833. }
  106834. this._fileName = fileName;
  106835. this._recordedChunks = [];
  106836. this._resolve = null;
  106837. this._reject = null;
  106838. this._canvas.isRecording = true;
  106839. this._mediaRecorder.start(this._options.recordChunckSize);
  106840. return new Promise(function (resolve, reject) {
  106841. _this._resolve = resolve;
  106842. _this._reject = reject;
  106843. });
  106844. };
  106845. /**
  106846. * Releases internal resources used during the recording.
  106847. */
  106848. VideoRecorder.prototype.dispose = function () {
  106849. this._canvas = null;
  106850. this._mediaRecorder = null;
  106851. this._recordedChunks = [];
  106852. this._fileName = null;
  106853. this._resolve = null;
  106854. this._reject = null;
  106855. };
  106856. VideoRecorder.prototype._handleDataAvailable = function (event) {
  106857. if (event.data.size > 0) {
  106858. this._recordedChunks.push(event.data);
  106859. }
  106860. };
  106861. VideoRecorder.prototype._handleError = function (event) {
  106862. this.stopRecording();
  106863. if (this._reject) {
  106864. this._reject(event.error);
  106865. }
  106866. else {
  106867. throw new event.error();
  106868. }
  106869. };
  106870. VideoRecorder.prototype._handleStop = function () {
  106871. this.stopRecording();
  106872. var superBuffer = new Blob(this._recordedChunks);
  106873. if (this._resolve) {
  106874. this._resolve(superBuffer);
  106875. }
  106876. window.URL.createObjectURL(superBuffer);
  106877. if (this._fileName) {
  106878. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  106879. }
  106880. };
  106881. VideoRecorder._defaultOptions = {
  106882. mimeType: "video/webm",
  106883. fps: 25,
  106884. recordChunckSize: 3000
  106885. };
  106886. return VideoRecorder;
  106887. }());
  106888. /***/ }),
  106889. /***/ "./Misc/virtualJoystick.ts":
  106890. /*!*********************************!*\
  106891. !*** ./Misc/virtualJoystick.ts ***!
  106892. \*********************************/
  106893. /*! exports provided: JoystickAxis, VirtualJoystick */
  106894. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106895. "use strict";
  106896. __webpack_require__.r(__webpack_exports__);
  106897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  106898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  106899. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106900. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  106901. // Mainly based on these 2 articles :
  106902. // 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
  106903. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  106904. /**
  106905. * Defines the potential axis of a Joystick
  106906. */
  106907. var JoystickAxis;
  106908. (function (JoystickAxis) {
  106909. /** X axis */
  106910. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  106911. /** Y axis */
  106912. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  106913. /** Z axis */
  106914. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  106915. })(JoystickAxis || (JoystickAxis = {}));
  106916. /**
  106917. * Class used to define virtual joystick (used in touch mode)
  106918. */
  106919. var VirtualJoystick = /** @class */ (function () {
  106920. /**
  106921. * Creates a new virtual joystick
  106922. * @param leftJoystick defines that the joystick is for left hand (false by default)
  106923. */
  106924. function VirtualJoystick(leftJoystick) {
  106925. var _this = this;
  106926. if (leftJoystick) {
  106927. this._leftJoystick = true;
  106928. }
  106929. else {
  106930. this._leftJoystick = false;
  106931. }
  106932. VirtualJoystick._globalJoystickIndex++;
  106933. // By default left & right arrow keys are moving the X
  106934. // and up & down keys are moving the Y
  106935. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  106936. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  106937. this.reverseLeftRight = false;
  106938. this.reverseUpDown = false;
  106939. // collections of pointers
  106940. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  106941. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106942. this._joystickSensibility = 25;
  106943. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  106944. this._onResize = function (evt) {
  106945. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  106946. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  106947. if (VirtualJoystick.Canvas) {
  106948. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  106949. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  106950. }
  106951. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  106952. };
  106953. // injecting a canvas element on top of the canvas 3D game
  106954. if (!VirtualJoystick.Canvas) {
  106955. window.addEventListener("resize", this._onResize, false);
  106956. VirtualJoystick.Canvas = document.createElement("canvas");
  106957. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  106958. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  106959. VirtualJoystick.Canvas.width = window.innerWidth;
  106960. VirtualJoystick.Canvas.height = window.innerHeight;
  106961. VirtualJoystick.Canvas.style.width = "100%";
  106962. VirtualJoystick.Canvas.style.height = "100%";
  106963. VirtualJoystick.Canvas.style.position = "absolute";
  106964. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  106965. VirtualJoystick.Canvas.style.top = "0px";
  106966. VirtualJoystick.Canvas.style.left = "0px";
  106967. VirtualJoystick.Canvas.style.zIndex = "5";
  106968. VirtualJoystick.Canvas.style.msTouchAction = "none";
  106969. // Support for jQuery PEP polyfill
  106970. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  106971. var context = VirtualJoystick.Canvas.getContext('2d');
  106972. if (!context) {
  106973. throw new Error("Unable to create canvas for virtual joystick");
  106974. }
  106975. VirtualJoystick.vjCanvasContext = context;
  106976. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  106977. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  106978. document.body.appendChild(VirtualJoystick.Canvas);
  106979. }
  106980. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  106981. this.pressed = false;
  106982. // default joystick color
  106983. this._joystickColor = "cyan";
  106984. this._joystickPointerID = -1;
  106985. // current joystick position
  106986. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  106987. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  106988. // origin joystick position
  106989. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  106990. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  106991. this._onPointerDownHandlerRef = function (evt) {
  106992. _this._onPointerDown(evt);
  106993. };
  106994. this._onPointerMoveHandlerRef = function (evt) {
  106995. _this._onPointerMove(evt);
  106996. };
  106997. this._onPointerUpHandlerRef = function (evt) {
  106998. _this._onPointerUp(evt);
  106999. };
  107000. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  107001. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  107002. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  107003. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  107004. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  107005. evt.preventDefault(); // Disables system menu
  107006. }, false);
  107007. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  107008. }
  107009. /**
  107010. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  107011. * @param newJoystickSensibility defines the new sensibility
  107012. */
  107013. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  107014. this._joystickSensibility = newJoystickSensibility;
  107015. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  107016. };
  107017. VirtualJoystick.prototype._onPointerDown = function (e) {
  107018. var positionOnScreenCondition;
  107019. e.preventDefault();
  107020. if (this._leftJoystick === true) {
  107021. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  107022. }
  107023. else {
  107024. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  107025. }
  107026. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  107027. // First contact will be dedicated to the virtual joystick
  107028. this._joystickPointerID = e.pointerId;
  107029. this._joystickPointerStartPos.x = e.clientX;
  107030. this._joystickPointerStartPos.y = e.clientY;
  107031. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  107032. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  107033. this._deltaJoystickVector.x = 0;
  107034. this._deltaJoystickVector.y = 0;
  107035. this.pressed = true;
  107036. this._touches.add(e.pointerId.toString(), e);
  107037. }
  107038. else {
  107039. // You can only trigger the action buttons with a joystick declared
  107040. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  107041. this._action();
  107042. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  107043. }
  107044. }
  107045. };
  107046. VirtualJoystick.prototype._onPointerMove = function (e) {
  107047. // If the current pointer is the one associated to the joystick (first touch contact)
  107048. if (this._joystickPointerID == e.pointerId) {
  107049. this._joystickPointerPos.x = e.clientX;
  107050. this._joystickPointerPos.y = e.clientY;
  107051. this._deltaJoystickVector = this._joystickPointerPos.clone();
  107052. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  107053. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  107054. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  107055. switch (this._axisTargetedByLeftAndRight) {
  107056. case JoystickAxis.X:
  107057. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  107058. break;
  107059. case JoystickAxis.Y:
  107060. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  107061. break;
  107062. case JoystickAxis.Z:
  107063. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  107064. break;
  107065. }
  107066. var directionUpDown = this.reverseUpDown ? 1 : -1;
  107067. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  107068. switch (this._axisTargetedByUpAndDown) {
  107069. case JoystickAxis.X:
  107070. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  107071. break;
  107072. case JoystickAxis.Y:
  107073. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  107074. break;
  107075. case JoystickAxis.Z:
  107076. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  107077. break;
  107078. }
  107079. }
  107080. else {
  107081. var data = this._touches.get(e.pointerId.toString());
  107082. if (data) {
  107083. data.x = e.clientX;
  107084. data.y = e.clientY;
  107085. }
  107086. }
  107087. };
  107088. VirtualJoystick.prototype._onPointerUp = function (e) {
  107089. if (this._joystickPointerID == e.pointerId) {
  107090. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  107091. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  107092. this._joystickPointerID = -1;
  107093. this.pressed = false;
  107094. }
  107095. else {
  107096. var touch = this._touches.get(e.pointerId.toString());
  107097. if (touch) {
  107098. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  107099. }
  107100. }
  107101. this._deltaJoystickVector.x = 0;
  107102. this._deltaJoystickVector.y = 0;
  107103. this._touches.remove(e.pointerId.toString());
  107104. };
  107105. /**
  107106. * Change the color of the virtual joystick
  107107. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  107108. */
  107109. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  107110. this._joystickColor = newColor;
  107111. };
  107112. /**
  107113. * Defines a callback to call when the joystick is touched
  107114. * @param action defines the callback
  107115. */
  107116. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  107117. this._action = action;
  107118. };
  107119. /**
  107120. * Defines which axis you'd like to control for left & right
  107121. * @param axis defines the axis to use
  107122. */
  107123. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  107124. switch (axis) {
  107125. case JoystickAxis.X:
  107126. case JoystickAxis.Y:
  107127. case JoystickAxis.Z:
  107128. this._axisTargetedByLeftAndRight = axis;
  107129. break;
  107130. default:
  107131. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  107132. break;
  107133. }
  107134. };
  107135. /**
  107136. * Defines which axis you'd like to control for up & down
  107137. * @param axis defines the axis to use
  107138. */
  107139. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  107140. switch (axis) {
  107141. case JoystickAxis.X:
  107142. case JoystickAxis.Y:
  107143. case JoystickAxis.Z:
  107144. this._axisTargetedByUpAndDown = axis;
  107145. break;
  107146. default:
  107147. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  107148. break;
  107149. }
  107150. };
  107151. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  107152. var _this = this;
  107153. if (this.pressed) {
  107154. this._touches.forEach(function (key, touch) {
  107155. if (touch.pointerId === _this._joystickPointerID) {
  107156. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  107157. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  107158. VirtualJoystick.vjCanvasContext.beginPath();
  107159. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  107160. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  107161. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  107162. VirtualJoystick.vjCanvasContext.stroke();
  107163. VirtualJoystick.vjCanvasContext.closePath();
  107164. VirtualJoystick.vjCanvasContext.beginPath();
  107165. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  107166. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  107167. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  107168. VirtualJoystick.vjCanvasContext.stroke();
  107169. VirtualJoystick.vjCanvasContext.closePath();
  107170. VirtualJoystick.vjCanvasContext.beginPath();
  107171. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  107172. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  107173. VirtualJoystick.vjCanvasContext.stroke();
  107174. VirtualJoystick.vjCanvasContext.closePath();
  107175. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  107176. }
  107177. else {
  107178. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  107179. VirtualJoystick.vjCanvasContext.beginPath();
  107180. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  107181. VirtualJoystick.vjCanvasContext.beginPath();
  107182. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  107183. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  107184. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  107185. VirtualJoystick.vjCanvasContext.stroke();
  107186. VirtualJoystick.vjCanvasContext.closePath();
  107187. touch.prevX = touch.x;
  107188. touch.prevY = touch.y;
  107189. }
  107190. });
  107191. }
  107192. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  107193. };
  107194. /**
  107195. * Release internal HTML canvas
  107196. */
  107197. VirtualJoystick.prototype.releaseCanvas = function () {
  107198. if (VirtualJoystick.Canvas) {
  107199. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  107200. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  107201. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  107202. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  107203. window.removeEventListener("resize", this._onResize);
  107204. document.body.removeChild(VirtualJoystick.Canvas);
  107205. VirtualJoystick.Canvas = null;
  107206. }
  107207. };
  107208. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  107209. VirtualJoystick._globalJoystickIndex = 0;
  107210. return VirtualJoystick;
  107211. }());
  107212. /***/ }),
  107213. /***/ "./Misc/webRequest.ts":
  107214. /*!****************************!*\
  107215. !*** ./Misc/webRequest.ts ***!
  107216. \****************************/
  107217. /*! exports provided: WebRequest */
  107218. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107219. "use strict";
  107220. __webpack_require__.r(__webpack_exports__);
  107221. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return WebRequest; });
  107222. /**
  107223. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  107224. */
  107225. var WebRequest = /** @class */ (function () {
  107226. function WebRequest() {
  107227. this._xhr = new XMLHttpRequest();
  107228. }
  107229. WebRequest.prototype._injectCustomRequestHeaders = function () {
  107230. for (var key in WebRequest.CustomRequestHeaders) {
  107231. var val = WebRequest.CustomRequestHeaders[key];
  107232. if (val) {
  107233. this._xhr.setRequestHeader(key, val);
  107234. }
  107235. }
  107236. };
  107237. Object.defineProperty(WebRequest.prototype, "onprogress", {
  107238. /**
  107239. * Gets or sets a function to be called when loading progress changes
  107240. */
  107241. get: function () {
  107242. return this._xhr.onprogress;
  107243. },
  107244. set: function (value) {
  107245. this._xhr.onprogress = value;
  107246. },
  107247. enumerable: true,
  107248. configurable: true
  107249. });
  107250. Object.defineProperty(WebRequest.prototype, "readyState", {
  107251. /**
  107252. * Returns client's state
  107253. */
  107254. get: function () {
  107255. return this._xhr.readyState;
  107256. },
  107257. enumerable: true,
  107258. configurable: true
  107259. });
  107260. Object.defineProperty(WebRequest.prototype, "status", {
  107261. /**
  107262. * Returns client's status
  107263. */
  107264. get: function () {
  107265. return this._xhr.status;
  107266. },
  107267. enumerable: true,
  107268. configurable: true
  107269. });
  107270. Object.defineProperty(WebRequest.prototype, "statusText", {
  107271. /**
  107272. * Returns client's status as a text
  107273. */
  107274. get: function () {
  107275. return this._xhr.statusText;
  107276. },
  107277. enumerable: true,
  107278. configurable: true
  107279. });
  107280. Object.defineProperty(WebRequest.prototype, "response", {
  107281. /**
  107282. * Returns client's response
  107283. */
  107284. get: function () {
  107285. return this._xhr.response;
  107286. },
  107287. enumerable: true,
  107288. configurable: true
  107289. });
  107290. Object.defineProperty(WebRequest.prototype, "responseURL", {
  107291. /**
  107292. * Returns client's response url
  107293. */
  107294. get: function () {
  107295. return this._xhr.responseURL;
  107296. },
  107297. enumerable: true,
  107298. configurable: true
  107299. });
  107300. Object.defineProperty(WebRequest.prototype, "responseText", {
  107301. /**
  107302. * Returns client's response as text
  107303. */
  107304. get: function () {
  107305. return this._xhr.responseText;
  107306. },
  107307. enumerable: true,
  107308. configurable: true
  107309. });
  107310. Object.defineProperty(WebRequest.prototype, "responseType", {
  107311. /**
  107312. * Gets or sets the expected response type
  107313. */
  107314. get: function () {
  107315. return this._xhr.responseType;
  107316. },
  107317. set: function (value) {
  107318. this._xhr.responseType = value;
  107319. },
  107320. enumerable: true,
  107321. configurable: true
  107322. });
  107323. WebRequest.prototype.addEventListener = function (type, listener, options) {
  107324. this._xhr.addEventListener(type, listener, options);
  107325. };
  107326. WebRequest.prototype.removeEventListener = function (type, listener, options) {
  107327. this._xhr.removeEventListener(type, listener, options);
  107328. };
  107329. /**
  107330. * Cancels any network activity
  107331. */
  107332. WebRequest.prototype.abort = function () {
  107333. this._xhr.abort();
  107334. };
  107335. /**
  107336. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  107337. * @param body defines an optional request body
  107338. */
  107339. WebRequest.prototype.send = function (body) {
  107340. if (WebRequest.CustomRequestHeaders) {
  107341. this._injectCustomRequestHeaders();
  107342. }
  107343. this._xhr.send(body);
  107344. };
  107345. /**
  107346. * Sets the request method, request URL
  107347. * @param method defines the method to use (GET, POST, etc..)
  107348. * @param url defines the url to connect with
  107349. */
  107350. WebRequest.prototype.open = function (method, url) {
  107351. for (var _i = 0, _a = WebRequest.CustomRequestModifiers; _i < _a.length; _i++) {
  107352. var update = _a[_i];
  107353. update(this._xhr);
  107354. }
  107355. return this._xhr.open(method, url, true);
  107356. };
  107357. /**
  107358. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107359. * i.e. when loading files, where the server/service expects an Authorization header
  107360. */
  107361. WebRequest.CustomRequestHeaders = {};
  107362. /**
  107363. * Add callback functions in this array to update all the requests before they get sent to the network
  107364. */
  107365. WebRequest.CustomRequestModifiers = new Array();
  107366. return WebRequest;
  107367. }());
  107368. /***/ }),
  107369. /***/ "./Misc/workerPool.ts":
  107370. /*!****************************!*\
  107371. !*** ./Misc/workerPool.ts ***!
  107372. \****************************/
  107373. /*! exports provided: WorkerPool */
  107374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107375. "use strict";
  107376. __webpack_require__.r(__webpack_exports__);
  107377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  107378. /**
  107379. * Helper class to push actions to a pool of workers.
  107380. */
  107381. var WorkerPool = /** @class */ (function () {
  107382. /**
  107383. * Constructor
  107384. * @param workers Array of workers to use for actions
  107385. */
  107386. function WorkerPool(workers) {
  107387. this._pendingActions = new Array();
  107388. this._workerInfos = workers.map(function (worker) { return ({
  107389. worker: worker,
  107390. active: false
  107391. }); });
  107392. }
  107393. /**
  107394. * Terminates all workers and clears any pending actions.
  107395. */
  107396. WorkerPool.prototype.dispose = function () {
  107397. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  107398. var workerInfo = _a[_i];
  107399. workerInfo.worker.terminate();
  107400. }
  107401. delete this._workerInfos;
  107402. delete this._pendingActions;
  107403. };
  107404. /**
  107405. * Pushes an action to the worker pool. If all the workers are active, the action will be
  107406. * pended until a worker has completed its action.
  107407. * @param action The action to perform. Call onComplete when the action is complete.
  107408. */
  107409. WorkerPool.prototype.push = function (action) {
  107410. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  107411. var workerInfo = _a[_i];
  107412. if (!workerInfo.active) {
  107413. this._execute(workerInfo, action);
  107414. return;
  107415. }
  107416. }
  107417. this._pendingActions.push(action);
  107418. };
  107419. WorkerPool.prototype._execute = function (workerInfo, action) {
  107420. var _this = this;
  107421. workerInfo.active = true;
  107422. action(workerInfo.worker, function () {
  107423. workerInfo.active = false;
  107424. var nextAction = _this._pendingActions.shift();
  107425. if (nextAction) {
  107426. _this._execute(workerInfo, nextAction);
  107427. }
  107428. });
  107429. };
  107430. return WorkerPool;
  107431. }());
  107432. /***/ }),
  107433. /***/ "./Morph/index.ts":
  107434. /*!************************!*\
  107435. !*** ./Morph/index.ts ***!
  107436. \************************/
  107437. /*! exports provided: MorphTarget, MorphTargetManager */
  107438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107439. "use strict";
  107440. __webpack_require__.r(__webpack_exports__);
  107441. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  107442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  107443. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  107444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  107445. /***/ }),
  107446. /***/ "./Morph/morphTarget.ts":
  107447. /*!******************************!*\
  107448. !*** ./Morph/morphTarget.ts ***!
  107449. \******************************/
  107450. /*! exports provided: MorphTarget */
  107451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107452. "use strict";
  107453. __webpack_require__.r(__webpack_exports__);
  107454. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  107455. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  107456. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  107457. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107458. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  107459. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  107460. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  107461. /**
  107462. * Defines a target to use with MorphTargetManager
  107463. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107464. */
  107465. var MorphTarget = /** @class */ (function () {
  107466. /**
  107467. * Creates a new MorphTarget
  107468. * @param name defines the name of the target
  107469. * @param influence defines the influence to use
  107470. * @param scene defines the scene the morphtarget belongs to
  107471. */
  107472. function MorphTarget(
  107473. /** defines the name of the target */
  107474. name, influence, scene) {
  107475. if (influence === void 0) { influence = 0; }
  107476. if (scene === void 0) { scene = null; }
  107477. this.name = name;
  107478. /**
  107479. * Gets or sets the list of animations
  107480. */
  107481. this.animations = new Array();
  107482. this._positions = null;
  107483. this._normals = null;
  107484. this._tangents = null;
  107485. /**
  107486. * Observable raised when the influence changes
  107487. */
  107488. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  107489. /** @hidden */
  107490. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  107491. this._animationPropertiesOverride = null;
  107492. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  107493. this.influence = influence;
  107494. }
  107495. Object.defineProperty(MorphTarget.prototype, "influence", {
  107496. /**
  107497. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  107498. */
  107499. get: function () {
  107500. return this._influence;
  107501. },
  107502. set: function (influence) {
  107503. if (this._influence === influence) {
  107504. return;
  107505. }
  107506. var previous = this._influence;
  107507. this._influence = influence;
  107508. if (this.onInfluenceChanged.hasObservers) {
  107509. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  107510. }
  107511. },
  107512. enumerable: true,
  107513. configurable: true
  107514. });
  107515. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  107516. /**
  107517. * Gets or sets the animation properties override
  107518. */
  107519. get: function () {
  107520. if (!this._animationPropertiesOverride && this._scene) {
  107521. return this._scene.animationPropertiesOverride;
  107522. }
  107523. return this._animationPropertiesOverride;
  107524. },
  107525. set: function (value) {
  107526. this._animationPropertiesOverride = value;
  107527. },
  107528. enumerable: true,
  107529. configurable: true
  107530. });
  107531. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  107532. /**
  107533. * Gets a boolean defining if the target contains position data
  107534. */
  107535. get: function () {
  107536. return !!this._positions;
  107537. },
  107538. enumerable: true,
  107539. configurable: true
  107540. });
  107541. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  107542. /**
  107543. * Gets a boolean defining if the target contains normal data
  107544. */
  107545. get: function () {
  107546. return !!this._normals;
  107547. },
  107548. enumerable: true,
  107549. configurable: true
  107550. });
  107551. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  107552. /**
  107553. * Gets a boolean defining if the target contains tangent data
  107554. */
  107555. get: function () {
  107556. return !!this._tangents;
  107557. },
  107558. enumerable: true,
  107559. configurable: true
  107560. });
  107561. /**
  107562. * Affects position data to this target
  107563. * @param data defines the position data to use
  107564. */
  107565. MorphTarget.prototype.setPositions = function (data) {
  107566. var hadPositions = this.hasPositions;
  107567. this._positions = data;
  107568. if (hadPositions !== this.hasPositions) {
  107569. this._onDataLayoutChanged.notifyObservers(undefined);
  107570. }
  107571. };
  107572. /**
  107573. * Gets the position data stored in this target
  107574. * @returns a FloatArray containing the position data (or null if not present)
  107575. */
  107576. MorphTarget.prototype.getPositions = function () {
  107577. return this._positions;
  107578. };
  107579. /**
  107580. * Affects normal data to this target
  107581. * @param data defines the normal data to use
  107582. */
  107583. MorphTarget.prototype.setNormals = function (data) {
  107584. var hadNormals = this.hasNormals;
  107585. this._normals = data;
  107586. if (hadNormals !== this.hasNormals) {
  107587. this._onDataLayoutChanged.notifyObservers(undefined);
  107588. }
  107589. };
  107590. /**
  107591. * Gets the normal data stored in this target
  107592. * @returns a FloatArray containing the normal data (or null if not present)
  107593. */
  107594. MorphTarget.prototype.getNormals = function () {
  107595. return this._normals;
  107596. };
  107597. /**
  107598. * Affects tangent data to this target
  107599. * @param data defines the tangent data to use
  107600. */
  107601. MorphTarget.prototype.setTangents = function (data) {
  107602. var hadTangents = this.hasTangents;
  107603. this._tangents = data;
  107604. if (hadTangents !== this.hasTangents) {
  107605. this._onDataLayoutChanged.notifyObservers(undefined);
  107606. }
  107607. };
  107608. /**
  107609. * Gets the tangent data stored in this target
  107610. * @returns a FloatArray containing the tangent data (or null if not present)
  107611. */
  107612. MorphTarget.prototype.getTangents = function () {
  107613. return this._tangents;
  107614. };
  107615. /**
  107616. * Serializes the current target into a Serialization object
  107617. * @returns the serialized object
  107618. */
  107619. MorphTarget.prototype.serialize = function () {
  107620. var serializationObject = {};
  107621. serializationObject.name = this.name;
  107622. serializationObject.influence = this.influence;
  107623. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  107624. if (this.id != null) {
  107625. serializationObject.id = this.id;
  107626. }
  107627. if (this.hasNormals) {
  107628. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  107629. }
  107630. if (this.hasTangents) {
  107631. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  107632. }
  107633. // Animations
  107634. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  107635. return serializationObject;
  107636. };
  107637. /**
  107638. * Returns the string "MorphTarget"
  107639. * @returns "MorphTarget"
  107640. */
  107641. MorphTarget.prototype.getClassName = function () {
  107642. return "MorphTarget";
  107643. };
  107644. // Statics
  107645. /**
  107646. * Creates a new target from serialized data
  107647. * @param serializationObject defines the serialized data to use
  107648. * @returns a new MorphTarget
  107649. */
  107650. MorphTarget.Parse = function (serializationObject) {
  107651. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  107652. result.setPositions(serializationObject.positions);
  107653. if (serializationObject.id != null) {
  107654. result.id = serializationObject.id;
  107655. }
  107656. if (serializationObject.normals) {
  107657. result.setNormals(serializationObject.normals);
  107658. }
  107659. if (serializationObject.tangents) {
  107660. result.setTangents(serializationObject.tangents);
  107661. }
  107662. // Animations
  107663. if (serializationObject.animations) {
  107664. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  107665. var parsedAnimation = serializationObject.animations[animationIndex];
  107666. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  107667. if (internalClass) {
  107668. result.animations.push(internalClass.Parse(parsedAnimation));
  107669. }
  107670. }
  107671. }
  107672. return result;
  107673. };
  107674. /**
  107675. * Creates a MorphTarget from mesh data
  107676. * @param mesh defines the source mesh
  107677. * @param name defines the name to use for the new target
  107678. * @param influence defines the influence to attach to the target
  107679. * @returns a new MorphTarget
  107680. */
  107681. MorphTarget.FromMesh = function (mesh, name, influence) {
  107682. if (!name) {
  107683. name = mesh.name;
  107684. }
  107685. var result = new MorphTarget(name, influence, mesh.getScene());
  107686. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  107687. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  107688. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  107689. }
  107690. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  107691. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  107692. }
  107693. return result;
  107694. };
  107695. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  107696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  107697. ], MorphTarget.prototype, "id", void 0);
  107698. return MorphTarget;
  107699. }());
  107700. /***/ }),
  107701. /***/ "./Morph/morphTargetManager.ts":
  107702. /*!*************************************!*\
  107703. !*** ./Morph/morphTargetManager.ts ***!
  107704. \*************************************/
  107705. /*! exports provided: MorphTargetManager */
  107706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107707. "use strict";
  107708. __webpack_require__.r(__webpack_exports__);
  107709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  107710. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  107711. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  107712. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107713. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  107714. /**
  107715. * This class is used to deform meshes using morphing between different targets
  107716. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107717. */
  107718. var MorphTargetManager = /** @class */ (function () {
  107719. /**
  107720. * Creates a new MorphTargetManager
  107721. * @param scene defines the current scene
  107722. */
  107723. function MorphTargetManager(scene) {
  107724. if (scene === void 0) { scene = null; }
  107725. this._targets = new Array();
  107726. this._targetInfluenceChangedObservers = new Array();
  107727. this._targetDataLayoutChangedObservers = new Array();
  107728. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  107729. this._supportsNormals = false;
  107730. this._supportsTangents = false;
  107731. this._vertexCount = 0;
  107732. this._uniqueId = 0;
  107733. this._tempInfluences = new Array();
  107734. if (!scene) {
  107735. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  107736. }
  107737. this._scene = scene;
  107738. if (this._scene) {
  107739. this._scene.morphTargetManagers.push(this);
  107740. this._uniqueId = this._scene.getUniqueId();
  107741. }
  107742. }
  107743. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  107744. /**
  107745. * Gets the unique ID of this manager
  107746. */
  107747. get: function () {
  107748. return this._uniqueId;
  107749. },
  107750. enumerable: true,
  107751. configurable: true
  107752. });
  107753. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  107754. /**
  107755. * Gets the number of vertices handled by this manager
  107756. */
  107757. get: function () {
  107758. return this._vertexCount;
  107759. },
  107760. enumerable: true,
  107761. configurable: true
  107762. });
  107763. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  107764. /**
  107765. * Gets a boolean indicating if this manager supports morphing of normals
  107766. */
  107767. get: function () {
  107768. return this._supportsNormals;
  107769. },
  107770. enumerable: true,
  107771. configurable: true
  107772. });
  107773. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  107774. /**
  107775. * Gets a boolean indicating if this manager supports morphing of tangents
  107776. */
  107777. get: function () {
  107778. return this._supportsTangents;
  107779. },
  107780. enumerable: true,
  107781. configurable: true
  107782. });
  107783. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  107784. /**
  107785. * Gets the number of targets stored in this manager
  107786. */
  107787. get: function () {
  107788. return this._targets.length;
  107789. },
  107790. enumerable: true,
  107791. configurable: true
  107792. });
  107793. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  107794. /**
  107795. * Gets the number of influencers (ie. the number of targets with influences > 0)
  107796. */
  107797. get: function () {
  107798. return this._activeTargets.length;
  107799. },
  107800. enumerable: true,
  107801. configurable: true
  107802. });
  107803. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  107804. /**
  107805. * Gets the list of influences (one per target)
  107806. */
  107807. get: function () {
  107808. return this._influences;
  107809. },
  107810. enumerable: true,
  107811. configurable: true
  107812. });
  107813. /**
  107814. * Gets the active target at specified index. An active target is a target with an influence > 0
  107815. * @param index defines the index to check
  107816. * @returns the requested target
  107817. */
  107818. MorphTargetManager.prototype.getActiveTarget = function (index) {
  107819. return this._activeTargets.data[index];
  107820. };
  107821. /**
  107822. * Gets the target at specified index
  107823. * @param index defines the index to check
  107824. * @returns the requested target
  107825. */
  107826. MorphTargetManager.prototype.getTarget = function (index) {
  107827. return this._targets[index];
  107828. };
  107829. /**
  107830. * Add a new target to this manager
  107831. * @param target defines the target to add
  107832. */
  107833. MorphTargetManager.prototype.addTarget = function (target) {
  107834. var _this = this;
  107835. this._targets.push(target);
  107836. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  107837. _this._syncActiveTargets(needUpdate);
  107838. }));
  107839. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  107840. _this._syncActiveTargets(true);
  107841. }));
  107842. this._syncActiveTargets(true);
  107843. };
  107844. /**
  107845. * Removes a target from the manager
  107846. * @param target defines the target to remove
  107847. */
  107848. MorphTargetManager.prototype.removeTarget = function (target) {
  107849. var index = this._targets.indexOf(target);
  107850. if (index >= 0) {
  107851. this._targets.splice(index, 1);
  107852. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  107853. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  107854. this._syncActiveTargets(true);
  107855. }
  107856. };
  107857. /**
  107858. * Serializes the current manager into a Serialization object
  107859. * @returns the serialized object
  107860. */
  107861. MorphTargetManager.prototype.serialize = function () {
  107862. var serializationObject = {};
  107863. serializationObject.id = this.uniqueId;
  107864. serializationObject.targets = [];
  107865. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  107866. var target = _a[_i];
  107867. serializationObject.targets.push(target.serialize());
  107868. }
  107869. return serializationObject;
  107870. };
  107871. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  107872. var influenceCount = 0;
  107873. this._activeTargets.reset();
  107874. this._supportsNormals = true;
  107875. this._supportsTangents = true;
  107876. this._vertexCount = 0;
  107877. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  107878. var target = _a[_i];
  107879. if (target.influence === 0) {
  107880. continue;
  107881. }
  107882. this._activeTargets.push(target);
  107883. this._tempInfluences[influenceCount++] = target.influence;
  107884. this._supportsNormals = this._supportsNormals && target.hasNormals;
  107885. this._supportsTangents = this._supportsTangents && target.hasTangents;
  107886. var positions = target.getPositions();
  107887. if (positions) {
  107888. var vertexCount = positions.length / 3;
  107889. if (this._vertexCount === 0) {
  107890. this._vertexCount = vertexCount;
  107891. }
  107892. else if (this._vertexCount !== vertexCount) {
  107893. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  107894. return;
  107895. }
  107896. }
  107897. }
  107898. if (!this._influences || this._influences.length !== influenceCount) {
  107899. this._influences = new Float32Array(influenceCount);
  107900. }
  107901. for (var index = 0; index < influenceCount; index++) {
  107902. this._influences[index] = this._tempInfluences[index];
  107903. }
  107904. if (needUpdate) {
  107905. this.synchronize();
  107906. }
  107907. };
  107908. /**
  107909. * Syncrhonize the targets with all the meshes using this morph target manager
  107910. */
  107911. MorphTargetManager.prototype.synchronize = function () {
  107912. if (!this._scene) {
  107913. return;
  107914. }
  107915. // Flag meshes as dirty to resync with the active targets
  107916. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  107917. var mesh = _a[_i];
  107918. if (mesh.morphTargetManager === this) {
  107919. mesh._syncGeometryWithMorphTargetManager();
  107920. }
  107921. }
  107922. };
  107923. // Statics
  107924. /**
  107925. * Creates a new MorphTargetManager from serialized data
  107926. * @param serializationObject defines the serialized data
  107927. * @param scene defines the hosting scene
  107928. * @returns the new MorphTargetManager
  107929. */
  107930. MorphTargetManager.Parse = function (serializationObject, scene) {
  107931. var result = new MorphTargetManager(scene);
  107932. result._uniqueId = serializationObject.id;
  107933. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  107934. var targetData = _a[_i];
  107935. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  107936. }
  107937. return result;
  107938. };
  107939. return MorphTargetManager;
  107940. }());
  107941. /***/ }),
  107942. /***/ "./Offline/database.ts":
  107943. /*!*****************************!*\
  107944. !*** ./Offline/database.ts ***!
  107945. \*****************************/
  107946. /*! exports provided: Database */
  107947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107948. "use strict";
  107949. __webpack_require__.r(__webpack_exports__);
  107950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  107951. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  107952. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  107953. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  107954. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  107955. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/webRequest */ "./Misc/webRequest.ts");
  107956. // Sets the default offline provider to Babylon.js
  107957. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  107958. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  107959. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  107960. };
  107961. /**
  107962. * Class used to enable access to IndexedDB
  107963. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  107964. */
  107965. var Database = /** @class */ (function () {
  107966. /**
  107967. * Creates a new Database
  107968. * @param urlToScene defines the url to load the scene
  107969. * @param callbackManifestChecked defines the callback to use when manifest is checked
  107970. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  107971. */
  107972. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  107973. var _this = this;
  107974. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  107975. // Handling various flavors of prefixed version of IndexedDB
  107976. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  107977. this._callbackManifestChecked = callbackManifestChecked;
  107978. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  107979. this._db = null;
  107980. this._enableSceneOffline = false;
  107981. this._enableTexturesOffline = false;
  107982. this._manifestVersionFound = 0;
  107983. this._mustUpdateRessources = false;
  107984. this._hasReachedQuota = false;
  107985. if (!Database.IDBStorageEnabled) {
  107986. this._callbackManifestChecked(true);
  107987. }
  107988. else {
  107989. if (disableManifestCheck) {
  107990. this._enableSceneOffline = true;
  107991. this._enableTexturesOffline = true;
  107992. this._manifestVersionFound = 1;
  107993. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  107994. _this._callbackManifestChecked(true);
  107995. });
  107996. }
  107997. else {
  107998. this._checkManifestFile();
  107999. }
  108000. }
  108001. }
  108002. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  108003. /**
  108004. * Gets a boolean indicating if scene must be saved in the database
  108005. */
  108006. get: function () {
  108007. return this._enableSceneOffline;
  108008. },
  108009. enumerable: true,
  108010. configurable: true
  108011. });
  108012. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  108013. /**
  108014. * Gets a boolean indicating if textures must be saved in the database
  108015. */
  108016. get: function () {
  108017. return this._enableTexturesOffline;
  108018. },
  108019. enumerable: true,
  108020. configurable: true
  108021. });
  108022. Database.prototype._checkManifestFile = function () {
  108023. var _this = this;
  108024. var noManifestFile = function () {
  108025. _this._enableSceneOffline = false;
  108026. _this._enableTexturesOffline = false;
  108027. _this._callbackManifestChecked(false);
  108028. };
  108029. var timeStampUsed = false;
  108030. var manifestURL = this._currentSceneUrl + ".manifest";
  108031. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  108032. if (navigator.onLine) {
  108033. // Adding a timestamp to by-pass browsers' cache
  108034. timeStampUsed = true;
  108035. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  108036. }
  108037. xhr.open("GET", manifestURL);
  108038. xhr.addEventListener("load", function () {
  108039. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  108040. try {
  108041. var manifestFile = JSON.parse(xhr.response);
  108042. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  108043. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  108044. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  108045. _this._manifestVersionFound = manifestFile.version;
  108046. }
  108047. if (_this._callbackManifestChecked) {
  108048. _this._callbackManifestChecked(true);
  108049. }
  108050. }
  108051. catch (ex) {
  108052. noManifestFile();
  108053. }
  108054. }
  108055. else {
  108056. noManifestFile();
  108057. }
  108058. }, false);
  108059. xhr.addEventListener("error", function () {
  108060. if (timeStampUsed) {
  108061. timeStampUsed = false;
  108062. // Let's retry without the timeStamp
  108063. // It could fail when coupled with HTML5 Offline API
  108064. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  108065. xhr.open("GET", retryManifestURL);
  108066. xhr.send();
  108067. }
  108068. else {
  108069. noManifestFile();
  108070. }
  108071. }, false);
  108072. try {
  108073. xhr.send();
  108074. }
  108075. catch (ex) {
  108076. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  108077. this._callbackManifestChecked(false);
  108078. }
  108079. };
  108080. /**
  108081. * Open the database and make it available
  108082. * @param successCallback defines the callback to call on success
  108083. * @param errorCallback defines the callback to call on error
  108084. */
  108085. Database.prototype.open = function (successCallback, errorCallback) {
  108086. var _this = this;
  108087. var handleError = function () {
  108088. _this._isSupported = false;
  108089. if (errorCallback) {
  108090. errorCallback();
  108091. }
  108092. };
  108093. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  108094. // Your browser doesn't support IndexedDB
  108095. this._isSupported = false;
  108096. if (errorCallback) {
  108097. errorCallback();
  108098. }
  108099. }
  108100. else {
  108101. // If the DB hasn't been opened or created yet
  108102. if (!this._db) {
  108103. this._hasReachedQuota = false;
  108104. this._isSupported = true;
  108105. var request = this._idbFactory.open("babylonjs", 1);
  108106. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  108107. request.onerror = function () {
  108108. handleError();
  108109. };
  108110. // executes when a version change transaction cannot complete due to other active transactions
  108111. request.onblocked = function () {
  108112. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  108113. handleError();
  108114. };
  108115. // DB has been opened successfully
  108116. request.onsuccess = function () {
  108117. _this._db = request.result;
  108118. successCallback();
  108119. };
  108120. // Initialization of the DB. Creating Scenes & Textures stores
  108121. request.onupgradeneeded = function (event) {
  108122. _this._db = (event.target).result;
  108123. if (_this._db) {
  108124. try {
  108125. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  108126. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  108127. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  108128. }
  108129. catch (ex) {
  108130. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  108131. handleError();
  108132. }
  108133. }
  108134. };
  108135. }
  108136. // DB has already been created and opened
  108137. else {
  108138. if (successCallback) {
  108139. successCallback();
  108140. }
  108141. }
  108142. }
  108143. };
  108144. /**
  108145. * Loads an image from the database
  108146. * @param url defines the url to load from
  108147. * @param image defines the target DOM image
  108148. */
  108149. Database.prototype.loadImage = function (url, image) {
  108150. var _this = this;
  108151. var completeURL = Database._ReturnFullUrlLocation(url);
  108152. var saveAndLoadImage = function () {
  108153. if (!_this._hasReachedQuota && _this._db !== null) {
  108154. // the texture is not yet in the DB, let's try to save it
  108155. _this._saveImageIntoDBAsync(completeURL, image);
  108156. }
  108157. // If the texture is not in the DB and we've reached the DB quota limit
  108158. // let's load it directly from the web
  108159. else {
  108160. image.src = url;
  108161. }
  108162. };
  108163. if (!this._mustUpdateRessources) {
  108164. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  108165. }
  108166. // First time we're download the images or update requested in the manifest file by a version change
  108167. else {
  108168. saveAndLoadImage();
  108169. }
  108170. };
  108171. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  108172. if (this._isSupported && this._db !== null) {
  108173. var texture;
  108174. var transaction = this._db.transaction(["textures"]);
  108175. transaction.onabort = function () {
  108176. image.src = url;
  108177. };
  108178. transaction.oncomplete = function () {
  108179. var blobTextureURL;
  108180. if (texture) {
  108181. var URL = window.URL || window.webkitURL;
  108182. blobTextureURL = URL.createObjectURL(texture.data);
  108183. image.onerror = function () {
  108184. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  108185. image.src = url;
  108186. };
  108187. image.src = blobTextureURL;
  108188. }
  108189. else {
  108190. notInDBCallback();
  108191. }
  108192. };
  108193. var getRequest = transaction.objectStore("textures").get(url);
  108194. getRequest.onsuccess = function (event) {
  108195. texture = (event.target).result;
  108196. };
  108197. getRequest.onerror = function () {
  108198. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  108199. image.src = url;
  108200. };
  108201. }
  108202. else {
  108203. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  108204. image.src = url;
  108205. }
  108206. };
  108207. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  108208. var _this = this;
  108209. if (this._isSupported) {
  108210. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  108211. var generateBlobUrl = function () {
  108212. var blobTextureURL;
  108213. if (blob) {
  108214. var URL = window.URL || window.webkitURL;
  108215. try {
  108216. blobTextureURL = URL.createObjectURL(blob);
  108217. }
  108218. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  108219. catch (ex) {
  108220. blobTextureURL = URL.createObjectURL(blob);
  108221. }
  108222. }
  108223. if (blobTextureURL) {
  108224. image.src = blobTextureURL;
  108225. }
  108226. };
  108227. if (Database.IsUASupportingBlobStorage) { // Create XHR
  108228. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"](), blob;
  108229. xhr.open("GET", url);
  108230. xhr.responseType = "blob";
  108231. xhr.addEventListener("load", function () {
  108232. if (xhr.status === 200 && _this._db) {
  108233. // Blob as response (XHR2)
  108234. blob = xhr.response;
  108235. var transaction = _this._db.transaction(["textures"], "readwrite");
  108236. // the transaction could abort because of a QuotaExceededError error
  108237. transaction.onabort = function (event) {
  108238. try {
  108239. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  108240. var srcElement = (event.srcElement || event.target);
  108241. var error = srcElement.error;
  108242. if (error && error.name === "QuotaExceededError") {
  108243. _this._hasReachedQuota = true;
  108244. }
  108245. }
  108246. catch (ex) { }
  108247. generateBlobUrl();
  108248. };
  108249. transaction.oncomplete = function () {
  108250. generateBlobUrl();
  108251. };
  108252. var newTexture = { textureUrl: url, data: blob };
  108253. try {
  108254. // Put the blob into the dabase
  108255. var addRequest = transaction.objectStore("textures").put(newTexture);
  108256. addRequest.onsuccess = function () {
  108257. };
  108258. addRequest.onerror = function () {
  108259. generateBlobUrl();
  108260. };
  108261. }
  108262. catch (ex) {
  108263. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  108264. if (ex.code === 25) {
  108265. Database.IsUASupportingBlobStorage = false;
  108266. _this._enableTexturesOffline = false;
  108267. }
  108268. image.src = url;
  108269. }
  108270. }
  108271. else {
  108272. image.src = url;
  108273. }
  108274. }, false);
  108275. xhr.addEventListener("error", function () {
  108276. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  108277. image.src = url;
  108278. }, false);
  108279. xhr.send();
  108280. }
  108281. else {
  108282. image.src = url;
  108283. }
  108284. }
  108285. else {
  108286. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  108287. image.src = url;
  108288. }
  108289. };
  108290. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  108291. var _this = this;
  108292. var updateVersion = function () {
  108293. // the version is not yet in the DB or we need to update it
  108294. _this._saveVersionIntoDBAsync(url, versionLoaded);
  108295. };
  108296. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  108297. };
  108298. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  108299. var _this = this;
  108300. if (this._isSupported && this._db) {
  108301. var version;
  108302. try {
  108303. var transaction = this._db.transaction(["versions"]);
  108304. transaction.oncomplete = function () {
  108305. if (version) {
  108306. // If the version in the JSON file is different from the version in DB
  108307. if (_this._manifestVersionFound !== version.data) {
  108308. _this._mustUpdateRessources = true;
  108309. updateInDBCallback();
  108310. }
  108311. else {
  108312. callback(version.data);
  108313. }
  108314. }
  108315. // version was not found in DB
  108316. else {
  108317. _this._mustUpdateRessources = true;
  108318. updateInDBCallback();
  108319. }
  108320. };
  108321. transaction.onabort = function () {
  108322. callback(-1);
  108323. };
  108324. var getRequest = transaction.objectStore("versions").get(url);
  108325. getRequest.onsuccess = function (event) {
  108326. version = (event.target).result;
  108327. };
  108328. getRequest.onerror = function () {
  108329. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  108330. callback(-1);
  108331. };
  108332. }
  108333. catch (ex) {
  108334. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  108335. callback(-1);
  108336. }
  108337. }
  108338. else {
  108339. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  108340. callback(-1);
  108341. }
  108342. };
  108343. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  108344. var _this = this;
  108345. if (this._isSupported && !this._hasReachedQuota && this._db) {
  108346. try {
  108347. // Open a transaction to the database
  108348. var transaction = this._db.transaction(["versions"], "readwrite");
  108349. // the transaction could abort because of a QuotaExceededError error
  108350. transaction.onabort = function (event) {
  108351. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  108352. var error = event.srcElement['error'];
  108353. if (error && error.name === "QuotaExceededError") {
  108354. _this._hasReachedQuota = true;
  108355. }
  108356. }
  108357. catch (ex) { }
  108358. callback(-1);
  108359. };
  108360. transaction.oncomplete = function () {
  108361. callback(_this._manifestVersionFound);
  108362. };
  108363. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  108364. // Put the scene into the database
  108365. var addRequest = transaction.objectStore("versions").put(newVersion);
  108366. addRequest.onsuccess = function () {
  108367. };
  108368. addRequest.onerror = function () {
  108369. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  108370. };
  108371. }
  108372. catch (ex) {
  108373. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  108374. callback(-1);
  108375. }
  108376. }
  108377. else {
  108378. callback(-1);
  108379. }
  108380. };
  108381. /**
  108382. * Loads a file from database
  108383. * @param url defines the URL to load from
  108384. * @param sceneLoaded defines a callback to call on success
  108385. * @param progressCallBack defines a callback to call when progress changed
  108386. * @param errorCallback defines a callback to call on error
  108387. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  108388. */
  108389. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  108390. var _this = this;
  108391. var completeUrl = Database._ReturnFullUrlLocation(url);
  108392. var saveAndLoadFile = function () {
  108393. // the scene is not yet in the DB, let's try to save it
  108394. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  108395. };
  108396. this._checkVersionFromDB(completeUrl, function (version) {
  108397. if (version !== -1) {
  108398. if (!_this._mustUpdateRessources) {
  108399. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  108400. }
  108401. else {
  108402. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  108403. }
  108404. }
  108405. else {
  108406. if (errorCallback) {
  108407. errorCallback();
  108408. }
  108409. }
  108410. });
  108411. };
  108412. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  108413. if (this._isSupported && this._db) {
  108414. var targetStore;
  108415. if (url.indexOf(".babylon") !== -1) {
  108416. targetStore = "scenes";
  108417. }
  108418. else {
  108419. targetStore = "textures";
  108420. }
  108421. var file;
  108422. var transaction = this._db.transaction([targetStore]);
  108423. transaction.oncomplete = function () {
  108424. if (file) {
  108425. callback(file.data);
  108426. }
  108427. // file was not found in DB
  108428. else {
  108429. notInDBCallback();
  108430. }
  108431. };
  108432. transaction.onabort = function () {
  108433. notInDBCallback();
  108434. };
  108435. var getRequest = transaction.objectStore(targetStore).get(url);
  108436. getRequest.onsuccess = function (event) {
  108437. file = (event.target).result;
  108438. };
  108439. getRequest.onerror = function () {
  108440. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  108441. notInDBCallback();
  108442. };
  108443. }
  108444. else {
  108445. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  108446. callback();
  108447. }
  108448. };
  108449. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  108450. var _this = this;
  108451. if (this._isSupported) {
  108452. var targetStore;
  108453. if (url.indexOf(".babylon") !== -1) {
  108454. targetStore = "scenes";
  108455. }
  108456. else {
  108457. targetStore = "textures";
  108458. }
  108459. // Create XHR
  108460. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  108461. var fileData;
  108462. xhr.open("GET", url + "?" + Date.now());
  108463. if (useArrayBuffer) {
  108464. xhr.responseType = "arraybuffer";
  108465. }
  108466. if (progressCallback) {
  108467. xhr.onprogress = progressCallback;
  108468. }
  108469. xhr.addEventListener("load", function () {
  108470. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  108471. // Blob as response (XHR2)
  108472. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  108473. if (!_this._hasReachedQuota && _this._db) {
  108474. // Open a transaction to the database
  108475. var transaction = _this._db.transaction([targetStore], "readwrite");
  108476. // the transaction could abort because of a QuotaExceededError error
  108477. transaction.onabort = function (event) {
  108478. try {
  108479. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  108480. var error = event.srcElement['error'];
  108481. if (error && error.name === "QuotaExceededError") {
  108482. _this._hasReachedQuota = true;
  108483. }
  108484. }
  108485. catch (ex) { }
  108486. callback(fileData);
  108487. };
  108488. transaction.oncomplete = function () {
  108489. callback(fileData);
  108490. };
  108491. var newFile;
  108492. if (targetStore === "scenes") {
  108493. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  108494. }
  108495. else {
  108496. newFile = { textureUrl: url, data: fileData };
  108497. }
  108498. try {
  108499. // Put the scene into the database
  108500. var addRequest = transaction.objectStore(targetStore).put(newFile);
  108501. addRequest.onsuccess = function () {
  108502. };
  108503. addRequest.onerror = function () {
  108504. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  108505. };
  108506. }
  108507. catch (ex) {
  108508. callback(fileData);
  108509. }
  108510. }
  108511. else {
  108512. callback(fileData);
  108513. }
  108514. }
  108515. else {
  108516. if (xhr.status >= 400 && errorCallback) {
  108517. errorCallback(xhr);
  108518. }
  108519. else {
  108520. callback();
  108521. }
  108522. }
  108523. }, false);
  108524. xhr.addEventListener("error", function () {
  108525. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  108526. callback();
  108527. }, false);
  108528. xhr.send();
  108529. }
  108530. else {
  108531. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  108532. callback();
  108533. }
  108534. };
  108535. /**
  108536. * Validates if xhr data is correct
  108537. * @param xhr defines the request to validate
  108538. * @param dataType defines the expected data type
  108539. * @returns true if data is correct
  108540. */
  108541. Database._ValidateXHRData = function (xhr, dataType) {
  108542. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  108543. if (dataType === void 0) { dataType = 7; }
  108544. try {
  108545. if (dataType & 1) {
  108546. if (xhr.responseText && xhr.responseText.length > 0) {
  108547. return true;
  108548. }
  108549. else if (dataType === 1) {
  108550. return false;
  108551. }
  108552. }
  108553. if (dataType & 2) {
  108554. // Check header width and height since there is no "TGA" magic number
  108555. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  108556. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  108557. return true;
  108558. }
  108559. else if (dataType === 2) {
  108560. return false;
  108561. }
  108562. }
  108563. if (dataType & 4) {
  108564. // Check for the "DDS" magic number
  108565. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  108566. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  108567. return true;
  108568. }
  108569. else {
  108570. return false;
  108571. }
  108572. }
  108573. }
  108574. catch (e) {
  108575. // Global protection
  108576. }
  108577. return false;
  108578. };
  108579. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  108580. Database.IsUASupportingBlobStorage = true;
  108581. /**
  108582. * Gets a boolean indicating if Database storate is enabled (off by default)
  108583. */
  108584. Database.IDBStorageEnabled = false;
  108585. Database._ParseURL = function (url) {
  108586. var a = document.createElement('a');
  108587. a.href = url;
  108588. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  108589. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  108590. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  108591. return absLocation;
  108592. };
  108593. Database._ReturnFullUrlLocation = function (url) {
  108594. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  108595. return (Database._ParseURL(window.location.href) + url);
  108596. }
  108597. else {
  108598. return url;
  108599. }
  108600. };
  108601. return Database;
  108602. }());
  108603. /***/ }),
  108604. /***/ "./Offline/index.ts":
  108605. /*!**************************!*\
  108606. !*** ./Offline/index.ts ***!
  108607. \**************************/
  108608. /*! exports provided: Database */
  108609. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108610. "use strict";
  108611. __webpack_require__.r(__webpack_exports__);
  108612. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  108613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  108614. /***/ }),
  108615. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  108616. /*!******************************************************!*\
  108617. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  108618. \******************************************************/
  108619. /*! exports provided: BoxParticleEmitter */
  108620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108621. "use strict";
  108622. __webpack_require__.r(__webpack_exports__);
  108623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  108624. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  108625. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  108626. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  108627. /**
  108628. * Particle emitter emitting particles from the inside of a box.
  108629. * It emits the particles randomly between 2 given directions.
  108630. */
  108631. var BoxParticleEmitter = /** @class */ (function () {
  108632. /**
  108633. * Creates a new instance BoxParticleEmitter
  108634. */
  108635. function BoxParticleEmitter() {
  108636. /**
  108637. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  108638. */
  108639. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  108640. /**
  108641. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  108642. */
  108643. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  108644. /**
  108645. * 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.
  108646. */
  108647. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  108648. /**
  108649. * 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.
  108650. */
  108651. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  108652. }
  108653. /**
  108654. * Called by the particle System when the direction is computed for the created particle.
  108655. * @param worldMatrix is the world matrix of the particle system
  108656. * @param directionToUpdate is the direction vector to update with the result
  108657. * @param particle is the particle we are computed the direction for
  108658. */
  108659. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  108660. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  108661. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  108662. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  108663. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  108664. };
  108665. /**
  108666. * Called by the particle System when the position is computed for the created particle.
  108667. * @param worldMatrix is the world matrix of the particle system
  108668. * @param positionToUpdate is the position vector to update with the result
  108669. * @param particle is the particle we are computed the position for
  108670. */
  108671. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  108672. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  108673. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  108674. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  108675. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  108676. };
  108677. /**
  108678. * Clones the current emitter and returns a copy of it
  108679. * @returns the new emitter
  108680. */
  108681. BoxParticleEmitter.prototype.clone = function () {
  108682. var newOne = new BoxParticleEmitter();
  108683. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  108684. return newOne;
  108685. };
  108686. /**
  108687. * Called by the GPUParticleSystem to setup the update shader
  108688. * @param effect defines the update shader
  108689. */
  108690. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  108691. effect.setVector3("direction1", this.direction1);
  108692. effect.setVector3("direction2", this.direction2);
  108693. effect.setVector3("minEmitBox", this.minEmitBox);
  108694. effect.setVector3("maxEmitBox", this.maxEmitBox);
  108695. };
  108696. /**
  108697. * Returns a string to use to update the GPU particles update shader
  108698. * @returns a string containng the defines string
  108699. */
  108700. BoxParticleEmitter.prototype.getEffectDefines = function () {
  108701. return "#define BOXEMITTER";
  108702. };
  108703. /**
  108704. * Returns the string "BoxParticleEmitter"
  108705. * @returns a string containing the class name
  108706. */
  108707. BoxParticleEmitter.prototype.getClassName = function () {
  108708. return "BoxParticleEmitter";
  108709. };
  108710. /**
  108711. * Serializes the particle system to a JSON object.
  108712. * @returns the JSON object
  108713. */
  108714. BoxParticleEmitter.prototype.serialize = function () {
  108715. var serializationObject = {};
  108716. serializationObject.type = this.getClassName();
  108717. serializationObject.direction1 = this.direction1.asArray();
  108718. serializationObject.direction2 = this.direction2.asArray();
  108719. serializationObject.minEmitBox = this.minEmitBox.asArray();
  108720. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  108721. return serializationObject;
  108722. };
  108723. /**
  108724. * Parse properties from a JSON object
  108725. * @param serializationObject defines the JSON object
  108726. */
  108727. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  108728. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  108729. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  108730. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  108731. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  108732. };
  108733. return BoxParticleEmitter;
  108734. }());
  108735. /***/ }),
  108736. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  108737. /*!*******************************************************!*\
  108738. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  108739. \*******************************************************/
  108740. /*! exports provided: ConeParticleEmitter */
  108741. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108742. "use strict";
  108743. __webpack_require__.r(__webpack_exports__);
  108744. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  108745. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  108746. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  108747. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  108748. /**
  108749. * Particle emitter emitting particles from the inside of a cone.
  108750. * It emits the particles alongside the cone volume from the base to the particle.
  108751. * The emission direction might be randomized.
  108752. */
  108753. var ConeParticleEmitter = /** @class */ (function () {
  108754. /**
  108755. * Creates a new instance ConeParticleEmitter
  108756. * @param radius the radius of the emission cone (1 by default)
  108757. * @param angle the cone base angle (PI by default)
  108758. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  108759. */
  108760. function ConeParticleEmitter(radius, angle,
  108761. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  108762. directionRandomizer) {
  108763. if (radius === void 0) { radius = 1; }
  108764. if (angle === void 0) { angle = Math.PI; }
  108765. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  108766. this.directionRandomizer = directionRandomizer;
  108767. /**
  108768. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  108769. */
  108770. this.radiusRange = 1;
  108771. /**
  108772. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  108773. */
  108774. this.heightRange = 1;
  108775. /**
  108776. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  108777. */
  108778. this.emitFromSpawnPointOnly = false;
  108779. this.angle = angle;
  108780. this.radius = radius;
  108781. }
  108782. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  108783. /**
  108784. * Gets or sets the radius of the emission cone
  108785. */
  108786. get: function () {
  108787. return this._radius;
  108788. },
  108789. set: function (value) {
  108790. this._radius = value;
  108791. this._buildHeight();
  108792. },
  108793. enumerable: true,
  108794. configurable: true
  108795. });
  108796. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  108797. /**
  108798. * Gets or sets the angle of the emission cone
  108799. */
  108800. get: function () {
  108801. return this._angle;
  108802. },
  108803. set: function (value) {
  108804. this._angle = value;
  108805. this._buildHeight();
  108806. },
  108807. enumerable: true,
  108808. configurable: true
  108809. });
  108810. ConeParticleEmitter.prototype._buildHeight = function () {
  108811. if (this._angle !== 0) {
  108812. this._height = this._radius / Math.tan(this._angle / 2);
  108813. }
  108814. else {
  108815. this._height = 1;
  108816. }
  108817. };
  108818. /**
  108819. * Called by the particle System when the direction is computed for the created particle.
  108820. * @param worldMatrix is the world matrix of the particle system
  108821. * @param directionToUpdate is the direction vector to update with the result
  108822. * @param particle is the particle we are computed the direction for
  108823. */
  108824. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  108825. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  108826. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  108827. }
  108828. else {
  108829. // measure the direction Vector from the emitter to the particle.
  108830. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  108831. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  108832. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  108833. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  108834. direction.x += randX;
  108835. direction.y += randY;
  108836. direction.z += randZ;
  108837. direction.normalize();
  108838. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  108839. }
  108840. };
  108841. /**
  108842. * Called by the particle System when the position is computed for the created particle.
  108843. * @param worldMatrix is the world matrix of the particle system
  108844. * @param positionToUpdate is the position vector to update with the result
  108845. * @param particle is the particle we are computed the position for
  108846. */
  108847. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  108848. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  108849. var h;
  108850. if (!this.emitFromSpawnPointOnly) {
  108851. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  108852. // Better distribution in a cone at normal angles.
  108853. h = 1 - h * h;
  108854. }
  108855. else {
  108856. h = 0.0001;
  108857. }
  108858. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  108859. radius = radius * h;
  108860. var randX = radius * Math.sin(s);
  108861. var randZ = radius * Math.cos(s);
  108862. var randY = h * this._height;
  108863. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  108864. };
  108865. /**
  108866. * Clones the current emitter and returns a copy of it
  108867. * @returns the new emitter
  108868. */
  108869. ConeParticleEmitter.prototype.clone = function () {
  108870. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  108871. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  108872. return newOne;
  108873. };
  108874. /**
  108875. * Called by the GPUParticleSystem to setup the update shader
  108876. * @param effect defines the update shader
  108877. */
  108878. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  108879. effect.setFloat2("radius", this._radius, this.radiusRange);
  108880. effect.setFloat("coneAngle", this._angle);
  108881. effect.setFloat2("height", this._height, this.heightRange);
  108882. effect.setFloat("directionRandomizer", this.directionRandomizer);
  108883. };
  108884. /**
  108885. * Returns a string to use to update the GPU particles update shader
  108886. * @returns a string containng the defines string
  108887. */
  108888. ConeParticleEmitter.prototype.getEffectDefines = function () {
  108889. var defines = "#define CONEEMITTER";
  108890. if (this.emitFromSpawnPointOnly) {
  108891. defines += "\n#define CONEEMITTERSPAWNPOINT";
  108892. }
  108893. return defines;
  108894. };
  108895. /**
  108896. * Returns the string "ConeParticleEmitter"
  108897. * @returns a string containing the class name
  108898. */
  108899. ConeParticleEmitter.prototype.getClassName = function () {
  108900. return "ConeParticleEmitter";
  108901. };
  108902. /**
  108903. * Serializes the particle system to a JSON object.
  108904. * @returns the JSON object
  108905. */
  108906. ConeParticleEmitter.prototype.serialize = function () {
  108907. var serializationObject = {};
  108908. serializationObject.type = this.getClassName();
  108909. serializationObject.radius = this._radius;
  108910. serializationObject.angle = this._angle;
  108911. serializationObject.directionRandomizer = this.directionRandomizer;
  108912. return serializationObject;
  108913. };
  108914. /**
  108915. * Parse properties from a JSON object
  108916. * @param serializationObject defines the JSON object
  108917. */
  108918. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  108919. this.radius = serializationObject.radius;
  108920. this.angle = serializationObject.angle;
  108921. this.directionRandomizer = serializationObject.directionRandomizer;
  108922. };
  108923. return ConeParticleEmitter;
  108924. }());
  108925. /***/ }),
  108926. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  108927. /*!***********************************************************!*\
  108928. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  108929. \***********************************************************/
  108930. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  108931. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108932. "use strict";
  108933. __webpack_require__.r(__webpack_exports__);
  108934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  108935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  108936. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  108937. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  108938. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  108939. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  108940. /**
  108941. * Particle emitter emitting particles from the inside of a cylinder.
  108942. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  108943. */
  108944. var CylinderParticleEmitter = /** @class */ (function () {
  108945. /**
  108946. * Creates a new instance CylinderParticleEmitter
  108947. * @param radius the radius of the emission cylinder (1 by default)
  108948. * @param height the height of the emission cylinder (1 by default)
  108949. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  108950. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  108951. */
  108952. function CylinderParticleEmitter(
  108953. /**
  108954. * The radius of the emission cylinder.
  108955. */
  108956. radius,
  108957. /**
  108958. * The height of the emission cylinder.
  108959. */
  108960. height,
  108961. /**
  108962. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  108963. */
  108964. radiusRange,
  108965. /**
  108966. * How much to randomize the particle direction [0-1].
  108967. */
  108968. directionRandomizer) {
  108969. if (radius === void 0) { radius = 1; }
  108970. if (height === void 0) { height = 1; }
  108971. if (radiusRange === void 0) { radiusRange = 1; }
  108972. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  108973. this.radius = radius;
  108974. this.height = height;
  108975. this.radiusRange = radiusRange;
  108976. this.directionRandomizer = directionRandomizer;
  108977. }
  108978. /**
  108979. * Called by the particle System when the direction is computed for the created particle.
  108980. * @param worldMatrix is the world matrix of the particle system
  108981. * @param directionToUpdate is the direction vector to update with the result
  108982. * @param particle is the particle we are computed the direction for
  108983. */
  108984. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  108985. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  108986. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  108987. var angle = Math.atan2(direction.x, direction.z);
  108988. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  108989. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  108990. direction.x = Math.sin(angle);
  108991. direction.z = Math.cos(angle);
  108992. direction.normalize();
  108993. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  108994. };
  108995. /**
  108996. * Called by the particle System when the position is computed for the created particle.
  108997. * @param worldMatrix is the world matrix of the particle system
  108998. * @param positionToUpdate is the position vector to update with the result
  108999. * @param particle is the particle we are computed the position for
  109000. */
  109001. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  109002. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  109003. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  109004. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  109005. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  109006. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  109007. var xPos = positionRadius * Math.cos(angle);
  109008. var zPos = positionRadius * Math.sin(angle);
  109009. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  109010. };
  109011. /**
  109012. * Clones the current emitter and returns a copy of it
  109013. * @returns the new emitter
  109014. */
  109015. CylinderParticleEmitter.prototype.clone = function () {
  109016. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  109017. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  109018. return newOne;
  109019. };
  109020. /**
  109021. * Called by the GPUParticleSystem to setup the update shader
  109022. * @param effect defines the update shader
  109023. */
  109024. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  109025. effect.setFloat("radius", this.radius);
  109026. effect.setFloat("height", this.height);
  109027. effect.setFloat("radiusRange", this.radiusRange);
  109028. effect.setFloat("directionRandomizer", this.directionRandomizer);
  109029. };
  109030. /**
  109031. * Returns a string to use to update the GPU particles update shader
  109032. * @returns a string containng the defines string
  109033. */
  109034. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  109035. return "#define CYLINDEREMITTER";
  109036. };
  109037. /**
  109038. * Returns the string "CylinderParticleEmitter"
  109039. * @returns a string containing the class name
  109040. */
  109041. CylinderParticleEmitter.prototype.getClassName = function () {
  109042. return "CylinderParticleEmitter";
  109043. };
  109044. /**
  109045. * Serializes the particle system to a JSON object.
  109046. * @returns the JSON object
  109047. */
  109048. CylinderParticleEmitter.prototype.serialize = function () {
  109049. var serializationObject = {};
  109050. serializationObject.type = this.getClassName();
  109051. serializationObject.radius = this.radius;
  109052. serializationObject.height = this.height;
  109053. serializationObject.radiusRange = this.radiusRange;
  109054. serializationObject.directionRandomizer = this.directionRandomizer;
  109055. return serializationObject;
  109056. };
  109057. /**
  109058. * Parse properties from a JSON object
  109059. * @param serializationObject defines the JSON object
  109060. */
  109061. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  109062. this.radius = serializationObject.radius;
  109063. this.height = serializationObject.height;
  109064. this.radiusRange = serializationObject.radiusRange;
  109065. this.directionRandomizer = serializationObject.directionRandomizer;
  109066. };
  109067. return CylinderParticleEmitter;
  109068. }());
  109069. /**
  109070. * Particle emitter emitting particles from the inside of a cylinder.
  109071. * It emits the particles randomly between two vectors.
  109072. */
  109073. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  109074. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  109075. /**
  109076. * Creates a new instance CylinderDirectedParticleEmitter
  109077. * @param radius the radius of the emission cylinder (1 by default)
  109078. * @param height the height of the emission cylinder (1 by default)
  109079. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  109080. * @param direction1 the min limit of the emission direction (up vector by default)
  109081. * @param direction2 the max limit of the emission direction (up vector by default)
  109082. */
  109083. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  109084. /**
  109085. * The min limit of the emission direction.
  109086. */
  109087. direction1,
  109088. /**
  109089. * The max limit of the emission direction.
  109090. */
  109091. direction2) {
  109092. if (radius === void 0) { radius = 1; }
  109093. if (height === void 0) { height = 1; }
  109094. if (radiusRange === void 0) { radiusRange = 1; }
  109095. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  109096. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  109097. var _this = _super.call(this, radius, height, radiusRange) || this;
  109098. _this.direction1 = direction1;
  109099. _this.direction2 = direction2;
  109100. return _this;
  109101. }
  109102. /**
  109103. * Called by the particle System when the direction is computed for the created particle.
  109104. * @param worldMatrix is the world matrix of the particle system
  109105. * @param directionToUpdate is the direction vector to update with the result
  109106. * @param particle is the particle we are computed the direction for
  109107. */
  109108. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  109109. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  109110. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  109111. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  109112. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  109113. };
  109114. /**
  109115. * Clones the current emitter and returns a copy of it
  109116. * @returns the new emitter
  109117. */
  109118. CylinderDirectedParticleEmitter.prototype.clone = function () {
  109119. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  109120. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  109121. return newOne;
  109122. };
  109123. /**
  109124. * Called by the GPUParticleSystem to setup the update shader
  109125. * @param effect defines the update shader
  109126. */
  109127. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  109128. effect.setFloat("radius", this.radius);
  109129. effect.setFloat("height", this.height);
  109130. effect.setFloat("radiusRange", this.radiusRange);
  109131. effect.setVector3("direction1", this.direction1);
  109132. effect.setVector3("direction2", this.direction2);
  109133. };
  109134. /**
  109135. * Returns a string to use to update the GPU particles update shader
  109136. * @returns a string containng the defines string
  109137. */
  109138. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  109139. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  109140. };
  109141. /**
  109142. * Returns the string "CylinderDirectedParticleEmitter"
  109143. * @returns a string containing the class name
  109144. */
  109145. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  109146. return "CylinderDirectedParticleEmitter";
  109147. };
  109148. /**
  109149. * Serializes the particle system to a JSON object.
  109150. * @returns the JSON object
  109151. */
  109152. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  109153. var serializationObject = _super.prototype.serialize.call(this);
  109154. serializationObject.direction1 = this.direction1.asArray();
  109155. serializationObject.direction2 = this.direction2.asArray();
  109156. return serializationObject;
  109157. };
  109158. /**
  109159. * Parse properties from a JSON object
  109160. * @param serializationObject defines the JSON object
  109161. */
  109162. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  109163. _super.prototype.parse.call(this, serializationObject);
  109164. this.direction1.copyFrom(serializationObject.direction1);
  109165. this.direction2.copyFrom(serializationObject.direction2);
  109166. };
  109167. return CylinderDirectedParticleEmitter;
  109168. }(CylinderParticleEmitter));
  109169. /***/ }),
  109170. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  109171. /*!**************************************************************!*\
  109172. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  109173. \**************************************************************/
  109174. /*! exports provided: HemisphericParticleEmitter */
  109175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109176. "use strict";
  109177. __webpack_require__.r(__webpack_exports__);
  109178. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  109179. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  109180. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109181. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  109182. /**
  109183. * Particle emitter emitting particles from the inside of a hemisphere.
  109184. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  109185. */
  109186. var HemisphericParticleEmitter = /** @class */ (function () {
  109187. /**
  109188. * Creates a new instance HemisphericParticleEmitter
  109189. * @param radius the radius of the emission hemisphere (1 by default)
  109190. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  109191. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  109192. */
  109193. function HemisphericParticleEmitter(
  109194. /**
  109195. * The radius of the emission hemisphere.
  109196. */
  109197. radius,
  109198. /**
  109199. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  109200. */
  109201. radiusRange,
  109202. /**
  109203. * How much to randomize the particle direction [0-1].
  109204. */
  109205. directionRandomizer) {
  109206. if (radius === void 0) { radius = 1; }
  109207. if (radiusRange === void 0) { radiusRange = 1; }
  109208. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  109209. this.radius = radius;
  109210. this.radiusRange = radiusRange;
  109211. this.directionRandomizer = directionRandomizer;
  109212. }
  109213. /**
  109214. * Called by the particle System when the direction is computed for the created particle.
  109215. * @param worldMatrix is the world matrix of the particle system
  109216. * @param directionToUpdate is the direction vector to update with the result
  109217. * @param particle is the particle we are computed the direction for
  109218. */
  109219. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  109220. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  109221. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  109222. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  109223. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  109224. direction.x += randX;
  109225. direction.y += randY;
  109226. direction.z += randZ;
  109227. direction.normalize();
  109228. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  109229. };
  109230. /**
  109231. * Called by the particle System when the position is computed for the created particle.
  109232. * @param worldMatrix is the world matrix of the particle system
  109233. * @param positionToUpdate is the position vector to update with the result
  109234. * @param particle is the particle we are computed the position for
  109235. */
  109236. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  109237. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  109238. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  109239. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  109240. var theta = Math.acos(2 * v - 1);
  109241. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  109242. var randY = randRadius * Math.cos(theta);
  109243. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  109244. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  109245. };
  109246. /**
  109247. * Clones the current emitter and returns a copy of it
  109248. * @returns the new emitter
  109249. */
  109250. HemisphericParticleEmitter.prototype.clone = function () {
  109251. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  109252. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  109253. return newOne;
  109254. };
  109255. /**
  109256. * Called by the GPUParticleSystem to setup the update shader
  109257. * @param effect defines the update shader
  109258. */
  109259. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  109260. effect.setFloat("radius", this.radius);
  109261. effect.setFloat("radiusRange", this.radiusRange);
  109262. effect.setFloat("directionRandomizer", this.directionRandomizer);
  109263. };
  109264. /**
  109265. * Returns a string to use to update the GPU particles update shader
  109266. * @returns a string containng the defines string
  109267. */
  109268. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  109269. return "#define HEMISPHERICEMITTER";
  109270. };
  109271. /**
  109272. * Returns the string "HemisphericParticleEmitter"
  109273. * @returns a string containing the class name
  109274. */
  109275. HemisphericParticleEmitter.prototype.getClassName = function () {
  109276. return "HemisphericParticleEmitter";
  109277. };
  109278. /**
  109279. * Serializes the particle system to a JSON object.
  109280. * @returns the JSON object
  109281. */
  109282. HemisphericParticleEmitter.prototype.serialize = function () {
  109283. var serializationObject = {};
  109284. serializationObject.type = this.getClassName();
  109285. serializationObject.radius = this.radius;
  109286. serializationObject.radiusRange = this.radiusRange;
  109287. serializationObject.directionRandomizer = this.directionRandomizer;
  109288. return serializationObject;
  109289. };
  109290. /**
  109291. * Parse properties from a JSON object
  109292. * @param serializationObject defines the JSON object
  109293. */
  109294. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  109295. this.radius = serializationObject.radius;
  109296. this.radiusRange = serializationObject.radiusRange;
  109297. this.directionRandomizer = serializationObject.directionRandomizer;
  109298. };
  109299. return HemisphericParticleEmitter;
  109300. }());
  109301. /***/ }),
  109302. /***/ "./Particles/EmitterTypes/index.ts":
  109303. /*!*****************************************!*\
  109304. !*** ./Particles/EmitterTypes/index.ts ***!
  109305. \*****************************************/
  109306. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  109307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109308. "use strict";
  109309. __webpack_require__.r(__webpack_exports__);
  109310. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  109311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  109312. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  109313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  109314. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  109315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  109316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  109317. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  109318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  109319. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  109320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  109321. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  109322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  109323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  109324. /***/ }),
  109325. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  109326. /*!********************************************************!*\
  109327. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  109328. \********************************************************/
  109329. /*! exports provided: PointParticleEmitter */
  109330. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109331. "use strict";
  109332. __webpack_require__.r(__webpack_exports__);
  109333. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  109334. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  109335. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109336. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  109337. /**
  109338. * Particle emitter emitting particles from a point.
  109339. * It emits the particles randomly between 2 given directions.
  109340. */
  109341. var PointParticleEmitter = /** @class */ (function () {
  109342. /**
  109343. * Creates a new instance PointParticleEmitter
  109344. */
  109345. function PointParticleEmitter() {
  109346. /**
  109347. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  109348. */
  109349. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  109350. /**
  109351. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  109352. */
  109353. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  109354. }
  109355. /**
  109356. * Called by the particle System when the direction is computed for the created particle.
  109357. * @param worldMatrix is the world matrix of the particle system
  109358. * @param directionToUpdate is the direction vector to update with the result
  109359. * @param particle is the particle we are computed the direction for
  109360. */
  109361. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  109362. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  109363. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  109364. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  109365. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  109366. };
  109367. /**
  109368. * Called by the particle System when the position is computed for the created particle.
  109369. * @param worldMatrix is the world matrix of the particle system
  109370. * @param positionToUpdate is the position vector to update with the result
  109371. * @param particle is the particle we are computed the position for
  109372. */
  109373. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  109374. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  109375. };
  109376. /**
  109377. * Clones the current emitter and returns a copy of it
  109378. * @returns the new emitter
  109379. */
  109380. PointParticleEmitter.prototype.clone = function () {
  109381. var newOne = new PointParticleEmitter();
  109382. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  109383. return newOne;
  109384. };
  109385. /**
  109386. * Called by the GPUParticleSystem to setup the update shader
  109387. * @param effect defines the update shader
  109388. */
  109389. PointParticleEmitter.prototype.applyToShader = function (effect) {
  109390. effect.setVector3("direction1", this.direction1);
  109391. effect.setVector3("direction2", this.direction2);
  109392. };
  109393. /**
  109394. * Returns a string to use to update the GPU particles update shader
  109395. * @returns a string containng the defines string
  109396. */
  109397. PointParticleEmitter.prototype.getEffectDefines = function () {
  109398. return "#define POINTEMITTER";
  109399. };
  109400. /**
  109401. * Returns the string "PointParticleEmitter"
  109402. * @returns a string containing the class name
  109403. */
  109404. PointParticleEmitter.prototype.getClassName = function () {
  109405. return "PointParticleEmitter";
  109406. };
  109407. /**
  109408. * Serializes the particle system to a JSON object.
  109409. * @returns the JSON object
  109410. */
  109411. PointParticleEmitter.prototype.serialize = function () {
  109412. var serializationObject = {};
  109413. serializationObject.type = this.getClassName();
  109414. serializationObject.direction1 = this.direction1.asArray();
  109415. serializationObject.direction2 = this.direction2.asArray();
  109416. return serializationObject;
  109417. };
  109418. /**
  109419. * Parse properties from a JSON object
  109420. * @param serializationObject defines the JSON object
  109421. */
  109422. PointParticleEmitter.prototype.parse = function (serializationObject) {
  109423. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  109424. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  109425. };
  109426. return PointParticleEmitter;
  109427. }());
  109428. /***/ }),
  109429. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  109430. /*!*********************************************************!*\
  109431. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  109432. \*********************************************************/
  109433. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  109434. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109435. "use strict";
  109436. __webpack_require__.r(__webpack_exports__);
  109437. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  109438. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  109439. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  109440. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109441. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  109442. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  109443. /**
  109444. * Particle emitter emitting particles from the inside of a sphere.
  109445. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  109446. */
  109447. var SphereParticleEmitter = /** @class */ (function () {
  109448. /**
  109449. * Creates a new instance SphereParticleEmitter
  109450. * @param radius the radius of the emission sphere (1 by default)
  109451. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  109452. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  109453. */
  109454. function SphereParticleEmitter(
  109455. /**
  109456. * The radius of the emission sphere.
  109457. */
  109458. radius,
  109459. /**
  109460. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  109461. */
  109462. radiusRange,
  109463. /**
  109464. * How much to randomize the particle direction [0-1].
  109465. */
  109466. directionRandomizer) {
  109467. if (radius === void 0) { radius = 1; }
  109468. if (radiusRange === void 0) { radiusRange = 1; }
  109469. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  109470. this.radius = radius;
  109471. this.radiusRange = radiusRange;
  109472. this.directionRandomizer = directionRandomizer;
  109473. }
  109474. /**
  109475. * Called by the particle System when the direction is computed for the created particle.
  109476. * @param worldMatrix is the world matrix of the particle system
  109477. * @param directionToUpdate is the direction vector to update with the result
  109478. * @param particle is the particle we are computed the direction for
  109479. */
  109480. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  109481. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  109482. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  109483. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  109484. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  109485. direction.x += randX;
  109486. direction.y += randY;
  109487. direction.z += randZ;
  109488. direction.normalize();
  109489. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  109490. };
  109491. /**
  109492. * Called by the particle System when the position is computed for the created particle.
  109493. * @param worldMatrix is the world matrix of the particle system
  109494. * @param positionToUpdate is the position vector to update with the result
  109495. * @param particle is the particle we are computed the position for
  109496. */
  109497. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  109498. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  109499. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  109500. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  109501. var theta = Math.acos(2 * v - 1);
  109502. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  109503. var randY = randRadius * Math.cos(theta);
  109504. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  109505. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  109506. };
  109507. /**
  109508. * Clones the current emitter and returns a copy of it
  109509. * @returns the new emitter
  109510. */
  109511. SphereParticleEmitter.prototype.clone = function () {
  109512. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  109513. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  109514. return newOne;
  109515. };
  109516. /**
  109517. * Called by the GPUParticleSystem to setup the update shader
  109518. * @param effect defines the update shader
  109519. */
  109520. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  109521. effect.setFloat("radius", this.radius);
  109522. effect.setFloat("radiusRange", this.radiusRange);
  109523. effect.setFloat("directionRandomizer", this.directionRandomizer);
  109524. };
  109525. /**
  109526. * Returns a string to use to update the GPU particles update shader
  109527. * @returns a string containng the defines string
  109528. */
  109529. SphereParticleEmitter.prototype.getEffectDefines = function () {
  109530. return "#define SPHEREEMITTER";
  109531. };
  109532. /**
  109533. * Returns the string "SphereParticleEmitter"
  109534. * @returns a string containing the class name
  109535. */
  109536. SphereParticleEmitter.prototype.getClassName = function () {
  109537. return "SphereParticleEmitter";
  109538. };
  109539. /**
  109540. * Serializes the particle system to a JSON object.
  109541. * @returns the JSON object
  109542. */
  109543. SphereParticleEmitter.prototype.serialize = function () {
  109544. var serializationObject = {};
  109545. serializationObject.type = this.getClassName();
  109546. serializationObject.radius = this.radius;
  109547. serializationObject.radiusRange = this.radiusRange;
  109548. serializationObject.directionRandomizer = this.directionRandomizer;
  109549. return serializationObject;
  109550. };
  109551. /**
  109552. * Parse properties from a JSON object
  109553. * @param serializationObject defines the JSON object
  109554. */
  109555. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  109556. this.radius = serializationObject.radius;
  109557. this.radiusRange = serializationObject.radiusRange;
  109558. this.directionRandomizer = serializationObject.directionRandomizer;
  109559. };
  109560. return SphereParticleEmitter;
  109561. }());
  109562. /**
  109563. * Particle emitter emitting particles from the inside of a sphere.
  109564. * It emits the particles randomly between two vectors.
  109565. */
  109566. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  109567. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  109568. /**
  109569. * Creates a new instance SphereDirectedParticleEmitter
  109570. * @param radius the radius of the emission sphere (1 by default)
  109571. * @param direction1 the min limit of the emission direction (up vector by default)
  109572. * @param direction2 the max limit of the emission direction (up vector by default)
  109573. */
  109574. function SphereDirectedParticleEmitter(radius,
  109575. /**
  109576. * The min limit of the emission direction.
  109577. */
  109578. direction1,
  109579. /**
  109580. * The max limit of the emission direction.
  109581. */
  109582. direction2) {
  109583. if (radius === void 0) { radius = 1; }
  109584. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  109585. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  109586. var _this = _super.call(this, radius) || this;
  109587. _this.direction1 = direction1;
  109588. _this.direction2 = direction2;
  109589. return _this;
  109590. }
  109591. /**
  109592. * Called by the particle System when the direction is computed for the created particle.
  109593. * @param worldMatrix is the world matrix of the particle system
  109594. * @param directionToUpdate is the direction vector to update with the result
  109595. * @param particle is the particle we are computed the direction for
  109596. */
  109597. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  109598. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  109599. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  109600. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  109601. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  109602. };
  109603. /**
  109604. * Clones the current emitter and returns a copy of it
  109605. * @returns the new emitter
  109606. */
  109607. SphereDirectedParticleEmitter.prototype.clone = function () {
  109608. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  109609. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  109610. return newOne;
  109611. };
  109612. /**
  109613. * Called by the GPUParticleSystem to setup the update shader
  109614. * @param effect defines the update shader
  109615. */
  109616. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  109617. effect.setFloat("radius", this.radius);
  109618. effect.setFloat("radiusRange", this.radiusRange);
  109619. effect.setVector3("direction1", this.direction1);
  109620. effect.setVector3("direction2", this.direction2);
  109621. };
  109622. /**
  109623. * Returns a string to use to update the GPU particles update shader
  109624. * @returns a string containng the defines string
  109625. */
  109626. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  109627. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  109628. };
  109629. /**
  109630. * Returns the string "SphereDirectedParticleEmitter"
  109631. * @returns a string containing the class name
  109632. */
  109633. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  109634. return "SphereDirectedParticleEmitter";
  109635. };
  109636. /**
  109637. * Serializes the particle system to a JSON object.
  109638. * @returns the JSON object
  109639. */
  109640. SphereDirectedParticleEmitter.prototype.serialize = function () {
  109641. var serializationObject = _super.prototype.serialize.call(this);
  109642. serializationObject.direction1 = this.direction1.asArray();
  109643. serializationObject.direction2 = this.direction2.asArray();
  109644. return serializationObject;
  109645. };
  109646. /**
  109647. * Parse properties from a JSON object
  109648. * @param serializationObject defines the JSON object
  109649. */
  109650. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  109651. _super.prototype.parse.call(this, serializationObject);
  109652. this.direction1.copyFrom(serializationObject.direction1);
  109653. this.direction2.copyFrom(serializationObject.direction2);
  109654. };
  109655. return SphereDirectedParticleEmitter;
  109656. }(SphereParticleEmitter));
  109657. /***/ }),
  109658. /***/ "./Particles/baseParticleSystem.ts":
  109659. /*!*****************************************!*\
  109660. !*** ./Particles/baseParticleSystem.ts ***!
  109661. \*****************************************/
  109662. /*! exports provided: BaseParticleSystem */
  109663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109664. "use strict";
  109665. __webpack_require__.r(__webpack_exports__);
  109666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  109667. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109668. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  109669. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  109670. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  109671. /**
  109672. * This represents the base class for particle system in Babylon.
  109673. * 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.
  109674. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  109675. * @example https://doc.babylonjs.com/babylon101/particles
  109676. */
  109677. var BaseParticleSystem = /** @class */ (function () {
  109678. /**
  109679. * Instantiates a particle system.
  109680. * 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.
  109681. * @param name The name of the particle system
  109682. */
  109683. function BaseParticleSystem(name) {
  109684. /**
  109685. * List of animations used by the particle system.
  109686. */
  109687. this.animations = [];
  109688. /**
  109689. * The rendering group used by the Particle system to chose when to render.
  109690. */
  109691. this.renderingGroupId = 0;
  109692. /**
  109693. * The emitter represents the Mesh or position we are attaching the particle system to.
  109694. */
  109695. this.emitter = null;
  109696. /**
  109697. * The maximum number of particles to emit per frame
  109698. */
  109699. this.emitRate = 10;
  109700. /**
  109701. * If you want to launch only a few particles at once, that can be done, as well.
  109702. */
  109703. this.manualEmitCount = -1;
  109704. /**
  109705. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  109706. */
  109707. this.updateSpeed = 0.01;
  109708. /**
  109709. * The amount of time the particle system is running (depends of the overall update speed).
  109710. */
  109711. this.targetStopDuration = 0;
  109712. /**
  109713. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  109714. */
  109715. this.disposeOnStop = false;
  109716. /**
  109717. * Minimum power of emitting particles.
  109718. */
  109719. this.minEmitPower = 1;
  109720. /**
  109721. * Maximum power of emitting particles.
  109722. */
  109723. this.maxEmitPower = 1;
  109724. /**
  109725. * Minimum life time of emitting particles.
  109726. */
  109727. this.minLifeTime = 1;
  109728. /**
  109729. * Maximum life time of emitting particles.
  109730. */
  109731. this.maxLifeTime = 1;
  109732. /**
  109733. * Minimum Size of emitting particles.
  109734. */
  109735. this.minSize = 1;
  109736. /**
  109737. * Maximum Size of emitting particles.
  109738. */
  109739. this.maxSize = 1;
  109740. /**
  109741. * Minimum scale of emitting particles on X axis.
  109742. */
  109743. this.minScaleX = 1;
  109744. /**
  109745. * Maximum scale of emitting particles on X axis.
  109746. */
  109747. this.maxScaleX = 1;
  109748. /**
  109749. * Minimum scale of emitting particles on Y axis.
  109750. */
  109751. this.minScaleY = 1;
  109752. /**
  109753. * Maximum scale of emitting particles on Y axis.
  109754. */
  109755. this.maxScaleY = 1;
  109756. /**
  109757. * Gets or sets the minimal initial rotation in radians.
  109758. */
  109759. this.minInitialRotation = 0;
  109760. /**
  109761. * Gets or sets the maximal initial rotation in radians.
  109762. */
  109763. this.maxInitialRotation = 0;
  109764. /**
  109765. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  109766. */
  109767. this.minAngularSpeed = 0;
  109768. /**
  109769. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  109770. */
  109771. this.maxAngularSpeed = 0;
  109772. /**
  109773. * The layer mask we are rendering the particles through.
  109774. */
  109775. this.layerMask = 0x0FFFFFFF;
  109776. /**
  109777. * This can help using your own shader to render the particle system.
  109778. * The according effect will be created
  109779. */
  109780. this.customShader = null;
  109781. /**
  109782. * By default particle system starts as soon as they are created. This prevents the
  109783. * automatic start to happen and let you decide when to start emitting particles.
  109784. */
  109785. this.preventAutoStart = false;
  109786. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  109787. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  109788. /**
  109789. * Callback triggered when the particle animation is ending.
  109790. */
  109791. this.onAnimationEnd = null;
  109792. /**
  109793. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  109794. */
  109795. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  109796. /**
  109797. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  109798. * to override the particles.
  109799. */
  109800. this.forceDepthWrite = false;
  109801. /** 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 */
  109802. this.preWarmCycles = 0;
  109803. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  109804. this.preWarmStepOffset = 1;
  109805. /**
  109806. * 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)
  109807. */
  109808. this.spriteCellChangeSpeed = 1;
  109809. /**
  109810. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  109811. */
  109812. this.startSpriteCellID = 0;
  109813. /**
  109814. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  109815. */
  109816. this.endSpriteCellID = 0;
  109817. /**
  109818. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  109819. */
  109820. this.spriteCellWidth = 0;
  109821. /**
  109822. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  109823. */
  109824. this.spriteCellHeight = 0;
  109825. /**
  109826. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  109827. */
  109828. this.spriteRandomStartCell = false;
  109829. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  109830. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  109831. /**
  109832. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  109833. */
  109834. this.beginAnimationOnStart = false;
  109835. /**
  109836. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  109837. */
  109838. this.beginAnimationFrom = 0;
  109839. /**
  109840. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  109841. */
  109842. this.beginAnimationTo = 60;
  109843. /**
  109844. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  109845. */
  109846. this.beginAnimationLoop = false;
  109847. /**
  109848. * Gets or sets a world offset applied to all particles
  109849. */
  109850. this.worldOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109851. /**
  109852. * You can use gravity if you want to give an orientation to your particles.
  109853. */
  109854. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109855. this._colorGradients = null;
  109856. this._sizeGradients = null;
  109857. this._lifeTimeGradients = null;
  109858. this._angularSpeedGradients = null;
  109859. this._velocityGradients = null;
  109860. this._limitVelocityGradients = null;
  109861. this._dragGradients = null;
  109862. this._emitRateGradients = null;
  109863. this._startSizeGradients = null;
  109864. this._rampGradients = null;
  109865. this._colorRemapGradients = null;
  109866. this._alphaRemapGradients = null;
  109867. /**
  109868. * Defines the delay in milliseconds before starting the system (0 by default)
  109869. */
  109870. this.startDelay = 0;
  109871. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  109872. this.limitVelocityDamping = 0.4;
  109873. /**
  109874. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  109875. */
  109876. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  109877. /**
  109878. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  109879. */
  109880. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  109881. /**
  109882. * Color the particle will have at the end of its lifetime
  109883. */
  109884. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  109885. /**
  109886. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  109887. */
  109888. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  109889. /** @hidden */
  109890. this._isSubEmitter = false;
  109891. /**
  109892. * Gets or sets the billboard mode to use when isBillboardBased = true.
  109893. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  109894. */
  109895. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  109896. this._isBillboardBased = true;
  109897. /**
  109898. * Local cache of defines for image processing.
  109899. */
  109900. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  109901. this.id = name;
  109902. this.name = name;
  109903. }
  109904. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  109905. /**
  109906. * Gets or sets a texture used to add random noise to particle positions
  109907. */
  109908. get: function () {
  109909. return this._noiseTexture;
  109910. },
  109911. set: function (value) {
  109912. if (this._noiseTexture === value) {
  109913. return;
  109914. }
  109915. this._noiseTexture = value;
  109916. this._reset();
  109917. },
  109918. enumerable: true,
  109919. configurable: true
  109920. });
  109921. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  109922. /**
  109923. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  109924. */
  109925. get: function () {
  109926. return this._isAnimationSheetEnabled;
  109927. },
  109928. set: function (value) {
  109929. if (this._isAnimationSheetEnabled == value) {
  109930. return;
  109931. }
  109932. this._isAnimationSheetEnabled = value;
  109933. this._reset();
  109934. },
  109935. enumerable: true,
  109936. configurable: true
  109937. });
  109938. /**
  109939. * Get hosting scene
  109940. * @returns the scene
  109941. */
  109942. BaseParticleSystem.prototype.getScene = function () {
  109943. return this._scene;
  109944. };
  109945. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  109946. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  109947. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  109948. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  109949. };
  109950. /**
  109951. * Gets the current list of drag gradients.
  109952. * You must use addDragGradient and removeDragGradient to udpate this list
  109953. * @returns the list of drag gradients
  109954. */
  109955. BaseParticleSystem.prototype.getDragGradients = function () {
  109956. return this._dragGradients;
  109957. };
  109958. /**
  109959. * Gets the current list of limit velocity gradients.
  109960. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  109961. * @returns the list of limit velocity gradients
  109962. */
  109963. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  109964. return this._limitVelocityGradients;
  109965. };
  109966. /**
  109967. * Gets the current list of color gradients.
  109968. * You must use addColorGradient and removeColorGradient to udpate this list
  109969. * @returns the list of color gradients
  109970. */
  109971. BaseParticleSystem.prototype.getColorGradients = function () {
  109972. return this._colorGradients;
  109973. };
  109974. /**
  109975. * Gets the current list of size gradients.
  109976. * You must use addSizeGradient and removeSizeGradient to udpate this list
  109977. * @returns the list of size gradients
  109978. */
  109979. BaseParticleSystem.prototype.getSizeGradients = function () {
  109980. return this._sizeGradients;
  109981. };
  109982. /**
  109983. * Gets the current list of color remap gradients.
  109984. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  109985. * @returns the list of color remap gradients
  109986. */
  109987. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  109988. return this._colorRemapGradients;
  109989. };
  109990. /**
  109991. * Gets the current list of alpha remap gradients.
  109992. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  109993. * @returns the list of alpha remap gradients
  109994. */
  109995. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  109996. return this._alphaRemapGradients;
  109997. };
  109998. /**
  109999. * Gets the current list of life time gradients.
  110000. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  110001. * @returns the list of life time gradients
  110002. */
  110003. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  110004. return this._lifeTimeGradients;
  110005. };
  110006. /**
  110007. * Gets the current list of angular speed gradients.
  110008. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  110009. * @returns the list of angular speed gradients
  110010. */
  110011. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  110012. return this._angularSpeedGradients;
  110013. };
  110014. /**
  110015. * Gets the current list of velocity gradients.
  110016. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  110017. * @returns the list of velocity gradients
  110018. */
  110019. BaseParticleSystem.prototype.getVelocityGradients = function () {
  110020. return this._velocityGradients;
  110021. };
  110022. /**
  110023. * Gets the current list of start size gradients.
  110024. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  110025. * @returns the list of start size gradients
  110026. */
  110027. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  110028. return this._startSizeGradients;
  110029. };
  110030. /**
  110031. * Gets the current list of emit rate gradients.
  110032. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  110033. * @returns the list of emit rate gradients
  110034. */
  110035. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  110036. return this._emitRateGradients;
  110037. };
  110038. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  110039. /**
  110040. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  110041. * This only works when particleEmitterTyps is a BoxParticleEmitter
  110042. */
  110043. get: function () {
  110044. if (this.particleEmitterType.direction1) {
  110045. return this.particleEmitterType.direction1;
  110046. }
  110047. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110048. },
  110049. set: function (value) {
  110050. if (this.particleEmitterType.direction1) {
  110051. this.particleEmitterType.direction1 = value;
  110052. }
  110053. },
  110054. enumerable: true,
  110055. configurable: true
  110056. });
  110057. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  110058. /**
  110059. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  110060. * This only works when particleEmitterTyps is a BoxParticleEmitter
  110061. */
  110062. get: function () {
  110063. if (this.particleEmitterType.direction2) {
  110064. return this.particleEmitterType.direction2;
  110065. }
  110066. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110067. },
  110068. set: function (value) {
  110069. if (this.particleEmitterType.direction2) {
  110070. this.particleEmitterType.direction2 = value;
  110071. }
  110072. },
  110073. enumerable: true,
  110074. configurable: true
  110075. });
  110076. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  110077. /**
  110078. * 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.
  110079. * This only works when particleEmitterTyps is a BoxParticleEmitter
  110080. */
  110081. get: function () {
  110082. if (this.particleEmitterType.minEmitBox) {
  110083. return this.particleEmitterType.minEmitBox;
  110084. }
  110085. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110086. },
  110087. set: function (value) {
  110088. if (this.particleEmitterType.minEmitBox) {
  110089. this.particleEmitterType.minEmitBox = value;
  110090. }
  110091. },
  110092. enumerable: true,
  110093. configurable: true
  110094. });
  110095. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  110096. /**
  110097. * 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.
  110098. * This only works when particleEmitterTyps is a BoxParticleEmitter
  110099. */
  110100. get: function () {
  110101. if (this.particleEmitterType.maxEmitBox) {
  110102. return this.particleEmitterType.maxEmitBox;
  110103. }
  110104. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  110105. },
  110106. set: function (value) {
  110107. if (this.particleEmitterType.maxEmitBox) {
  110108. this.particleEmitterType.maxEmitBox = value;
  110109. }
  110110. },
  110111. enumerable: true,
  110112. configurable: true
  110113. });
  110114. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  110115. /**
  110116. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  110117. */
  110118. get: function () {
  110119. return this._isBillboardBased;
  110120. },
  110121. set: function (value) {
  110122. if (this._isBillboardBased === value) {
  110123. return;
  110124. }
  110125. this._isBillboardBased = value;
  110126. this._reset();
  110127. },
  110128. enumerable: true,
  110129. configurable: true
  110130. });
  110131. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  110132. /**
  110133. * Gets the image processing configuration used either in this material.
  110134. */
  110135. get: function () {
  110136. return this._imageProcessingConfiguration;
  110137. },
  110138. /**
  110139. * Sets the Default image processing configuration used either in the this material.
  110140. *
  110141. * If sets to null, the scene one is in use.
  110142. */
  110143. set: function (value) {
  110144. this._attachImageProcessingConfiguration(value);
  110145. },
  110146. enumerable: true,
  110147. configurable: true
  110148. });
  110149. /**
  110150. * Attaches a new image processing configuration to the Standard Material.
  110151. * @param configuration
  110152. */
  110153. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  110154. if (configuration === this._imageProcessingConfiguration) {
  110155. return;
  110156. }
  110157. // Pick the scene configuration if needed.
  110158. if (!configuration) {
  110159. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  110160. }
  110161. else {
  110162. this._imageProcessingConfiguration = configuration;
  110163. }
  110164. };
  110165. /** @hidden */
  110166. BaseParticleSystem.prototype._reset = function () {
  110167. };
  110168. /** @hidden */
  110169. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  110170. if (!gradients) {
  110171. return this;
  110172. }
  110173. var index = 0;
  110174. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  110175. var valueGradient = gradients_1[_i];
  110176. if (valueGradient.gradient === gradient) {
  110177. gradients.splice(index, 1);
  110178. break;
  110179. }
  110180. index++;
  110181. }
  110182. if (texture) {
  110183. texture.dispose();
  110184. }
  110185. return this;
  110186. };
  110187. /**
  110188. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  110189. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  110190. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  110191. * @returns the emitter
  110192. */
  110193. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  110194. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  110195. particleEmitter.direction1 = direction1;
  110196. particleEmitter.direction2 = direction2;
  110197. this.particleEmitterType = particleEmitter;
  110198. return particleEmitter;
  110199. };
  110200. /**
  110201. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  110202. * @param radius The radius of the hemisphere to emit from
  110203. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  110204. * @returns the emitter
  110205. */
  110206. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  110207. if (radius === void 0) { radius = 1; }
  110208. if (radiusRange === void 0) { radiusRange = 1; }
  110209. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  110210. this.particleEmitterType = particleEmitter;
  110211. return particleEmitter;
  110212. };
  110213. /**
  110214. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  110215. * @param radius The radius of the sphere to emit from
  110216. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  110217. * @returns the emitter
  110218. */
  110219. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  110220. if (radius === void 0) { radius = 1; }
  110221. if (radiusRange === void 0) { radiusRange = 1; }
  110222. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  110223. this.particleEmitterType = particleEmitter;
  110224. return particleEmitter;
  110225. };
  110226. /**
  110227. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  110228. * @param radius The radius of the sphere to emit from
  110229. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  110230. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  110231. * @returns the emitter
  110232. */
  110233. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  110234. if (radius === void 0) { radius = 1; }
  110235. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  110236. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  110237. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  110238. this.particleEmitterType = particleEmitter;
  110239. return particleEmitter;
  110240. };
  110241. /**
  110242. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  110243. * @param radius The radius of the emission cylinder
  110244. * @param height The height of the emission cylinder
  110245. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  110246. * @param directionRandomizer How much to randomize the particle direction [0-1]
  110247. * @returns the emitter
  110248. */
  110249. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  110250. if (radius === void 0) { radius = 1; }
  110251. if (height === void 0) { height = 1; }
  110252. if (radiusRange === void 0) { radiusRange = 1; }
  110253. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  110254. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  110255. this.particleEmitterType = particleEmitter;
  110256. return particleEmitter;
  110257. };
  110258. /**
  110259. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  110260. * @param radius The radius of the cylinder to emit from
  110261. * @param height The height of the emission cylinder
  110262. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  110263. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  110264. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  110265. * @returns the emitter
  110266. */
  110267. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  110268. if (radius === void 0) { radius = 1; }
  110269. if (height === void 0) { height = 1; }
  110270. if (radiusRange === void 0) { radiusRange = 1; }
  110271. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  110272. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  110273. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  110274. this.particleEmitterType = particleEmitter;
  110275. return particleEmitter;
  110276. };
  110277. /**
  110278. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  110279. * @param radius The radius of the cone to emit from
  110280. * @param angle The base angle of the cone
  110281. * @returns the emitter
  110282. */
  110283. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  110284. if (radius === void 0) { radius = 1; }
  110285. if (angle === void 0) { angle = Math.PI / 4; }
  110286. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  110287. this.particleEmitterType = particleEmitter;
  110288. return particleEmitter;
  110289. };
  110290. /**
  110291. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  110292. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  110293. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  110294. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  110295. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  110296. * @returns the emitter
  110297. */
  110298. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  110299. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  110300. this.particleEmitterType = particleEmitter;
  110301. this.direction1 = direction1;
  110302. this.direction2 = direction2;
  110303. this.minEmitBox = minEmitBox;
  110304. this.maxEmitBox = maxEmitBox;
  110305. return particleEmitter;
  110306. };
  110307. /**
  110308. * Source color is added to the destination color without alpha affecting the result
  110309. */
  110310. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  110311. /**
  110312. * Blend current color and particle color using particle’s alpha
  110313. */
  110314. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  110315. /**
  110316. * Add current color and particle color multiplied by particle’s alpha
  110317. */
  110318. BaseParticleSystem.BLENDMODE_ADD = 2;
  110319. /**
  110320. * Multiply current color with particle color
  110321. */
  110322. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  110323. /**
  110324. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  110325. */
  110326. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  110327. return BaseParticleSystem;
  110328. }());
  110329. /***/ }),
  110330. /***/ "./Particles/gpuParticleSystem.ts":
  110331. /*!****************************************!*\
  110332. !*** ./Particles/gpuParticleSystem.ts ***!
  110333. \****************************************/
  110334. /*! exports provided: GPUParticleSystem */
  110335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110336. "use strict";
  110337. __webpack_require__.r(__webpack_exports__);
  110338. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  110339. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  110340. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  110341. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  110342. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110343. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  110344. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  110345. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  110346. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  110347. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  110348. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  110349. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  110350. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  110351. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  110352. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  110353. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  110354. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  110355. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  110356. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  110357. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  110358. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  110359. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  110360. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  110361. /**
  110362. * This represents a GPU particle system in Babylon
  110363. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  110364. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  110365. */
  110366. var GPUParticleSystem = /** @class */ (function (_super) {
  110367. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  110368. /**
  110369. * Instantiates a GPU particle system.
  110370. * 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.
  110371. * @param name The name of the particle system
  110372. * @param options The options used to create the system
  110373. * @param scene The scene the particle system belongs to
  110374. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  110375. */
  110376. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  110377. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  110378. var _this = _super.call(this, name) || this;
  110379. /**
  110380. * The layer mask we are rendering the particles through.
  110381. */
  110382. _this.layerMask = 0x0FFFFFFF;
  110383. _this._accumulatedCount = 0;
  110384. _this._targetIndex = 0;
  110385. _this._currentRenderId = -1;
  110386. _this._started = false;
  110387. _this._stopped = false;
  110388. _this._timeDelta = 0;
  110389. _this._actualFrame = 0;
  110390. _this._rawTextureWidth = 256;
  110391. /**
  110392. * An event triggered when the system is disposed.
  110393. */
  110394. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  110395. /**
  110396. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  110397. * to override the particles.
  110398. */
  110399. _this.forceDepthWrite = false;
  110400. _this._preWarmDone = false;
  110401. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  110402. // Setup the default processing configuration to the scene.
  110403. _this._attachImageProcessingConfiguration(null);
  110404. _this._engine = _this._scene.getEngine();
  110405. if (!options.randomTextureSize) {
  110406. delete options.randomTextureSize;
  110407. }
  110408. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  110409. var optionsAsNumber = options;
  110410. if (isFinite(optionsAsNumber)) {
  110411. fullOptions.capacity = optionsAsNumber;
  110412. }
  110413. _this._capacity = fullOptions.capacity;
  110414. _this._activeCount = fullOptions.capacity;
  110415. _this._currentActiveCount = 0;
  110416. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  110417. _this._scene.particleSystems.push(_this);
  110418. _this._updateEffectOptions = {
  110419. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  110420. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  110421. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  110422. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  110423. uniformBuffersNames: [],
  110424. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  110425. defines: "",
  110426. fallbacks: null,
  110427. onCompiled: null,
  110428. onError: null,
  110429. indexParameters: null,
  110430. maxSimultaneousLights: 0,
  110431. transformFeedbackVaryings: []
  110432. };
  110433. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  110434. // Random data
  110435. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  110436. var d = [];
  110437. for (var i = 0; i < maxTextureSize; ++i) {
  110438. d.push(Math.random());
  110439. d.push(Math.random());
  110440. d.push(Math.random());
  110441. d.push(Math.random());
  110442. }
  110443. _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);
  110444. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  110445. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  110446. d = [];
  110447. for (var i = 0; i < maxTextureSize; ++i) {
  110448. d.push(Math.random());
  110449. d.push(Math.random());
  110450. d.push(Math.random());
  110451. d.push(Math.random());
  110452. }
  110453. _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);
  110454. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  110455. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  110456. _this._randomTextureSize = maxTextureSize;
  110457. return _this;
  110458. }
  110459. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  110460. /**
  110461. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  110462. */
  110463. get: function () {
  110464. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  110465. return false;
  110466. }
  110467. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  110468. },
  110469. enumerable: true,
  110470. configurable: true
  110471. });
  110472. /**
  110473. * Gets the maximum number of particles active at the same time.
  110474. * @returns The max number of active particles.
  110475. */
  110476. GPUParticleSystem.prototype.getCapacity = function () {
  110477. return this._capacity;
  110478. };
  110479. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  110480. /**
  110481. * Gets or set the number of active particles
  110482. */
  110483. get: function () {
  110484. return this._activeCount;
  110485. },
  110486. set: function (value) {
  110487. this._activeCount = Math.min(value, this._capacity);
  110488. },
  110489. enumerable: true,
  110490. configurable: true
  110491. });
  110492. /**
  110493. * Is this system ready to be used/rendered
  110494. * @return true if the system is ready
  110495. */
  110496. GPUParticleSystem.prototype.isReady = function () {
  110497. if (!this._updateEffect) {
  110498. this._recreateUpdateEffect();
  110499. this._recreateRenderEffect();
  110500. return false;
  110501. }
  110502. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  110503. return false;
  110504. }
  110505. return true;
  110506. };
  110507. /**
  110508. * Gets if the system has been started. (Note: this will still be true after stop is called)
  110509. * @returns True if it has been started, otherwise false.
  110510. */
  110511. GPUParticleSystem.prototype.isStarted = function () {
  110512. return this._started;
  110513. };
  110514. /**
  110515. * Starts the particle system and begins to emit
  110516. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  110517. */
  110518. GPUParticleSystem.prototype.start = function (delay) {
  110519. var _this = this;
  110520. if (delay === void 0) { delay = this.startDelay; }
  110521. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  110522. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  110523. }
  110524. if (delay) {
  110525. setTimeout(function () {
  110526. _this.start(0);
  110527. }, delay);
  110528. return;
  110529. }
  110530. this._started = true;
  110531. this._stopped = false;
  110532. this._preWarmDone = false;
  110533. // Animations
  110534. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  110535. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  110536. }
  110537. };
  110538. /**
  110539. * Stops the particle system.
  110540. */
  110541. GPUParticleSystem.prototype.stop = function () {
  110542. this._stopped = true;
  110543. };
  110544. /**
  110545. * Remove all active particles
  110546. */
  110547. GPUParticleSystem.prototype.reset = function () {
  110548. this._releaseBuffers();
  110549. this._releaseVAOs();
  110550. this._currentActiveCount = 0;
  110551. this._targetIndex = 0;
  110552. };
  110553. /**
  110554. * Returns the string "GPUParticleSystem"
  110555. * @returns a string containing the class name
  110556. */
  110557. GPUParticleSystem.prototype.getClassName = function () {
  110558. return "GPUParticleSystem";
  110559. };
  110560. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  110561. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  110562. this._releaseBuffers();
  110563. return this;
  110564. };
  110565. /**
  110566. * Adds a new color gradient
  110567. * @param gradient defines the gradient to use (between 0 and 1)
  110568. * @param color1 defines the color to affect to the specified gradient
  110569. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  110570. * @returns the current particle system
  110571. */
  110572. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  110573. if (!this._colorGradients) {
  110574. this._colorGradients = [];
  110575. }
  110576. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  110577. colorGradient.gradient = gradient;
  110578. colorGradient.color1 = color1;
  110579. this._colorGradients.push(colorGradient);
  110580. this._colorGradients.sort(function (a, b) {
  110581. if (a.gradient < b.gradient) {
  110582. return -1;
  110583. }
  110584. else if (a.gradient > b.gradient) {
  110585. return 1;
  110586. }
  110587. return 0;
  110588. });
  110589. if (this._colorGradientsTexture) {
  110590. this._colorGradientsTexture.dispose();
  110591. this._colorGradientsTexture = null;
  110592. }
  110593. this._releaseBuffers();
  110594. return this;
  110595. };
  110596. /**
  110597. * Remove a specific color gradient
  110598. * @param gradient defines the gradient to remove
  110599. * @returns the current particle system
  110600. */
  110601. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  110602. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  110603. this._colorGradientsTexture = null;
  110604. return this;
  110605. };
  110606. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  110607. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  110608. valueGradient.gradient = gradient;
  110609. valueGradient.factor1 = factor;
  110610. factorGradients.push(valueGradient);
  110611. factorGradients.sort(function (a, b) {
  110612. if (a.gradient < b.gradient) {
  110613. return -1;
  110614. }
  110615. else if (a.gradient > b.gradient) {
  110616. return 1;
  110617. }
  110618. return 0;
  110619. });
  110620. this._releaseBuffers();
  110621. };
  110622. /**
  110623. * Adds a new size gradient
  110624. * @param gradient defines the gradient to use (between 0 and 1)
  110625. * @param factor defines the size factor to affect to the specified gradient
  110626. * @returns the current particle system
  110627. */
  110628. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  110629. if (!this._sizeGradients) {
  110630. this._sizeGradients = [];
  110631. }
  110632. this._addFactorGradient(this._sizeGradients, gradient, factor);
  110633. if (this._sizeGradientsTexture) {
  110634. this._sizeGradientsTexture.dispose();
  110635. this._sizeGradientsTexture = null;
  110636. }
  110637. this._releaseBuffers();
  110638. return this;
  110639. };
  110640. /**
  110641. * Remove a specific size gradient
  110642. * @param gradient defines the gradient to remove
  110643. * @returns the current particle system
  110644. */
  110645. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  110646. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  110647. this._sizeGradientsTexture = null;
  110648. return this;
  110649. };
  110650. /**
  110651. * Adds a new angular speed gradient
  110652. * @param gradient defines the gradient to use (between 0 and 1)
  110653. * @param factor defines the angular speed to affect to the specified gradient
  110654. * @returns the current particle system
  110655. */
  110656. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  110657. if (!this._angularSpeedGradients) {
  110658. this._angularSpeedGradients = [];
  110659. }
  110660. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  110661. if (this._angularSpeedGradientsTexture) {
  110662. this._angularSpeedGradientsTexture.dispose();
  110663. this._angularSpeedGradientsTexture = null;
  110664. }
  110665. this._releaseBuffers();
  110666. return this;
  110667. };
  110668. /**
  110669. * Remove a specific angular speed gradient
  110670. * @param gradient defines the gradient to remove
  110671. * @returns the current particle system
  110672. */
  110673. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  110674. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  110675. this._angularSpeedGradientsTexture = null;
  110676. return this;
  110677. };
  110678. /**
  110679. * Adds a new velocity gradient
  110680. * @param gradient defines the gradient to use (between 0 and 1)
  110681. * @param factor defines the velocity to affect to the specified gradient
  110682. * @returns the current particle system
  110683. */
  110684. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  110685. if (!this._velocityGradients) {
  110686. this._velocityGradients = [];
  110687. }
  110688. this._addFactorGradient(this._velocityGradients, gradient, factor);
  110689. if (this._velocityGradientsTexture) {
  110690. this._velocityGradientsTexture.dispose();
  110691. this._velocityGradientsTexture = null;
  110692. }
  110693. this._releaseBuffers();
  110694. return this;
  110695. };
  110696. /**
  110697. * Remove a specific velocity gradient
  110698. * @param gradient defines the gradient to remove
  110699. * @returns the current particle system
  110700. */
  110701. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  110702. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  110703. this._velocityGradientsTexture = null;
  110704. return this;
  110705. };
  110706. /**
  110707. * Adds a new limit velocity gradient
  110708. * @param gradient defines the gradient to use (between 0 and 1)
  110709. * @param factor defines the limit velocity value to affect to the specified gradient
  110710. * @returns the current particle system
  110711. */
  110712. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  110713. if (!this._limitVelocityGradients) {
  110714. this._limitVelocityGradients = [];
  110715. }
  110716. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  110717. if (this._limitVelocityGradientsTexture) {
  110718. this._limitVelocityGradientsTexture.dispose();
  110719. this._limitVelocityGradientsTexture = null;
  110720. }
  110721. this._releaseBuffers();
  110722. return this;
  110723. };
  110724. /**
  110725. * Remove a specific limit velocity gradient
  110726. * @param gradient defines the gradient to remove
  110727. * @returns the current particle system
  110728. */
  110729. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  110730. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  110731. this._limitVelocityGradientsTexture = null;
  110732. return this;
  110733. };
  110734. /**
  110735. * Adds a new drag gradient
  110736. * @param gradient defines the gradient to use (between 0 and 1)
  110737. * @param factor defines the drag value to affect to the specified gradient
  110738. * @returns the current particle system
  110739. */
  110740. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  110741. if (!this._dragGradients) {
  110742. this._dragGradients = [];
  110743. }
  110744. this._addFactorGradient(this._dragGradients, gradient, factor);
  110745. if (this._dragGradientsTexture) {
  110746. this._dragGradientsTexture.dispose();
  110747. this._dragGradientsTexture = null;
  110748. }
  110749. this._releaseBuffers();
  110750. return this;
  110751. };
  110752. /**
  110753. * Remove a specific drag gradient
  110754. * @param gradient defines the gradient to remove
  110755. * @returns the current particle system
  110756. */
  110757. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  110758. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  110759. this._dragGradientsTexture = null;
  110760. return this;
  110761. };
  110762. /**
  110763. * Not supported by GPUParticleSystem
  110764. * @param gradient defines the gradient to use (between 0 and 1)
  110765. * @param factor defines the emit rate value to affect to the specified gradient
  110766. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110767. * @returns the current particle system
  110768. */
  110769. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  110770. // Do nothing as emit rate is not supported by GPUParticleSystem
  110771. return this;
  110772. };
  110773. /**
  110774. * Not supported by GPUParticleSystem
  110775. * @param gradient defines the gradient to remove
  110776. * @returns the current particle system
  110777. */
  110778. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  110779. // Do nothing as emit rate is not supported by GPUParticleSystem
  110780. return this;
  110781. };
  110782. /**
  110783. * Not supported by GPUParticleSystem
  110784. * @param gradient defines the gradient to use (between 0 and 1)
  110785. * @param factor defines the start size value to affect to the specified gradient
  110786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110787. * @returns the current particle system
  110788. */
  110789. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  110790. // Do nothing as start size is not supported by GPUParticleSystem
  110791. return this;
  110792. };
  110793. /**
  110794. * Not supported by GPUParticleSystem
  110795. * @param gradient defines the gradient to remove
  110796. * @returns the current particle system
  110797. */
  110798. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  110799. // Do nothing as start size is not supported by GPUParticleSystem
  110800. return this;
  110801. };
  110802. /**
  110803. * Not supported by GPUParticleSystem
  110804. * @param gradient defines the gradient to use (between 0 and 1)
  110805. * @param min defines the color remap minimal range
  110806. * @param max defines the color remap maximal range
  110807. * @returns the current particle system
  110808. */
  110809. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  110810. // Do nothing as start size is not supported by GPUParticleSystem
  110811. return this;
  110812. };
  110813. /**
  110814. * Not supported by GPUParticleSystem
  110815. * @param gradient defines the gradient to remove
  110816. * @returns the current particle system
  110817. */
  110818. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  110819. // Do nothing as start size is not supported by GPUParticleSystem
  110820. return this;
  110821. };
  110822. /**
  110823. * Not supported by GPUParticleSystem
  110824. * @param gradient defines the gradient to use (between 0 and 1)
  110825. * @param min defines the alpha remap minimal range
  110826. * @param max defines the alpha remap maximal range
  110827. * @returns the current particle system
  110828. */
  110829. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  110830. // Do nothing as start size is not supported by GPUParticleSystem
  110831. return this;
  110832. };
  110833. /**
  110834. * Not supported by GPUParticleSystem
  110835. * @param gradient defines the gradient to remove
  110836. * @returns the current particle system
  110837. */
  110838. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  110839. // Do nothing as start size is not supported by GPUParticleSystem
  110840. return this;
  110841. };
  110842. /**
  110843. * Not supported by GPUParticleSystem
  110844. * @param gradient defines the gradient to use (between 0 and 1)
  110845. * @param color defines the color to affect to the specified gradient
  110846. * @returns the current particle system
  110847. */
  110848. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  110849. //Not supported by GPUParticleSystem
  110850. return this;
  110851. };
  110852. /**
  110853. * Not supported by GPUParticleSystem
  110854. * @param gradient defines the gradient to remove
  110855. * @returns the current particle system
  110856. */
  110857. GPUParticleSystem.prototype.removeRampGradient = function () {
  110858. //Not supported by GPUParticleSystem
  110859. return this;
  110860. };
  110861. /**
  110862. * Not supported by GPUParticleSystem
  110863. * @returns the list of ramp gradients
  110864. */
  110865. GPUParticleSystem.prototype.getRampGradients = function () {
  110866. return null;
  110867. };
  110868. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  110869. /**
  110870. * Not supported by GPUParticleSystem
  110871. * Gets or sets a boolean indicating that ramp gradients must be used
  110872. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  110873. */
  110874. get: function () {
  110875. //Not supported by GPUParticleSystem
  110876. return false;
  110877. },
  110878. set: function (value) {
  110879. //Not supported by GPUParticleSystem
  110880. },
  110881. enumerable: true,
  110882. configurable: true
  110883. });
  110884. /**
  110885. * Not supported by GPUParticleSystem
  110886. * @param gradient defines the gradient to use (between 0 and 1)
  110887. * @param factor defines the life time factor to affect to the specified gradient
  110888. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110889. * @returns the current particle system
  110890. */
  110891. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  110892. //Not supported by GPUParticleSystem
  110893. return this;
  110894. };
  110895. /**
  110896. * Not supported by GPUParticleSystem
  110897. * @param gradient defines the gradient to remove
  110898. * @returns the current particle system
  110899. */
  110900. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  110901. //Not supported by GPUParticleSystem
  110902. return this;
  110903. };
  110904. GPUParticleSystem.prototype._reset = function () {
  110905. this._releaseBuffers();
  110906. };
  110907. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  110908. var updateVertexBuffers = {};
  110909. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  110910. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  110911. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  110912. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  110913. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  110914. var offset = 12;
  110915. if (!this._colorGradientsTexture) {
  110916. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  110917. offset += 4;
  110918. }
  110919. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  110920. offset += 3;
  110921. if (!this._isBillboardBased) {
  110922. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  110923. offset += 3;
  110924. }
  110925. if (this._angularSpeedGradientsTexture) {
  110926. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  110927. offset += 1;
  110928. }
  110929. else {
  110930. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  110931. offset += 2;
  110932. }
  110933. if (this._isAnimationSheetEnabled) {
  110934. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  110935. offset += 1;
  110936. if (this.spriteRandomStartCell) {
  110937. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  110938. offset += 1;
  110939. }
  110940. }
  110941. if (this.noiseTexture) {
  110942. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  110943. offset += 3;
  110944. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  110945. offset += 3;
  110946. }
  110947. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  110948. this._engine.bindArrayBuffer(null);
  110949. return vao;
  110950. };
  110951. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  110952. var renderVertexBuffers = {};
  110953. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  110954. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  110955. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  110956. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  110957. var offset = 12;
  110958. if (!this._colorGradientsTexture) {
  110959. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  110960. offset += 4;
  110961. }
  110962. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  110963. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  110964. }
  110965. offset += 3; // Direction
  110966. if (!this._isBillboardBased) {
  110967. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  110968. offset += 3;
  110969. }
  110970. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  110971. if (this._angularSpeedGradientsTexture) {
  110972. offset++;
  110973. }
  110974. else {
  110975. offset += 2;
  110976. }
  110977. if (this._isAnimationSheetEnabled) {
  110978. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  110979. offset += 1;
  110980. if (this.spriteRandomStartCell) {
  110981. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  110982. offset += 1;
  110983. }
  110984. }
  110985. if (this.noiseTexture) {
  110986. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  110987. offset += 3;
  110988. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  110989. offset += 3;
  110990. }
  110991. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  110992. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  110993. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  110994. this._engine.bindArrayBuffer(null);
  110995. return vao;
  110996. };
  110997. GPUParticleSystem.prototype._initialize = function (force) {
  110998. if (force === void 0) { force = false; }
  110999. if (this._buffer0 && !force) {
  111000. return;
  111001. }
  111002. var engine = this._scene.getEngine();
  111003. var data = new Array();
  111004. this._attributesStrideSize = 21;
  111005. this._targetIndex = 0;
  111006. if (!this.isBillboardBased) {
  111007. this._attributesStrideSize += 3;
  111008. }
  111009. if (this._colorGradientsTexture) {
  111010. this._attributesStrideSize -= 4;
  111011. }
  111012. if (this._angularSpeedGradientsTexture) {
  111013. this._attributesStrideSize -= 1;
  111014. }
  111015. if (this._isAnimationSheetEnabled) {
  111016. this._attributesStrideSize += 1;
  111017. if (this.spriteRandomStartCell) {
  111018. this._attributesStrideSize += 1;
  111019. }
  111020. }
  111021. if (this.noiseTexture) {
  111022. this._attributesStrideSize += 6;
  111023. }
  111024. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  111025. // position
  111026. data.push(0.0);
  111027. data.push(0.0);
  111028. data.push(0.0);
  111029. // Age and life
  111030. data.push(0.0); // create the particle as a dead one to create a new one at start
  111031. data.push(0.0);
  111032. // Seed
  111033. data.push(Math.random());
  111034. data.push(Math.random());
  111035. data.push(Math.random());
  111036. data.push(Math.random());
  111037. // Size
  111038. data.push(0.0);
  111039. data.push(0.0);
  111040. data.push(0.0);
  111041. if (!this._colorGradientsTexture) {
  111042. // color
  111043. data.push(0.0);
  111044. data.push(0.0);
  111045. data.push(0.0);
  111046. data.push(0.0);
  111047. }
  111048. // direction
  111049. data.push(0.0);
  111050. data.push(0.0);
  111051. data.push(0.0);
  111052. if (!this.isBillboardBased) {
  111053. // initialDirection
  111054. data.push(0.0);
  111055. data.push(0.0);
  111056. data.push(0.0);
  111057. }
  111058. // angle
  111059. data.push(0.0);
  111060. if (!this._angularSpeedGradientsTexture) {
  111061. data.push(0.0);
  111062. }
  111063. if (this._isAnimationSheetEnabled) {
  111064. data.push(0.0);
  111065. if (this.spriteRandomStartCell) {
  111066. data.push(0.0);
  111067. }
  111068. }
  111069. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  111070. data.push(Math.random());
  111071. data.push(Math.random());
  111072. data.push(Math.random());
  111073. data.push(Math.random());
  111074. data.push(Math.random());
  111075. data.push(Math.random());
  111076. }
  111077. }
  111078. // Sprite data
  111079. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  111080. -0.5, 0.5, 0, 1,
  111081. -0.5, -0.5, 0, 0,
  111082. 0.5, -0.5, 1, 0]);
  111083. // Buffers
  111084. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  111085. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  111086. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  111087. // Update VAO
  111088. this._updateVAO = [];
  111089. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  111090. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  111091. // Render VAO
  111092. this._renderVAO = [];
  111093. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  111094. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  111095. // Links
  111096. this._sourceBuffer = this._buffer0;
  111097. this._targetBuffer = this._buffer1;
  111098. };
  111099. /** @hidden */
  111100. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  111101. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  111102. if (this._isBillboardBased) {
  111103. defines += "\n#define BILLBOARD";
  111104. }
  111105. if (this._colorGradientsTexture) {
  111106. defines += "\n#define COLORGRADIENTS";
  111107. }
  111108. if (this._sizeGradientsTexture) {
  111109. defines += "\n#define SIZEGRADIENTS";
  111110. }
  111111. if (this._angularSpeedGradientsTexture) {
  111112. defines += "\n#define ANGULARSPEEDGRADIENTS";
  111113. }
  111114. if (this._velocityGradientsTexture) {
  111115. defines += "\n#define VELOCITYGRADIENTS";
  111116. }
  111117. if (this._limitVelocityGradientsTexture) {
  111118. defines += "\n#define LIMITVELOCITYGRADIENTS";
  111119. }
  111120. if (this._dragGradientsTexture) {
  111121. defines += "\n#define DRAGGRADIENTS";
  111122. }
  111123. if (this.isAnimationSheetEnabled) {
  111124. defines += "\n#define ANIMATESHEET";
  111125. if (this.spriteRandomStartCell) {
  111126. defines += "\n#define ANIMATESHEETRANDOMSTART";
  111127. }
  111128. }
  111129. if (this.noiseTexture) {
  111130. defines += "\n#define NOISE";
  111131. }
  111132. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  111133. return;
  111134. }
  111135. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  111136. if (!this._colorGradientsTexture) {
  111137. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  111138. }
  111139. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  111140. if (!this._isBillboardBased) {
  111141. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  111142. }
  111143. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  111144. if (this.isAnimationSheetEnabled) {
  111145. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  111146. if (this.spriteRandomStartCell) {
  111147. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  111148. }
  111149. }
  111150. if (this.noiseTexture) {
  111151. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  111152. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  111153. }
  111154. this._updateEffectOptions.defines = defines;
  111155. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  111156. };
  111157. /** @hidden */
  111158. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  111159. var defines = "";
  111160. if (this._scene.clipPlane) {
  111161. defines = "\n#define CLIPPLANE";
  111162. }
  111163. if (this._scene.clipPlane2) {
  111164. defines = "\n#define CLIPPLANE2";
  111165. }
  111166. if (this._scene.clipPlane3) {
  111167. defines = "\n#define CLIPPLANE3";
  111168. }
  111169. if (this._scene.clipPlane4) {
  111170. defines = "\n#define CLIPPLANE4";
  111171. }
  111172. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  111173. defines = "\n#define BLENDMULTIPLYMODE";
  111174. }
  111175. if (this._isBillboardBased) {
  111176. defines += "\n#define BILLBOARD";
  111177. switch (this.billboardMode) {
  111178. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  111179. defines += "\n#define BILLBOARDY";
  111180. break;
  111181. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  111182. defines += "\n#define BILLBOARDSTRETCHED";
  111183. break;
  111184. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  111185. default:
  111186. break;
  111187. }
  111188. }
  111189. if (this._colorGradientsTexture) {
  111190. defines += "\n#define COLORGRADIENTS";
  111191. }
  111192. if (this.isAnimationSheetEnabled) {
  111193. defines += "\n#define ANIMATESHEET";
  111194. }
  111195. if (this._imageProcessingConfiguration) {
  111196. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  111197. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  111198. }
  111199. if (this._renderEffect && this._renderEffect.defines === defines) {
  111200. return;
  111201. }
  111202. var uniforms = ["worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  111203. var samplers = ["textureSampler", "colorGradientSampler"];
  111204. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  111205. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  111206. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  111207. }
  111208. 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);
  111209. };
  111210. /**
  111211. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111212. * @param preWarm defines if we are in the pre-warmimg phase
  111213. */
  111214. GPUParticleSystem.prototype.animate = function (preWarm) {
  111215. if (preWarm === void 0) { preWarm = false; }
  111216. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  111217. this._actualFrame += this._timeDelta;
  111218. if (!this._stopped) {
  111219. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  111220. this.stop();
  111221. }
  111222. }
  111223. };
  111224. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  111225. var texture = this[textureName];
  111226. if (!factorGradients || !factorGradients.length || texture) {
  111227. return;
  111228. }
  111229. var data = new Float32Array(this._rawTextureWidth);
  111230. for (var x = 0; x < this._rawTextureWidth; x++) {
  111231. var ratio = x / this._rawTextureWidth;
  111232. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  111233. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  111234. });
  111235. }
  111236. 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);
  111237. };
  111238. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  111239. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  111240. };
  111241. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  111242. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  111243. };
  111244. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  111245. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  111246. };
  111247. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  111248. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  111249. };
  111250. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  111251. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  111252. };
  111253. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  111254. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  111255. return;
  111256. }
  111257. var data = new Uint8Array(this._rawTextureWidth * 4);
  111258. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  111259. for (var x = 0; x < this._rawTextureWidth; x++) {
  111260. var ratio = x / this._rawTextureWidth;
  111261. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  111262. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  111263. data[x * 4] = tmpColor.r * 255;
  111264. data[x * 4 + 1] = tmpColor.g * 255;
  111265. data[x * 4 + 2] = tmpColor.b * 255;
  111266. data[x * 4 + 3] = tmpColor.a * 255;
  111267. });
  111268. }
  111269. 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);
  111270. };
  111271. /**
  111272. * Renders the particle system in its current state
  111273. * @param preWarm defines if the system should only update the particles but not render them
  111274. * @returns the current number of particles
  111275. */
  111276. GPUParticleSystem.prototype.render = function (preWarm) {
  111277. if (preWarm === void 0) { preWarm = false; }
  111278. if (!this._started) {
  111279. return 0;
  111280. }
  111281. this._createColorGradientTexture();
  111282. this._createSizeGradientTexture();
  111283. this._createAngularSpeedGradientTexture();
  111284. this._createVelocityGradientTexture();
  111285. this._createLimitVelocityGradientTexture();
  111286. this._createDragGradientTexture();
  111287. this._recreateUpdateEffect();
  111288. this._recreateRenderEffect();
  111289. if (!this.isReady()) {
  111290. return 0;
  111291. }
  111292. if (!preWarm) {
  111293. if (!this._preWarmDone && this.preWarmCycles) {
  111294. for (var index = 0; index < this.preWarmCycles; index++) {
  111295. this.animate(true);
  111296. this.render(true);
  111297. }
  111298. this._preWarmDone = true;
  111299. }
  111300. if (this._currentRenderId === this._scene.getFrameId()) {
  111301. return 0;
  111302. }
  111303. this._currentRenderId = this._scene.getFrameId();
  111304. }
  111305. // Get everything ready to render
  111306. this._initialize();
  111307. this._accumulatedCount += this.emitRate * this._timeDelta;
  111308. if (this._accumulatedCount > 1) {
  111309. var intPart = this._accumulatedCount | 0;
  111310. this._accumulatedCount -= intPart;
  111311. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  111312. }
  111313. if (!this._currentActiveCount) {
  111314. return 0;
  111315. }
  111316. // Enable update effect
  111317. this._engine.enableEffect(this._updateEffect);
  111318. this._engine.setState(false);
  111319. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  111320. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  111321. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  111322. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  111323. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  111324. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  111325. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  111326. if (!this._colorGradientsTexture) {
  111327. this._updateEffect.setDirectColor4("color1", this.color1);
  111328. this._updateEffect.setDirectColor4("color2", this.color2);
  111329. }
  111330. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  111331. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  111332. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  111333. this._updateEffect.setVector3("gravity", this.gravity);
  111334. if (this._sizeGradientsTexture) {
  111335. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  111336. }
  111337. if (this._angularSpeedGradientsTexture) {
  111338. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  111339. }
  111340. if (this._velocityGradientsTexture) {
  111341. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  111342. }
  111343. if (this._limitVelocityGradientsTexture) {
  111344. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  111345. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  111346. }
  111347. if (this._dragGradientsTexture) {
  111348. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  111349. }
  111350. if (this.particleEmitterType) {
  111351. this.particleEmitterType.applyToShader(this._updateEffect);
  111352. }
  111353. if (this._isAnimationSheetEnabled) {
  111354. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  111355. }
  111356. if (this.noiseTexture) {
  111357. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  111358. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  111359. }
  111360. var emitterWM;
  111361. if (this.emitter.position) {
  111362. var emitterMesh = this.emitter;
  111363. emitterWM = emitterMesh.getWorldMatrix();
  111364. }
  111365. else {
  111366. var emitterPosition = this.emitter;
  111367. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  111368. }
  111369. this._updateEffect.setMatrix("emitterWM", emitterWM);
  111370. // Bind source VAO
  111371. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  111372. // Update
  111373. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  111374. this._engine.setRasterizerState(false);
  111375. this._engine.beginTransformFeedback(true);
  111376. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  111377. this._engine.endTransformFeedback();
  111378. this._engine.setRasterizerState(true);
  111379. this._engine.bindTransformFeedbackBuffer(null);
  111380. if (!preWarm) {
  111381. // Enable render effect
  111382. this._engine.enableEffect(this._renderEffect);
  111383. var viewMatrix = this._scene.getViewMatrix();
  111384. this._renderEffect.setMatrix("view", viewMatrix);
  111385. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  111386. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  111387. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  111388. this._renderEffect.setVector3("worldOffset", this.worldOffset);
  111389. if (this._colorGradientsTexture) {
  111390. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  111391. }
  111392. else {
  111393. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  111394. }
  111395. if (this._isAnimationSheetEnabled && this.particleTexture) {
  111396. var baseSize = this.particleTexture.getBaseSize();
  111397. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  111398. }
  111399. if (this._isBillboardBased) {
  111400. var camera = this._scene.activeCamera;
  111401. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  111402. }
  111403. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  111404. var invView = viewMatrix.clone();
  111405. invView.invert();
  111406. this._renderEffect.setMatrix("invView", invView);
  111407. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  111408. }
  111409. // image processing
  111410. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  111411. this._imageProcessingConfiguration.bind(this._renderEffect);
  111412. }
  111413. // Draw order
  111414. switch (this.blendMode) {
  111415. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  111416. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  111417. break;
  111418. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  111419. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  111420. break;
  111421. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  111422. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  111423. break;
  111424. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  111425. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  111426. break;
  111427. }
  111428. if (this.forceDepthWrite) {
  111429. this._engine.setDepthWrite(true);
  111430. }
  111431. // Bind source VAO
  111432. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  111433. // Render
  111434. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  111435. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  111436. }
  111437. // Switch VAOs
  111438. this._targetIndex++;
  111439. if (this._targetIndex === 2) {
  111440. this._targetIndex = 0;
  111441. }
  111442. // Switch buffers
  111443. var tmpBuffer = this._sourceBuffer;
  111444. this._sourceBuffer = this._targetBuffer;
  111445. this._targetBuffer = tmpBuffer;
  111446. return this._currentActiveCount;
  111447. };
  111448. /**
  111449. * Rebuilds the particle system
  111450. */
  111451. GPUParticleSystem.prototype.rebuild = function () {
  111452. this._initialize(true);
  111453. };
  111454. GPUParticleSystem.prototype._releaseBuffers = function () {
  111455. if (this._buffer0) {
  111456. this._buffer0.dispose();
  111457. this._buffer0 = null;
  111458. }
  111459. if (this._buffer1) {
  111460. this._buffer1.dispose();
  111461. this._buffer1 = null;
  111462. }
  111463. if (this._spriteBuffer) {
  111464. this._spriteBuffer.dispose();
  111465. this._spriteBuffer = null;
  111466. }
  111467. };
  111468. GPUParticleSystem.prototype._releaseVAOs = function () {
  111469. if (!this._updateVAO) {
  111470. return;
  111471. }
  111472. for (var index = 0; index < this._updateVAO.length; index++) {
  111473. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  111474. }
  111475. this._updateVAO = [];
  111476. for (var index = 0; index < this._renderVAO.length; index++) {
  111477. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  111478. }
  111479. this._renderVAO = [];
  111480. };
  111481. /**
  111482. * Disposes the particle system and free the associated resources
  111483. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111484. */
  111485. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  111486. if (disposeTexture === void 0) { disposeTexture = true; }
  111487. var index = this._scene.particleSystems.indexOf(this);
  111488. if (index > -1) {
  111489. this._scene.particleSystems.splice(index, 1);
  111490. }
  111491. this._releaseBuffers();
  111492. this._releaseVAOs();
  111493. if (this._colorGradientsTexture) {
  111494. this._colorGradientsTexture.dispose();
  111495. this._colorGradientsTexture = null;
  111496. }
  111497. if (this._sizeGradientsTexture) {
  111498. this._sizeGradientsTexture.dispose();
  111499. this._sizeGradientsTexture = null;
  111500. }
  111501. if (this._angularSpeedGradientsTexture) {
  111502. this._angularSpeedGradientsTexture.dispose();
  111503. this._angularSpeedGradientsTexture = null;
  111504. }
  111505. if (this._velocityGradientsTexture) {
  111506. this._velocityGradientsTexture.dispose();
  111507. this._velocityGradientsTexture = null;
  111508. }
  111509. if (this._limitVelocityGradientsTexture) {
  111510. this._limitVelocityGradientsTexture.dispose();
  111511. this._limitVelocityGradientsTexture = null;
  111512. }
  111513. if (this._dragGradientsTexture) {
  111514. this._dragGradientsTexture.dispose();
  111515. this._dragGradientsTexture = null;
  111516. }
  111517. if (this._randomTexture) {
  111518. this._randomTexture.dispose();
  111519. this._randomTexture = null;
  111520. }
  111521. if (this._randomTexture2) {
  111522. this._randomTexture2.dispose();
  111523. this._randomTexture2 = null;
  111524. }
  111525. if (disposeTexture && this.particleTexture) {
  111526. this.particleTexture.dispose();
  111527. this.particleTexture = null;
  111528. }
  111529. if (disposeTexture && this.noiseTexture) {
  111530. this.noiseTexture.dispose();
  111531. this.noiseTexture = null;
  111532. }
  111533. // Callback
  111534. this.onDisposeObservable.notifyObservers(this);
  111535. this.onDisposeObservable.clear();
  111536. };
  111537. /**
  111538. * Clones the particle system.
  111539. * @param name The name of the cloned object
  111540. * @param newEmitter The new emitter to use
  111541. * @returns the cloned particle system
  111542. */
  111543. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  111544. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  111545. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  111546. if (newEmitter === undefined) {
  111547. newEmitter = this.emitter;
  111548. }
  111549. result.emitter = newEmitter;
  111550. if (this.particleTexture) {
  111551. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  111552. }
  111553. return result;
  111554. };
  111555. /**
  111556. * Serializes the particle system to a JSON object.
  111557. * @returns the JSON object
  111558. */
  111559. GPUParticleSystem.prototype.serialize = function () {
  111560. var serializationObject = {};
  111561. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  111562. serializationObject.activeParticleCount = this.activeParticleCount;
  111563. return serializationObject;
  111564. };
  111565. /**
  111566. * Parses a JSON object to create a GPU particle system.
  111567. * @param parsedParticleSystem The JSON object to parse
  111568. * @param scene The scene to create the particle system in
  111569. * @param rootUrl The root url to use to load external dependencies like texture
  111570. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111571. * @returns the parsed GPU particle system
  111572. */
  111573. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  111574. if (doNotStart === void 0) { doNotStart = false; }
  111575. var name = parsedParticleSystem.name;
  111576. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  111577. if (parsedParticleSystem.activeParticleCount) {
  111578. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  111579. }
  111580. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  111581. // Auto start
  111582. if (parsedParticleSystem.preventAutoStart) {
  111583. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  111584. }
  111585. if (!doNotStart && !particleSystem.preventAutoStart) {
  111586. particleSystem.start();
  111587. }
  111588. return particleSystem;
  111589. };
  111590. return GPUParticleSystem;
  111591. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  111592. /***/ }),
  111593. /***/ "./Particles/index.ts":
  111594. /*!****************************!*\
  111595. !*** ./Particles/index.ts ***!
  111596. \****************************/
  111597. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  111598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111599. "use strict";
  111600. __webpack_require__.r(__webpack_exports__);
  111601. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  111602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  111603. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  111604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  111605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  111606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  111607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  111608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  111609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  111610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  111611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  111612. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  111613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  111614. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  111615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  111616. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  111617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  111618. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  111619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  111620. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  111621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  111622. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  111623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  111624. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  111625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  111626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  111627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  111628. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  111629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  111630. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  111631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  111632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  111633. /***/ }),
  111634. /***/ "./Particles/particle.ts":
  111635. /*!*******************************!*\
  111636. !*** ./Particles/particle.ts ***!
  111637. \*******************************/
  111638. /*! exports provided: Particle */
  111639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111640. "use strict";
  111641. __webpack_require__.r(__webpack_exports__);
  111642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  111643. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111644. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  111645. /**
  111646. * A particle represents one of the element emitted by a particle system.
  111647. * This is mainly define by its coordinates, direction, velocity and age.
  111648. */
  111649. var Particle = /** @class */ (function () {
  111650. /**
  111651. * Creates a new instance Particle
  111652. * @param particleSystem the particle system the particle belongs to
  111653. */
  111654. function Particle(
  111655. /**
  111656. * The particle system the particle belongs to.
  111657. */
  111658. particleSystem) {
  111659. this.particleSystem = particleSystem;
  111660. /**
  111661. * The world position of the particle in the scene.
  111662. */
  111663. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111664. /**
  111665. * The world direction of the particle in the scene.
  111666. */
  111667. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111668. /**
  111669. * The color of the particle.
  111670. */
  111671. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  111672. /**
  111673. * The color change of the particle per step.
  111674. */
  111675. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  111676. /**
  111677. * Defines how long will the life of the particle be.
  111678. */
  111679. this.lifeTime = 1.0;
  111680. /**
  111681. * The current age of the particle.
  111682. */
  111683. this.age = 0;
  111684. /**
  111685. * The current size of the particle.
  111686. */
  111687. this.size = 0;
  111688. /**
  111689. * The current scale of the particle.
  111690. */
  111691. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  111692. /**
  111693. * The current angle of the particle.
  111694. */
  111695. this.angle = 0;
  111696. /**
  111697. * Defines how fast is the angle changing.
  111698. */
  111699. this.angularSpeed = 0;
  111700. /**
  111701. * Defines the cell index used by the particle to be rendered from a sprite.
  111702. */
  111703. this.cellIndex = 0;
  111704. /** @hidden */
  111705. this._attachedSubEmitters = null;
  111706. /** @hidden */
  111707. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  111708. /** @hidden */
  111709. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  111710. /** @hidden */
  111711. this._currentSize1 = 0;
  111712. /** @hidden */
  111713. this._currentSize2 = 0;
  111714. /** @hidden */
  111715. this._currentAngularSpeed1 = 0;
  111716. /** @hidden */
  111717. this._currentAngularSpeed2 = 0;
  111718. /** @hidden */
  111719. this._currentVelocity1 = 0;
  111720. /** @hidden */
  111721. this._currentVelocity2 = 0;
  111722. /** @hidden */
  111723. this._currentLimitVelocity1 = 0;
  111724. /** @hidden */
  111725. this._currentLimitVelocity2 = 0;
  111726. /** @hidden */
  111727. this._currentDrag1 = 0;
  111728. /** @hidden */
  111729. this._currentDrag2 = 0;
  111730. this.id = Particle._Count++;
  111731. if (!this.particleSystem.isAnimationSheetEnabled) {
  111732. return;
  111733. }
  111734. this.updateCellInfoFromSystem();
  111735. }
  111736. Particle.prototype.updateCellInfoFromSystem = function () {
  111737. this.cellIndex = this.particleSystem.startSpriteCellID;
  111738. };
  111739. /**
  111740. * Defines how the sprite cell index is updated for the particle
  111741. */
  111742. Particle.prototype.updateCellIndex = function () {
  111743. var offsetAge = this.age;
  111744. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  111745. if (this.particleSystem.spriteRandomStartCell) {
  111746. if (this._randomCellOffset === undefined) {
  111747. this._randomCellOffset = Math.random() * this.lifeTime;
  111748. }
  111749. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  111750. changeSpeed = 1;
  111751. offsetAge = this._randomCellOffset;
  111752. }
  111753. else {
  111754. offsetAge += this._randomCellOffset;
  111755. }
  111756. }
  111757. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  111758. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  111759. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  111760. };
  111761. /** @hidden */
  111762. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  111763. if (subEmitter.particleSystem.emitter.position) {
  111764. var emitterMesh = subEmitter.particleSystem.emitter;
  111765. emitterMesh.position.copyFrom(this.position);
  111766. if (subEmitter.inheritDirection) {
  111767. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  111768. // Look at using Y as forward
  111769. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  111770. }
  111771. }
  111772. else {
  111773. var emitterPosition = subEmitter.particleSystem.emitter;
  111774. emitterPosition.copyFrom(this.position);
  111775. }
  111776. // Set inheritedVelocityOffset to be used when new particles are created
  111777. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  111778. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  111779. };
  111780. /** @hidden */
  111781. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  111782. var _this = this;
  111783. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  111784. this._attachedSubEmitters.forEach(function (subEmitter) {
  111785. _this._inheritParticleInfoToSubEmitter(subEmitter);
  111786. });
  111787. }
  111788. };
  111789. /** @hidden */
  111790. Particle.prototype._reset = function () {
  111791. this.age = 0;
  111792. this._currentColorGradient = null;
  111793. this._currentSizeGradient = null;
  111794. this._currentAngularSpeedGradient = null;
  111795. this._currentVelocityGradient = null;
  111796. this._currentLimitVelocityGradient = null;
  111797. this._currentDragGradient = null;
  111798. this.cellIndex = this.particleSystem.startSpriteCellID;
  111799. this._randomCellOffset = undefined;
  111800. };
  111801. /**
  111802. * Copy the properties of particle to another one.
  111803. * @param other the particle to copy the information to.
  111804. */
  111805. Particle.prototype.copyTo = function (other) {
  111806. other.position.copyFrom(this.position);
  111807. if (this._initialDirection) {
  111808. if (other._initialDirection) {
  111809. other._initialDirection.copyFrom(this._initialDirection);
  111810. }
  111811. else {
  111812. other._initialDirection = this._initialDirection.clone();
  111813. }
  111814. }
  111815. else {
  111816. other._initialDirection = null;
  111817. }
  111818. other.direction.copyFrom(this.direction);
  111819. other.color.copyFrom(this.color);
  111820. other.colorStep.copyFrom(this.colorStep);
  111821. other.lifeTime = this.lifeTime;
  111822. other.age = this.age;
  111823. other._randomCellOffset = this._randomCellOffset;
  111824. other.size = this.size;
  111825. other.scale.copyFrom(this.scale);
  111826. other.angle = this.angle;
  111827. other.angularSpeed = this.angularSpeed;
  111828. other.particleSystem = this.particleSystem;
  111829. other.cellIndex = this.cellIndex;
  111830. other.id = this.id;
  111831. other._attachedSubEmitters = this._attachedSubEmitters;
  111832. if (this._currentColorGradient) {
  111833. other._currentColorGradient = this._currentColorGradient;
  111834. other._currentColor1.copyFrom(this._currentColor1);
  111835. other._currentColor2.copyFrom(this._currentColor2);
  111836. }
  111837. if (this._currentSizeGradient) {
  111838. other._currentSizeGradient = this._currentSizeGradient;
  111839. other._currentSize1 = this._currentSize1;
  111840. other._currentSize2 = this._currentSize2;
  111841. }
  111842. if (this._currentAngularSpeedGradient) {
  111843. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  111844. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  111845. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  111846. }
  111847. if (this._currentVelocityGradient) {
  111848. other._currentVelocityGradient = this._currentVelocityGradient;
  111849. other._currentVelocity1 = this._currentVelocity1;
  111850. other._currentVelocity2 = this._currentVelocity2;
  111851. }
  111852. if (this._currentLimitVelocityGradient) {
  111853. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  111854. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  111855. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  111856. }
  111857. if (this._currentDragGradient) {
  111858. other._currentDragGradient = this._currentDragGradient;
  111859. other._currentDrag1 = this._currentDrag1;
  111860. other._currentDrag2 = this._currentDrag2;
  111861. }
  111862. if (this.particleSystem.isAnimationSheetEnabled) {
  111863. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  111864. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  111865. }
  111866. if (this.particleSystem.useRampGradients) {
  111867. other.remapData.copyFrom(this.remapData);
  111868. }
  111869. if (this._randomNoiseCoordinates1) {
  111870. if (other._randomNoiseCoordinates1) {
  111871. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  111872. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  111873. }
  111874. else {
  111875. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  111876. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  111877. }
  111878. }
  111879. };
  111880. Particle._Count = 0;
  111881. return Particle;
  111882. }());
  111883. /***/ }),
  111884. /***/ "./Particles/particleHelper.ts":
  111885. /*!*************************************!*\
  111886. !*** ./Particles/particleHelper.ts ***!
  111887. \*************************************/
  111888. /*! exports provided: ParticleHelper */
  111889. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111890. "use strict";
  111891. __webpack_require__.r(__webpack_exports__);
  111892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  111893. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  111894. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111895. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  111896. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  111897. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  111898. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  111899. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  111900. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  111901. /**
  111902. * This class is made for on one-liner static method to help creating particle system set.
  111903. */
  111904. var ParticleHelper = /** @class */ (function () {
  111905. function ParticleHelper() {
  111906. }
  111907. /**
  111908. * Create a default particle system that you can tweak
  111909. * @param emitter defines the emitter to use
  111910. * @param capacity defines the system capacity (default is 500 particles)
  111911. * @param scene defines the hosting scene
  111912. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111913. * @returns the new Particle system
  111914. */
  111915. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  111916. if (capacity === void 0) { capacity = 500; }
  111917. if (useGPU === void 0) { useGPU = false; }
  111918. var system;
  111919. if (useGPU) {
  111920. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  111921. }
  111922. else {
  111923. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  111924. }
  111925. system.emitter = emitter;
  111926. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  111927. system.createConeEmitter(0.1, Math.PI / 4);
  111928. // Particle color
  111929. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  111930. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  111931. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  111932. // Particle Size
  111933. system.minSize = 0.1;
  111934. system.maxSize = 0.1;
  111935. // Emission speed
  111936. system.minEmitPower = 2;
  111937. system.maxEmitPower = 2;
  111938. // Update speed
  111939. system.updateSpeed = 1 / 60;
  111940. system.emitRate = 30;
  111941. return system;
  111942. };
  111943. /**
  111944. * This is the main static method (one-liner) of this helper to create different particle systems
  111945. * @param type This string represents the type to the particle system to create
  111946. * @param scene The scene where the particle system should live
  111947. * @param gpu If the system will use gpu
  111948. * @returns the ParticleSystemSet created
  111949. */
  111950. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  111951. if (gpu === void 0) { gpu = false; }
  111952. if (!scene) {
  111953. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  111954. }
  111955. var token = {};
  111956. scene._addPendingData(token);
  111957. return new Promise(function (resolve, reject) {
  111958. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  111959. scene._removePendingData(token);
  111960. return reject("Particle system with GPU is not supported.");
  111961. }
  111962. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  111963. scene._removePendingData(token);
  111964. var newData = JSON.parse(data.toString());
  111965. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  111966. }, undefined, undefined, undefined, function () {
  111967. scene._removePendingData(token);
  111968. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  111969. });
  111970. });
  111971. };
  111972. /**
  111973. * Static function used to export a particle system to a ParticleSystemSet variable.
  111974. * Please note that the emitter shape is not exported
  111975. * @param systems defines the particle systems to export
  111976. * @returns the created particle system set
  111977. */
  111978. ParticleHelper.ExportSet = function (systems) {
  111979. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  111980. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  111981. var system = systems_1[_i];
  111982. set.systems.push(system);
  111983. }
  111984. return set;
  111985. };
  111986. /**
  111987. * Gets or sets base Assets URL
  111988. */
  111989. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  111990. return ParticleHelper;
  111991. }());
  111992. /***/ }),
  111993. /***/ "./Particles/particleSystem.ts":
  111994. /*!*************************************!*\
  111995. !*** ./Particles/particleSystem.ts ***!
  111996. \*************************************/
  111997. /*! exports provided: ParticleSystem */
  111998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111999. "use strict";
  112000. __webpack_require__.r(__webpack_exports__);
  112001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  112002. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112003. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  112004. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  112005. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112006. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  112007. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  112008. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  112009. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  112010. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  112011. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  112012. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  112013. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  112014. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  112015. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  112016. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  112017. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  112018. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  112019. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  112020. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  112021. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  112022. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  112023. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  112024. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  112025. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  112026. /**
  112027. * This represents a particle system in Babylon.
  112028. * 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.
  112029. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  112030. * @example https://doc.babylonjs.com/babylon101/particles
  112031. */
  112032. var ParticleSystem = /** @class */ (function (_super) {
  112033. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  112034. /**
  112035. * Instantiates a particle system.
  112036. * 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.
  112037. * @param name The name of the particle system
  112038. * @param capacity The max number of particles alive at the same time
  112039. * @param scene The scene the particle system belongs to
  112040. * @param customEffect a custom effect used to change the way particles are rendered by default
  112041. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  112042. * @param epsilon Offset used to render the particles
  112043. */
  112044. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  112045. if (customEffect === void 0) { customEffect = null; }
  112046. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  112047. if (epsilon === void 0) { epsilon = 0.01; }
  112048. var _this = _super.call(this, name) || this;
  112049. /**
  112050. * @hidden
  112051. */
  112052. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  112053. /**
  112054. * An event triggered when the system is disposed
  112055. */
  112056. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  112057. _this._particles = new Array();
  112058. _this._stockParticles = new Array();
  112059. _this._newPartsExcess = 0;
  112060. _this._vertexBuffers = {};
  112061. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  112062. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  112063. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  112064. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  112065. _this._currentRenderId = -1;
  112066. _this._useInstancing = false;
  112067. _this._started = false;
  112068. _this._stopped = false;
  112069. _this._actualFrame = 0;
  112070. /** @hidden */
  112071. _this._currentEmitRate1 = 0;
  112072. /** @hidden */
  112073. _this._currentEmitRate2 = 0;
  112074. /** @hidden */
  112075. _this._currentStartSize1 = 0;
  112076. /** @hidden */
  112077. _this._currentStartSize2 = 0;
  112078. _this._rawTextureWidth = 256;
  112079. _this._useRampGradients = false;
  112080. /**
  112081. * @hidden
  112082. * If the particle systems emitter should be disposed when the particle system is disposed
  112083. */
  112084. _this._disposeEmitterOnDispose = false;
  112085. // start of sub system methods
  112086. /**
  112087. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  112088. * Its lifetime will start back at 0.
  112089. */
  112090. _this.recycleParticle = function (particle) {
  112091. // move particle from activeParticle list to stock particles
  112092. var lastParticle = _this._particles.pop();
  112093. if (lastParticle !== particle) {
  112094. lastParticle.copyTo(particle);
  112095. }
  112096. _this._stockParticles.push(lastParticle);
  112097. };
  112098. _this._createParticle = function () {
  112099. var particle;
  112100. if (_this._stockParticles.length !== 0) {
  112101. particle = _this._stockParticles.pop();
  112102. particle._reset();
  112103. }
  112104. else {
  112105. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  112106. }
  112107. // Attach emitters
  112108. if (_this._subEmitters && _this._subEmitters.length > 0) {
  112109. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  112110. particle._attachedSubEmitters = [];
  112111. subEmitters.forEach(function (subEmitter) {
  112112. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  112113. var newEmitter = subEmitter.clone();
  112114. particle._attachedSubEmitters.push(newEmitter);
  112115. newEmitter.particleSystem.start();
  112116. }
  112117. });
  112118. }
  112119. return particle;
  112120. };
  112121. _this._emitFromParticle = function (particle) {
  112122. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  112123. return;
  112124. }
  112125. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  112126. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  112127. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  112128. var subSystem = subEmitter.clone();
  112129. particle._inheritParticleInfoToSubEmitter(subSystem);
  112130. subSystem.particleSystem._rootParticleSystem = _this;
  112131. _this.activeSubSystems.push(subSystem.particleSystem);
  112132. subSystem.particleSystem.start();
  112133. }
  112134. });
  112135. };
  112136. _this._capacity = capacity;
  112137. _this._epsilon = epsilon;
  112138. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  112139. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  112140. // Setup the default processing configuration to the scene.
  112141. _this._attachImageProcessingConfiguration(null);
  112142. _this._customEffect = customEffect;
  112143. _this._scene.particleSystems.push(_this);
  112144. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  112145. _this._createIndexBuffer();
  112146. _this._createVertexBuffers();
  112147. // Default emitter type
  112148. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  112149. // Update
  112150. _this.updateFunction = function (particles) {
  112151. var noiseTextureSize = null;
  112152. var noiseTextureData = null;
  112153. if (_this.noiseTexture) { // We need to get texture data back to CPU
  112154. noiseTextureSize = _this.noiseTexture.getSize();
  112155. noiseTextureData = (_this.noiseTexture.getContent());
  112156. }
  112157. var _loop_1 = function () {
  112158. particle = particles[index];
  112159. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  112160. var previousAge = particle.age;
  112161. particle.age += scaledUpdateSpeed;
  112162. // Evaluate step to death
  112163. if (particle.age > particle.lifeTime) {
  112164. var diff = particle.age - previousAge;
  112165. var oldDiff = particle.lifeTime - previousAge;
  112166. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  112167. particle.age = particle.lifeTime;
  112168. }
  112169. var ratio = particle.age / particle.lifeTime;
  112170. // Color
  112171. if (_this._colorGradients && _this._colorGradients.length > 0) {
  112172. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  112173. if (currentGradient !== particle._currentColorGradient) {
  112174. particle._currentColor1.copyFrom(particle._currentColor2);
  112175. nextGradient.getColorToRef(particle._currentColor2);
  112176. particle._currentColorGradient = currentGradient;
  112177. }
  112178. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  112179. });
  112180. }
  112181. else {
  112182. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  112183. particle.color.addInPlace(_this._scaledColorStep);
  112184. if (particle.color.a < 0) {
  112185. particle.color.a = 0;
  112186. }
  112187. }
  112188. // Angular speed
  112189. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  112190. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  112191. if (currentGradient !== particle._currentAngularSpeedGradient) {
  112192. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  112193. particle._currentAngularSpeed2 = nextGradient.getFactor();
  112194. particle._currentAngularSpeedGradient = currentGradient;
  112195. }
  112196. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  112197. });
  112198. }
  112199. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  112200. // Direction
  112201. var directionScale = scaledUpdateSpeed;
  112202. /// Velocity
  112203. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  112204. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  112205. if (currentGradient !== particle._currentVelocityGradient) {
  112206. particle._currentVelocity1 = particle._currentVelocity2;
  112207. particle._currentVelocity2 = nextGradient.getFactor();
  112208. particle._currentVelocityGradient = currentGradient;
  112209. }
  112210. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  112211. });
  112212. }
  112213. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  112214. /// Limit velocity
  112215. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  112216. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  112217. if (currentGradient !== particle._currentLimitVelocityGradient) {
  112218. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  112219. particle._currentLimitVelocity2 = nextGradient.getFactor();
  112220. particle._currentLimitVelocityGradient = currentGradient;
  112221. }
  112222. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  112223. var currentVelocity = particle.direction.length();
  112224. if (currentVelocity > limitVelocity) {
  112225. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  112226. }
  112227. });
  112228. }
  112229. /// Drag
  112230. if (_this._dragGradients && _this._dragGradients.length > 0) {
  112231. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  112232. if (currentGradient !== particle._currentDragGradient) {
  112233. particle._currentDrag1 = particle._currentDrag2;
  112234. particle._currentDrag2 = nextGradient.getFactor();
  112235. particle._currentDragGradient = currentGradient;
  112236. }
  112237. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  112238. _this._scaledDirection.scaleInPlace(1.0 - drag);
  112239. });
  112240. }
  112241. particle.position.addInPlace(_this._scaledDirection);
  112242. // Noise
  112243. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  112244. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  112245. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  112246. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  112247. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  112248. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  112249. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  112250. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  112251. particle.direction.addInPlace(scaledForce);
  112252. }
  112253. // Gravity
  112254. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  112255. particle.direction.addInPlace(_this._scaledGravity);
  112256. // Size
  112257. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  112258. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  112259. if (currentGradient !== particle._currentSizeGradient) {
  112260. particle._currentSize1 = particle._currentSize2;
  112261. particle._currentSize2 = nextGradient.getFactor();
  112262. particle._currentSizeGradient = currentGradient;
  112263. }
  112264. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  112265. });
  112266. }
  112267. // Remap data
  112268. if (_this._useRampGradients) {
  112269. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  112270. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  112271. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  112272. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  112273. particle.remapData.x = min;
  112274. particle.remapData.y = max - min;
  112275. });
  112276. }
  112277. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  112278. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  112279. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  112280. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  112281. particle.remapData.z = min;
  112282. particle.remapData.w = max - min;
  112283. });
  112284. }
  112285. }
  112286. if (_this._isAnimationSheetEnabled) {
  112287. particle.updateCellIndex();
  112288. }
  112289. // Update the position of the attached sub-emitters to match their attached particle
  112290. particle._inheritParticleInfoToSubEmitters();
  112291. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  112292. _this._emitFromParticle(particle);
  112293. if (particle._attachedSubEmitters) {
  112294. particle._attachedSubEmitters.forEach(function (subEmitter) {
  112295. subEmitter.particleSystem.disposeOnStop = true;
  112296. subEmitter.particleSystem.stop();
  112297. });
  112298. particle._attachedSubEmitters = null;
  112299. }
  112300. _this.recycleParticle(particle);
  112301. index--;
  112302. return "continue";
  112303. }
  112304. };
  112305. var particle;
  112306. for (var index = 0; index < particles.length; index++) {
  112307. _loop_1();
  112308. }
  112309. };
  112310. return _this;
  112311. }
  112312. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  112313. /**
  112314. * Sets a callback that will be triggered when the system is disposed
  112315. */
  112316. set: function (callback) {
  112317. if (this._onDisposeObserver) {
  112318. this.onDisposeObservable.remove(this._onDisposeObserver);
  112319. }
  112320. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  112321. },
  112322. enumerable: true,
  112323. configurable: true
  112324. });
  112325. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  112326. /** Gets or sets a boolean indicating that ramp gradients must be used
  112327. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  112328. */
  112329. get: function () {
  112330. return this._useRampGradients;
  112331. },
  112332. set: function (value) {
  112333. if (this._useRampGradients === value) {
  112334. return;
  112335. }
  112336. this._useRampGradients = value;
  112337. this._resetEffect();
  112338. },
  112339. enumerable: true,
  112340. configurable: true
  112341. });
  112342. Object.defineProperty(ParticleSystem.prototype, "particles", {
  112343. //end of Sub-emitter
  112344. /**
  112345. * Gets the current list of active particles
  112346. */
  112347. get: function () {
  112348. return this._particles;
  112349. },
  112350. enumerable: true,
  112351. configurable: true
  112352. });
  112353. /**
  112354. * Returns the string "ParticleSystem"
  112355. * @returns a string containing the class name
  112356. */
  112357. ParticleSystem.prototype.getClassName = function () {
  112358. return "ParticleSystem";
  112359. };
  112360. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  112361. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  112362. newGradient.gradient = gradient;
  112363. newGradient.factor1 = factor;
  112364. newGradient.factor2 = factor2;
  112365. factorGradients.push(newGradient);
  112366. factorGradients.sort(function (a, b) {
  112367. if (a.gradient < b.gradient) {
  112368. return -1;
  112369. }
  112370. else if (a.gradient > b.gradient) {
  112371. return 1;
  112372. }
  112373. return 0;
  112374. });
  112375. };
  112376. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  112377. if (!factorGradients) {
  112378. return;
  112379. }
  112380. var index = 0;
  112381. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  112382. var factorGradient = factorGradients_1[_i];
  112383. if (factorGradient.gradient === gradient) {
  112384. factorGradients.splice(index, 1);
  112385. break;
  112386. }
  112387. index++;
  112388. }
  112389. };
  112390. /**
  112391. * Adds a new life time gradient
  112392. * @param gradient defines the gradient to use (between 0 and 1)
  112393. * @param factor defines the life time factor to affect to the specified gradient
  112394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  112395. * @returns the current particle system
  112396. */
  112397. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  112398. if (!this._lifeTimeGradients) {
  112399. this._lifeTimeGradients = [];
  112400. }
  112401. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  112402. return this;
  112403. };
  112404. /**
  112405. * Remove a specific life time gradient
  112406. * @param gradient defines the gradient to remove
  112407. * @returns the current particle system
  112408. */
  112409. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  112410. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  112411. return this;
  112412. };
  112413. /**
  112414. * Adds a new size gradient
  112415. * @param gradient defines the gradient to use (between 0 and 1)
  112416. * @param factor defines the size factor to affect to the specified gradient
  112417. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  112418. * @returns the current particle system
  112419. */
  112420. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  112421. if (!this._sizeGradients) {
  112422. this._sizeGradients = [];
  112423. }
  112424. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  112425. return this;
  112426. };
  112427. /**
  112428. * Remove a specific size gradient
  112429. * @param gradient defines the gradient to remove
  112430. * @returns the current particle system
  112431. */
  112432. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  112433. this._removeFactorGradient(this._sizeGradients, gradient);
  112434. return this;
  112435. };
  112436. /**
  112437. * Adds a new color remap gradient
  112438. * @param gradient defines the gradient to use (between 0 and 1)
  112439. * @param min defines the color remap minimal range
  112440. * @param max defines the color remap maximal range
  112441. * @returns the current particle system
  112442. */
  112443. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  112444. if (!this._colorRemapGradients) {
  112445. this._colorRemapGradients = [];
  112446. }
  112447. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  112448. return this;
  112449. };
  112450. /**
  112451. * Remove a specific color remap gradient
  112452. * @param gradient defines the gradient to remove
  112453. * @returns the current particle system
  112454. */
  112455. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  112456. this._removeFactorGradient(this._colorRemapGradients, gradient);
  112457. return this;
  112458. };
  112459. /**
  112460. * Adds a new alpha remap gradient
  112461. * @param gradient defines the gradient to use (between 0 and 1)
  112462. * @param min defines the alpha remap minimal range
  112463. * @param max defines the alpha remap maximal range
  112464. * @returns the current particle system
  112465. */
  112466. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  112467. if (!this._alphaRemapGradients) {
  112468. this._alphaRemapGradients = [];
  112469. }
  112470. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  112471. return this;
  112472. };
  112473. /**
  112474. * Remove a specific alpha remap gradient
  112475. * @param gradient defines the gradient to remove
  112476. * @returns the current particle system
  112477. */
  112478. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  112479. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  112480. return this;
  112481. };
  112482. /**
  112483. * Adds a new angular speed gradient
  112484. * @param gradient defines the gradient to use (between 0 and 1)
  112485. * @param factor defines the angular speed to affect to the specified gradient
  112486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  112487. * @returns the current particle system
  112488. */
  112489. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  112490. if (!this._angularSpeedGradients) {
  112491. this._angularSpeedGradients = [];
  112492. }
  112493. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  112494. return this;
  112495. };
  112496. /**
  112497. * Remove a specific angular speed gradient
  112498. * @param gradient defines the gradient to remove
  112499. * @returns the current particle system
  112500. */
  112501. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  112502. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  112503. return this;
  112504. };
  112505. /**
  112506. * Adds a new velocity gradient
  112507. * @param gradient defines the gradient to use (between 0 and 1)
  112508. * @param factor defines the velocity to affect to the specified gradient
  112509. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  112510. * @returns the current particle system
  112511. */
  112512. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  112513. if (!this._velocityGradients) {
  112514. this._velocityGradients = [];
  112515. }
  112516. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  112517. return this;
  112518. };
  112519. /**
  112520. * Remove a specific velocity gradient
  112521. * @param gradient defines the gradient to remove
  112522. * @returns the current particle system
  112523. */
  112524. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  112525. this._removeFactorGradient(this._velocityGradients, gradient);
  112526. return this;
  112527. };
  112528. /**
  112529. * Adds a new limit velocity gradient
  112530. * @param gradient defines the gradient to use (between 0 and 1)
  112531. * @param factor defines the limit velocity value to affect to the specified gradient
  112532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  112533. * @returns the current particle system
  112534. */
  112535. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  112536. if (!this._limitVelocityGradients) {
  112537. this._limitVelocityGradients = [];
  112538. }
  112539. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  112540. return this;
  112541. };
  112542. /**
  112543. * Remove a specific limit velocity gradient
  112544. * @param gradient defines the gradient to remove
  112545. * @returns the current particle system
  112546. */
  112547. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  112548. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  112549. return this;
  112550. };
  112551. /**
  112552. * Adds a new drag gradient
  112553. * @param gradient defines the gradient to use (between 0 and 1)
  112554. * @param factor defines the drag value to affect to the specified gradient
  112555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  112556. * @returns the current particle system
  112557. */
  112558. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  112559. if (!this._dragGradients) {
  112560. this._dragGradients = [];
  112561. }
  112562. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  112563. return this;
  112564. };
  112565. /**
  112566. * Remove a specific drag gradient
  112567. * @param gradient defines the gradient to remove
  112568. * @returns the current particle system
  112569. */
  112570. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  112571. this._removeFactorGradient(this._dragGradients, gradient);
  112572. return this;
  112573. };
  112574. /**
  112575. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  112576. * @param gradient defines the gradient to use (between 0 and 1)
  112577. * @param factor defines the emit rate value to affect to the specified gradient
  112578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  112579. * @returns the current particle system
  112580. */
  112581. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  112582. if (!this._emitRateGradients) {
  112583. this._emitRateGradients = [];
  112584. }
  112585. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  112586. return this;
  112587. };
  112588. /**
  112589. * Remove a specific emit rate gradient
  112590. * @param gradient defines the gradient to remove
  112591. * @returns the current particle system
  112592. */
  112593. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  112594. this._removeFactorGradient(this._emitRateGradients, gradient);
  112595. return this;
  112596. };
  112597. /**
  112598. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  112599. * @param gradient defines the gradient to use (between 0 and 1)
  112600. * @param factor defines the start size value to affect to the specified gradient
  112601. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  112602. * @returns the current particle system
  112603. */
  112604. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  112605. if (!this._startSizeGradients) {
  112606. this._startSizeGradients = [];
  112607. }
  112608. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  112609. return this;
  112610. };
  112611. /**
  112612. * Remove a specific start size gradient
  112613. * @param gradient defines the gradient to remove
  112614. * @returns the current particle system
  112615. */
  112616. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  112617. this._removeFactorGradient(this._emitRateGradients, gradient);
  112618. return this;
  112619. };
  112620. ParticleSystem.prototype._createRampGradientTexture = function () {
  112621. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  112622. return;
  112623. }
  112624. var data = new Uint8Array(this._rawTextureWidth * 4);
  112625. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  112626. for (var x = 0; x < this._rawTextureWidth; x++) {
  112627. var ratio = x / this._rawTextureWidth;
  112628. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  112629. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  112630. data[x * 4] = tmpColor.r * 255;
  112631. data[x * 4 + 1] = tmpColor.g * 255;
  112632. data[x * 4 + 2] = tmpColor.b * 255;
  112633. data[x * 4 + 3] = 255;
  112634. });
  112635. }
  112636. 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);
  112637. };
  112638. /**
  112639. * Gets the current list of ramp gradients.
  112640. * You must use addRampGradient and removeRampGradient to udpate this list
  112641. * @returns the list of ramp gradients
  112642. */
  112643. ParticleSystem.prototype.getRampGradients = function () {
  112644. return this._rampGradients;
  112645. };
  112646. /**
  112647. * Adds a new ramp gradient used to remap particle colors
  112648. * @param gradient defines the gradient to use (between 0 and 1)
  112649. * @param color defines the color to affect to the specified gradient
  112650. * @returns the current particle system
  112651. */
  112652. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  112653. if (!this._rampGradients) {
  112654. this._rampGradients = [];
  112655. }
  112656. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  112657. rampGradient.gradient = gradient;
  112658. rampGradient.color = color;
  112659. this._rampGradients.push(rampGradient);
  112660. this._rampGradients.sort(function (a, b) {
  112661. if (a.gradient < b.gradient) {
  112662. return -1;
  112663. }
  112664. else if (a.gradient > b.gradient) {
  112665. return 1;
  112666. }
  112667. return 0;
  112668. });
  112669. if (this._rampGradientsTexture) {
  112670. this._rampGradientsTexture.dispose();
  112671. this._rampGradientsTexture = null;
  112672. }
  112673. this._createRampGradientTexture();
  112674. return this;
  112675. };
  112676. /**
  112677. * Remove a specific ramp gradient
  112678. * @param gradient defines the gradient to remove
  112679. * @returns the current particle system
  112680. */
  112681. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  112682. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  112683. this._rampGradientsTexture = null;
  112684. if (this._rampGradients && this._rampGradients.length > 0) {
  112685. this._createRampGradientTexture();
  112686. }
  112687. return this;
  112688. };
  112689. /**
  112690. * Adds a new color gradient
  112691. * @param gradient defines the gradient to use (between 0 and 1)
  112692. * @param color1 defines the color to affect to the specified gradient
  112693. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  112694. * @returns this particle system
  112695. */
  112696. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  112697. if (!this._colorGradients) {
  112698. this._colorGradients = [];
  112699. }
  112700. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  112701. colorGradient.gradient = gradient;
  112702. colorGradient.color1 = color1;
  112703. colorGradient.color2 = color2;
  112704. this._colorGradients.push(colorGradient);
  112705. this._colorGradients.sort(function (a, b) {
  112706. if (a.gradient < b.gradient) {
  112707. return -1;
  112708. }
  112709. else if (a.gradient > b.gradient) {
  112710. return 1;
  112711. }
  112712. return 0;
  112713. });
  112714. return this;
  112715. };
  112716. /**
  112717. * Remove a specific color gradient
  112718. * @param gradient defines the gradient to remove
  112719. * @returns this particle system
  112720. */
  112721. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  112722. if (!this._colorGradients) {
  112723. return this;
  112724. }
  112725. var index = 0;
  112726. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  112727. var colorGradient = _a[_i];
  112728. if (colorGradient.gradient === gradient) {
  112729. this._colorGradients.splice(index, 1);
  112730. break;
  112731. }
  112732. index++;
  112733. }
  112734. return this;
  112735. };
  112736. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  112737. u = Math.abs(u) * 0.5 + 0.5;
  112738. v = Math.abs(v) * 0.5 + 0.5;
  112739. var wrappedU = ((u * width) % width) | 0;
  112740. var wrappedV = ((v * height) % height) | 0;
  112741. var position = (wrappedU + wrappedV * width) * 4;
  112742. return pixels[position] / 255;
  112743. };
  112744. ParticleSystem.prototype._reset = function () {
  112745. this._resetEffect();
  112746. };
  112747. ParticleSystem.prototype._resetEffect = function () {
  112748. if (this._vertexBuffer) {
  112749. this._vertexBuffer.dispose();
  112750. this._vertexBuffer = null;
  112751. }
  112752. if (this._spriteBuffer) {
  112753. this._spriteBuffer.dispose();
  112754. this._spriteBuffer = null;
  112755. }
  112756. this._createVertexBuffers();
  112757. };
  112758. ParticleSystem.prototype._createVertexBuffers = function () {
  112759. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  112760. if (this._isAnimationSheetEnabled) {
  112761. this._vertexBufferSize += 1;
  112762. }
  112763. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  112764. this._vertexBufferSize += 3;
  112765. }
  112766. if (this._useRampGradients) {
  112767. this._vertexBufferSize += 4;
  112768. }
  112769. var engine = this._scene.getEngine();
  112770. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  112771. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  112772. var dataOffset = 0;
  112773. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  112774. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  112775. dataOffset += 3;
  112776. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  112777. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  112778. dataOffset += 4;
  112779. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  112780. this._vertexBuffers["angle"] = options;
  112781. dataOffset += 1;
  112782. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  112783. this._vertexBuffers["size"] = size;
  112784. dataOffset += 2;
  112785. if (this._isAnimationSheetEnabled) {
  112786. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  112787. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  112788. dataOffset += 1;
  112789. }
  112790. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  112791. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  112792. this._vertexBuffers["direction"] = directionBuffer;
  112793. dataOffset += 3;
  112794. }
  112795. if (this._useRampGradients) {
  112796. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  112797. this._vertexBuffers["remapData"] = rampDataBuffer;
  112798. dataOffset += 4;
  112799. }
  112800. var offsets;
  112801. if (this._useInstancing) {
  112802. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  112803. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  112804. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  112805. }
  112806. else {
  112807. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  112808. dataOffset += 2;
  112809. }
  112810. this._vertexBuffers["offset"] = offsets;
  112811. };
  112812. ParticleSystem.prototype._createIndexBuffer = function () {
  112813. if (this._useInstancing) {
  112814. return;
  112815. }
  112816. var indices = [];
  112817. var index = 0;
  112818. for (var count = 0; count < this._capacity; count++) {
  112819. indices.push(index);
  112820. indices.push(index + 1);
  112821. indices.push(index + 2);
  112822. indices.push(index);
  112823. indices.push(index + 2);
  112824. indices.push(index + 3);
  112825. index += 4;
  112826. }
  112827. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  112828. };
  112829. /**
  112830. * Gets the maximum number of particles active at the same time.
  112831. * @returns The max number of active particles.
  112832. */
  112833. ParticleSystem.prototype.getCapacity = function () {
  112834. return this._capacity;
  112835. };
  112836. /**
  112837. * Gets whether there are still active particles in the system.
  112838. * @returns True if it is alive, otherwise false.
  112839. */
  112840. ParticleSystem.prototype.isAlive = function () {
  112841. return this._alive;
  112842. };
  112843. /**
  112844. * Gets if the system has been started. (Note: this will still be true after stop is called)
  112845. * @returns True if it has been started, otherwise false.
  112846. */
  112847. ParticleSystem.prototype.isStarted = function () {
  112848. return this._started;
  112849. };
  112850. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  112851. var _this = this;
  112852. this._subEmitters = new Array();
  112853. if (this.subEmitters) {
  112854. this.subEmitters.forEach(function (subEmitter) {
  112855. if (subEmitter instanceof ParticleSystem) {
  112856. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  112857. }
  112858. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  112859. _this._subEmitters.push([subEmitter]);
  112860. }
  112861. else if (subEmitter instanceof Array) {
  112862. _this._subEmitters.push(subEmitter);
  112863. }
  112864. });
  112865. }
  112866. };
  112867. /**
  112868. * Starts the particle system and begins to emit
  112869. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  112870. */
  112871. ParticleSystem.prototype.start = function (delay) {
  112872. var _this = this;
  112873. if (delay === void 0) { delay = this.startDelay; }
  112874. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  112875. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  112876. }
  112877. if (delay) {
  112878. setTimeout(function () {
  112879. _this.start(0);
  112880. }, delay);
  112881. return;
  112882. }
  112883. // Convert the subEmitters field to the constant type field _subEmitters
  112884. this._prepareSubEmitterInternalArray();
  112885. this._started = true;
  112886. this._stopped = false;
  112887. this._actualFrame = 0;
  112888. if (this._subEmitters && this._subEmitters.length != 0) {
  112889. this.activeSubSystems = new Array();
  112890. }
  112891. // Reset emit gradient so it acts the same on every start
  112892. if (this._emitRateGradients) {
  112893. if (this._emitRateGradients.length > 0) {
  112894. this._currentEmitRateGradient = this._emitRateGradients[0];
  112895. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  112896. this._currentEmitRate2 = this._currentEmitRate1;
  112897. }
  112898. if (this._emitRateGradients.length > 1) {
  112899. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  112900. }
  112901. }
  112902. // Reset start size gradient so it acts the same on every start
  112903. if (this._startSizeGradients) {
  112904. if (this._startSizeGradients.length > 0) {
  112905. this._currentStartSizeGradient = this._startSizeGradients[0];
  112906. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  112907. this._currentStartSize2 = this._currentStartSize1;
  112908. }
  112909. if (this._startSizeGradients.length > 1) {
  112910. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  112911. }
  112912. }
  112913. if (this.preWarmCycles) {
  112914. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  112915. this.emitter.computeWorldMatrix(true);
  112916. }
  112917. var noiseTextureAsProcedural_1 = this.noiseTexture;
  112918. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  112919. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  112920. setTimeout(function () {
  112921. for (var index = 0; index < _this.preWarmCycles; index++) {
  112922. _this.animate(true);
  112923. noiseTextureAsProcedural_1.render();
  112924. }
  112925. });
  112926. });
  112927. }
  112928. else {
  112929. for (var index = 0; index < this.preWarmCycles; index++) {
  112930. this.animate(true);
  112931. }
  112932. }
  112933. }
  112934. // Animations
  112935. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  112936. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  112937. }
  112938. };
  112939. /**
  112940. * Stops the particle system.
  112941. * @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.
  112942. */
  112943. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  112944. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  112945. this._stopped = true;
  112946. if (stopSubEmitters) {
  112947. this._stopSubEmitters();
  112948. }
  112949. };
  112950. // animation sheet
  112951. /**
  112952. * Remove all active particles
  112953. */
  112954. ParticleSystem.prototype.reset = function () {
  112955. this._stockParticles = [];
  112956. this._particles = [];
  112957. };
  112958. /**
  112959. * @hidden (for internal use only)
  112960. */
  112961. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  112962. var offset = index * this._vertexBufferSize;
  112963. this._vertexData[offset++] = particle.position.x + this.worldOffset.x;
  112964. this._vertexData[offset++] = particle.position.y + this.worldOffset.y;
  112965. this._vertexData[offset++] = particle.position.z + this.worldOffset.z;
  112966. this._vertexData[offset++] = particle.color.r;
  112967. this._vertexData[offset++] = particle.color.g;
  112968. this._vertexData[offset++] = particle.color.b;
  112969. this._vertexData[offset++] = particle.color.a;
  112970. this._vertexData[offset++] = particle.angle;
  112971. this._vertexData[offset++] = particle.scale.x * particle.size;
  112972. this._vertexData[offset++] = particle.scale.y * particle.size;
  112973. if (this._isAnimationSheetEnabled) {
  112974. this._vertexData[offset++] = particle.cellIndex;
  112975. }
  112976. if (!this._isBillboardBased) {
  112977. if (particle._initialDirection) {
  112978. this._vertexData[offset++] = particle._initialDirection.x;
  112979. this._vertexData[offset++] = particle._initialDirection.y;
  112980. this._vertexData[offset++] = particle._initialDirection.z;
  112981. }
  112982. else {
  112983. this._vertexData[offset++] = particle.direction.x;
  112984. this._vertexData[offset++] = particle.direction.y;
  112985. this._vertexData[offset++] = particle.direction.z;
  112986. }
  112987. }
  112988. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  112989. this._vertexData[offset++] = particle.direction.x;
  112990. this._vertexData[offset++] = particle.direction.y;
  112991. this._vertexData[offset++] = particle.direction.z;
  112992. }
  112993. if (this._useRampGradients) {
  112994. this._vertexData[offset++] = particle.remapData.x;
  112995. this._vertexData[offset++] = particle.remapData.y;
  112996. this._vertexData[offset++] = particle.remapData.z;
  112997. this._vertexData[offset++] = particle.remapData.w;
  112998. }
  112999. if (!this._useInstancing) {
  113000. if (this._isAnimationSheetEnabled) {
  113001. if (offsetX === 0) {
  113002. offsetX = this._epsilon;
  113003. }
  113004. else if (offsetX === 1) {
  113005. offsetX = 1 - this._epsilon;
  113006. }
  113007. if (offsetY === 0) {
  113008. offsetY = this._epsilon;
  113009. }
  113010. else if (offsetY === 1) {
  113011. offsetY = 1 - this._epsilon;
  113012. }
  113013. }
  113014. this._vertexData[offset++] = offsetX;
  113015. this._vertexData[offset++] = offsetY;
  113016. }
  113017. };
  113018. ParticleSystem.prototype._stopSubEmitters = function () {
  113019. if (!this.activeSubSystems) {
  113020. return;
  113021. }
  113022. this.activeSubSystems.forEach(function (subSystem) {
  113023. subSystem.stop(true);
  113024. });
  113025. this.activeSubSystems = new Array();
  113026. };
  113027. ParticleSystem.prototype._removeFromRoot = function () {
  113028. if (!this._rootParticleSystem) {
  113029. return;
  113030. }
  113031. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  113032. if (index !== -1) {
  113033. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  113034. }
  113035. this._rootParticleSystem = null;
  113036. };
  113037. // End of sub system methods
  113038. ParticleSystem.prototype._update = function (newParticles) {
  113039. var _this = this;
  113040. // Update current
  113041. this._alive = this._particles.length > 0;
  113042. if (this.emitter.position) {
  113043. var emitterMesh = this.emitter;
  113044. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  113045. }
  113046. else {
  113047. var emitterPosition = this.emitter;
  113048. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  113049. }
  113050. this.updateFunction(this._particles);
  113051. // Add new ones
  113052. var particle;
  113053. var _loop_2 = function () {
  113054. if (this_1._particles.length === this_1._capacity) {
  113055. return "break";
  113056. }
  113057. particle = this_1._createParticle();
  113058. this_1._particles.push(particle);
  113059. // Emitter
  113060. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  113061. if (this_1.startPositionFunction) {
  113062. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  113063. }
  113064. else {
  113065. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  113066. }
  113067. if (this_1.startDirectionFunction) {
  113068. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  113069. }
  113070. else {
  113071. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  113072. }
  113073. if (emitPower === 0) {
  113074. if (!particle._initialDirection) {
  113075. particle._initialDirection = particle.direction.clone();
  113076. }
  113077. else {
  113078. particle._initialDirection.copyFrom(particle.direction);
  113079. }
  113080. }
  113081. else {
  113082. particle._initialDirection = null;
  113083. }
  113084. particle.direction.scaleInPlace(emitPower);
  113085. // Life time
  113086. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  113087. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  113088. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  113089. var factorGradient1 = currentGradient;
  113090. var factorGradient2 = nextGradient;
  113091. var lifeTime1 = factorGradient1.getFactor();
  113092. var lifeTime2 = factorGradient2.getFactor();
  113093. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  113094. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  113095. });
  113096. }
  113097. else {
  113098. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  113099. }
  113100. // Size
  113101. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  113102. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  113103. }
  113104. else {
  113105. particle._currentSizeGradient = this_1._sizeGradients[0];
  113106. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  113107. particle.size = particle._currentSize1;
  113108. if (this_1._sizeGradients.length > 1) {
  113109. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  113110. }
  113111. else {
  113112. particle._currentSize2 = particle._currentSize1;
  113113. }
  113114. }
  113115. // Size and scale
  113116. 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));
  113117. // Adjust scale by start size
  113118. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  113119. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  113120. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  113121. if (currentGradient !== _this._currentStartSizeGradient) {
  113122. _this._currentStartSize1 = _this._currentStartSize2;
  113123. _this._currentStartSize2 = nextGradient.getFactor();
  113124. _this._currentStartSizeGradient = currentGradient;
  113125. }
  113126. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  113127. particle.scale.scaleInPlace(value);
  113128. });
  113129. }
  113130. // Angle
  113131. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  113132. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  113133. }
  113134. else {
  113135. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  113136. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  113137. particle._currentAngularSpeed1 = particle.angularSpeed;
  113138. if (this_1._angularSpeedGradients.length > 1) {
  113139. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  113140. }
  113141. else {
  113142. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  113143. }
  113144. }
  113145. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  113146. // Velocity
  113147. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  113148. particle._currentVelocityGradient = this_1._velocityGradients[0];
  113149. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  113150. if (this_1._velocityGradients.length > 1) {
  113151. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  113152. }
  113153. else {
  113154. particle._currentVelocity2 = particle._currentVelocity1;
  113155. }
  113156. }
  113157. // Limit velocity
  113158. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  113159. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  113160. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  113161. if (this_1._limitVelocityGradients.length > 1) {
  113162. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  113163. }
  113164. else {
  113165. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  113166. }
  113167. }
  113168. // Drag
  113169. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  113170. particle._currentDragGradient = this_1._dragGradients[0];
  113171. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  113172. if (this_1._dragGradients.length > 1) {
  113173. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  113174. }
  113175. else {
  113176. particle._currentDrag2 = particle._currentDrag1;
  113177. }
  113178. }
  113179. // Color
  113180. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  113181. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  113182. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  113183. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  113184. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  113185. }
  113186. else {
  113187. particle._currentColorGradient = this_1._colorGradients[0];
  113188. particle._currentColorGradient.getColorToRef(particle.color);
  113189. particle._currentColor1.copyFrom(particle.color);
  113190. if (this_1._colorGradients.length > 1) {
  113191. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  113192. }
  113193. else {
  113194. particle._currentColor2.copyFrom(particle.color);
  113195. }
  113196. }
  113197. // Sheet
  113198. if (this_1._isAnimationSheetEnabled) {
  113199. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  113200. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  113201. }
  113202. // Inherited Velocity
  113203. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  113204. // Ramp
  113205. if (this_1._useRampGradients) {
  113206. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  113207. }
  113208. // Noise texture coordinates
  113209. if (this_1.noiseTexture) {
  113210. if (particle._randomNoiseCoordinates1) {
  113211. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  113212. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  113213. }
  113214. else {
  113215. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  113216. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  113217. }
  113218. }
  113219. // Update the position of the attached sub-emitters to match their attached particle
  113220. particle._inheritParticleInfoToSubEmitters();
  113221. };
  113222. var this_1 = this, step;
  113223. for (var index = 0; index < newParticles; index++) {
  113224. var state_1 = _loop_2();
  113225. if (state_1 === "break")
  113226. break;
  113227. }
  113228. };
  113229. /** @hidden */
  113230. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  113231. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  113232. if (isBillboardBased === void 0) { isBillboardBased = false; }
  113233. if (useRampGradients === void 0) { useRampGradients = false; }
  113234. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  113235. if (isAnimationSheetEnabled) {
  113236. attributeNamesOrOptions.push("cellIndex");
  113237. }
  113238. if (!isBillboardBased) {
  113239. attributeNamesOrOptions.push("direction");
  113240. }
  113241. if (useRampGradients) {
  113242. attributeNamesOrOptions.push("remapData");
  113243. }
  113244. return attributeNamesOrOptions;
  113245. };
  113246. /** @hidden */
  113247. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  113248. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  113249. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  113250. if (isAnimationSheetEnabled) {
  113251. effectCreationOption.push("particlesInfos");
  113252. }
  113253. return effectCreationOption;
  113254. };
  113255. /** @hidden */
  113256. ParticleSystem.prototype._getEffect = function (blendMode) {
  113257. if (this._customEffect) {
  113258. return this._customEffect;
  113259. }
  113260. var defines = [];
  113261. if (this._scene.clipPlane) {
  113262. defines.push("#define CLIPPLANE");
  113263. }
  113264. if (this._scene.clipPlane2) {
  113265. defines.push("#define CLIPPLANE2");
  113266. }
  113267. if (this._scene.clipPlane3) {
  113268. defines.push("#define CLIPPLANE3");
  113269. }
  113270. if (this._scene.clipPlane4) {
  113271. defines.push("#define CLIPPLANE4");
  113272. }
  113273. if (this._isAnimationSheetEnabled) {
  113274. defines.push("#define ANIMATESHEET");
  113275. }
  113276. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  113277. defines.push("#define BLENDMULTIPLYMODE");
  113278. }
  113279. if (this._useRampGradients) {
  113280. defines.push("#define RAMPGRADIENT");
  113281. }
  113282. if (this._isBillboardBased) {
  113283. defines.push("#define BILLBOARD");
  113284. switch (this.billboardMode) {
  113285. case ParticleSystem.BILLBOARDMODE_Y:
  113286. defines.push("#define BILLBOARDY");
  113287. break;
  113288. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  113289. defines.push("#define BILLBOARDSTRETCHED");
  113290. break;
  113291. case ParticleSystem.BILLBOARDMODE_ALL:
  113292. default:
  113293. break;
  113294. }
  113295. }
  113296. if (this._imageProcessingConfiguration) {
  113297. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  113298. defines.push(this._imageProcessingConfigurationDefines.toString());
  113299. }
  113300. // Effect
  113301. var join = defines.join("\n");
  113302. if (this._cachedDefines !== join) {
  113303. this._cachedDefines = join;
  113304. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  113305. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  113306. var samplers = ["diffuseSampler", "rampSampler"];
  113307. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  113308. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  113309. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  113310. }
  113311. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  113312. }
  113313. return this._effect;
  113314. };
  113315. /**
  113316. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  113317. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  113318. */
  113319. ParticleSystem.prototype.animate = function (preWarmOnly) {
  113320. var _this = this;
  113321. if (preWarmOnly === void 0) { preWarmOnly = false; }
  113322. if (!this._started) {
  113323. return;
  113324. }
  113325. if (!preWarmOnly) {
  113326. // Check
  113327. if (!this.isReady()) {
  113328. return;
  113329. }
  113330. if (this._currentRenderId === this._scene.getFrameId()) {
  113331. return;
  113332. }
  113333. this._currentRenderId = this._scene.getFrameId();
  113334. }
  113335. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  113336. // Determine the number of particles we need to create
  113337. var newParticles;
  113338. if (this.manualEmitCount > -1) {
  113339. newParticles = this.manualEmitCount;
  113340. this._newPartsExcess = 0;
  113341. this.manualEmitCount = 0;
  113342. }
  113343. else {
  113344. var rate_1 = this.emitRate;
  113345. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  113346. var ratio = this._actualFrame / this.targetStopDuration;
  113347. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  113348. if (currentGradient !== _this._currentEmitRateGradient) {
  113349. _this._currentEmitRate1 = _this._currentEmitRate2;
  113350. _this._currentEmitRate2 = nextGradient.getFactor();
  113351. _this._currentEmitRateGradient = currentGradient;
  113352. }
  113353. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  113354. });
  113355. }
  113356. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  113357. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  113358. }
  113359. if (this._newPartsExcess > 1.0) {
  113360. newParticles += this._newPartsExcess >> 0;
  113361. this._newPartsExcess -= this._newPartsExcess >> 0;
  113362. }
  113363. this._alive = false;
  113364. if (!this._stopped) {
  113365. this._actualFrame += this._scaledUpdateSpeed;
  113366. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  113367. this.stop();
  113368. }
  113369. }
  113370. else {
  113371. newParticles = 0;
  113372. }
  113373. this._update(newParticles);
  113374. // Stopped?
  113375. if (this._stopped) {
  113376. if (!this._alive) {
  113377. this._started = false;
  113378. if (this.onAnimationEnd) {
  113379. this.onAnimationEnd();
  113380. }
  113381. if (this.disposeOnStop) {
  113382. this._scene._toBeDisposed.push(this);
  113383. }
  113384. }
  113385. }
  113386. if (!preWarmOnly) {
  113387. // Update VBO
  113388. var offset = 0;
  113389. for (var index = 0; index < this._particles.length; index++) {
  113390. var particle = this._particles[index];
  113391. this._appendParticleVertices(offset, particle);
  113392. offset += this._useInstancing ? 1 : 4;
  113393. }
  113394. if (this._vertexBuffer) {
  113395. this._vertexBuffer.update(this._vertexData);
  113396. }
  113397. }
  113398. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  113399. this.stop();
  113400. }
  113401. };
  113402. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  113403. this._appendParticleVertex(offset++, particle, 0, 0);
  113404. if (!this._useInstancing) {
  113405. this._appendParticleVertex(offset++, particle, 1, 0);
  113406. this._appendParticleVertex(offset++, particle, 1, 1);
  113407. this._appendParticleVertex(offset++, particle, 0, 1);
  113408. }
  113409. };
  113410. /**
  113411. * Rebuilds the particle system.
  113412. */
  113413. ParticleSystem.prototype.rebuild = function () {
  113414. this._createIndexBuffer();
  113415. if (this._vertexBuffer) {
  113416. this._vertexBuffer._rebuild();
  113417. }
  113418. };
  113419. /**
  113420. * Is this system ready to be used/rendered
  113421. * @return true if the system is ready
  113422. */
  113423. ParticleSystem.prototype.isReady = function () {
  113424. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  113425. return false;
  113426. }
  113427. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  113428. if (!this._getEffect(this.blendMode).isReady()) {
  113429. return false;
  113430. }
  113431. }
  113432. else {
  113433. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  113434. return false;
  113435. }
  113436. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  113437. return false;
  113438. }
  113439. }
  113440. return true;
  113441. };
  113442. ParticleSystem.prototype._render = function (blendMode) {
  113443. var effect = this._getEffect(blendMode);
  113444. var engine = this._scene.getEngine();
  113445. // Render
  113446. engine.enableEffect(effect);
  113447. var viewMatrix = this._scene.getViewMatrix();
  113448. effect.setTexture("diffuseSampler", this.particleTexture);
  113449. effect.setMatrix("view", viewMatrix);
  113450. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  113451. if (this._isAnimationSheetEnabled && this.particleTexture) {
  113452. var baseSize = this.particleTexture.getBaseSize();
  113453. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  113454. }
  113455. effect.setVector2("translationPivot", this.translationPivot);
  113456. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  113457. if (this._isBillboardBased) {
  113458. var camera = this._scene.activeCamera;
  113459. effect.setVector3("eyePosition", camera.globalPosition);
  113460. }
  113461. if (this._rampGradientsTexture) {
  113462. effect.setTexture("rampSampler", this._rampGradientsTexture);
  113463. }
  113464. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  113465. var invView = viewMatrix.clone();
  113466. invView.invert();
  113467. effect.setMatrix("invView", invView);
  113468. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  113469. }
  113470. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  113471. // image processing
  113472. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  113473. this._imageProcessingConfiguration.bind(effect);
  113474. }
  113475. // Draw order
  113476. switch (blendMode) {
  113477. case ParticleSystem.BLENDMODE_ADD:
  113478. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  113479. break;
  113480. case ParticleSystem.BLENDMODE_ONEONE:
  113481. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  113482. break;
  113483. case ParticleSystem.BLENDMODE_STANDARD:
  113484. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  113485. break;
  113486. case ParticleSystem.BLENDMODE_MULTIPLY:
  113487. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  113488. break;
  113489. }
  113490. if (this._useInstancing) {
  113491. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  113492. }
  113493. else {
  113494. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  113495. }
  113496. return this._particles.length;
  113497. };
  113498. /**
  113499. * Renders the particle system in its current state.
  113500. * @returns the current number of particles
  113501. */
  113502. ParticleSystem.prototype.render = function () {
  113503. // Check
  113504. if (!this.isReady() || !this._particles.length) {
  113505. return 0;
  113506. }
  113507. var engine = this._scene.getEngine();
  113508. engine.setState(false);
  113509. if (this.forceDepthWrite) {
  113510. engine.setDepthWrite(true);
  113511. }
  113512. var outparticles = 0;
  113513. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  113514. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  113515. }
  113516. outparticles = this._render(this.blendMode);
  113517. engine.unbindInstanceAttributes();
  113518. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  113519. return outparticles;
  113520. };
  113521. /**
  113522. * Disposes the particle system and free the associated resources
  113523. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  113524. */
  113525. ParticleSystem.prototype.dispose = function (disposeTexture) {
  113526. if (disposeTexture === void 0) { disposeTexture = true; }
  113527. if (this._vertexBuffer) {
  113528. this._vertexBuffer.dispose();
  113529. this._vertexBuffer = null;
  113530. }
  113531. if (this._spriteBuffer) {
  113532. this._spriteBuffer.dispose();
  113533. this._spriteBuffer = null;
  113534. }
  113535. if (this._indexBuffer) {
  113536. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  113537. this._indexBuffer = null;
  113538. }
  113539. if (disposeTexture && this.particleTexture) {
  113540. this.particleTexture.dispose();
  113541. this.particleTexture = null;
  113542. }
  113543. if (disposeTexture && this.noiseTexture) {
  113544. this.noiseTexture.dispose();
  113545. this.noiseTexture = null;
  113546. }
  113547. if (this._rampGradientsTexture) {
  113548. this._rampGradientsTexture.dispose();
  113549. this._rampGradientsTexture = null;
  113550. }
  113551. this._removeFromRoot();
  113552. if (this._subEmitters && this._subEmitters.length) {
  113553. for (var index = 0; index < this._subEmitters.length; index++) {
  113554. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  113555. var subEmitter = _a[_i];
  113556. subEmitter.dispose();
  113557. }
  113558. }
  113559. this._subEmitters = [];
  113560. this.subEmitters = [];
  113561. }
  113562. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  113563. this.emitter.dispose(true);
  113564. }
  113565. // Remove from scene
  113566. var index = this._scene.particleSystems.indexOf(this);
  113567. if (index > -1) {
  113568. this._scene.particleSystems.splice(index, 1);
  113569. }
  113570. this._scene._activeParticleSystems.dispose();
  113571. // Callback
  113572. this.onDisposeObservable.notifyObservers(this);
  113573. this.onDisposeObservable.clear();
  113574. this.reset();
  113575. };
  113576. // Clone
  113577. /**
  113578. * Clones the particle system.
  113579. * @param name The name of the cloned object
  113580. * @param newEmitter The new emitter to use
  113581. * @returns the cloned particle system
  113582. */
  113583. ParticleSystem.prototype.clone = function (name, newEmitter) {
  113584. var custom = null;
  113585. var program = null;
  113586. if (this.customShader != null) {
  113587. program = this.customShader;
  113588. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  113589. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  113590. }
  113591. else if (this._customEffect) {
  113592. custom = this._customEffect;
  113593. }
  113594. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  113595. result.customShader = program;
  113596. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  113597. if (newEmitter === undefined) {
  113598. newEmitter = this.emitter;
  113599. }
  113600. result.noiseTexture = this.noiseTexture;
  113601. result.emitter = newEmitter;
  113602. if (this.particleTexture) {
  113603. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  113604. }
  113605. // Clone gradients
  113606. if (this._colorGradients) {
  113607. this._colorGradients.forEach(function (v) {
  113608. result.addColorGradient(v.gradient, v.color1, v.color2);
  113609. });
  113610. }
  113611. if (this._dragGradients) {
  113612. this._dragGradients.forEach(function (v) {
  113613. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  113614. });
  113615. }
  113616. if (this._angularSpeedGradients) {
  113617. this._angularSpeedGradients.forEach(function (v) {
  113618. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  113619. });
  113620. }
  113621. if (this._emitRateGradients) {
  113622. this._emitRateGradients.forEach(function (v) {
  113623. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  113624. });
  113625. }
  113626. if (this._lifeTimeGradients) {
  113627. this._lifeTimeGradients.forEach(function (v) {
  113628. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  113629. });
  113630. }
  113631. if (this._limitVelocityGradients) {
  113632. this._limitVelocityGradients.forEach(function (v) {
  113633. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  113634. });
  113635. }
  113636. if (this._sizeGradients) {
  113637. this._sizeGradients.forEach(function (v) {
  113638. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  113639. });
  113640. }
  113641. if (this._startSizeGradients) {
  113642. this._startSizeGradients.forEach(function (v) {
  113643. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  113644. });
  113645. }
  113646. if (this._velocityGradients) {
  113647. this._velocityGradients.forEach(function (v) {
  113648. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  113649. });
  113650. }
  113651. if (this._rampGradients) {
  113652. this._rampGradients.forEach(function (v) {
  113653. result.addRampGradient(v.gradient, v.color);
  113654. });
  113655. }
  113656. if (this._colorRemapGradients) {
  113657. this._colorRemapGradients.forEach(function (v) {
  113658. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  113659. });
  113660. }
  113661. if (this._alphaRemapGradients) {
  113662. this._alphaRemapGradients.forEach(function (v) {
  113663. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  113664. });
  113665. }
  113666. if (!this.preventAutoStart) {
  113667. result.start();
  113668. }
  113669. return result;
  113670. };
  113671. /**
  113672. * Serializes the particle system to a JSON object.
  113673. * @returns the JSON object
  113674. */
  113675. ParticleSystem.prototype.serialize = function () {
  113676. var serializationObject = {};
  113677. ParticleSystem._Serialize(serializationObject, this);
  113678. serializationObject.textureMask = this.textureMask.asArray();
  113679. serializationObject.customShader = this.customShader;
  113680. serializationObject.preventAutoStart = this.preventAutoStart;
  113681. // SubEmitters
  113682. if (this.subEmitters) {
  113683. serializationObject.subEmitters = [];
  113684. if (!this._subEmitters) {
  113685. this._prepareSubEmitterInternalArray();
  113686. }
  113687. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  113688. var subs = _a[_i];
  113689. var cell = [];
  113690. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  113691. var sub = subs_1[_b];
  113692. cell.push(sub.serialize());
  113693. }
  113694. serializationObject.subEmitters.push(cell);
  113695. }
  113696. }
  113697. return serializationObject;
  113698. };
  113699. /** @hidden */
  113700. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  113701. serializationObject.name = particleSystem.name;
  113702. serializationObject.id = particleSystem.id;
  113703. serializationObject.capacity = particleSystem.getCapacity();
  113704. // Emitter
  113705. if (particleSystem.emitter.position) {
  113706. var emitterMesh = particleSystem.emitter;
  113707. serializationObject.emitterId = emitterMesh.id;
  113708. }
  113709. else {
  113710. var emitterPosition = particleSystem.emitter;
  113711. serializationObject.emitter = emitterPosition.asArray();
  113712. }
  113713. // Emitter
  113714. if (particleSystem.particleEmitterType) {
  113715. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  113716. }
  113717. if (particleSystem.particleTexture) {
  113718. serializationObject.textureName = particleSystem.particleTexture.name;
  113719. serializationObject.invertY = particleSystem.particleTexture._invertY;
  113720. }
  113721. // Animations
  113722. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  113723. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  113724. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  113725. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  113726. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  113727. // Particle system
  113728. serializationObject.startDelay = particleSystem.startDelay;
  113729. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  113730. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  113731. serializationObject.billboardMode = particleSystem.billboardMode;
  113732. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  113733. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  113734. serializationObject.minSize = particleSystem.minSize;
  113735. serializationObject.maxSize = particleSystem.maxSize;
  113736. serializationObject.minScaleX = particleSystem.minScaleX;
  113737. serializationObject.maxScaleX = particleSystem.maxScaleX;
  113738. serializationObject.minScaleY = particleSystem.minScaleY;
  113739. serializationObject.maxScaleY = particleSystem.maxScaleY;
  113740. serializationObject.minEmitPower = particleSystem.minEmitPower;
  113741. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  113742. serializationObject.minLifeTime = particleSystem.minLifeTime;
  113743. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  113744. serializationObject.emitRate = particleSystem.emitRate;
  113745. serializationObject.gravity = particleSystem.gravity.asArray();
  113746. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  113747. serializationObject.color1 = particleSystem.color1.asArray();
  113748. serializationObject.color2 = particleSystem.color2.asArray();
  113749. serializationObject.colorDead = particleSystem.colorDead.asArray();
  113750. serializationObject.updateSpeed = particleSystem.updateSpeed;
  113751. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  113752. serializationObject.blendMode = particleSystem.blendMode;
  113753. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  113754. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  113755. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  113756. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  113757. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  113758. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  113759. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  113760. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  113761. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  113762. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  113763. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  113764. var colorGradients = particleSystem.getColorGradients();
  113765. if (colorGradients) {
  113766. serializationObject.colorGradients = [];
  113767. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  113768. var colorGradient = colorGradients_1[_i];
  113769. var serializedGradient = {
  113770. gradient: colorGradient.gradient,
  113771. color1: colorGradient.color1.asArray()
  113772. };
  113773. if (colorGradient.color2) {
  113774. serializedGradient.color2 = colorGradient.color2.asArray();
  113775. }
  113776. serializationObject.colorGradients.push(serializedGradient);
  113777. }
  113778. }
  113779. var rampGradients = particleSystem.getRampGradients();
  113780. if (rampGradients) {
  113781. serializationObject.rampGradients = [];
  113782. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  113783. var rampGradient = rampGradients_1[_a];
  113784. var serializedGradient = {
  113785. gradient: rampGradient.gradient,
  113786. color: rampGradient.color.asArray()
  113787. };
  113788. serializationObject.rampGradients.push(serializedGradient);
  113789. }
  113790. serializationObject.useRampGradients = particleSystem.useRampGradients;
  113791. }
  113792. var colorRemapGradients = particleSystem.getColorRemapGradients();
  113793. if (colorRemapGradients) {
  113794. serializationObject.colorRemapGradients = [];
  113795. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  113796. var colorRemapGradient = colorRemapGradients_1[_b];
  113797. var serializedGradient = {
  113798. gradient: colorRemapGradient.gradient,
  113799. factor1: colorRemapGradient.factor1
  113800. };
  113801. if (colorRemapGradient.factor2 !== undefined) {
  113802. serializedGradient.factor2 = colorRemapGradient.factor2;
  113803. }
  113804. serializationObject.colorRemapGradients.push(serializedGradient);
  113805. }
  113806. }
  113807. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  113808. if (alphaRemapGradients) {
  113809. serializationObject.alphaRemapGradients = [];
  113810. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  113811. var alphaRemapGradient = alphaRemapGradients_1[_c];
  113812. var serializedGradient = {
  113813. gradient: alphaRemapGradient.gradient,
  113814. factor1: alphaRemapGradient.factor1
  113815. };
  113816. if (alphaRemapGradient.factor2 !== undefined) {
  113817. serializedGradient.factor2 = alphaRemapGradient.factor2;
  113818. }
  113819. serializationObject.alphaRemapGradients.push(serializedGradient);
  113820. }
  113821. }
  113822. var sizeGradients = particleSystem.getSizeGradients();
  113823. if (sizeGradients) {
  113824. serializationObject.sizeGradients = [];
  113825. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  113826. var sizeGradient = sizeGradients_1[_d];
  113827. var serializedGradient = {
  113828. gradient: sizeGradient.gradient,
  113829. factor1: sizeGradient.factor1
  113830. };
  113831. if (sizeGradient.factor2 !== undefined) {
  113832. serializedGradient.factor2 = sizeGradient.factor2;
  113833. }
  113834. serializationObject.sizeGradients.push(serializedGradient);
  113835. }
  113836. }
  113837. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  113838. if (angularSpeedGradients) {
  113839. serializationObject.angularSpeedGradients = [];
  113840. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  113841. var angularSpeedGradient = angularSpeedGradients_1[_e];
  113842. var serializedGradient = {
  113843. gradient: angularSpeedGradient.gradient,
  113844. factor1: angularSpeedGradient.factor1
  113845. };
  113846. if (angularSpeedGradient.factor2 !== undefined) {
  113847. serializedGradient.factor2 = angularSpeedGradient.factor2;
  113848. }
  113849. serializationObject.angularSpeedGradients.push(serializedGradient);
  113850. }
  113851. }
  113852. var velocityGradients = particleSystem.getVelocityGradients();
  113853. if (velocityGradients) {
  113854. serializationObject.velocityGradients = [];
  113855. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  113856. var velocityGradient = velocityGradients_1[_f];
  113857. var serializedGradient = {
  113858. gradient: velocityGradient.gradient,
  113859. factor1: velocityGradient.factor1
  113860. };
  113861. if (velocityGradient.factor2 !== undefined) {
  113862. serializedGradient.factor2 = velocityGradient.factor2;
  113863. }
  113864. serializationObject.velocityGradients.push(serializedGradient);
  113865. }
  113866. }
  113867. var dragGradients = particleSystem.getDragGradients();
  113868. if (dragGradients) {
  113869. serializationObject.dragyGradients = [];
  113870. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  113871. var dragGradient = dragGradients_1[_g];
  113872. var serializedGradient = {
  113873. gradient: dragGradient.gradient,
  113874. factor1: dragGradient.factor1
  113875. };
  113876. if (dragGradient.factor2 !== undefined) {
  113877. serializedGradient.factor2 = dragGradient.factor2;
  113878. }
  113879. serializationObject.dragGradients.push(serializedGradient);
  113880. }
  113881. }
  113882. var emitRateGradients = particleSystem.getEmitRateGradients();
  113883. if (emitRateGradients) {
  113884. serializationObject.emitRateGradients = [];
  113885. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  113886. var emitRateGradient = emitRateGradients_1[_h];
  113887. var serializedGradient = {
  113888. gradient: emitRateGradient.gradient,
  113889. factor1: emitRateGradient.factor1
  113890. };
  113891. if (emitRateGradient.factor2 !== undefined) {
  113892. serializedGradient.factor2 = emitRateGradient.factor2;
  113893. }
  113894. serializationObject.emitRateGradients.push(serializedGradient);
  113895. }
  113896. }
  113897. var startSizeGradients = particleSystem.getStartSizeGradients();
  113898. if (startSizeGradients) {
  113899. serializationObject.startSizeGradients = [];
  113900. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  113901. var startSizeGradient = startSizeGradients_1[_j];
  113902. var serializedGradient = {
  113903. gradient: startSizeGradient.gradient,
  113904. factor1: startSizeGradient.factor1
  113905. };
  113906. if (startSizeGradient.factor2 !== undefined) {
  113907. serializedGradient.factor2 = startSizeGradient.factor2;
  113908. }
  113909. serializationObject.startSizeGradients.push(serializedGradient);
  113910. }
  113911. }
  113912. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  113913. if (lifeTimeGradients) {
  113914. serializationObject.lifeTimeGradients = [];
  113915. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  113916. var lifeTimeGradient = lifeTimeGradients_1[_k];
  113917. var serializedGradient = {
  113918. gradient: lifeTimeGradient.gradient,
  113919. factor1: lifeTimeGradient.factor1
  113920. };
  113921. if (lifeTimeGradient.factor2 !== undefined) {
  113922. serializedGradient.factor2 = lifeTimeGradient.factor2;
  113923. }
  113924. serializationObject.lifeTimeGradients.push(serializedGradient);
  113925. }
  113926. }
  113927. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  113928. if (limitVelocityGradients) {
  113929. serializationObject.limitVelocityGradients = [];
  113930. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  113931. var limitVelocityGradient = limitVelocityGradients_1[_l];
  113932. var serializedGradient = {
  113933. gradient: limitVelocityGradient.gradient,
  113934. factor1: limitVelocityGradient.factor1
  113935. };
  113936. if (limitVelocityGradient.factor2 !== undefined) {
  113937. serializedGradient.factor2 = limitVelocityGradient.factor2;
  113938. }
  113939. serializationObject.limitVelocityGradients.push(serializedGradient);
  113940. }
  113941. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  113942. }
  113943. if (particleSystem.noiseTexture) {
  113944. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  113945. }
  113946. };
  113947. /** @hidden */
  113948. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  113949. // Texture
  113950. if (parsedParticleSystem.textureName) {
  113951. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  113952. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  113953. }
  113954. // Emitter
  113955. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  113956. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  113957. }
  113958. else if (parsedParticleSystem.emitterId) {
  113959. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  113960. }
  113961. else {
  113962. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  113963. }
  113964. // Misc.
  113965. if (parsedParticleSystem.renderingGroupId !== undefined) {
  113966. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  113967. }
  113968. if (parsedParticleSystem.isBillboardBased !== undefined) {
  113969. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  113970. }
  113971. if (parsedParticleSystem.billboardMode !== undefined) {
  113972. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  113973. }
  113974. // Animations
  113975. if (parsedParticleSystem.animations) {
  113976. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  113977. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  113978. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  113979. if (internalClass) {
  113980. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  113981. }
  113982. }
  113983. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  113984. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  113985. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  113986. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  113987. }
  113988. if (parsedParticleSystem.autoAnimate) {
  113989. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  113990. }
  113991. // Particle system
  113992. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  113993. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  113994. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  113995. particleSystem.minSize = parsedParticleSystem.minSize;
  113996. particleSystem.maxSize = parsedParticleSystem.maxSize;
  113997. if (parsedParticleSystem.minScaleX) {
  113998. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  113999. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  114000. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  114001. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  114002. }
  114003. if (parsedParticleSystem.preWarmCycles !== undefined) {
  114004. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  114005. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  114006. }
  114007. if (parsedParticleSystem.minInitialRotation !== undefined) {
  114008. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  114009. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  114010. }
  114011. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  114012. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  114013. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  114014. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  114015. particleSystem.emitRate = parsedParticleSystem.emitRate;
  114016. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  114017. if (parsedParticleSystem.noiseStrength) {
  114018. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  114019. }
  114020. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  114021. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  114022. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  114023. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  114024. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  114025. particleSystem.blendMode = parsedParticleSystem.blendMode;
  114026. if (parsedParticleSystem.colorGradients) {
  114027. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  114028. var colorGradient = _a[_i];
  114029. 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);
  114030. }
  114031. }
  114032. if (parsedParticleSystem.rampGradients) {
  114033. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  114034. var rampGradient = _c[_b];
  114035. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  114036. }
  114037. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  114038. }
  114039. if (parsedParticleSystem.colorRemapGradients) {
  114040. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  114041. var colorRemapGradient = _e[_d];
  114042. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  114043. }
  114044. }
  114045. if (parsedParticleSystem.alphaRemapGradients) {
  114046. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  114047. var alphaRemapGradient = _g[_f];
  114048. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  114049. }
  114050. }
  114051. if (parsedParticleSystem.sizeGradients) {
  114052. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  114053. var sizeGradient = _j[_h];
  114054. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  114055. }
  114056. }
  114057. if (parsedParticleSystem.sizeGradients) {
  114058. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  114059. var sizeGradient = _l[_k];
  114060. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  114061. }
  114062. }
  114063. if (parsedParticleSystem.angularSpeedGradients) {
  114064. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  114065. var angularSpeedGradient = _o[_m];
  114066. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  114067. }
  114068. }
  114069. if (parsedParticleSystem.velocityGradients) {
  114070. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  114071. var velocityGradient = _q[_p];
  114072. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  114073. }
  114074. }
  114075. if (parsedParticleSystem.dragGradients) {
  114076. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  114077. var dragGradient = _s[_r];
  114078. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  114079. }
  114080. }
  114081. if (parsedParticleSystem.emitRateGradients) {
  114082. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  114083. var emitRateGradient = _u[_t];
  114084. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  114085. }
  114086. }
  114087. if (parsedParticleSystem.startSizeGradients) {
  114088. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  114089. var startSizeGradient = _w[_v];
  114090. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  114091. }
  114092. }
  114093. if (parsedParticleSystem.lifeTimeGradients) {
  114094. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  114095. var lifeTimeGradient = _y[_x];
  114096. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  114097. }
  114098. }
  114099. if (parsedParticleSystem.limitVelocityGradients) {
  114100. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  114101. var limitVelocityGradient = _0[_z];
  114102. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  114103. }
  114104. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  114105. }
  114106. if (parsedParticleSystem.noiseTexture) {
  114107. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  114108. }
  114109. // Emitter
  114110. var emitterType;
  114111. if (parsedParticleSystem.particleEmitterType) {
  114112. switch (parsedParticleSystem.particleEmitterType.type) {
  114113. case "SphereParticleEmitter":
  114114. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  114115. break;
  114116. case "SphereDirectedParticleEmitter":
  114117. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  114118. break;
  114119. case "ConeEmitter":
  114120. case "ConeParticleEmitter":
  114121. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  114122. break;
  114123. case "CylinderParticleEmitter":
  114124. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  114125. break;
  114126. case "HemisphericParticleEmitter":
  114127. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  114128. break;
  114129. case "BoxEmitter":
  114130. case "BoxParticleEmitter":
  114131. default:
  114132. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  114133. break;
  114134. }
  114135. emitterType.parse(parsedParticleSystem.particleEmitterType);
  114136. }
  114137. else {
  114138. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  114139. emitterType.parse(parsedParticleSystem);
  114140. }
  114141. particleSystem.particleEmitterType = emitterType;
  114142. // Animation sheet
  114143. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  114144. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  114145. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  114146. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  114147. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  114148. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  114149. };
  114150. /**
  114151. * Parses a JSON object to create a particle system.
  114152. * @param parsedParticleSystem The JSON object to parse
  114153. * @param scene The scene to create the particle system in
  114154. * @param rootUrl The root url to use to load external dependencies like texture
  114155. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  114156. * @returns the Parsed particle system
  114157. */
  114158. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  114159. if (doNotStart === void 0) { doNotStart = false; }
  114160. var name = parsedParticleSystem.name;
  114161. var custom = null;
  114162. var program = null;
  114163. if (parsedParticleSystem.customShader) {
  114164. program = parsedParticleSystem.customShader;
  114165. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  114166. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  114167. }
  114168. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  114169. particleSystem.customShader = program;
  114170. if (parsedParticleSystem.id) {
  114171. particleSystem.id = parsedParticleSystem.id;
  114172. }
  114173. // SubEmitters
  114174. if (parsedParticleSystem.subEmitters) {
  114175. particleSystem.subEmitters = [];
  114176. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  114177. var cell = _a[_i];
  114178. var cellArray = [];
  114179. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  114180. var sub = cell_1[_b];
  114181. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  114182. }
  114183. particleSystem.subEmitters.push(cellArray);
  114184. }
  114185. }
  114186. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  114187. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  114188. // Auto start
  114189. if (parsedParticleSystem.preventAutoStart) {
  114190. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  114191. }
  114192. if (!doNotStart && !particleSystem.preventAutoStart) {
  114193. particleSystem.start();
  114194. }
  114195. return particleSystem;
  114196. };
  114197. /**
  114198. * Billboard mode will only apply to Y axis
  114199. */
  114200. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  114201. /**
  114202. * Billboard mode will apply to all axes
  114203. */
  114204. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  114205. /**
  114206. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  114207. */
  114208. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  114209. return ParticleSystem;
  114210. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  114211. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  114212. /***/ }),
  114213. /***/ "./Particles/particleSystemComponent.ts":
  114214. /*!**********************************************!*\
  114215. !*** ./Particles/particleSystemComponent.ts ***!
  114216. \**********************************************/
  114217. /*! exports provided: _IDoNeedToBeInTheBuild */
  114218. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114219. "use strict";
  114220. __webpack_require__.r(__webpack_exports__);
  114221. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  114222. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  114223. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  114224. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  114225. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  114226. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  114227. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  114228. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  114229. // Adds the parsers to the scene parsers.
  114230. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  114231. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  114232. if (!individualParser) {
  114233. return;
  114234. }
  114235. // Particles Systems
  114236. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  114237. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  114238. var parsedParticleSystem = parsedData.particleSystems[index];
  114239. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  114240. }
  114241. }
  114242. });
  114243. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  114244. if (parsedParticleSystem.activeParticleCount) {
  114245. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  114246. return ps;
  114247. }
  114248. else {
  114249. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  114250. return ps;
  114251. }
  114252. });
  114253. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  114254. if (uniformsNames === void 0) { uniformsNames = []; }
  114255. if (samplers === void 0) { samplers = []; }
  114256. if (defines === void 0) { defines = ""; }
  114257. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  114258. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  114259. if (defines.indexOf(" BILLBOARD") === -1) {
  114260. defines += "\n#define BILLBOARD\n";
  114261. }
  114262. if (samplers.indexOf("diffuseSampler") === -1) {
  114263. samplers.push("diffuseSampler");
  114264. }
  114265. return this.createEffect({
  114266. vertex: "particles",
  114267. fragmentElement: fragmentName
  114268. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  114269. };
  114270. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  114271. var results = new Array();
  114272. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  114273. var particleSystem = this.getScene().particleSystems[index];
  114274. if (particleSystem.emitter === this) {
  114275. results.push(particleSystem);
  114276. }
  114277. }
  114278. return results;
  114279. };
  114280. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  114281. var results = new Array();
  114282. var descendants = this.getDescendants();
  114283. descendants.push(this);
  114284. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  114285. var particleSystem = this.getScene().particleSystems[index];
  114286. var emitter = particleSystem.emitter;
  114287. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  114288. results.push(particleSystem);
  114289. }
  114290. }
  114291. return results;
  114292. };
  114293. /**
  114294. * @hidden
  114295. */
  114296. var _IDoNeedToBeInTheBuild = 42;
  114297. /***/ }),
  114298. /***/ "./Particles/particleSystemSet.ts":
  114299. /*!****************************************!*\
  114300. !*** ./Particles/particleSystemSet.ts ***!
  114301. \****************************************/
  114302. /*! exports provided: ParticleSystemSet */
  114303. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114304. "use strict";
  114305. __webpack_require__.r(__webpack_exports__);
  114306. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  114307. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  114308. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  114309. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  114310. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  114311. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  114312. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  114313. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  114314. /** Internal class used to store shapes for emitters */
  114315. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  114316. function ParticleSystemSetEmitterCreationOptions() {
  114317. }
  114318. return ParticleSystemSetEmitterCreationOptions;
  114319. }());
  114320. /**
  114321. * Represents a set of particle systems working together to create a specific effect
  114322. */
  114323. var ParticleSystemSet = /** @class */ (function () {
  114324. function ParticleSystemSet() {
  114325. /**
  114326. * Gets the particle system list
  114327. */
  114328. this.systems = new Array();
  114329. }
  114330. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  114331. /**
  114332. * Gets the emitter node used with this set
  114333. */
  114334. get: function () {
  114335. return this._emitterNode;
  114336. },
  114337. enumerable: true,
  114338. configurable: true
  114339. });
  114340. /**
  114341. * Creates a new emitter mesh as a sphere
  114342. * @param options defines the options used to create the sphere
  114343. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  114344. * @param scene defines the hosting scene
  114345. */
  114346. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  114347. if (this._emitterNode) {
  114348. this._emitterNode.dispose();
  114349. }
  114350. this._emitterCreationOptions = {
  114351. kind: "Sphere",
  114352. options: options,
  114353. renderingGroupId: renderingGroupId
  114354. };
  114355. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  114356. emitterMesh.renderingGroupId = renderingGroupId;
  114357. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  114358. material.emissiveColor = options.color;
  114359. emitterMesh.material = material;
  114360. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  114361. var system = _a[_i];
  114362. system.emitter = emitterMesh;
  114363. }
  114364. this._emitterNode = emitterMesh;
  114365. };
  114366. /**
  114367. * Starts all particle systems of the set
  114368. * @param emitter defines an optional mesh to use as emitter for the particle systems
  114369. */
  114370. ParticleSystemSet.prototype.start = function (emitter) {
  114371. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  114372. var system = _a[_i];
  114373. if (emitter) {
  114374. system.emitter = emitter;
  114375. }
  114376. system.start();
  114377. }
  114378. };
  114379. /**
  114380. * Release all associated resources
  114381. */
  114382. ParticleSystemSet.prototype.dispose = function () {
  114383. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  114384. var system = _a[_i];
  114385. system.dispose();
  114386. }
  114387. this.systems = [];
  114388. if (this._emitterNode) {
  114389. this._emitterNode.dispose();
  114390. this._emitterNode = null;
  114391. }
  114392. };
  114393. /**
  114394. * Serialize the set into a JSON compatible object
  114395. * @returns a JSON compatible representation of the set
  114396. */
  114397. ParticleSystemSet.prototype.serialize = function () {
  114398. var result = {};
  114399. result.systems = [];
  114400. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  114401. var system = _a[_i];
  114402. result.systems.push(system.serialize());
  114403. }
  114404. if (this._emitterNode) {
  114405. result.emitter = this._emitterCreationOptions;
  114406. }
  114407. return result;
  114408. };
  114409. /**
  114410. * Parse a new ParticleSystemSet from a serialized source
  114411. * @param data defines a JSON compatible representation of the set
  114412. * @param scene defines the hosting scene
  114413. * @param gpu defines if we want GPU particles or CPU particles
  114414. * @returns a new ParticleSystemSet
  114415. */
  114416. ParticleSystemSet.Parse = function (data, scene, gpu) {
  114417. if (gpu === void 0) { gpu = false; }
  114418. var result = new ParticleSystemSet();
  114419. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  114420. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  114421. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  114422. var system = _a[_i];
  114423. 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));
  114424. }
  114425. if (data.emitter) {
  114426. var options = data.emitter.options;
  114427. switch (data.emitter.kind) {
  114428. case "Sphere":
  114429. result.setEmitterAsSphere({
  114430. diameter: options.diameter,
  114431. segments: options.segments,
  114432. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  114433. }, data.emitter.renderingGroupId, scene);
  114434. break;
  114435. }
  114436. }
  114437. return result;
  114438. };
  114439. return ParticleSystemSet;
  114440. }());
  114441. /***/ }),
  114442. /***/ "./Particles/solidParticle.ts":
  114443. /*!************************************!*\
  114444. !*** ./Particles/solidParticle.ts ***!
  114445. \************************************/
  114446. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  114447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114448. "use strict";
  114449. __webpack_require__.r(__webpack_exports__);
  114450. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  114451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  114452. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  114453. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  114454. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  114455. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  114456. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  114457. /**
  114458. * Represents one particle of a solid particle system.
  114459. */
  114460. var SolidParticle = /** @class */ (function () {
  114461. /**
  114462. * Creates a Solid Particle object.
  114463. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  114464. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  114465. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  114466. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  114467. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  114468. * @param shapeId (integer) is the model shape identifier in the SPS.
  114469. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  114470. * @param sps defines the sps it is associated to
  114471. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  114472. */
  114473. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  114474. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  114475. /**
  114476. * particle global index
  114477. */
  114478. this.idx = 0;
  114479. /**
  114480. * The color of the particle
  114481. */
  114482. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  114483. /**
  114484. * The world space position of the particle.
  114485. */
  114486. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  114487. /**
  114488. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  114489. */
  114490. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  114491. /**
  114492. * The scaling of the particle.
  114493. */
  114494. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  114495. /**
  114496. * The uvs of the particle.
  114497. */
  114498. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  114499. /**
  114500. * The current speed of the particle.
  114501. */
  114502. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  114503. /**
  114504. * The pivot point in the particle local space.
  114505. */
  114506. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  114507. /**
  114508. * Must the particle be translated from its pivot point in its local space ?
  114509. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  114510. * Default : false
  114511. */
  114512. this.translateFromPivot = false;
  114513. /**
  114514. * Is the particle active or not ?
  114515. */
  114516. this.alive = true;
  114517. /**
  114518. * Is the particle visible or not ?
  114519. */
  114520. this.isVisible = true;
  114521. /**
  114522. * Index of this particle in the global "positions" array (Internal use)
  114523. * @hidden
  114524. */
  114525. this._pos = 0;
  114526. /**
  114527. * @hidden Index of this particle in the global "indices" array (Internal use)
  114528. */
  114529. this._ind = 0;
  114530. /**
  114531. * ModelShape id of this particle
  114532. */
  114533. this.shapeId = 0;
  114534. /**
  114535. * Index of the particle in its shape id (Internal use)
  114536. */
  114537. this.idxInShape = 0;
  114538. /**
  114539. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  114540. */
  114541. this._stillInvisible = false;
  114542. /**
  114543. * @hidden Last computed particle rotation matrix
  114544. */
  114545. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  114546. /**
  114547. * Parent particle Id, if any.
  114548. * Default null.
  114549. */
  114550. this.parentId = null;
  114551. /**
  114552. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  114553. * The possible values are :
  114554. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  114555. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  114556. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  114557. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  114558. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  114559. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  114560. * */
  114561. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  114562. /**
  114563. * @hidden Internal global position in the SPS.
  114564. */
  114565. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  114566. this.idx = particleIndex;
  114567. this._pos = positionIndex;
  114568. this._ind = indiceIndex;
  114569. this._model = model;
  114570. this.shapeId = shapeId;
  114571. this.idxInShape = idxInShape;
  114572. this._sps = sps;
  114573. if (modelBoundingInfo) {
  114574. this._modelBoundingInfo = modelBoundingInfo;
  114575. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  114576. }
  114577. }
  114578. Object.defineProperty(SolidParticle.prototype, "scale", {
  114579. /**
  114580. * Legacy support, changed scale to scaling
  114581. */
  114582. get: function () {
  114583. return this.scaling;
  114584. },
  114585. /**
  114586. * Legacy support, changed scale to scaling
  114587. */
  114588. set: function (scale) {
  114589. this.scaling = scale;
  114590. },
  114591. enumerable: true,
  114592. configurable: true
  114593. });
  114594. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  114595. /**
  114596. * Legacy support, changed quaternion to rotationQuaternion
  114597. */
  114598. get: function () {
  114599. return this.rotationQuaternion;
  114600. },
  114601. /**
  114602. * Legacy support, changed quaternion to rotationQuaternion
  114603. */
  114604. set: function (q) {
  114605. this.rotationQuaternion = q;
  114606. },
  114607. enumerable: true,
  114608. configurable: true
  114609. });
  114610. /**
  114611. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  114612. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  114613. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  114614. * @returns true if it intersects
  114615. */
  114616. SolidParticle.prototype.intersectsMesh = function (target) {
  114617. if (!this._boundingInfo || !target._boundingInfo) {
  114618. return false;
  114619. }
  114620. if (this._sps._bSphereOnly) {
  114621. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  114622. }
  114623. return this._boundingInfo.intersects(target._boundingInfo, false);
  114624. };
  114625. /**
  114626. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  114627. * A particle is in the frustum if its bounding box intersects the frustum
  114628. * @param frustumPlanes defines the frustum to test
  114629. * @returns true if the particle is in the frustum planes
  114630. */
  114631. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  114632. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  114633. };
  114634. /**
  114635. * get the rotation matrix of the particle
  114636. * @hidden
  114637. */
  114638. SolidParticle.prototype.getRotationMatrix = function (m) {
  114639. var quaternion;
  114640. if (this.rotationQuaternion) {
  114641. quaternion = this.rotationQuaternion;
  114642. }
  114643. else {
  114644. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  114645. var rotation = this.rotation;
  114646. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  114647. }
  114648. quaternion.toRotationMatrix(m);
  114649. };
  114650. return SolidParticle;
  114651. }());
  114652. /**
  114653. * Represents the shape of the model used by one particle of a solid particle system.
  114654. * SPS internal tool, don't use it manually.
  114655. */
  114656. var ModelShape = /** @class */ (function () {
  114657. /**
  114658. * 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.
  114659. * SPS internal tool, don't use it manually.
  114660. * @hidden
  114661. */
  114662. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  114663. /**
  114664. * length of the shape in the model indices array (internal use)
  114665. * @hidden
  114666. */
  114667. this._indicesLength = 0;
  114668. this.shapeID = id;
  114669. this._shape = shape;
  114670. this._indicesLength = indicesLength;
  114671. this._shapeUV = shapeUV;
  114672. this._positionFunction = posFunction;
  114673. this._vertexFunction = vtxFunction;
  114674. }
  114675. return ModelShape;
  114676. }());
  114677. /**
  114678. * Represents a Depth Sorted Particle in the solid particle system.
  114679. */
  114680. var DepthSortedParticle = /** @class */ (function () {
  114681. function DepthSortedParticle() {
  114682. /**
  114683. * Index of the particle in the "indices" array
  114684. */
  114685. this.ind = 0;
  114686. /**
  114687. * Length of the particle shape in the "indices" array
  114688. */
  114689. this.indicesLength = 0;
  114690. /**
  114691. * Squared distance from the particle to the camera
  114692. */
  114693. this.sqDistance = 0.0;
  114694. }
  114695. return DepthSortedParticle;
  114696. }());
  114697. /***/ }),
  114698. /***/ "./Particles/solidParticleSystem.ts":
  114699. /*!******************************************!*\
  114700. !*** ./Particles/solidParticleSystem.ts ***!
  114701. \******************************************/
  114702. /*! exports provided: SolidParticleSystem */
  114703. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114704. "use strict";
  114705. __webpack_require__.r(__webpack_exports__);
  114706. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  114707. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  114708. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  114709. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  114710. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  114711. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  114712. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  114713. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  114714. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  114715. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  114716. /**
  114717. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  114718. *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.
  114719. * The SPS is also a particle system. It provides some methods to manage the particles.
  114720. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  114721. *
  114722. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  114723. */
  114724. var SolidParticleSystem = /** @class */ (function () {
  114725. /**
  114726. * Creates a SPS (Solid Particle System) object.
  114727. * @param name (String) is the SPS name, this will be the underlying mesh name.
  114728. * @param scene (Scene) is the scene in which the SPS is added.
  114729. * @param options defines the options of the sps e.g.
  114730. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  114731. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  114732. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  114733. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  114734. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  114735. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  114736. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  114737. */
  114738. function SolidParticleSystem(name, scene, options) {
  114739. /**
  114740. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  114741. * Example : var p = SPS.particles[i];
  114742. */
  114743. this.particles = new Array();
  114744. /**
  114745. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  114746. */
  114747. this.nbParticles = 0;
  114748. /**
  114749. * If the particles must ever face the camera (default false). Useful for planar particles.
  114750. */
  114751. this.billboard = false;
  114752. /**
  114753. * Recompute normals when adding a shape
  114754. */
  114755. this.recomputeNormals = true;
  114756. /**
  114757. * This a counter ofr your own usage. It's not set by any SPS functions.
  114758. */
  114759. this.counter = 0;
  114760. /**
  114761. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  114762. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  114763. */
  114764. this.vars = {};
  114765. /**
  114766. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  114767. * @hidden
  114768. */
  114769. this._bSphereOnly = false;
  114770. /**
  114771. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  114772. * @hidden
  114773. */
  114774. this._bSphereRadiusFactor = 1.0;
  114775. this._positions = new Array();
  114776. this._indices = new Array();
  114777. this._normals = new Array();
  114778. this._colors = new Array();
  114779. this._uvs = new Array();
  114780. this._index = 0; // indices index
  114781. this._updatable = true;
  114782. this._pickable = false;
  114783. this._isVisibilityBoxLocked = false;
  114784. this._alwaysVisible = false;
  114785. this._depthSort = false;
  114786. this._shapeCounter = 0;
  114787. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  114788. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  114789. this._computeParticleColor = true;
  114790. this._computeParticleTexture = true;
  114791. this._computeParticleRotation = true;
  114792. this._computeParticleVertex = false;
  114793. this._computeBoundingBox = false;
  114794. this._depthSortParticles = true;
  114795. this._mustUnrotateFixedNormals = false;
  114796. this._particlesIntersect = false;
  114797. this._needs32Bits = false;
  114798. this.name = name;
  114799. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  114800. this._camera = scene.activeCamera;
  114801. this._pickable = options ? options.isPickable : false;
  114802. this._depthSort = options ? options.enableDepthSort : false;
  114803. this._particlesIntersect = options ? options.particleIntersection : false;
  114804. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  114805. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  114806. if (options && options.updatable !== undefined) {
  114807. this._updatable = options.updatable;
  114808. }
  114809. else {
  114810. this._updatable = true;
  114811. }
  114812. if (this._pickable) {
  114813. this.pickedParticles = [];
  114814. }
  114815. if (this._depthSort) {
  114816. this.depthSortedParticles = [];
  114817. }
  114818. }
  114819. /**
  114820. * Builds the SPS underlying mesh. Returns a standard Mesh.
  114821. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  114822. * @returns the created mesh
  114823. */
  114824. SolidParticleSystem.prototype.buildMesh = function () {
  114825. if (this.nbParticles === 0) {
  114826. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  114827. this.addShape(triangle, 1);
  114828. triangle.dispose();
  114829. }
  114830. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  114831. this._positions32 = new Float32Array(this._positions);
  114832. this._uvs32 = new Float32Array(this._uvs);
  114833. this._colors32 = new Float32Array(this._colors);
  114834. if (this.recomputeNormals) {
  114835. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  114836. }
  114837. this._normals32 = new Float32Array(this._normals);
  114838. this._fixedNormal32 = new Float32Array(this._normals);
  114839. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  114840. this._unrotateFixedNormals();
  114841. }
  114842. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  114843. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  114844. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  114845. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  114846. if (this._uvs32.length > 0) {
  114847. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  114848. }
  114849. if (this._colors32.length > 0) {
  114850. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  114851. }
  114852. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  114853. vertexData.applyToMesh(mesh, this._updatable);
  114854. this.mesh = mesh;
  114855. this.mesh.isPickable = this._pickable;
  114856. // free memory
  114857. if (!this._depthSort) {
  114858. this._indices = null;
  114859. }
  114860. this._positions = null;
  114861. this._normals = null;
  114862. this._uvs = null;
  114863. this._colors = null;
  114864. if (!this._updatable) {
  114865. this.particles.length = 0;
  114866. }
  114867. return mesh;
  114868. };
  114869. /**
  114870. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  114871. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  114872. * Thus the particles generated from `digest()` have their property `position` set yet.
  114873. * @param mesh ( Mesh ) is the mesh to be digested
  114874. * @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
  114875. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  114876. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  114877. * @returns the current SPS
  114878. */
  114879. SolidParticleSystem.prototype.digest = function (mesh, options) {
  114880. var size = (options && options.facetNb) || 1;
  114881. var number = (options && options.number) || 0;
  114882. var delta = (options && options.delta) || 0;
  114883. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  114884. var meshInd = mesh.getIndices();
  114885. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  114886. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  114887. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  114888. var f = 0; // facet counter
  114889. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  114890. // compute size from number
  114891. if (number) {
  114892. number = (number > totalFacets) ? totalFacets : number;
  114893. size = Math.round(totalFacets / number);
  114894. delta = 0;
  114895. }
  114896. else {
  114897. size = (size > totalFacets) ? totalFacets : size;
  114898. }
  114899. var facetPos = []; // submesh positions
  114900. var facetInd = []; // submesh indices
  114901. var facetUV = []; // submesh UV
  114902. var facetCol = []; // submesh colors
  114903. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  114904. var sizeO = size;
  114905. while (f < totalFacets) {
  114906. size = sizeO + Math.floor((1 + delta) * Math.random());
  114907. if (f > totalFacets - size) {
  114908. size = totalFacets - f;
  114909. }
  114910. // reset temp arrays
  114911. facetPos.length = 0;
  114912. facetInd.length = 0;
  114913. facetUV.length = 0;
  114914. facetCol.length = 0;
  114915. // iterate over "size" facets
  114916. var fi = 0;
  114917. for (var j = f * 3; j < (f + size) * 3; j++) {
  114918. facetInd.push(fi);
  114919. var i = meshInd[j];
  114920. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  114921. if (meshUV) {
  114922. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  114923. }
  114924. if (meshCol) {
  114925. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  114926. }
  114927. fi++;
  114928. }
  114929. // create a model shape for each single particle
  114930. var idx = this.nbParticles;
  114931. var shape = this._posToShape(facetPos);
  114932. var shapeUV = this._uvsToShapeUV(facetUV);
  114933. // compute the barycenter of the shape
  114934. var v;
  114935. for (v = 0; v < shape.length; v++) {
  114936. barycenter.addInPlace(shape[v]);
  114937. }
  114938. barycenter.scaleInPlace(1 / shape.length);
  114939. // shift the shape from its barycenter to the origin
  114940. for (v = 0; v < shape.length; v++) {
  114941. shape[v].subtractInPlace(barycenter);
  114942. }
  114943. var bInfo;
  114944. if (this._particlesIntersect) {
  114945. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  114946. }
  114947. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  114948. // add the particle in the SPS
  114949. var currentPos = this._positions.length;
  114950. var currentInd = this._indices.length;
  114951. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  114952. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  114953. // initialize the particle position
  114954. this.particles[this.nbParticles].position.addInPlace(barycenter);
  114955. this._index += shape.length;
  114956. idx++;
  114957. this.nbParticles++;
  114958. this._shapeCounter++;
  114959. f += size;
  114960. }
  114961. return this;
  114962. };
  114963. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  114964. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  114965. var index = 0;
  114966. var idx = 0;
  114967. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  114968. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  114969. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  114970. for (var p = 0; p < this.particles.length; p++) {
  114971. var particle = this.particles[p];
  114972. var shape = particle._model._shape;
  114973. // computing the inverse of the rotation matrix from the quaternion
  114974. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  114975. if (particle.rotationQuaternion) {
  114976. particle.rotationQuaternion.conjugateToRef(quaternion);
  114977. }
  114978. else {
  114979. var rotation = particle.rotation;
  114980. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  114981. quaternion.conjugateInPlace();
  114982. }
  114983. quaternion.toRotationMatrix(invertedRotMatrix);
  114984. for (var pt = 0; pt < shape.length; pt++) {
  114985. idx = index + pt * 3;
  114986. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  114987. tmpNormal.toArray(this._fixedNormal32, idx);
  114988. }
  114989. index = idx + 3;
  114990. }
  114991. };
  114992. //reset copy
  114993. SolidParticleSystem.prototype._resetCopy = function () {
  114994. var copy = this._copy;
  114995. copy.position.setAll(0);
  114996. copy.rotation.setAll(0);
  114997. copy.rotationQuaternion = null;
  114998. copy.scaling.setAll(1);
  114999. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  115000. copy.color = null;
  115001. copy.translateFromPivot = false;
  115002. };
  115003. // _meshBuilder : inserts the shape model in the global SPS mesh
  115004. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  115005. var i;
  115006. var u = 0;
  115007. var c = 0;
  115008. var n = 0;
  115009. this._resetCopy();
  115010. var copy = this._copy;
  115011. if (options && options.positionFunction) { // call to custom positionFunction
  115012. options.positionFunction(copy, idx, idxInShape);
  115013. this._mustUnrotateFixedNormals = true;
  115014. }
  115015. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  115016. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  115017. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  115018. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  115019. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  115020. copy.getRotationMatrix(rotMatrix);
  115021. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  115022. if (copy.translateFromPivot) {
  115023. pivotBackTranslation.setAll(0.0);
  115024. }
  115025. else {
  115026. pivotBackTranslation.copyFrom(scaledPivot);
  115027. }
  115028. for (i = 0; i < shape.length; i++) {
  115029. tmpVertex.copyFrom(shape[i]);
  115030. if (options && options.vertexFunction) {
  115031. options.vertexFunction(copy, tmpVertex, i);
  115032. }
  115033. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  115034. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  115035. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  115036. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  115037. if (meshUV) {
  115038. var copyUvs = copy.uvs;
  115039. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  115040. u += 2;
  115041. }
  115042. if (copy.color) {
  115043. this._color = copy.color;
  115044. }
  115045. else {
  115046. var color = this._color;
  115047. if (meshCol && meshCol[c] !== undefined) {
  115048. color.r = meshCol[c];
  115049. color.g = meshCol[c + 1];
  115050. color.b = meshCol[c + 2];
  115051. color.a = meshCol[c + 3];
  115052. }
  115053. else {
  115054. color.r = 1.0;
  115055. color.g = 1.0;
  115056. color.b = 1.0;
  115057. color.a = 1.0;
  115058. }
  115059. }
  115060. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  115061. c += 4;
  115062. if (!this.recomputeNormals && meshNor) {
  115063. tmpVertex.x = meshNor[n];
  115064. tmpVertex.y = meshNor[n + 1];
  115065. tmpVertex.z = meshNor[n + 2];
  115066. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  115067. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  115068. n += 3;
  115069. }
  115070. }
  115071. for (i = 0; i < meshInd.length; i++) {
  115072. var current_ind = p + meshInd[i];
  115073. indices.push(current_ind);
  115074. if (current_ind > 65535) {
  115075. this._needs32Bits = true;
  115076. }
  115077. }
  115078. if (this._pickable) {
  115079. var nbfaces = meshInd.length / 3;
  115080. for (i = 0; i < nbfaces; i++) {
  115081. this.pickedParticles.push({ idx: idx, faceId: i });
  115082. }
  115083. }
  115084. if (this._depthSort) {
  115085. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  115086. }
  115087. return copy;
  115088. };
  115089. // returns a shape array from positions array
  115090. SolidParticleSystem.prototype._posToShape = function (positions) {
  115091. var shape = [];
  115092. for (var i = 0; i < positions.length; i += 3) {
  115093. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  115094. }
  115095. return shape;
  115096. };
  115097. // returns a shapeUV array from a Vector4 uvs
  115098. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  115099. var shapeUV = [];
  115100. if (uvs) {
  115101. for (var i = 0; i < uvs.length; i++) {
  115102. shapeUV.push(uvs[i]);
  115103. }
  115104. }
  115105. return shapeUV;
  115106. };
  115107. // adds a new particle object in the particles array
  115108. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  115109. if (bInfo === void 0) { bInfo = null; }
  115110. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  115111. this.particles.push(sp);
  115112. return sp;
  115113. };
  115114. /**
  115115. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115116. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  115117. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115118. * @param nb (positive integer) the number of particles to be created from this model
  115119. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115120. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115121. * @returns the number of shapes in the system
  115122. */
  115123. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  115124. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  115125. var meshInd = mesh.getIndices();
  115126. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  115127. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  115128. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  115129. var bbInfo;
  115130. if (this._particlesIntersect) {
  115131. bbInfo = mesh.getBoundingInfo();
  115132. }
  115133. var shape = this._posToShape(meshPos);
  115134. var shapeUV = this._uvsToShapeUV(meshUV);
  115135. var posfunc = options ? options.positionFunction : null;
  115136. var vtxfunc = options ? options.vertexFunction : null;
  115137. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  115138. // particles
  115139. var sp;
  115140. var currentCopy;
  115141. var idx = this.nbParticles;
  115142. for (var i = 0; i < nb; i++) {
  115143. var currentPos = this._positions.length;
  115144. var currentInd = this._indices.length;
  115145. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  115146. if (this._updatable) {
  115147. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  115148. sp.position.copyFrom(currentCopy.position);
  115149. sp.rotation.copyFrom(currentCopy.rotation);
  115150. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  115151. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  115152. }
  115153. if (currentCopy.color && sp.color) {
  115154. sp.color.copyFrom(currentCopy.color);
  115155. }
  115156. sp.scaling.copyFrom(currentCopy.scaling);
  115157. sp.uvs.copyFrom(currentCopy.uvs);
  115158. }
  115159. this._index += shape.length;
  115160. idx++;
  115161. }
  115162. this.nbParticles += nb;
  115163. this._shapeCounter++;
  115164. return this._shapeCounter - 1;
  115165. };
  115166. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115167. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  115168. this._resetCopy();
  115169. var copy = this._copy;
  115170. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  115171. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  115172. }
  115173. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  115174. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  115175. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  115176. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  115177. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  115178. copy.getRotationMatrix(rotMatrix);
  115179. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  115180. if (copy.translateFromPivot) {
  115181. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  115182. }
  115183. else {
  115184. pivotBackTranslation.copyFrom(scaledPivot);
  115185. }
  115186. var shape = particle._model._shape;
  115187. for (var pt = 0; pt < shape.length; pt++) {
  115188. tmpVertex.copyFrom(shape[pt]);
  115189. if (particle._model._vertexFunction) {
  115190. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  115191. }
  115192. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  115193. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  115194. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  115195. }
  115196. particle.position.setAll(0.0);
  115197. particle.rotation.setAll(0.0);
  115198. particle.rotationQuaternion = null;
  115199. particle.scaling.setAll(1.0);
  115200. particle.uvs.setAll(0.0);
  115201. particle.pivot.setAll(0.0);
  115202. particle.translateFromPivot = false;
  115203. particle.parentId = null;
  115204. };
  115205. /**
  115206. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115207. * @returns the SPS.
  115208. */
  115209. SolidParticleSystem.prototype.rebuildMesh = function () {
  115210. for (var p = 0; p < this.particles.length; p++) {
  115211. this._rebuildParticle(this.particles[p]);
  115212. }
  115213. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  115214. return this;
  115215. };
  115216. /**
  115217. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115218. * This method calls `updateParticle()` for each particle of the SPS.
  115219. * For an animated SPS, it is usually called within the render loop.
  115220. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115221. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115222. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115223. * @returns the SPS.
  115224. */
  115225. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  115226. if (start === void 0) { start = 0; }
  115227. if (end === void 0) { end = this.nbParticles - 1; }
  115228. if (update === void 0) { update = true; }
  115229. if (!this._updatable) {
  115230. return this;
  115231. }
  115232. // custom beforeUpdate
  115233. this.beforeUpdateParticles(start, end, update);
  115234. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  115235. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  115236. var mesh = this.mesh;
  115237. var colors32 = this._colors32;
  115238. var positions32 = this._positions32;
  115239. var normals32 = this._normals32;
  115240. var uvs32 = this._uvs32;
  115241. var indices32 = this._indices32;
  115242. var indices = this._indices;
  115243. var fixedNormal32 = this._fixedNormal32;
  115244. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  115245. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  115246. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  115247. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  115248. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  115249. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  115250. var camInvertedPosition = tempVectors[10].setAll(0);
  115251. // cases when the World Matrix is to be computed first
  115252. if (this.billboard || this._depthSort) {
  115253. this.mesh.computeWorldMatrix(true);
  115254. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  115255. }
  115256. // if the particles will always face the camera
  115257. if (this.billboard) {
  115258. // compute the camera position and un-rotate it by the current mesh rotation
  115259. var tmpVertex = tempVectors[0];
  115260. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  115261. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  115262. camAxisZ.normalize();
  115263. // same for camera up vector extracted from the cam view matrix
  115264. var view = this._camera.getViewMatrix(true);
  115265. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  115266. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  115267. camAxisY.normalize();
  115268. camAxisX.normalize();
  115269. }
  115270. // if depthSort, compute the camera global position in the mesh local system
  115271. if (this._depthSort) {
  115272. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  115273. }
  115274. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  115275. var idx = 0; // current position index in the global array positions32
  115276. var index = 0; // position start index in the global array positions32 of the current particle
  115277. var colidx = 0; // current color index in the global array colors32
  115278. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  115279. var uvidx = 0; // current uv index in the global array uvs32
  115280. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  115281. var pt = 0; // current index in the particle model shape
  115282. if (this.mesh.isFacetDataEnabled) {
  115283. this._computeBoundingBox = true;
  115284. }
  115285. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  115286. if (this._computeBoundingBox) {
  115287. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  115288. var boundingInfo = this.mesh._boundingInfo;
  115289. if (boundingInfo) {
  115290. minimum.copyFrom(boundingInfo.minimum);
  115291. maximum.copyFrom(boundingInfo.maximum);
  115292. }
  115293. }
  115294. }
  115295. // particle loop
  115296. index = this.particles[start]._pos;
  115297. var vpos = (index / 3) | 0;
  115298. colorIndex = vpos * 4;
  115299. uvIndex = vpos * 2;
  115300. for (var p = start; p <= end; p++) {
  115301. var particle = this.particles[p];
  115302. // call to custom user function to update the particle properties
  115303. this.updateParticle(particle);
  115304. var shape = particle._model._shape;
  115305. var shapeUV = particle._model._shapeUV;
  115306. var particleRotationMatrix = particle._rotationMatrix;
  115307. var particlePosition = particle.position;
  115308. var particleRotation = particle.rotation;
  115309. var particleScaling = particle.scaling;
  115310. var particleGlobalPosition = particle._globalPosition;
  115311. // camera-particle distance for depth sorting
  115312. if (this._depthSort && this._depthSortParticles) {
  115313. var dsp = this.depthSortedParticles[p];
  115314. dsp.ind = particle._ind;
  115315. dsp.indicesLength = particle._model._indicesLength;
  115316. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  115317. }
  115318. // skip the computations for inactive or already invisible particles
  115319. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  115320. // increment indexes for the next particle
  115321. pt = shape.length;
  115322. index += pt * 3;
  115323. colorIndex += pt * 4;
  115324. uvIndex += pt * 2;
  115325. continue;
  115326. }
  115327. if (particle.isVisible) {
  115328. particle._stillInvisible = false; // un-mark permanent invisibility
  115329. var scaledPivot = tempVectors[12];
  115330. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  115331. // particle rotation matrix
  115332. if (this.billboard) {
  115333. particleRotation.x = 0.0;
  115334. particleRotation.y = 0.0;
  115335. }
  115336. if (this._computeParticleRotation || this.billboard) {
  115337. particle.getRotationMatrix(rotMatrix);
  115338. }
  115339. var particleHasParent = (particle.parentId !== null);
  115340. if (particleHasParent) {
  115341. var parent_1 = this.particles[particle.parentId];
  115342. var parentRotationMatrix = parent_1._rotationMatrix;
  115343. var parentGlobalPosition = parent_1._globalPosition;
  115344. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  115345. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  115346. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  115347. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  115348. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  115349. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  115350. if (this._computeParticleRotation || this.billboard) {
  115351. var rotMatrixValues = rotMatrix.m;
  115352. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  115353. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  115354. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  115355. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  115356. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  115357. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  115358. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  115359. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  115360. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  115361. }
  115362. }
  115363. else {
  115364. particleGlobalPosition.x = particlePosition.x;
  115365. particleGlobalPosition.y = particlePosition.y;
  115366. particleGlobalPosition.z = particlePosition.z;
  115367. if (this._computeParticleRotation || this.billboard) {
  115368. var rotMatrixValues = rotMatrix.m;
  115369. particleRotationMatrix[0] = rotMatrixValues[0];
  115370. particleRotationMatrix[1] = rotMatrixValues[1];
  115371. particleRotationMatrix[2] = rotMatrixValues[2];
  115372. particleRotationMatrix[3] = rotMatrixValues[4];
  115373. particleRotationMatrix[4] = rotMatrixValues[5];
  115374. particleRotationMatrix[5] = rotMatrixValues[6];
  115375. particleRotationMatrix[6] = rotMatrixValues[8];
  115376. particleRotationMatrix[7] = rotMatrixValues[9];
  115377. particleRotationMatrix[8] = rotMatrixValues[10];
  115378. }
  115379. }
  115380. var pivotBackTranslation = tempVectors[11];
  115381. if (particle.translateFromPivot) {
  115382. pivotBackTranslation.setAll(0.0);
  115383. }
  115384. else {
  115385. pivotBackTranslation.copyFrom(scaledPivot);
  115386. }
  115387. // particle vertex loop
  115388. for (pt = 0; pt < shape.length; pt++) {
  115389. idx = index + pt * 3;
  115390. colidx = colorIndex + pt * 4;
  115391. uvidx = uvIndex + pt * 2;
  115392. var tmpVertex = tempVectors[0];
  115393. tmpVertex.copyFrom(shape[pt]);
  115394. if (this._computeParticleVertex) {
  115395. this.updateParticleVertex(particle, tmpVertex, pt);
  115396. }
  115397. // positions
  115398. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  115399. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  115400. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  115401. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  115402. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  115403. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  115404. rotatedX += pivotBackTranslation.x;
  115405. rotatedY += pivotBackTranslation.y;
  115406. rotatedZ += pivotBackTranslation.z;
  115407. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  115408. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  115409. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  115410. if (this._computeBoundingBox) {
  115411. minimum.minimizeInPlaceFromFloats(px, py, pz);
  115412. maximum.maximizeInPlaceFromFloats(px, py, pz);
  115413. }
  115414. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  115415. if (!this._computeParticleVertex) {
  115416. var normalx = fixedNormal32[idx];
  115417. var normaly = fixedNormal32[idx + 1];
  115418. var normalz = fixedNormal32[idx + 2];
  115419. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  115420. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  115421. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  115422. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  115423. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  115424. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  115425. }
  115426. if (this._computeParticleColor && particle.color) {
  115427. var color = particle.color;
  115428. var colors32_1 = this._colors32;
  115429. colors32_1[colidx] = color.r;
  115430. colors32_1[colidx + 1] = color.g;
  115431. colors32_1[colidx + 2] = color.b;
  115432. colors32_1[colidx + 3] = color.a;
  115433. }
  115434. if (this._computeParticleTexture) {
  115435. var uvs = particle.uvs;
  115436. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  115437. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  115438. }
  115439. }
  115440. }
  115441. // particle just set invisible : scaled to zero and positioned at the origin
  115442. else {
  115443. particle._stillInvisible = true; // mark the particle as invisible
  115444. for (pt = 0; pt < shape.length; pt++) {
  115445. idx = index + pt * 3;
  115446. colidx = colorIndex + pt * 4;
  115447. uvidx = uvIndex + pt * 2;
  115448. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  115449. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  115450. if (this._computeParticleColor && particle.color) {
  115451. var color = particle.color;
  115452. colors32[colidx] = color.r;
  115453. colors32[colidx + 1] = color.g;
  115454. colors32[colidx + 2] = color.b;
  115455. colors32[colidx + 3] = color.a;
  115456. }
  115457. if (this._computeParticleTexture) {
  115458. var uvs = particle.uvs;
  115459. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  115460. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  115461. }
  115462. }
  115463. }
  115464. // if the particle intersections must be computed : update the bbInfo
  115465. if (this._particlesIntersect) {
  115466. var bInfo = particle._boundingInfo;
  115467. var bBox = bInfo.boundingBox;
  115468. var bSphere = bInfo.boundingSphere;
  115469. var modelBoundingInfo = particle._modelBoundingInfo;
  115470. if (!this._bSphereOnly) {
  115471. // place, scale and rotate the particle bbox within the SPS local system, then update it
  115472. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  115473. var tempMin = tempVectors[1];
  115474. var tempMax = tempVectors[2];
  115475. tempMin.setAll(Number.MAX_VALUE);
  115476. tempMax.setAll(-Number.MAX_VALUE);
  115477. for (var b = 0; b < 8; b++) {
  115478. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  115479. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  115480. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  115481. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  115482. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  115483. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  115484. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  115485. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  115486. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  115487. tempMin.minimizeInPlaceFromFloats(x, y, z);
  115488. tempMax.maximizeInPlaceFromFloats(x, y, z);
  115489. }
  115490. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  115491. }
  115492. // place and scale the particle bouding sphere in the SPS local system, then update it
  115493. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  115494. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  115495. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  115496. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  115497. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  115498. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  115499. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  115500. }
  115501. // increment indexes for the next particle
  115502. index = idx + 3;
  115503. colorIndex = colidx + 4;
  115504. uvIndex = uvidx + 2;
  115505. }
  115506. // if the VBO must be updated
  115507. if (update) {
  115508. if (this._computeParticleColor) {
  115509. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  115510. }
  115511. if (this._computeParticleTexture) {
  115512. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  115513. }
  115514. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  115515. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  115516. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  115517. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  115518. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  115519. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  115520. for (var i = 0; i < normals32.length; i++) {
  115521. fixedNormal32[i] = normals32[i];
  115522. }
  115523. }
  115524. if (!mesh.areNormalsFrozen) {
  115525. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  115526. }
  115527. }
  115528. if (this._depthSort && this._depthSortParticles) {
  115529. var depthSortedParticles = this.depthSortedParticles;
  115530. depthSortedParticles.sort(depthSortFunction);
  115531. var dspl = depthSortedParticles.length;
  115532. var sid = 0;
  115533. for (var sorted = 0; sorted < dspl; sorted++) {
  115534. var lind = depthSortedParticles[sorted].indicesLength;
  115535. var sind = depthSortedParticles[sorted].ind;
  115536. for (var i = 0; i < lind; i++) {
  115537. indices32[sid] = indices[sind + i];
  115538. sid++;
  115539. }
  115540. }
  115541. mesh.updateIndices(indices32);
  115542. }
  115543. }
  115544. if (this._computeBoundingBox) {
  115545. if (mesh._boundingInfo) {
  115546. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  115547. }
  115548. else {
  115549. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  115550. }
  115551. }
  115552. this.afterUpdateParticles(start, end, update);
  115553. return this;
  115554. };
  115555. /**
  115556. * Disposes the SPS.
  115557. */
  115558. SolidParticleSystem.prototype.dispose = function () {
  115559. this.mesh.dispose();
  115560. this.vars = null;
  115561. // drop references to internal big arrays for the GC
  115562. this._positions = null;
  115563. this._indices = null;
  115564. this._normals = null;
  115565. this._uvs = null;
  115566. this._colors = null;
  115567. this._indices32 = null;
  115568. this._positions32 = null;
  115569. this._normals32 = null;
  115570. this._fixedNormal32 = null;
  115571. this._uvs32 = null;
  115572. this._colors32 = null;
  115573. this.pickedParticles = null;
  115574. };
  115575. /**
  115576. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  115577. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  115578. * @returns the SPS.
  115579. */
  115580. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  115581. if (!this._isVisibilityBoxLocked) {
  115582. this.mesh.refreshBoundingInfo();
  115583. }
  115584. return this;
  115585. };
  115586. /**
  115587. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  115588. * @param size the size (float) of the visibility box
  115589. * note : this doesn't lock the SPS mesh bounding box.
  115590. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  115591. */
  115592. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  115593. var vis = size / 2;
  115594. 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));
  115595. };
  115596. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  115597. /**
  115598. * Gets whether the SPS as always visible or not
  115599. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  115600. */
  115601. get: function () {
  115602. return this._alwaysVisible;
  115603. },
  115604. /**
  115605. * Sets the SPS as always visible or not
  115606. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  115607. */
  115608. set: function (val) {
  115609. this._alwaysVisible = val;
  115610. this.mesh.alwaysSelectAsActiveMesh = val;
  115611. },
  115612. enumerable: true,
  115613. configurable: true
  115614. });
  115615. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  115616. /**
  115617. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115618. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  115619. */
  115620. get: function () {
  115621. return this._isVisibilityBoxLocked;
  115622. },
  115623. /**
  115624. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115625. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  115626. */
  115627. set: function (val) {
  115628. this._isVisibilityBoxLocked = val;
  115629. var boundingInfo = this.mesh.getBoundingInfo();
  115630. boundingInfo.isLocked = val;
  115631. },
  115632. enumerable: true,
  115633. configurable: true
  115634. });
  115635. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  115636. /**
  115637. * Gets if `setParticles()` computes the particle rotations or not.
  115638. * Default value : true. The SPS is faster when it's set to false.
  115639. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115640. */
  115641. get: function () {
  115642. return this._computeParticleRotation;
  115643. },
  115644. /**
  115645. * Tells to `setParticles()` to compute the particle rotations or not.
  115646. * Default value : true. The SPS is faster when it's set to false.
  115647. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115648. */
  115649. set: function (val) {
  115650. this._computeParticleRotation = val;
  115651. },
  115652. enumerable: true,
  115653. configurable: true
  115654. });
  115655. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  115656. /**
  115657. * Gets if `setParticles()` computes the particle colors or not.
  115658. * Default value : true. The SPS is faster when it's set to false.
  115659. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115660. */
  115661. get: function () {
  115662. return this._computeParticleColor;
  115663. },
  115664. /**
  115665. * Tells to `setParticles()` to compute the particle colors or not.
  115666. * Default value : true. The SPS is faster when it's set to false.
  115667. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115668. */
  115669. set: function (val) {
  115670. this._computeParticleColor = val;
  115671. },
  115672. enumerable: true,
  115673. configurable: true
  115674. });
  115675. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  115676. /**
  115677. * Gets if `setParticles()` computes the particle textures or not.
  115678. * Default value : true. The SPS is faster when it's set to false.
  115679. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  115680. */
  115681. get: function () {
  115682. return this._computeParticleTexture;
  115683. },
  115684. set: function (val) {
  115685. this._computeParticleTexture = val;
  115686. },
  115687. enumerable: true,
  115688. configurable: true
  115689. });
  115690. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  115691. /**
  115692. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  115693. * Default value : false. The SPS is faster when it's set to false.
  115694. * Note : the particle custom vertex positions aren't stored values.
  115695. */
  115696. get: function () {
  115697. return this._computeParticleVertex;
  115698. },
  115699. /**
  115700. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  115701. * Default value : false. The SPS is faster when it's set to false.
  115702. * Note : the particle custom vertex positions aren't stored values.
  115703. */
  115704. set: function (val) {
  115705. this._computeParticleVertex = val;
  115706. },
  115707. enumerable: true,
  115708. configurable: true
  115709. });
  115710. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  115711. /**
  115712. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  115713. */
  115714. get: function () {
  115715. return this._computeBoundingBox;
  115716. },
  115717. /**
  115718. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  115719. */
  115720. set: function (val) {
  115721. this._computeBoundingBox = val;
  115722. },
  115723. enumerable: true,
  115724. configurable: true
  115725. });
  115726. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  115727. /**
  115728. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  115729. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115730. * Default : `true`
  115731. */
  115732. get: function () {
  115733. return this._depthSortParticles;
  115734. },
  115735. /**
  115736. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  115737. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115738. * Default : `true`
  115739. */
  115740. set: function (val) {
  115741. this._depthSortParticles = val;
  115742. },
  115743. enumerable: true,
  115744. configurable: true
  115745. });
  115746. // =======================================================================
  115747. // Particle behavior logic
  115748. // these following methods may be overwritten by the user to fit his needs
  115749. /**
  115750. * This function does nothing. It may be overwritten to set all the particle first values.
  115751. * The SPS doesn't call this function, you may have to call it by your own.
  115752. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  115753. */
  115754. SolidParticleSystem.prototype.initParticles = function () {
  115755. };
  115756. /**
  115757. * This function does nothing. It may be overwritten to recycle a particle.
  115758. * The SPS doesn't call this function, you may have to call it by your own.
  115759. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  115760. * @param particle The particle to recycle
  115761. * @returns the recycled particle
  115762. */
  115763. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  115764. return particle;
  115765. };
  115766. /**
  115767. * Updates a particle : this function should be overwritten by the user.
  115768. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  115769. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  115770. * @example : just set a particle position or velocity and recycle conditions
  115771. * @param particle The particle to update
  115772. * @returns the updated particle
  115773. */
  115774. SolidParticleSystem.prototype.updateParticle = function (particle) {
  115775. return particle;
  115776. };
  115777. /**
  115778. * Updates a vertex of a particle : it can be overwritten by the user.
  115779. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  115780. * @param particle the current particle
  115781. * @param vertex the current index of the current particle
  115782. * @param pt the index of the current vertex in the particle shape
  115783. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  115784. * @example : just set a vertex particle position
  115785. * @returns the updated vertex
  115786. */
  115787. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  115788. return vertex;
  115789. };
  115790. /**
  115791. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  115792. * This does nothing and may be overwritten by the user.
  115793. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115794. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115795. * @param update the boolean update value actually passed to setParticles()
  115796. */
  115797. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  115798. };
  115799. /**
  115800. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  115801. * This will be passed three parameters.
  115802. * This does nothing and may be overwritten by the user.
  115803. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115804. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115805. * @param update the boolean update value actually passed to setParticles()
  115806. */
  115807. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  115808. };
  115809. return SolidParticleSystem;
  115810. }());
  115811. /***/ }),
  115812. /***/ "./Particles/subEmitter.ts":
  115813. /*!*********************************!*\
  115814. !*** ./Particles/subEmitter.ts ***!
  115815. \*********************************/
  115816. /*! exports provided: SubEmitterType, SubEmitter */
  115817. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115818. "use strict";
  115819. __webpack_require__.r(__webpack_exports__);
  115820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  115821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  115822. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115823. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  115824. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  115825. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  115826. /**
  115827. * Type of sub emitter
  115828. */
  115829. var SubEmitterType;
  115830. (function (SubEmitterType) {
  115831. /**
  115832. * Attached to the particle over it's lifetime
  115833. */
  115834. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  115835. /**
  115836. * Created when the particle dies
  115837. */
  115838. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  115839. })(SubEmitterType || (SubEmitterType = {}));
  115840. /**
  115841. * Sub emitter class used to emit particles from an existing particle
  115842. */
  115843. var SubEmitter = /** @class */ (function () {
  115844. /**
  115845. * Creates a sub emitter
  115846. * @param particleSystem the particle system to be used by the sub emitter
  115847. */
  115848. function SubEmitter(
  115849. /**
  115850. * the particle system to be used by the sub emitter
  115851. */
  115852. particleSystem) {
  115853. this.particleSystem = particleSystem;
  115854. /**
  115855. * Type of the submitter (Default: END)
  115856. */
  115857. this.type = SubEmitterType.END;
  115858. /**
  115859. * 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)
  115860. * Note: This only is supported when using an emitter of type Mesh
  115861. */
  115862. this.inheritDirection = false;
  115863. /**
  115864. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  115865. */
  115866. this.inheritedVelocityAmount = 0;
  115867. // Create mesh as emitter to support rotation
  115868. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  115869. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  115870. }
  115871. // Automatically dispose of subemitter when system is disposed
  115872. particleSystem.onDisposeObservable.add(function () {
  115873. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  115874. particleSystem.emitter.dispose();
  115875. }
  115876. });
  115877. }
  115878. /**
  115879. * Clones the sub emitter
  115880. * @returns the cloned sub emitter
  115881. */
  115882. SubEmitter.prototype.clone = function () {
  115883. // Clone particle system
  115884. var emitter = this.particleSystem.emitter;
  115885. if (!emitter) {
  115886. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  115887. }
  115888. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  115889. emitter = emitter.clone();
  115890. }
  115891. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  115892. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  115893. emitter.isVisible = false;
  115894. }
  115895. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  115896. // Clone properties
  115897. clone.type = this.type;
  115898. clone.inheritDirection = this.inheritDirection;
  115899. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  115900. clone.particleSystem._disposeEmitterOnDispose = true;
  115901. clone.particleSystem.disposeOnStop = true;
  115902. return clone;
  115903. };
  115904. /**
  115905. * Serialize current object to a JSON object
  115906. * @returns the serialized object
  115907. */
  115908. SubEmitter.prototype.serialize = function () {
  115909. var serializationObject = {};
  115910. serializationObject.type = this.type;
  115911. serializationObject.inheritDirection = this.inheritDirection;
  115912. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  115913. serializationObject.particleSystem = this.particleSystem.serialize();
  115914. return serializationObject;
  115915. };
  115916. /** @hidden */
  115917. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  115918. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  115919. };
  115920. /**
  115921. * Creates a new SubEmitter from a serialized JSON version
  115922. * @param serializationObject defines the JSON object to read from
  115923. * @param scene defines the hosting scene
  115924. * @param rootUrl defines the rootUrl for data loading
  115925. * @returns a new SubEmitter
  115926. */
  115927. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  115928. var system = serializationObject.particleSystem;
  115929. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  115930. subEmitter.type = serializationObject.type;
  115931. subEmitter.inheritDirection = serializationObject.inheritDirection;
  115932. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  115933. subEmitter.particleSystem._isSubEmitter = true;
  115934. return subEmitter;
  115935. };
  115936. /** Release associated resources */
  115937. SubEmitter.prototype.dispose = function () {
  115938. this.particleSystem.dispose();
  115939. };
  115940. return SubEmitter;
  115941. }());
  115942. /***/ }),
  115943. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  115944. /*!*****************************************!*\
  115945. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  115946. \*****************************************/
  115947. /*! exports provided: AmmoJSPlugin */
  115948. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115949. "use strict";
  115950. __webpack_require__.r(__webpack_exports__);
  115951. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  115952. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  115953. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  115954. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  115955. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  115956. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  115957. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  115958. /* harmony import */ var _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Meshes/Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  115959. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  115960. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  115961. /**
  115962. * AmmoJS Physics plugin
  115963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  115964. * @see https://github.com/kripken/ammo.js/
  115965. */
  115966. var AmmoJSPlugin = /** @class */ (function () {
  115967. /**
  115968. * Initializes the ammoJS plugin
  115969. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  115970. * @param ammoInjection can be used to inject your own ammo reference
  115971. */
  115972. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  115973. var _this = this;
  115974. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  115975. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  115976. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  115977. /**
  115978. * Reference to the Ammo library
  115979. */
  115980. this.bjsAMMO = {};
  115981. /**
  115982. * Name of the plugin
  115983. */
  115984. this.name = "AmmoJSPlugin";
  115985. this._timeStep = 1 / 60;
  115986. this._fixedTimeStep = 1 / 60;
  115987. this._maxSteps = 5;
  115988. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  115989. this._tmpContactCallbackResult = false;
  115990. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  115991. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  115992. if (typeof ammoInjection === "function") {
  115993. ammoInjection(this.bjsAMMO);
  115994. }
  115995. else {
  115996. this.bjsAMMO = ammoInjection;
  115997. }
  115998. if (!this.isSupported()) {
  115999. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  116000. return;
  116001. }
  116002. // Initialize the physics world
  116003. this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration();
  116004. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  116005. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  116006. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  116007. this._softBodySolver = new this.bjsAMMO.btDefaultSoftBodySolver();
  116008. this.world = new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration, this._softBodySolver);
  116009. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  116010. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  116011. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_8__["PhysicsRaycastResult"]();
  116012. // Create temp ammo variables
  116013. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  116014. this._tmpAmmoTransform.setIdentity();
  116015. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  116016. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  116017. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  116018. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  116019. this._tmpAmmoVectorD = new this.bjsAMMO.btVector3(0, 0, 0);
  116020. }
  116021. /**
  116022. * Sets the gravity of the physics world (m/(s^2))
  116023. * @param gravity Gravity to set
  116024. */
  116025. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  116026. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  116027. this.world.setGravity(this._tmpAmmoVectorA);
  116028. this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA);
  116029. };
  116030. /**
  116031. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116032. * @param timeStep timestep to use in seconds
  116033. */
  116034. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  116035. this._timeStep = timeStep;
  116036. };
  116037. /**
  116038. * 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)
  116039. * @param fixedTimeStep fixedTimeStep to use in seconds
  116040. */
  116041. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  116042. this._fixedTimeStep = fixedTimeStep;
  116043. };
  116044. /**
  116045. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116046. * @param maxSteps the maximum number of steps by the physics engine per frame
  116047. */
  116048. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  116049. this._maxSteps = maxSteps;
  116050. };
  116051. /**
  116052. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116053. * @returns the current timestep in seconds
  116054. */
  116055. AmmoJSPlugin.prototype.getTimeStep = function () {
  116056. return this._timeStep;
  116057. };
  116058. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  116059. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  116060. this._tmpContactCallbackResult = false;
  116061. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  116062. return this._tmpContactCallbackResult;
  116063. };
  116064. // Ammo's collision events have some weird quirks
  116065. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  116066. // so only fire event if both contactTest and contactPairTest have a hit
  116067. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  116068. this._tmpContactCallbackResult = false;
  116069. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  116070. return this._tmpContactCallbackResult;
  116071. };
  116072. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  116073. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  116074. //
  116075. // When maxSteps is 0 do the entire simulation in one step
  116076. // 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)
  116077. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  116078. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  116079. if (timeStep === void 0) { timeStep = 1 / 60; }
  116080. if (maxSteps === void 0) { maxSteps = 10; }
  116081. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  116082. if (maxSteps == 0) {
  116083. this.world.stepSimulation(timeStep, 0);
  116084. }
  116085. else {
  116086. while (maxSteps > 0 && timeStep > 0) {
  116087. if (timeStep - fixedTimeStep < fixedTimeStep) {
  116088. this.world.stepSimulation(timeStep, 0);
  116089. timeStep = 0;
  116090. }
  116091. else {
  116092. timeStep -= fixedTimeStep;
  116093. this.world.stepSimulation(fixedTimeStep, 0);
  116094. }
  116095. maxSteps--;
  116096. }
  116097. }
  116098. };
  116099. /**
  116100. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116101. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116102. * After the step the babylon meshes are set to the position of the physics imposters
  116103. * @param delta amount of time to step forward
  116104. * @param impostors array of imposters to update before/after the step
  116105. */
  116106. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  116107. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  116108. var impostor = impostors_1[_i];
  116109. // Update physics world objects to match babylon world
  116110. if (!impostor.soft) {
  116111. impostor.beforeStep();
  116112. }
  116113. }
  116114. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  116115. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  116116. var mainImpostor = impostors_2[_a];
  116117. // After physics update make babylon world objects match physics world objects
  116118. if (mainImpostor.soft) {
  116119. this._afterSoftStep(mainImpostor);
  116120. }
  116121. else {
  116122. mainImpostor.afterStep();
  116123. }
  116124. // Handle collision event
  116125. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  116126. if (this._isImpostorInContact(mainImpostor)) {
  116127. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  116128. var collideCallback = _c[_b];
  116129. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  116130. var otherImpostor = _e[_d];
  116131. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  116132. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  116133. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  116134. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  116135. }
  116136. }
  116137. }
  116138. }
  116139. }
  116140. }
  116141. }
  116142. };
  116143. /**
  116144. * Update babylon mesh to match physics world object
  116145. * @param impostor imposter to match
  116146. */
  116147. AmmoJSPlugin.prototype._afterSoftStep = function (impostor) {
  116148. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor) {
  116149. this._ropeStep(impostor);
  116150. }
  116151. else {
  116152. this._softbodyOrClothStep(impostor);
  116153. }
  116154. };
  116155. /**
  116156. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116157. * @param impostor imposter to match
  116158. */
  116159. AmmoJSPlugin.prototype._ropeStep = function (impostor) {
  116160. var bodyVertices = impostor.physicsBody.get_m_nodes();
  116161. var nbVertices = bodyVertices.size();
  116162. var node;
  116163. var nodePositions;
  116164. var x, y, z;
  116165. var path = new Array();
  116166. for (var n = 0; n < nbVertices; n++) {
  116167. node = bodyVertices.at(n);
  116168. nodePositions = node.get_m_x();
  116169. x = nodePositions.x();
  116170. y = nodePositions.y();
  116171. z = nodePositions.z();
  116172. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](x, y, z));
  116173. }
  116174. var object = impostor.object;
  116175. var shape = impostor.getParam("shape");
  116176. if (impostor._isFromLine) {
  116177. impostor.object = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines("lines", { points: path, instance: object });
  116178. }
  116179. else {
  116180. impostor.object = _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__["ShapeBuilder"].ExtrudeShape("ext", { shape: shape, path: path, instance: object });
  116181. }
  116182. };
  116183. /**
  116184. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116185. * @param impostor imposter to match
  116186. */
  116187. AmmoJSPlugin.prototype._softbodyOrClothStep = function (impostor) {
  116188. var normalDirection = (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor) ? 1 : -1;
  116189. var object = impostor.object;
  116190. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  116191. if (!vertexPositions) {
  116192. vertexPositions = [];
  116193. }
  116194. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  116195. if (!vertexNormals) {
  116196. vertexNormals = [];
  116197. }
  116198. var nbVertices = vertexPositions.length / 3;
  116199. var bodyVertices = impostor.physicsBody.get_m_nodes();
  116200. var node;
  116201. var nodePositions;
  116202. var nodeNormals;
  116203. var x, y, z;
  116204. var nx, ny, nz;
  116205. for (var n = 0; n < nbVertices; n++) {
  116206. node = bodyVertices.at(n);
  116207. nodePositions = node.get_m_x();
  116208. x = nodePositions.x();
  116209. y = nodePositions.y();
  116210. z = nodePositions.z() * normalDirection;
  116211. var nodeNormals = node.get_m_n();
  116212. nx = nodeNormals.x();
  116213. ny = nodeNormals.y();
  116214. nz = nodeNormals.z() * normalDirection;
  116215. vertexPositions[3 * n] = x;
  116216. vertexPositions[3 * n + 1] = y;
  116217. vertexPositions[3 * n + 2] = z;
  116218. vertexNormals[3 * n] = nx;
  116219. vertexNormals[3 * n + 1] = ny;
  116220. vertexNormals[3 * n + 2] = nz;
  116221. }
  116222. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  116223. vertex_data.positions = vertexPositions;
  116224. vertex_data.normals = vertexNormals;
  116225. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  116226. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  116227. if (object && object.getIndices) {
  116228. vertex_data.indices = object.getIndices();
  116229. }
  116230. vertex_data.applyToMesh(object);
  116231. };
  116232. /**
  116233. * Applies an impulse on the imposter
  116234. * @param impostor imposter to apply impulse to
  116235. * @param force amount of force to be applied to the imposter
  116236. * @param contactPoint the location to apply the impulse on the imposter
  116237. */
  116238. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  116239. if (!impostor.soft) {
  116240. impostor.physicsBody.activate();
  116241. var worldPoint = this._tmpAmmoVectorA;
  116242. var impulse = this._tmpAmmoVectorB;
  116243. // Convert contactPoint into world space
  116244. if (impostor.object && impostor.object.getWorldMatrix) {
  116245. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  116246. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  116247. contactPoint = this._tmpVector;
  116248. }
  116249. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  116250. impulse.setValue(force.x, force.y, force.z);
  116251. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  116252. }
  116253. else {
  116254. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  116255. }
  116256. };
  116257. /**
  116258. * Applies a force on the imposter
  116259. * @param impostor imposter to apply force
  116260. * @param force amount of force to be applied to the imposter
  116261. * @param contactPoint the location to apply the force on the imposter
  116262. */
  116263. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  116264. if (!impostor.soft) {
  116265. impostor.physicsBody.activate();
  116266. var worldPoint = this._tmpAmmoVectorA;
  116267. var impulse = this._tmpAmmoVectorB;
  116268. // Convert contactPoint into world space
  116269. if (impostor.object && impostor.object.getWorldMatrix) {
  116270. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  116271. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  116272. contactPoint = this._tmpVector;
  116273. }
  116274. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  116275. impulse.setValue(force.x, force.y, force.z);
  116276. impostor.physicsBody.applyForce(impulse, worldPoint);
  116277. }
  116278. else {
  116279. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  116280. }
  116281. };
  116282. /**
  116283. * Creates a physics body using the plugin
  116284. * @param impostor the imposter to create the physics body on
  116285. */
  116286. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  116287. // Note: this method will not be called on child imposotrs for compound impostors
  116288. impostor._pluginData.toDispose = [];
  116289. //parent-child relationship
  116290. if (impostor.parent) {
  116291. if (impostor.physicsBody) {
  116292. this.removePhysicsBody(impostor);
  116293. impostor.forceUpdate();
  116294. }
  116295. return;
  116296. }
  116297. if (impostor.isBodyInitRequired()) {
  116298. var colShape = this._createShape(impostor);
  116299. var mass = impostor.getParam("mass");
  116300. impostor._pluginData.mass = mass;
  116301. if (impostor.soft) {
  116302. colShape.get_m_cfg().set_collisions(0x11);
  116303. colShape.get_m_cfg().set_kDP(impostor.getParam("damping"));
  116304. Ammo.castObject(colShape, Ammo.btCollisionObject).getCollisionShape().setMargin(impostor.getParam("margin"));
  116305. colShape.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  116306. this.world.addSoftBody(colShape, 1, -1);
  116307. impostor.physicsBody = colShape;
  116308. impostor._pluginData.toDispose.push(colShape);
  116309. this.setBodyPressure(impostor, 0);
  116310. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  116311. this.setBodyPressure(impostor, impostor.getParam("pressure"));
  116312. }
  116313. this.setBodyStiffness(impostor, impostor.getParam("stiffness"));
  116314. this.setBodyVelocityIterations(impostor, impostor.getParam("velocityIterations"));
  116315. this.setBodyPositionIterations(impostor, impostor.getParam("positionIterations"));
  116316. }
  116317. else {
  116318. var localInertia = new Ammo.btVector3(0, 0, 0);
  116319. var startTransform = new Ammo.btTransform();
  116320. startTransform.setIdentity();
  116321. if (mass !== 0) {
  116322. colShape.calculateLocalInertia(mass, localInertia);
  116323. }
  116324. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  116325. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  116326. startTransform.setOrigin(this._tmpAmmoVectorA);
  116327. startTransform.setRotation(this._tmpAmmoQuaternion);
  116328. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  116329. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  116330. var body = new Ammo.btRigidBody(rbInfo);
  116331. // Make objects kinematic if it's mass is 0
  116332. if (mass === 0) {
  116333. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  116334. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  116335. }
  116336. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  116337. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  116338. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  116339. }
  116340. this.world.addRigidBody(body);
  116341. impostor.physicsBody = body;
  116342. impostor._pluginData.toDispose = impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  116343. }
  116344. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  116345. this.setBodyFriction(impostor, impostor.getParam("friction"));
  116346. }
  116347. };
  116348. /**
  116349. * Removes the physics body from the imposter and disposes of the body's memory
  116350. * @param impostor imposter to remove the physics body from
  116351. */
  116352. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  116353. var _this = this;
  116354. if (this.world) {
  116355. this.world.removeRigidBody(impostor.physicsBody);
  116356. if (impostor._pluginData) {
  116357. impostor._pluginData.toDispose.forEach(function (d) {
  116358. _this.bjsAMMO.destroy(d);
  116359. });
  116360. }
  116361. }
  116362. };
  116363. /**
  116364. * Generates a joint
  116365. * @param impostorJoint the imposter joint to create the joint with
  116366. */
  116367. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  116368. var mainBody = impostorJoint.mainImpostor.physicsBody;
  116369. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  116370. if (!mainBody || !connectedBody) {
  116371. return;
  116372. }
  116373. var jointData = impostorJoint.joint.jointData;
  116374. if (!jointData.mainPivot) {
  116375. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  116376. }
  116377. if (!jointData.connectedPivot) {
  116378. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  116379. }
  116380. var joint;
  116381. switch (impostorJoint.joint.type) {
  116382. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  116383. var distance = jointData.maxDistance;
  116384. if (distance) {
  116385. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  116386. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  116387. }
  116388. 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));
  116389. break;
  116390. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  116391. if (!jointData.mainAxis) {
  116392. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  116393. }
  116394. if (!jointData.connectedAxis) {
  116395. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  116396. }
  116397. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  116398. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  116399. 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);
  116400. break;
  116401. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  116402. 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));
  116403. break;
  116404. default:
  116405. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  116406. 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));
  116407. break;
  116408. }
  116409. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  116410. impostorJoint.joint.physicsJoint = joint;
  116411. };
  116412. /**
  116413. * Removes a joint
  116414. * @param impostorJoint the imposter joint to remove the joint from
  116415. */
  116416. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  116417. if (this.world) {
  116418. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  116419. }
  116420. };
  116421. // adds all verticies (including child verticies) to the triangle mesh
  116422. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  116423. var _this = this;
  116424. var triangleCount = 0;
  116425. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  116426. var indices = object.getIndices();
  116427. if (!indices) {
  116428. indices = [];
  116429. }
  116430. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  116431. if (!vertexPositions) {
  116432. vertexPositions = [];
  116433. }
  116434. object.computeWorldMatrix(false);
  116435. var faceCount = indices.length / 3;
  116436. for (var i = 0; i < faceCount; i++) {
  116437. var triPoints = [];
  116438. for (var point = 0; point < 3; point++) {
  116439. 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]);
  116440. // Adjust for initial scaling
  116441. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  116442. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  116443. var vec;
  116444. if (point == 0) {
  116445. vec = this._tmpAmmoVectorA;
  116446. }
  116447. else if (point == 1) {
  116448. vec = this._tmpAmmoVectorB;
  116449. }
  116450. else {
  116451. vec = this._tmpAmmoVectorC;
  116452. }
  116453. vec.setValue(v.x, v.y, v.z);
  116454. triPoints.push(vec);
  116455. }
  116456. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  116457. triangleCount++;
  116458. }
  116459. object.getChildMeshes().forEach(function (m) {
  116460. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  116461. });
  116462. }
  116463. return triangleCount;
  116464. };
  116465. /**
  116466. * Initialise the soft body vertices to match its object's (mesh) vertices
  116467. * Softbody vertices (nodes) are in world space and to match this
  116468. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  116469. * @param impostor to create the softbody for
  116470. */
  116471. AmmoJSPlugin.prototype._softVertexData = function (impostor) {
  116472. var object = impostor.object;
  116473. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  116474. var indices = object.getIndices();
  116475. if (!indices) {
  116476. indices = [];
  116477. }
  116478. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  116479. if (!vertexPositions) {
  116480. vertexPositions = [];
  116481. }
  116482. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  116483. if (!vertexNormals) {
  116484. vertexNormals = [];
  116485. }
  116486. object.computeWorldMatrix(false);
  116487. var newPoints = [];
  116488. var newNorms = [];
  116489. for (var i = 0; i < vertexPositions.length; i += 3) {
  116490. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  116491. var n = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  116492. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  116493. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(n, object.getWorldMatrix());
  116494. newPoints.push(v.x, v.y, v.z);
  116495. newNorms.push(n.x, n.y, n.z);
  116496. }
  116497. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  116498. vertex_data.positions = newPoints;
  116499. vertex_data.normals = newNorms;
  116500. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  116501. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  116502. if (object && object.getIndices) {
  116503. vertex_data.indices = object.getIndices();
  116504. }
  116505. vertex_data.applyToMesh(object);
  116506. object.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  116507. object.rotationQuaternion = null;
  116508. object.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  116509. object.computeWorldMatrix(true);
  116510. return vertex_data;
  116511. }
  116512. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"].ExtractFromMesh(object);
  116513. };
  116514. /**
  116515. * Create an impostor's soft body
  116516. * @param impostor to create the softbody for
  116517. */
  116518. AmmoJSPlugin.prototype._createSoftbody = function (impostor) {
  116519. var object = impostor.object;
  116520. if (object && object.getIndices) {
  116521. var indices = object.getIndices();
  116522. if (!indices) {
  116523. indices = [];
  116524. }
  116525. var vertex_data = this._softVertexData(impostor);
  116526. var vertexPositions = vertex_data.positions;
  116527. var vertexNormals = vertex_data.normals;
  116528. if (vertexPositions === null || vertexNormals === null) {
  116529. return new Ammo.btCompoundShape();
  116530. }
  116531. else {
  116532. var triPoints = [];
  116533. var triNorms = [];
  116534. for (var i = 0; i < vertexPositions.length; i += 3) {
  116535. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  116536. var n = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  116537. triPoints.push(v.x, v.y, -v.z);
  116538. triNorms.push(n.x, n.y, -n.z);
  116539. }
  116540. var softBody = new Ammo.btSoftBodyHelpers().CreateFromTriMesh(this.world.getWorldInfo(), triPoints, object.getIndices(), indices.length / 3, true);
  116541. var nbVertices = vertexPositions.length / 3;
  116542. var bodyVertices = softBody.get_m_nodes();
  116543. var node;
  116544. var nodeNormals;
  116545. for (var i = 0; i < nbVertices; i++) {
  116546. node = bodyVertices.at(i);
  116547. var nodeNormals = node.get_m_n();
  116548. nodeNormals.setX(triNorms[3 * i]);
  116549. nodeNormals.setY(triNorms[3 * i + 1]);
  116550. nodeNormals.setZ(triNorms[3 * i + 2]);
  116551. }
  116552. return softBody;
  116553. }
  116554. }
  116555. };
  116556. /**
  116557. * Create cloth for an impostor
  116558. * @param impostor to create the softbody for
  116559. */
  116560. AmmoJSPlugin.prototype._createCloth = function (impostor) {
  116561. var object = impostor.object;
  116562. if (object && object.getIndices) {
  116563. var indices = object.getIndices();
  116564. if (!indices) {
  116565. indices = [];
  116566. }
  116567. var vertex_data = this._softVertexData(impostor);
  116568. var vertexPositions = vertex_data.positions;
  116569. var vertexNormals = vertex_data.normals;
  116570. if (vertexPositions === null || vertexNormals === null) {
  116571. return new Ammo.btCompoundShape();
  116572. }
  116573. else {
  116574. var len = vertexPositions.length;
  116575. var segments = Math.sqrt(len / 3);
  116576. impostor.segments = segments;
  116577. var segs = segments - 1;
  116578. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  116579. this._tmpAmmoVectorB.setValue(vertexPositions[3 * segs], vertexPositions[3 * segs + 1], vertexPositions[3 * segs + 2]);
  116580. this._tmpAmmoVectorD.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  116581. this._tmpAmmoVectorC.setValue(vertexPositions[len - 3 - 3 * segs], vertexPositions[len - 2 - 3 * segs], vertexPositions[len - 1 - 3 * segs]);
  116582. var clothBody = new Ammo.btSoftBodyHelpers().CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, segments, segments, impostor.getParam("fixedPoints"), true);
  116583. return clothBody;
  116584. }
  116585. }
  116586. };
  116587. /**
  116588. * Create rope for an impostor
  116589. * @param impostor to create the softbody for
  116590. */
  116591. AmmoJSPlugin.prototype._createRope = function (impostor) {
  116592. var len;
  116593. var segments;
  116594. var vertex_data = this._softVertexData(impostor);
  116595. var vertexPositions = vertex_data.positions;
  116596. var vertexNormals = vertex_data.normals;
  116597. if (vertexPositions === null || vertexNormals === null) {
  116598. return new Ammo.btCompoundShape();
  116599. }
  116600. //force the mesh to be updatable
  116601. vertex_data.applyToMesh(impostor.object, true);
  116602. impostor._isFromLine = true;
  116603. // If in lines mesh all normals will be zero
  116604. var vertexSquared = vertexNormals.map(function (x) { return x * x; });
  116605. var reducer = function (accumulator, currentValue) { return accumulator + currentValue; };
  116606. var reduced = vertexSquared.reduce(reducer);
  116607. if (reduced === 0) { // line mesh
  116608. len = vertexPositions.length;
  116609. segments = len / 3 - 1;
  116610. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  116611. this._tmpAmmoVectorB.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  116612. }
  116613. else { //extruded mesh
  116614. impostor._isFromLine = false;
  116615. var pathVectors = impostor.getParam("path");
  116616. var shape = impostor.getParam("shape");
  116617. if (shape === null) {
  116618. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("No shape available for extruded mesh");
  116619. return new Ammo.btCompoundShape();
  116620. }
  116621. if ((vertexPositions.length % (3 * pathVectors.length)) !== 0) {
  116622. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Path does not match extrusion");
  116623. return new Ammo.btCompoundShape();
  116624. }
  116625. len = pathVectors.length;
  116626. segments = len - 1;
  116627. this._tmpAmmoVectorA.setValue(pathVectors[0].x, pathVectors[0].y, pathVectors[0].z);
  116628. this._tmpAmmoVectorB.setValue(pathVectors[len - 1].x, pathVectors[len - 1].y, pathVectors[len - 1].z);
  116629. }
  116630. impostor.segments = segments;
  116631. var fixedPoints = impostor.getParam("fixedPoints");
  116632. fixedPoints = (fixedPoints > 3) ? 3 : fixedPoints;
  116633. var ropeBody = new Ammo.btSoftBodyHelpers().CreateRope(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, segments - 1, fixedPoints);
  116634. ropeBody.get_m_cfg().set_collisions(0x11);
  116635. return ropeBody;
  116636. };
  116637. // adds all verticies (including child verticies) to the convex hull shape
  116638. AmmoJSPlugin.prototype._addHullVerts = function (btConvexHullShape, topLevelObject, object) {
  116639. var _this = this;
  116640. var triangleCount = 0;
  116641. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  116642. var indices = object.getIndices();
  116643. if (!indices) {
  116644. indices = [];
  116645. }
  116646. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  116647. if (!vertexPositions) {
  116648. vertexPositions = [];
  116649. }
  116650. object.computeWorldMatrix(false);
  116651. var faceCount = indices.length / 3;
  116652. for (var i = 0; i < faceCount; i++) {
  116653. var triPoints = [];
  116654. for (var point = 0; point < 3; point++) {
  116655. 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]);
  116656. // Adjust for initial scaling
  116657. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  116658. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  116659. var vec;
  116660. if (point == 0) {
  116661. vec = this._tmpAmmoVectorA;
  116662. }
  116663. else if (point == 1) {
  116664. vec = this._tmpAmmoVectorB;
  116665. }
  116666. else {
  116667. vec = this._tmpAmmoVectorC;
  116668. }
  116669. vec.setValue(v.x, v.y, v.z);
  116670. triPoints.push(vec);
  116671. }
  116672. btConvexHullShape.addPoint(triPoints[0], true);
  116673. btConvexHullShape.addPoint(triPoints[1], true);
  116674. btConvexHullShape.addPoint(triPoints[2], true);
  116675. triangleCount++;
  116676. }
  116677. object.getChildMeshes().forEach(function (m) {
  116678. triangleCount += _this._addHullVerts(btConvexHullShape, topLevelObject, m);
  116679. });
  116680. }
  116681. return triangleCount;
  116682. };
  116683. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  116684. var _this = this;
  116685. if (ignoreChildren === void 0) { ignoreChildren = false; }
  116686. var object = impostor.object;
  116687. var returnValue;
  116688. var extendSize = impostor.getObjectExtendSize();
  116689. if (!ignoreChildren) {
  116690. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  116691. returnValue = new Ammo.btCompoundShape();
  116692. // Add shape of all children to the compound shape
  116693. var childrenAdded = 0;
  116694. meshChildren.forEach(function (childMesh) {
  116695. var childImpostor = childMesh.getPhysicsImpostor();
  116696. if (childImpostor) {
  116697. if (childImpostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor) {
  116698. throw "A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";
  116699. }
  116700. var shape = _this._createShape(childImpostor);
  116701. // Position needs to be scaled based on parent's scaling
  116702. var parentMat = childMesh.parent.getWorldMatrix().clone();
  116703. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  116704. parentMat.decompose(s);
  116705. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  116706. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  116707. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  116708. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  116709. childImpostor.dispose();
  116710. childrenAdded++;
  116711. }
  116712. });
  116713. if (childrenAdded > 0) {
  116714. // Add parents shape as a child if present
  116715. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  116716. var shape = this._createShape(impostor, true);
  116717. if (shape) {
  116718. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  116719. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  116720. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  116721. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  116722. }
  116723. }
  116724. return returnValue;
  116725. }
  116726. else {
  116727. // If no children with impostors create the actual shape below instead
  116728. Ammo.destroy(returnValue);
  116729. returnValue = null;
  116730. }
  116731. }
  116732. switch (impostor.type) {
  116733. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  116734. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  116735. break;
  116736. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  116737. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  116738. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  116739. break;
  116740. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  116741. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  116742. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  116743. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  116744. break;
  116745. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  116746. if (impostor.getParam("mass") == 0) {
  116747. // Only create btBvhTriangleMeshShape impostor is static
  116748. // See https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=7283
  116749. var tetraMesh = new Ammo.btTriangleMesh();
  116750. impostor._pluginData.toDispose.push(tetraMesh);
  116751. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  116752. if (triangeCount == 0) {
  116753. returnValue = new Ammo.btCompoundShape();
  116754. }
  116755. else {
  116756. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  116757. }
  116758. break;
  116759. }
  116760. // Otherwise create convexHullImpostor
  116761. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ConvexHullImpostor:
  116762. var convexMesh = new Ammo.btConvexHullShape();
  116763. var triangeCount = this._addHullVerts(convexMesh, object, object);
  116764. if (triangeCount == 0) {
  116765. // Cleanup Unused Convex Hull Shape
  116766. impostor._pluginData.toDispose.push(convexMesh);
  116767. returnValue = new Ammo.btCompoundShape();
  116768. }
  116769. else {
  116770. returnValue = convexMesh;
  116771. }
  116772. break;
  116773. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  116774. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  116775. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  116776. break;
  116777. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor:
  116778. // Only usable with a mesh that has sufficient and shared vertices
  116779. returnValue = this._createSoftbody(impostor);
  116780. break;
  116781. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor:
  116782. // Only usable with a ground mesh that has sufficient and shared vertices
  116783. returnValue = this._createCloth(impostor);
  116784. break;
  116785. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor:
  116786. // Only usable with a line mesh or an extruded mesh that is updatable
  116787. returnValue = this._createRope(impostor);
  116788. break;
  116789. default:
  116790. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  116791. break;
  116792. }
  116793. return returnValue;
  116794. };
  116795. /**
  116796. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  116797. * @param impostor imposter containing the physics body and babylon object
  116798. */
  116799. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  116800. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  116801. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  116802. if (!impostor.object.rotationQuaternion) {
  116803. if (impostor.object.rotation) {
  116804. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  116805. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  116806. }
  116807. }
  116808. else {
  116809. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  116810. }
  116811. };
  116812. /**
  116813. * Sets the babylon object's position/rotation from the physics body's position/rotation
  116814. * @param impostor imposter containing the physics body and babylon object
  116815. * @param newPosition new position
  116816. * @param newRotation new rotation
  116817. */
  116818. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  116819. var trans = impostor.physicsBody.getWorldTransform();
  116820. // If rotation/position has changed update and activate riged body
  116821. if (trans.getOrigin().x() != newPosition.x ||
  116822. trans.getOrigin().y() != newPosition.y ||
  116823. trans.getOrigin().z() != newPosition.z ||
  116824. trans.getRotation().x() != newRotation.x ||
  116825. trans.getRotation().y() != newRotation.y ||
  116826. trans.getRotation().z() != newRotation.z ||
  116827. trans.getRotation().w() != newRotation.w) {
  116828. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  116829. trans.setOrigin(this._tmpAmmoVectorA);
  116830. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  116831. trans.setRotation(this._tmpAmmoQuaternion);
  116832. impostor.physicsBody.setWorldTransform(trans);
  116833. if (impostor.mass == 0) {
  116834. // Kinematic objects must be updated using motion state
  116835. var motionState = impostor.physicsBody.getMotionState();
  116836. if (motionState) {
  116837. motionState.setWorldTransform(trans);
  116838. }
  116839. }
  116840. else {
  116841. impostor.physicsBody.activate();
  116842. }
  116843. }
  116844. };
  116845. /**
  116846. * If this plugin is supported
  116847. * @returns true if its supported
  116848. */
  116849. AmmoJSPlugin.prototype.isSupported = function () {
  116850. return this.bjsAMMO !== undefined;
  116851. };
  116852. /**
  116853. * Sets the linear velocity of the physics body
  116854. * @param impostor imposter to set the velocity on
  116855. * @param velocity velocity to set
  116856. */
  116857. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  116858. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  116859. if (impostor.soft) {
  116860. impostor.physicsBody.linearVelocity(this._tmpAmmoVectorA);
  116861. }
  116862. else {
  116863. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  116864. }
  116865. };
  116866. /**
  116867. * Sets the angular velocity of the physics body
  116868. * @param impostor imposter to set the velocity on
  116869. * @param velocity velocity to set
  116870. */
  116871. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  116872. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  116873. if (impostor.soft) {
  116874. impostor.physicsBody.angularVelocity(this._tmpAmmoVectorA);
  116875. }
  116876. else {
  116877. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  116878. }
  116879. };
  116880. /**
  116881. * gets the linear velocity
  116882. * @param impostor imposter to get linear velocity from
  116883. * @returns linear velocity
  116884. */
  116885. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  116886. if (impostor.soft) {
  116887. var v = impostor.physicsBody.linearVelocity();
  116888. }
  116889. else {
  116890. var v = impostor.physicsBody.getLinearVelocity();
  116891. }
  116892. if (!v) {
  116893. return null;
  116894. }
  116895. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  116896. Ammo.destroy(v);
  116897. return result;
  116898. };
  116899. /**
  116900. * gets the angular velocity
  116901. * @param impostor imposter to get angular velocity from
  116902. * @returns angular velocity
  116903. */
  116904. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  116905. if (impostor.soft) {
  116906. var v = impostor.physicsBody.angularVelocity();
  116907. }
  116908. else {
  116909. var v = impostor.physicsBody.getAngularVelocity();
  116910. }
  116911. if (!v) {
  116912. return null;
  116913. }
  116914. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  116915. Ammo.destroy(v);
  116916. return result;
  116917. };
  116918. /**
  116919. * Sets the mass of physics body
  116920. * @param impostor imposter to set the mass on
  116921. * @param mass mass to set
  116922. */
  116923. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  116924. if (impostor.soft) {
  116925. impostor.physicsBody.setTotalMass(mass, false);
  116926. }
  116927. else {
  116928. impostor.physicsBody.setMassProps(mass);
  116929. }
  116930. impostor._pluginData.mass = mass;
  116931. };
  116932. /**
  116933. * Gets the mass of the physics body
  116934. * @param impostor imposter to get the mass from
  116935. * @returns mass
  116936. */
  116937. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  116938. return impostor._pluginData.mass || 0;
  116939. };
  116940. /**
  116941. * Gets friction of the impostor
  116942. * @param impostor impostor to get friction from
  116943. * @returns friction value
  116944. */
  116945. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  116946. return impostor._pluginData.friction || 0;
  116947. };
  116948. /**
  116949. * Sets friction of the impostor
  116950. * @param impostor impostor to set friction on
  116951. * @param friction friction value
  116952. */
  116953. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  116954. if (impostor.soft) {
  116955. impostor.physicsBody.get_m_cfg().set_kDF(friction);
  116956. }
  116957. else {
  116958. impostor.physicsBody.setFriction(friction);
  116959. }
  116960. impostor._pluginData.friction = friction;
  116961. };
  116962. /**
  116963. * Gets restitution of the impostor
  116964. * @param impostor impostor to get restitution from
  116965. * @returns restitution value
  116966. */
  116967. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  116968. return impostor._pluginData.restitution || 0;
  116969. };
  116970. /**
  116971. * Sets resitution of the impostor
  116972. * @param impostor impostor to set resitution on
  116973. * @param restitution resitution value
  116974. */
  116975. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  116976. impostor.physicsBody.setRestitution(restitution);
  116977. impostor._pluginData.restitution = restitution;
  116978. };
  116979. /**
  116980. * Gets pressure inside the impostor
  116981. * @param impostor impostor to get pressure from
  116982. * @returns pressure value
  116983. */
  116984. AmmoJSPlugin.prototype.getBodyPressure = function (impostor) {
  116985. if (!impostor.soft) {
  116986. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure is not a property of a rigid body");
  116987. return 0;
  116988. }
  116989. return impostor._pluginData.pressure || 0;
  116990. };
  116991. /**
  116992. * Sets pressure inside a soft body impostor
  116993. * Cloth and rope must remain 0 pressure
  116994. * @param impostor impostor to set pressure on
  116995. * @param pressure pressure value
  116996. */
  116997. AmmoJSPlugin.prototype.setBodyPressure = function (impostor, pressure) {
  116998. if (impostor.soft) {
  116999. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  117000. impostor.physicsBody.get_m_cfg().set_kPR(pressure);
  117001. impostor._pluginData.pressure = pressure;
  117002. }
  117003. else {
  117004. impostor.physicsBody.get_m_cfg().set_kPR(0);
  117005. impostor._pluginData.pressure = 0;
  117006. }
  117007. }
  117008. else {
  117009. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure can only be applied to a softbody");
  117010. }
  117011. };
  117012. /**
  117013. * Gets stiffness of the impostor
  117014. * @param impostor impostor to get stiffness from
  117015. * @returns pressure value
  117016. */
  117017. AmmoJSPlugin.prototype.getBodyStiffness = function (impostor) {
  117018. if (!impostor.soft) {
  117019. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness is not a property of a rigid body");
  117020. return 0;
  117021. }
  117022. return impostor._pluginData.stiffness || 0;
  117023. };
  117024. /**
  117025. * Sets stiffness of the impostor
  117026. * @param impostor impostor to set stiffness on
  117027. * @param stiffness stiffness value from 0 to 1
  117028. */
  117029. AmmoJSPlugin.prototype.setBodyStiffness = function (impostor, stiffness) {
  117030. if (impostor.soft) {
  117031. stiffness = stiffness < 0 ? 0 : stiffness;
  117032. stiffness = stiffness > 1 ? 1 : stiffness;
  117033. impostor.physicsBody.get_m_materials().at(0).set_m_kLST(stiffness);
  117034. impostor._pluginData.stiffness = stiffness;
  117035. }
  117036. else {
  117037. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness cannot be applied to a rigid body");
  117038. }
  117039. };
  117040. /**
  117041. * Gets velocityIterations of the impostor
  117042. * @param impostor impostor to get velocity iterations from
  117043. * @returns velocityIterations value
  117044. */
  117045. AmmoJSPlugin.prototype.getBodyVelocityIterations = function (impostor) {
  117046. if (!impostor.soft) {
  117047. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations is not a property of a rigid body");
  117048. return 0;
  117049. }
  117050. return impostor._pluginData.velocityIterations || 0;
  117051. };
  117052. /**
  117053. * Sets velocityIterations of the impostor
  117054. * @param impostor impostor to set velocity iterations on
  117055. * @param velocityIterations velocityIterations value
  117056. */
  117057. AmmoJSPlugin.prototype.setBodyVelocityIterations = function (impostor, velocityIterations) {
  117058. if (impostor.soft) {
  117059. velocityIterations = velocityIterations < 0 ? 0 : velocityIterations;
  117060. impostor.physicsBody.get_m_cfg().set_viterations(velocityIterations);
  117061. impostor._pluginData.velocityIterations = velocityIterations;
  117062. }
  117063. else {
  117064. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations cannot be applied to a rigid body");
  117065. }
  117066. };
  117067. /**
  117068. * Gets positionIterations of the impostor
  117069. * @param impostor impostor to get position iterations from
  117070. * @returns positionIterations value
  117071. */
  117072. AmmoJSPlugin.prototype.getBodyPositionIterations = function (impostor) {
  117073. if (!impostor.soft) {
  117074. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations is not a property of a rigid body");
  117075. return 0;
  117076. }
  117077. return impostor._pluginData.positionIterations || 0;
  117078. };
  117079. /**
  117080. * Sets positionIterations of the impostor
  117081. * @param impostor impostor to set position on
  117082. * @param positionIterations positionIterations value
  117083. */
  117084. AmmoJSPlugin.prototype.setBodyPositionIterations = function (impostor, positionIterations) {
  117085. if (impostor.soft) {
  117086. positionIterations = positionIterations < 0 ? 0 : positionIterations;
  117087. impostor.physicsBody.get_m_cfg().set_piterations(positionIterations);
  117088. impostor._pluginData.positionIterations = positionIterations;
  117089. }
  117090. else {
  117091. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations cannot be applied to a rigid body");
  117092. }
  117093. };
  117094. /**
  117095. * Append an anchor to a cloth object
  117096. * @param impostor is the cloth impostor to add anchor to
  117097. * @param otherImpostor is the rigid impostor to anchor to
  117098. * @param width ratio across width from 0 to 1
  117099. * @param height ratio up height from 0 to 1
  117100. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  117101. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  117102. */
  117103. AmmoJSPlugin.prototype.appendAnchor = function (impostor, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  117104. if (influence === void 0) { influence = 1; }
  117105. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  117106. var segs = impostor.segments;
  117107. var nbAcross = Math.round((segs - 1) * width);
  117108. var nbUp = Math.round((segs - 1) * height);
  117109. var nbDown = segs - 1 - nbUp;
  117110. var node = nbAcross + segs * nbDown;
  117111. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  117112. };
  117113. /**
  117114. * Append an hook to a rope object
  117115. * @param impostor is the rope impostor to add hook to
  117116. * @param otherImpostor is the rigid impostor to hook to
  117117. * @param length ratio along the rope from 0 to 1
  117118. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  117119. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  117120. */
  117121. AmmoJSPlugin.prototype.appendHook = function (impostor, otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  117122. if (influence === void 0) { influence = 1; }
  117123. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  117124. var node = Math.round(impostor.segments * length);
  117125. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  117126. };
  117127. /**
  117128. * Sleeps the physics body and stops it from being active
  117129. * @param impostor impostor to sleep
  117130. */
  117131. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  117132. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  117133. };
  117134. /**
  117135. * Activates the physics body
  117136. * @param impostor impostor to activate
  117137. */
  117138. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  117139. impostor.physicsBody.activate();
  117140. };
  117141. /**
  117142. * Updates the distance parameters of the joint
  117143. * @param joint joint to update
  117144. * @param maxDistance maximum distance of the joint
  117145. * @param minDistance minimum distance of the joint
  117146. */
  117147. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  117148. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  117149. };
  117150. /**
  117151. * Sets a motor on the joint
  117152. * @param joint joint to set motor on
  117153. * @param speed speed of the motor
  117154. * @param maxForce maximum force of the motor
  117155. * @param motorIndex index of the motor
  117156. */
  117157. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  117158. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  117159. };
  117160. /**
  117161. * Sets the motors limit
  117162. * @param joint joint to set limit on
  117163. * @param upperLimit upper limit
  117164. * @param lowerLimit lower limit
  117165. */
  117166. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  117167. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  117168. };
  117169. /**
  117170. * Syncs the position and rotation of a mesh with the impostor
  117171. * @param mesh mesh to sync
  117172. * @param impostor impostor to update the mesh with
  117173. */
  117174. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  117175. var body = impostor.physicsBody;
  117176. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  117177. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  117178. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  117179. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  117180. if (mesh.rotationQuaternion) {
  117181. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  117182. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  117183. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  117184. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  117185. }
  117186. };
  117187. /**
  117188. * Gets the radius of the impostor
  117189. * @param impostor impostor to get radius from
  117190. * @returns the radius
  117191. */
  117192. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  117193. var exntend = impostor.getObjectExtendSize();
  117194. return exntend.x / 2;
  117195. };
  117196. /**
  117197. * Gets the box size of the impostor
  117198. * @param impostor impostor to get box size from
  117199. * @param result the resulting box size
  117200. */
  117201. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  117202. var exntend = impostor.getObjectExtendSize();
  117203. result.x = exntend.x;
  117204. result.y = exntend.y;
  117205. result.z = exntend.z;
  117206. };
  117207. /**
  117208. * Disposes of the impostor
  117209. */
  117210. AmmoJSPlugin.prototype.dispose = function () {
  117211. // Dispose of world
  117212. Ammo.destroy(this.world);
  117213. Ammo.destroy(this._solver);
  117214. Ammo.destroy(this._overlappingPairCache);
  117215. Ammo.destroy(this._dispatcher);
  117216. Ammo.destroy(this._collisionConfiguration);
  117217. // Dispose of tmp variables
  117218. Ammo.destroy(this._tmpAmmoVectorA);
  117219. Ammo.destroy(this._tmpAmmoVectorB);
  117220. Ammo.destroy(this._tmpAmmoVectorC);
  117221. Ammo.destroy(this._tmpAmmoTransform);
  117222. Ammo.destroy(this._tmpAmmoQuaternion);
  117223. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  117224. this.world = null;
  117225. };
  117226. /**
  117227. * Does a raycast in the physics world
  117228. * @param from when should the ray start?
  117229. * @param to when should the ray end?
  117230. * @returns PhysicsRaycastResult
  117231. */
  117232. AmmoJSPlugin.prototype.raycast = function (from, to) {
  117233. this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(from.x, from.y, from.z);
  117234. this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(to.x, to.y, to.z);
  117235. var rayCallback = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB);
  117236. this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, rayCallback);
  117237. this._raycastResult.reset(from, to);
  117238. if (rayCallback.hasHit()) {
  117239. // TODO: do we want/need the body? If so, set all the data
  117240. /*
  117241. var rigidBody = this.bjsAMMO.btRigidBody.prototype.upcast(
  117242. rayCallback.get_m_collisionObject()
  117243. );
  117244. var body = {};
  117245. */
  117246. this._raycastResult.setHitData({
  117247. x: rayCallback.get_m_hitNormalWorld().x(),
  117248. y: rayCallback.get_m_hitNormalWorld().y(),
  117249. z: rayCallback.get_m_hitNormalWorld().z(),
  117250. }, {
  117251. x: rayCallback.get_m_hitPointWorld().x(),
  117252. y: rayCallback.get_m_hitPointWorld().y(),
  117253. z: rayCallback.get_m_hitPointWorld().z(),
  117254. });
  117255. this._raycastResult.calculateHitDistance();
  117256. }
  117257. Ammo.destroy(rayCallback);
  117258. Ammo.destroy(this._tmpAmmoVectorRCA);
  117259. Ammo.destroy(this._tmpAmmoVectorRCB);
  117260. return this._raycastResult;
  117261. };
  117262. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  117263. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  117264. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  117265. return AmmoJSPlugin;
  117266. }());
  117267. /***/ }),
  117268. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  117269. /*!*******************************************!*\
  117270. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  117271. \*******************************************/
  117272. /*! exports provided: CannonJSPlugin */
  117273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117274. "use strict";
  117275. __webpack_require__.r(__webpack_exports__);
  117276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  117277. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  117278. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  117279. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  117280. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  117281. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  117282. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  117283. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  117284. /** @hidden */
  117285. var CannonJSPlugin = /** @class */ (function () {
  117286. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  117287. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  117288. if (iterations === void 0) { iterations = 10; }
  117289. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  117290. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  117291. this.name = "CannonJSPlugin";
  117292. this._physicsMaterials = new Array();
  117293. this._fixedTimeStep = 1 / 60;
  117294. this._removeAfterStep = new Array();
  117295. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  117296. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  117297. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  117298. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  117299. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  117300. this.BJSCANNON = cannonInjection;
  117301. if (!this.isSupported()) {
  117302. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  117303. return;
  117304. }
  117305. this._extendNamespace();
  117306. this.world = new this.BJSCANNON.World();
  117307. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  117308. this.world.solver.iterations = iterations;
  117309. this._cannonRaycastResult = new this.BJSCANNON.RaycastResult();
  117310. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__["PhysicsRaycastResult"]();
  117311. }
  117312. CannonJSPlugin.prototype.setGravity = function (gravity) {
  117313. this.world.gravity.copy(gravity);
  117314. };
  117315. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  117316. this._fixedTimeStep = timeStep;
  117317. };
  117318. CannonJSPlugin.prototype.getTimeStep = function () {
  117319. return this._fixedTimeStep;
  117320. };
  117321. CannonJSPlugin.prototype.executeStep = function (delta) {
  117322. var _this = this;
  117323. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  117324. if (this._removeAfterStep.length > 0) {
  117325. this._removeAfterStep.forEach(function (impostor) {
  117326. _this.world.remove(impostor.physicsBody);
  117327. });
  117328. this._removeAfterStep = [];
  117329. }
  117330. };
  117331. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  117332. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  117333. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  117334. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  117335. };
  117336. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  117337. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  117338. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  117339. impostor.physicsBody.applyForce(impulse, worldPoint);
  117340. };
  117341. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  117342. //parent-child relationship. Does this impostor has a parent impostor?
  117343. if (impostor.parent) {
  117344. if (impostor.physicsBody) {
  117345. this.removePhysicsBody(impostor);
  117346. //TODO is that needed?
  117347. impostor.forceUpdate();
  117348. }
  117349. return;
  117350. }
  117351. //should a new body be created for this impostor?
  117352. if (impostor.isBodyInitRequired()) {
  117353. var shape = this._createShape(impostor);
  117354. //unregister events, if body is being changed
  117355. var oldBody = impostor.physicsBody;
  117356. if (oldBody) {
  117357. this.removePhysicsBody(impostor);
  117358. }
  117359. //create the body and material
  117360. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  117361. var bodyCreationObject = {
  117362. mass: impostor.getParam("mass"),
  117363. material: material
  117364. };
  117365. // A simple extend, in case native options were used.
  117366. var nativeOptions = impostor.getParam("nativeOptions");
  117367. for (var key in nativeOptions) {
  117368. if (nativeOptions.hasOwnProperty(key)) {
  117369. bodyCreationObject[key] = nativeOptions[key];
  117370. }
  117371. }
  117372. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  117373. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  117374. this.world.addEventListener("preStep", impostor.beforeStep);
  117375. this.world.addEventListener("postStep", impostor.afterStep);
  117376. impostor.physicsBody.addShape(shape);
  117377. this.world.add(impostor.physicsBody);
  117378. //try to keep the body moving in the right direction by taking old properties.
  117379. //Should be tested!
  117380. if (oldBody) {
  117381. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  117382. impostor.physicsBody[param].copy(oldBody[param]);
  117383. });
  117384. }
  117385. this._processChildMeshes(impostor);
  117386. }
  117387. //now update the body's transformation
  117388. this._updatePhysicsBodyTransformation(impostor);
  117389. };
  117390. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  117391. var _this = this;
  117392. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  117393. var currentRotation = mainImpostor.object.rotationQuaternion;
  117394. if (meshChildren.length) {
  117395. var processMesh = function (localPosition, mesh) {
  117396. if (!currentRotation || !mesh.rotationQuaternion) {
  117397. return;
  117398. }
  117399. var childImpostor = mesh.getPhysicsImpostor();
  117400. if (childImpostor) {
  117401. var parent = childImpostor.parent;
  117402. if (parent !== mainImpostor) {
  117403. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  117404. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  117405. if (childImpostor.physicsBody) {
  117406. _this.removePhysicsBody(childImpostor);
  117407. childImpostor.physicsBody = null;
  117408. }
  117409. childImpostor.parent = mainImpostor;
  117410. childImpostor.resetUpdateFlags();
  117411. 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));
  117412. //Add the mass of the children.
  117413. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  117414. }
  117415. }
  117416. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  117417. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  117418. };
  117419. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  117420. }
  117421. };
  117422. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  117423. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  117424. this.world.removeEventListener("preStep", impostor.beforeStep);
  117425. this.world.removeEventListener("postStep", impostor.afterStep);
  117426. // Only remove the physics body after the physics step to avoid disrupting cannon's internal state
  117427. this._removeAfterStep.push(impostor);
  117428. };
  117429. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  117430. var mainBody = impostorJoint.mainImpostor.physicsBody;
  117431. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  117432. if (!mainBody || !connectedBody) {
  117433. return;
  117434. }
  117435. var constraint;
  117436. var jointData = impostorJoint.joint.jointData;
  117437. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  117438. var constraintData = {
  117439. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  117440. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  117441. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  117442. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  117443. maxForce: jointData.nativeParams.maxForce,
  117444. collideConnected: !!jointData.collision
  117445. };
  117446. switch (impostorJoint.joint.type) {
  117447. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  117448. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  117449. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  117450. break;
  117451. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  117452. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  117453. break;
  117454. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  117455. var springData = jointData;
  117456. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  117457. restLength: springData.length,
  117458. stiffness: springData.stiffness,
  117459. damping: springData.damping,
  117460. localAnchorA: constraintData.pivotA,
  117461. localAnchorB: constraintData.pivotB
  117462. });
  117463. break;
  117464. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  117465. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  117466. break;
  117467. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  117468. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  117469. default:
  117470. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  117471. break;
  117472. }
  117473. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  117474. constraint.collideConnected = !!jointData.collision;
  117475. impostorJoint.joint.physicsJoint = constraint;
  117476. //don't add spring as constraint, as it is not one.
  117477. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  117478. this.world.addConstraint(constraint);
  117479. }
  117480. else {
  117481. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  117482. constraint.applyForce();
  117483. };
  117484. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  117485. }
  117486. };
  117487. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  117488. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  117489. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  117490. }
  117491. else {
  117492. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  117493. }
  117494. };
  117495. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  117496. var index;
  117497. var mat;
  117498. for (index = 0; index < this._physicsMaterials.length; index++) {
  117499. mat = this._physicsMaterials[index];
  117500. if (mat.friction === friction && mat.restitution === restitution) {
  117501. return mat;
  117502. }
  117503. }
  117504. var currentMat = new this.BJSCANNON.Material(name);
  117505. currentMat.friction = friction;
  117506. currentMat.restitution = restitution;
  117507. this._physicsMaterials.push(currentMat);
  117508. return currentMat;
  117509. };
  117510. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  117511. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  117512. };
  117513. CannonJSPlugin.prototype._createShape = function (impostor) {
  117514. var object = impostor.object;
  117515. var returnValue;
  117516. var extendSize = impostor.getObjectExtendSize();
  117517. switch (impostor.type) {
  117518. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  117519. var radiusX = extendSize.x;
  117520. var radiusY = extendSize.y;
  117521. var radiusZ = extendSize.z;
  117522. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  117523. break;
  117524. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  117525. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  117526. var nativeParams = impostor.getParam("nativeOptions");
  117527. if (!nativeParams) {
  117528. nativeParams = {};
  117529. }
  117530. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  117531. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  117532. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  117533. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  117534. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  117535. // Rotate 90 degrees as this shape is horizontal in cannon
  117536. var quat = new this.BJSCANNON.Quaternion();
  117537. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  117538. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  117539. returnValue.transformAllPoints(translation, quat);
  117540. break;
  117541. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  117542. var box = extendSize.scale(0.5);
  117543. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  117544. break;
  117545. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  117546. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  117547. returnValue = new this.BJSCANNON.Plane();
  117548. break;
  117549. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  117550. // should transform the vertex data to world coordinates!!
  117551. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  117552. var rawFaces = object.getIndices ? object.getIndices() : [];
  117553. if (!rawVerts) {
  117554. return;
  117555. }
  117556. // get only scale! so the object could transform correctly.
  117557. var oldPosition = object.position.clone();
  117558. var oldRotation = object.rotation && object.rotation.clone();
  117559. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  117560. object.position.copyFromFloats(0, 0, 0);
  117561. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  117562. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  117563. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  117564. var transform = object.computeWorldMatrix(true);
  117565. // convert rawVerts to object space
  117566. var temp = new Array();
  117567. var index;
  117568. for (index = 0; index < rawVerts.length; index += 3) {
  117569. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  117570. }
  117571. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  117572. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  117573. //now set back the transformation!
  117574. object.position.copyFrom(oldPosition);
  117575. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  117576. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  117577. break;
  117578. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  117579. var oldPosition2 = object.position.clone();
  117580. var oldRotation2 = object.rotation && object.rotation.clone();
  117581. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  117582. object.position.copyFromFloats(0, 0, 0);
  117583. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  117584. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  117585. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  117586. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  117587. returnValue = this._createHeightmap(object);
  117588. object.position.copyFrom(oldPosition2);
  117589. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  117590. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  117591. object.computeWorldMatrix(true);
  117592. break;
  117593. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  117594. returnValue = new this.BJSCANNON.Particle();
  117595. break;
  117596. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  117597. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  117598. break;
  117599. }
  117600. return returnValue;
  117601. };
  117602. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  117603. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  117604. var transform = object.computeWorldMatrix(true);
  117605. // convert rawVerts to object space
  117606. var temp = new Array();
  117607. var index;
  117608. for (index = 0; index < pos.length; index += 3) {
  117609. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  117610. }
  117611. pos = temp;
  117612. var matrix = new Array();
  117613. //For now pointDepth will not be used and will be automatically calculated.
  117614. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  117615. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  117616. var boundingInfo = object.getBoundingInfo();
  117617. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  117618. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  117619. var elementSize = dim * 2 / arraySize;
  117620. for (var i = 0; i < pos.length; i = i + 3) {
  117621. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  117622. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  117623. var y = -pos[i + 2] + minY;
  117624. if (!matrix[x]) {
  117625. matrix[x] = [];
  117626. }
  117627. if (!matrix[x][z]) {
  117628. matrix[x][z] = y;
  117629. }
  117630. matrix[x][z] = Math.max(y, matrix[x][z]);
  117631. }
  117632. for (var x = 0; x <= arraySize; ++x) {
  117633. if (!matrix[x]) {
  117634. var loc = 1;
  117635. while (!matrix[(x + loc) % arraySize]) {
  117636. loc++;
  117637. }
  117638. matrix[x] = matrix[(x + loc) % arraySize].slice();
  117639. //console.log("missing x", x);
  117640. }
  117641. for (var z = 0; z <= arraySize; ++z) {
  117642. if (!matrix[x][z]) {
  117643. var loc = 1;
  117644. var newValue;
  117645. while (newValue === undefined) {
  117646. newValue = matrix[x][(z + loc++) % arraySize];
  117647. }
  117648. matrix[x][z] = newValue;
  117649. }
  117650. }
  117651. }
  117652. var shape = new this.BJSCANNON.Heightfield(matrix, {
  117653. elementSize: elementSize
  117654. });
  117655. //For future reference, needed for body transformation
  117656. shape.minY = minY;
  117657. return shape;
  117658. };
  117659. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  117660. var object = impostor.object;
  117661. //make sure it is updated...
  117662. object.computeWorldMatrix && object.computeWorldMatrix(true);
  117663. // The delta between the mesh position and the mesh bounding box center
  117664. var bInfo = object.getBoundingInfo();
  117665. if (!bInfo) {
  117666. return;
  117667. }
  117668. var center = impostor.getObjectCenter();
  117669. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  117670. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  117671. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  117672. this._tmpPosition.copyFrom(center);
  117673. var quaternion = object.rotationQuaternion;
  117674. if (!quaternion) {
  117675. return;
  117676. }
  117677. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  117678. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  117679. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  117680. //-90 DEG in X, precalculated
  117681. quaternion = quaternion.multiply(this._minus90X);
  117682. //Invert! (Precalculated, 90 deg in X)
  117683. //No need to clone. this will never change.
  117684. impostor.setDeltaRotation(this._plus90X);
  117685. }
  117686. //If it is a heightfield, if should be centered.
  117687. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  117688. var mesh = object;
  117689. var boundingInfo = mesh.getBoundingInfo();
  117690. //calculate the correct body position:
  117691. var rotationQuaternion = mesh.rotationQuaternion;
  117692. mesh.rotationQuaternion = this._tmpUnityRotation;
  117693. mesh.computeWorldMatrix(true);
  117694. //get original center with no rotation
  117695. var c = center.clone();
  117696. var oldPivot = mesh.getPivotMatrix();
  117697. if (oldPivot) {
  117698. // create a copy the pivot Matrix as it is modified in place
  117699. oldPivot = oldPivot.clone();
  117700. }
  117701. else {
  117702. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  117703. }
  117704. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  117705. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  117706. mesh.setPreTransformMatrix(p);
  117707. mesh.computeWorldMatrix(true);
  117708. //calculate the translation
  117709. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  117710. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  117711. //add it inverted to the delta
  117712. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  117713. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  117714. //rotation is back
  117715. mesh.rotationQuaternion = rotationQuaternion;
  117716. mesh.setPreTransformMatrix(oldPivot);
  117717. mesh.computeWorldMatrix(true);
  117718. }
  117719. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  117720. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  117721. //this._tmpPosition.copyFrom(object.position);
  117722. }
  117723. impostor.setDeltaPosition(this._tmpDeltaPosition);
  117724. //Now update the impostor object
  117725. impostor.physicsBody.position.copy(this._tmpPosition);
  117726. impostor.physicsBody.quaternion.copy(quaternion);
  117727. };
  117728. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  117729. impostor.object.position.copyFrom(impostor.physicsBody.position);
  117730. if (impostor.object.rotationQuaternion) {
  117731. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  117732. }
  117733. };
  117734. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  117735. impostor.physicsBody.position.copy(newPosition);
  117736. impostor.physicsBody.quaternion.copy(newRotation);
  117737. };
  117738. CannonJSPlugin.prototype.isSupported = function () {
  117739. return this.BJSCANNON !== undefined;
  117740. };
  117741. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  117742. impostor.physicsBody.velocity.copy(velocity);
  117743. };
  117744. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  117745. impostor.physicsBody.angularVelocity.copy(velocity);
  117746. };
  117747. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  117748. var v = impostor.physicsBody.velocity;
  117749. if (!v) {
  117750. return null;
  117751. }
  117752. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  117753. };
  117754. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  117755. var v = impostor.physicsBody.angularVelocity;
  117756. if (!v) {
  117757. return null;
  117758. }
  117759. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  117760. };
  117761. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  117762. impostor.physicsBody.mass = mass;
  117763. impostor.physicsBody.updateMassProperties();
  117764. };
  117765. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  117766. return impostor.physicsBody.mass;
  117767. };
  117768. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  117769. return impostor.physicsBody.material.friction;
  117770. };
  117771. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  117772. impostor.physicsBody.material.friction = friction;
  117773. };
  117774. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  117775. return impostor.physicsBody.material.restitution;
  117776. };
  117777. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  117778. impostor.physicsBody.material.restitution = restitution;
  117779. };
  117780. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  117781. impostor.physicsBody.sleep();
  117782. };
  117783. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  117784. impostor.physicsBody.wakeUp();
  117785. };
  117786. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  117787. joint.physicsJoint.distance = maxDistance;
  117788. };
  117789. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  117790. // if (!motorIndex) {
  117791. // joint.physicsJoint.enableMotor();
  117792. // }
  117793. // }
  117794. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  117795. // if (!motorIndex) {
  117796. // joint.physicsJoint.disableMotor();
  117797. // }
  117798. // }
  117799. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  117800. if (!motorIndex) {
  117801. joint.physicsJoint.enableMotor();
  117802. joint.physicsJoint.setMotorSpeed(speed);
  117803. if (maxForce) {
  117804. this.setLimit(joint, maxForce);
  117805. }
  117806. }
  117807. };
  117808. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  117809. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  117810. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  117811. };
  117812. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  117813. var body = impostor.physicsBody;
  117814. mesh.position.x = body.position.x;
  117815. mesh.position.y = body.position.y;
  117816. mesh.position.z = body.position.z;
  117817. if (mesh.rotationQuaternion) {
  117818. mesh.rotationQuaternion.x = body.quaternion.x;
  117819. mesh.rotationQuaternion.y = body.quaternion.y;
  117820. mesh.rotationQuaternion.z = body.quaternion.z;
  117821. mesh.rotationQuaternion.w = body.quaternion.w;
  117822. }
  117823. };
  117824. CannonJSPlugin.prototype.getRadius = function (impostor) {
  117825. var shape = impostor.physicsBody.shapes[0];
  117826. return shape.boundingSphereRadius;
  117827. };
  117828. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  117829. var shape = impostor.physicsBody.shapes[0];
  117830. result.x = shape.halfExtents.x * 2;
  117831. result.y = shape.halfExtents.y * 2;
  117832. result.z = shape.halfExtents.z * 2;
  117833. };
  117834. CannonJSPlugin.prototype.dispose = function () {
  117835. };
  117836. CannonJSPlugin.prototype._extendNamespace = function () {
  117837. //this will force cannon to execute at least one step when using interpolation
  117838. var step_tmp1 = new this.BJSCANNON.Vec3();
  117839. var Engine = this.BJSCANNON;
  117840. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  117841. maxSubSteps = maxSubSteps || 10;
  117842. timeSinceLastCalled = timeSinceLastCalled || 0;
  117843. if (timeSinceLastCalled === 0) {
  117844. this.internalStep(dt);
  117845. this.time += dt;
  117846. }
  117847. else {
  117848. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  117849. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  117850. var t0 = performance.now();
  117851. for (var i = 0; i !== internalSteps; i++) {
  117852. this.internalStep(dt);
  117853. if (performance.now() - t0 > dt * 1000) {
  117854. break;
  117855. }
  117856. }
  117857. this.time += timeSinceLastCalled;
  117858. var h = this.time % dt;
  117859. var h_div_dt = h / dt;
  117860. var interpvelo = step_tmp1;
  117861. var bodies = this.bodies;
  117862. for (var j = 0; j !== bodies.length; j++) {
  117863. var b = bodies[j];
  117864. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  117865. b.position.vsub(b.previousPosition, interpvelo);
  117866. interpvelo.scale(h_div_dt, interpvelo);
  117867. b.position.vadd(interpvelo, b.interpolatedPosition);
  117868. }
  117869. else {
  117870. b.interpolatedPosition.copy(b.position);
  117871. b.interpolatedQuaternion.copy(b.quaternion);
  117872. }
  117873. }
  117874. }
  117875. };
  117876. };
  117877. /**
  117878. * Does a raycast in the physics world
  117879. * @param from when should the ray start?
  117880. * @param to when should the ray end?
  117881. * @returns PhysicsRaycastResult
  117882. */
  117883. CannonJSPlugin.prototype.raycast = function (from, to) {
  117884. this._cannonRaycastResult.reset();
  117885. this.world.raycastClosest(from, to, {}, this._cannonRaycastResult);
  117886. this._raycastResult.reset(from, to);
  117887. if (this._cannonRaycastResult.hasHit) {
  117888. // TODO: do we also want to get the body it hit?
  117889. this._raycastResult.setHitData({
  117890. x: this._cannonRaycastResult.hitNormalWorld.x,
  117891. y: this._cannonRaycastResult.hitNormalWorld.y,
  117892. z: this._cannonRaycastResult.hitNormalWorld.z,
  117893. }, {
  117894. x: this._cannonRaycastResult.hitPointWorld.x,
  117895. y: this._cannonRaycastResult.hitPointWorld.y,
  117896. z: this._cannonRaycastResult.hitPointWorld.z,
  117897. });
  117898. this._raycastResult.setHitDistance(this._cannonRaycastResult.distance);
  117899. }
  117900. return this._raycastResult;
  117901. };
  117902. return CannonJSPlugin;
  117903. }());
  117904. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  117905. /***/ }),
  117906. /***/ "./Physics/Plugins/index.ts":
  117907. /*!**********************************!*\
  117908. !*** ./Physics/Plugins/index.ts ***!
  117909. \**********************************/
  117910. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  117911. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117912. "use strict";
  117913. __webpack_require__.r(__webpack_exports__);
  117914. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  117915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  117916. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  117917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  117918. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  117919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  117920. /***/ }),
  117921. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  117922. /*!*****************************************!*\
  117923. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  117924. \*****************************************/
  117925. /*! exports provided: OimoJSPlugin */
  117926. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117927. "use strict";
  117928. __webpack_require__.r(__webpack_exports__);
  117929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  117930. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  117931. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  117932. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  117933. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  117934. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  117935. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  117936. /** @hidden */
  117937. var OimoJSPlugin = /** @class */ (function () {
  117938. function OimoJSPlugin(iterations, oimoInjection) {
  117939. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  117940. this.name = "OimoJSPlugin";
  117941. this._tmpImpostorsArray = [];
  117942. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  117943. this.BJSOIMO = oimoInjection;
  117944. this.world = new this.BJSOIMO.World({
  117945. iterations: iterations
  117946. });
  117947. this.world.clear();
  117948. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__["PhysicsRaycastResult"]();
  117949. }
  117950. OimoJSPlugin.prototype.setGravity = function (gravity) {
  117951. this.world.gravity.copy(gravity);
  117952. };
  117953. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  117954. this.world.timeStep = timeStep;
  117955. };
  117956. OimoJSPlugin.prototype.getTimeStep = function () {
  117957. return this.world.timeStep;
  117958. };
  117959. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  117960. var _this = this;
  117961. impostors.forEach(function (impostor) {
  117962. impostor.beforeStep();
  117963. });
  117964. this.world.step();
  117965. impostors.forEach(function (impostor) {
  117966. impostor.afterStep();
  117967. //update the ordered impostors array
  117968. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  117969. });
  117970. //check for collisions
  117971. var contact = this.world.contacts;
  117972. while (contact !== null) {
  117973. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  117974. contact = contact.next;
  117975. continue;
  117976. }
  117977. //is this body colliding with any other? get the impostor
  117978. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  117979. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  117980. if (!mainImpostor || !collidingImpostor) {
  117981. contact = contact.next;
  117982. continue;
  117983. }
  117984. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  117985. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  117986. contact = contact.next;
  117987. }
  117988. };
  117989. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  117990. var mass = impostor.physicsBody.mass;
  117991. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  117992. };
  117993. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  117994. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  117995. this.applyImpulse(impostor, force, contactPoint);
  117996. };
  117997. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  117998. var _this = this;
  117999. //parent-child relationship. Does this impostor has a parent impostor?
  118000. if (impostor.parent) {
  118001. if (impostor.physicsBody) {
  118002. this.removePhysicsBody(impostor);
  118003. //TODO is that needed?
  118004. impostor.forceUpdate();
  118005. }
  118006. return;
  118007. }
  118008. if (impostor.isBodyInitRequired()) {
  118009. var bodyConfig = {
  118010. name: impostor.uniqueId,
  118011. //Oimo must have mass, also for static objects.
  118012. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  118013. size: [],
  118014. type: [],
  118015. pos: [],
  118016. posShape: [],
  118017. rot: [],
  118018. rotShape: [],
  118019. move: impostor.getParam("mass") !== 0,
  118020. density: impostor.getParam("mass"),
  118021. friction: impostor.getParam("friction"),
  118022. restitution: impostor.getParam("restitution"),
  118023. //Supporting older versions of Oimo
  118024. world: this.world
  118025. };
  118026. var impostors = [impostor];
  118027. var addToArray = function (parent) {
  118028. if (!parent.getChildMeshes) {
  118029. return;
  118030. }
  118031. parent.getChildMeshes().forEach(function (m) {
  118032. if (m.physicsImpostor) {
  118033. impostors.push(m.physicsImpostor);
  118034. //m.physicsImpostor._init();
  118035. }
  118036. });
  118037. };
  118038. addToArray(impostor.object);
  118039. var checkWithEpsilon_1 = function (value) {
  118040. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  118041. };
  118042. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  118043. impostors.forEach(function (i) {
  118044. if (!i.object.rotationQuaternion) {
  118045. return;
  118046. }
  118047. //get the correct bounding box
  118048. var oldQuaternion = i.object.rotationQuaternion;
  118049. globalQuaternion_1 = oldQuaternion.clone();
  118050. var rot = oldQuaternion.toEulerAngles();
  118051. var extendSize = i.getObjectExtendSize();
  118052. var radToDeg = 57.295779513082320876;
  118053. if (i === impostor) {
  118054. var center = impostor.getObjectCenter();
  118055. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  118056. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  118057. //Can also use Array.prototype.push.apply
  118058. bodyConfig.pos.push(center.x);
  118059. bodyConfig.pos.push(center.y);
  118060. bodyConfig.pos.push(center.z);
  118061. bodyConfig.posShape.push(0, 0, 0);
  118062. bodyConfig.rotShape.push(0, 0, 0);
  118063. }
  118064. else {
  118065. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  118066. bodyConfig.posShape.push(localPosition.x);
  118067. bodyConfig.posShape.push(localPosition.y);
  118068. bodyConfig.posShape.push(localPosition.z);
  118069. bodyConfig.pos.push(0, 0, 0);
  118070. bodyConfig.rotShape.push(rot.x * radToDeg);
  118071. bodyConfig.rotShape.push(rot.y * radToDeg);
  118072. bodyConfig.rotShape.push(rot.z * radToDeg);
  118073. }
  118074. // register mesh
  118075. switch (i.type) {
  118076. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  118077. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  118078. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  118079. var radiusX = extendSize.x;
  118080. var radiusY = extendSize.y;
  118081. var radiusZ = extendSize.z;
  118082. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  118083. bodyConfig.type.push('sphere');
  118084. //due to the way oimo works with compounds, add 3 times
  118085. bodyConfig.size.push(size);
  118086. bodyConfig.size.push(size);
  118087. bodyConfig.size.push(size);
  118088. break;
  118089. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  118090. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  118091. var sizeY = checkWithEpsilon_1(extendSize.y);
  118092. bodyConfig.type.push('cylinder');
  118093. bodyConfig.size.push(sizeX);
  118094. bodyConfig.size.push(sizeY);
  118095. //due to the way oimo works with compounds, add one more value.
  118096. bodyConfig.size.push(sizeY);
  118097. break;
  118098. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  118099. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  118100. default:
  118101. var sizeX = checkWithEpsilon_1(extendSize.x);
  118102. var sizeY = checkWithEpsilon_1(extendSize.y);
  118103. var sizeZ = checkWithEpsilon_1(extendSize.z);
  118104. bodyConfig.type.push('box');
  118105. //if (i === impostor) {
  118106. bodyConfig.size.push(sizeX);
  118107. bodyConfig.size.push(sizeY);
  118108. bodyConfig.size.push(sizeZ);
  118109. //} else {
  118110. // bodyConfig.size.push(0,0,0);
  118111. //}
  118112. break;
  118113. }
  118114. //actually not needed, but hey...
  118115. i.object.rotationQuaternion = oldQuaternion;
  118116. });
  118117. impostor.physicsBody = this.world.add(bodyConfig);
  118118. // set the quaternion, ignoring the previously defined (euler) rotation
  118119. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  118120. // update with delta 0, so the body will reveive the new rotation.
  118121. impostor.physicsBody.updatePosition(0);
  118122. }
  118123. else {
  118124. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  118125. }
  118126. impostor.setDeltaPosition(this._tmpPositionVector);
  118127. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  118128. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  118129. };
  118130. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  118131. //impostor.physicsBody.dispose();
  118132. //Same as : (older oimo versions)
  118133. this.world.removeRigidBody(impostor.physicsBody);
  118134. };
  118135. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  118136. var mainBody = impostorJoint.mainImpostor.physicsBody;
  118137. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  118138. if (!mainBody || !connectedBody) {
  118139. return;
  118140. }
  118141. var jointData = impostorJoint.joint.jointData;
  118142. var options = jointData.nativeParams || {};
  118143. var type;
  118144. var nativeJointData = {
  118145. body1: mainBody,
  118146. body2: connectedBody,
  118147. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  118148. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  118149. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  118150. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  118151. min: options.min,
  118152. max: options.max,
  118153. collision: options.collision || jointData.collision,
  118154. spring: options.spring,
  118155. //supporting older version of Oimo
  118156. world: this.world
  118157. };
  118158. switch (impostorJoint.joint.type) {
  118159. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  118160. type = "jointBall";
  118161. break;
  118162. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  118163. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  118164. var springData = jointData;
  118165. nativeJointData.min = springData.length || nativeJointData.min;
  118166. //Max should also be set, just make sure it is at least min
  118167. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  118168. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  118169. type = "jointDistance";
  118170. nativeJointData.max = jointData.maxDistance;
  118171. break;
  118172. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  118173. type = "jointPrisme";
  118174. break;
  118175. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  118176. type = "jointSlide";
  118177. break;
  118178. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  118179. type = "jointWheel";
  118180. break;
  118181. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  118182. default:
  118183. type = "jointHinge";
  118184. break;
  118185. }
  118186. nativeJointData.type = type;
  118187. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  118188. };
  118189. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  118190. //Bug in Oimo prevents us from disposing a joint in the playground
  118191. //joint.joint.physicsJoint.dispose();
  118192. //So we will bruteforce it!
  118193. try {
  118194. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  118195. }
  118196. catch (e) {
  118197. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  118198. }
  118199. };
  118200. OimoJSPlugin.prototype.isSupported = function () {
  118201. return this.BJSOIMO !== undefined;
  118202. };
  118203. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  118204. if (!impostor.physicsBody.sleeping) {
  118205. //TODO check that
  118206. /*if (impostor.physicsBody.shapes.next) {
  118207. var parentShape = this._getLastShape(impostor.physicsBody);
  118208. impostor.object.position.copyFrom(parentShape.position);
  118209. console.log(parentShape.position);
  118210. } else {*/
  118211. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  118212. //}
  118213. if (impostor.object.rotationQuaternion) {
  118214. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  118215. }
  118216. }
  118217. };
  118218. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  118219. var body = impostor.physicsBody;
  118220. body.position.copy(newPosition);
  118221. body.orientation.copy(newRotation);
  118222. body.syncShapes();
  118223. body.awake();
  118224. };
  118225. /*private _getLastShape(body: any): any {
  118226. var lastShape = body.shapes;
  118227. while (lastShape.next) {
  118228. lastShape = lastShape.next;
  118229. }
  118230. return lastShape;
  118231. }*/
  118232. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  118233. impostor.physicsBody.linearVelocity.copy(velocity);
  118234. };
  118235. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  118236. impostor.physicsBody.angularVelocity.copy(velocity);
  118237. };
  118238. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  118239. var v = impostor.physicsBody.linearVelocity;
  118240. if (!v) {
  118241. return null;
  118242. }
  118243. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  118244. };
  118245. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  118246. var v = impostor.physicsBody.angularVelocity;
  118247. if (!v) {
  118248. return null;
  118249. }
  118250. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  118251. };
  118252. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  118253. var staticBody = mass === 0;
  118254. //this will actually set the body's density and not its mass.
  118255. //But this is how oimo treats the mass variable.
  118256. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  118257. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  118258. };
  118259. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  118260. return impostor.physicsBody.shapes.density;
  118261. };
  118262. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  118263. return impostor.physicsBody.shapes.friction;
  118264. };
  118265. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  118266. impostor.physicsBody.shapes.friction = friction;
  118267. };
  118268. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  118269. return impostor.physicsBody.shapes.restitution;
  118270. };
  118271. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  118272. impostor.physicsBody.shapes.restitution = restitution;
  118273. };
  118274. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  118275. impostor.physicsBody.sleep();
  118276. };
  118277. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  118278. impostor.physicsBody.awake();
  118279. };
  118280. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  118281. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  118282. if (minDistance !== void 0) {
  118283. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  118284. }
  118285. };
  118286. OimoJSPlugin.prototype.setMotor = function (joint, speed, force, motorIndex) {
  118287. if (force !== undefined) {
  118288. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter");
  118289. }
  118290. else {
  118291. force = 1e6;
  118292. }
  118293. speed *= -1;
  118294. //TODO separate rotational and transational motors.
  118295. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  118296. if (motor) {
  118297. motor.setMotor(speed, force);
  118298. }
  118299. };
  118300. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  118301. //TODO separate rotational and transational motors.
  118302. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  118303. if (motor) {
  118304. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  118305. }
  118306. };
  118307. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  118308. var body = impostor.physicsBody;
  118309. mesh.position.x = body.position.x;
  118310. mesh.position.y = body.position.y;
  118311. mesh.position.z = body.position.z;
  118312. if (mesh.rotationQuaternion) {
  118313. mesh.rotationQuaternion.x = body.orientation.x;
  118314. mesh.rotationQuaternion.y = body.orientation.y;
  118315. mesh.rotationQuaternion.z = body.orientation.z;
  118316. mesh.rotationQuaternion.w = body.orientation.s;
  118317. }
  118318. };
  118319. OimoJSPlugin.prototype.getRadius = function (impostor) {
  118320. return impostor.physicsBody.shapes.radius;
  118321. };
  118322. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  118323. var shape = impostor.physicsBody.shapes;
  118324. result.x = shape.halfWidth * 2;
  118325. result.y = shape.halfHeight * 2;
  118326. result.z = shape.halfDepth * 2;
  118327. };
  118328. OimoJSPlugin.prototype.dispose = function () {
  118329. this.world.clear();
  118330. };
  118331. /**
  118332. * Does a raycast in the physics world
  118333. * @param from when should the ray start?
  118334. * @param to when should the ray end?
  118335. * @returns PhysicsRaycastResult
  118336. */
  118337. OimoJSPlugin.prototype.raycast = function (from, to) {
  118338. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("raycast is not currently supported by the Oimo physics plugin");
  118339. this._raycastResult.reset(from, to);
  118340. return this._raycastResult;
  118341. };
  118342. return OimoJSPlugin;
  118343. }());
  118344. /***/ }),
  118345. /***/ "./Physics/index.ts":
  118346. /*!**************************!*\
  118347. !*** ./Physics/index.ts ***!
  118348. \**************************/
  118349. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  118350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118351. "use strict";
  118352. __webpack_require__.r(__webpack_exports__);
  118353. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  118354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  118355. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  118356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  118357. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  118358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  118359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEventOptions"]; });
  118360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEventOptions"]; });
  118361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEventOptions"]; });
  118362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  118363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  118364. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  118365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  118366. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  118367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  118368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  118369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  118370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  118371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  118372. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  118373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  118374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  118375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  118376. /***/ }),
  118377. /***/ "./Physics/physicsEngine.ts":
  118378. /*!**********************************!*\
  118379. !*** ./Physics/physicsEngine.ts ***!
  118380. \**********************************/
  118381. /*! exports provided: PhysicsEngine */
  118382. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118383. "use strict";
  118384. __webpack_require__.r(__webpack_exports__);
  118385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  118386. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118387. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  118388. /**
  118389. * Class used to control physics engine
  118390. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  118391. */
  118392. var PhysicsEngine = /** @class */ (function () {
  118393. /**
  118394. * Creates a new Physics Engine
  118395. * @param gravity defines the gravity vector used by the simulation
  118396. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  118397. */
  118398. function PhysicsEngine(gravity, _physicsPlugin) {
  118399. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  118400. this._physicsPlugin = _physicsPlugin;
  118401. this._impostors = [];
  118402. this._joints = [];
  118403. if (!this._physicsPlugin.isSupported()) {
  118404. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  118405. + "Please make sure it is included.");
  118406. }
  118407. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  118408. this.setGravity(gravity);
  118409. this.setTimeStep();
  118410. }
  118411. /**
  118412. * Factory used to create the default physics plugin.
  118413. * @returns The default physics plugin
  118414. */
  118415. PhysicsEngine.DefaultPluginFactory = function () {
  118416. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  118417. };
  118418. /**
  118419. * Sets the gravity vector used by the simulation
  118420. * @param gravity defines the gravity vector to use
  118421. */
  118422. PhysicsEngine.prototype.setGravity = function (gravity) {
  118423. this.gravity = gravity;
  118424. this._physicsPlugin.setGravity(this.gravity);
  118425. };
  118426. /**
  118427. * Set the time step of the physics engine.
  118428. * Default is 1/60.
  118429. * To slow it down, enter 1/600 for example.
  118430. * To speed it up, 1/30
  118431. * @param newTimeStep defines the new timestep to apply to this world.
  118432. */
  118433. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  118434. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  118435. this._physicsPlugin.setTimeStep(newTimeStep);
  118436. };
  118437. /**
  118438. * Get the time step of the physics engine.
  118439. * @returns the current time step
  118440. */
  118441. PhysicsEngine.prototype.getTimeStep = function () {
  118442. return this._physicsPlugin.getTimeStep();
  118443. };
  118444. /**
  118445. * Release all resources
  118446. */
  118447. PhysicsEngine.prototype.dispose = function () {
  118448. this._impostors.forEach(function (impostor) {
  118449. impostor.dispose();
  118450. });
  118451. this._physicsPlugin.dispose();
  118452. };
  118453. /**
  118454. * Gets the name of the current physics plugin
  118455. * @returns the name of the plugin
  118456. */
  118457. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  118458. return this._physicsPlugin.name;
  118459. };
  118460. /**
  118461. * Adding a new impostor for the impostor tracking.
  118462. * This will be done by the impostor itself.
  118463. * @param impostor the impostor to add
  118464. */
  118465. PhysicsEngine.prototype.addImpostor = function (impostor) {
  118466. impostor.uniqueId = this._impostors.push(impostor);
  118467. //if no parent, generate the body
  118468. if (!impostor.parent) {
  118469. this._physicsPlugin.generatePhysicsBody(impostor);
  118470. }
  118471. };
  118472. /**
  118473. * Remove an impostor from the engine.
  118474. * This impostor and its mesh will not longer be updated by the physics engine.
  118475. * @param impostor the impostor to remove
  118476. */
  118477. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  118478. var index = this._impostors.indexOf(impostor);
  118479. if (index > -1) {
  118480. var removed = this._impostors.splice(index, 1);
  118481. //Is it needed?
  118482. if (removed.length) {
  118483. this.getPhysicsPlugin().removePhysicsBody(impostor);
  118484. }
  118485. }
  118486. };
  118487. /**
  118488. * Add a joint to the physics engine
  118489. * @param mainImpostor defines the main impostor to which the joint is added.
  118490. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  118491. * @param joint defines the joint that will connect both impostors.
  118492. */
  118493. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  118494. var impostorJoint = {
  118495. mainImpostor: mainImpostor,
  118496. connectedImpostor: connectedImpostor,
  118497. joint: joint
  118498. };
  118499. joint.physicsPlugin = this._physicsPlugin;
  118500. this._joints.push(impostorJoint);
  118501. this._physicsPlugin.generateJoint(impostorJoint);
  118502. };
  118503. /**
  118504. * Removes a joint from the simulation
  118505. * @param mainImpostor defines the impostor used with the joint
  118506. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  118507. * @param joint defines the joint to remove
  118508. */
  118509. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  118510. var matchingJoints = this._joints.filter(function (impostorJoint) {
  118511. return (impostorJoint.connectedImpostor === connectedImpostor
  118512. && impostorJoint.joint === joint
  118513. && impostorJoint.mainImpostor === mainImpostor);
  118514. });
  118515. if (matchingJoints.length) {
  118516. this._physicsPlugin.removeJoint(matchingJoints[0]);
  118517. //TODO remove it from the list as well
  118518. }
  118519. };
  118520. /**
  118521. * Called by the scene. No need to call it.
  118522. * @param delta defines the timespam between frames
  118523. */
  118524. PhysicsEngine.prototype._step = function (delta) {
  118525. var _this = this;
  118526. //check if any mesh has no body / requires an update
  118527. this._impostors.forEach(function (impostor) {
  118528. if (impostor.isBodyInitRequired()) {
  118529. _this._physicsPlugin.generatePhysicsBody(impostor);
  118530. }
  118531. });
  118532. if (delta > 0.1) {
  118533. delta = 0.1;
  118534. }
  118535. else if (delta <= 0) {
  118536. delta = 1.0 / 60.0;
  118537. }
  118538. this._physicsPlugin.executeStep(delta, this._impostors);
  118539. };
  118540. /**
  118541. * Gets the current plugin used to run the simulation
  118542. * @returns current plugin
  118543. */
  118544. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  118545. return this._physicsPlugin;
  118546. };
  118547. /**
  118548. * Gets the list of physic impostors
  118549. * @returns an array of PhysicsImpostor
  118550. */
  118551. PhysicsEngine.prototype.getImpostors = function () {
  118552. return this._impostors;
  118553. };
  118554. /**
  118555. * Gets the impostor for a physics enabled object
  118556. * @param object defines the object impersonated by the impostor
  118557. * @returns the PhysicsImpostor or null if not found
  118558. */
  118559. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  118560. for (var i = 0; i < this._impostors.length; ++i) {
  118561. if (this._impostors[i].object === object) {
  118562. return this._impostors[i];
  118563. }
  118564. }
  118565. return null;
  118566. };
  118567. /**
  118568. * Gets the impostor for a physics body object
  118569. * @param body defines physics body used by the impostor
  118570. * @returns the PhysicsImpostor or null if not found
  118571. */
  118572. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  118573. for (var i = 0; i < this._impostors.length; ++i) {
  118574. if (this._impostors[i].physicsBody === body) {
  118575. return this._impostors[i];
  118576. }
  118577. }
  118578. return null;
  118579. };
  118580. /**
  118581. * Does a raycast in the physics world
  118582. * @param from when should the ray start?
  118583. * @param to when should the ray end?
  118584. * @returns PhysicsRaycastResult
  118585. */
  118586. PhysicsEngine.prototype.raycast = function (from, to) {
  118587. return this._physicsPlugin.raycast(from, to);
  118588. };
  118589. /**
  118590. * Global value used to control the smallest number supported by the simulation
  118591. */
  118592. PhysicsEngine.Epsilon = 0.001;
  118593. return PhysicsEngine;
  118594. }());
  118595. /***/ }),
  118596. /***/ "./Physics/physicsEngineComponent.ts":
  118597. /*!*******************************************!*\
  118598. !*** ./Physics/physicsEngineComponent.ts ***!
  118599. \*******************************************/
  118600. /*! exports provided: PhysicsEngineSceneComponent */
  118601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118602. "use strict";
  118603. __webpack_require__.r(__webpack_exports__);
  118604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  118605. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  118606. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  118607. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  118608. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  118609. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  118610. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  118611. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  118612. /**
  118613. * Gets the current physics engine
  118614. * @returns a IPhysicsEngine or null if none attached
  118615. */
  118616. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  118617. return this._physicsEngine;
  118618. };
  118619. /**
  118620. * Enables physics to the current scene
  118621. * @param gravity defines the scene's gravity for the physics engine
  118622. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  118623. * @return a boolean indicating if the physics engine was initialized
  118624. */
  118625. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  118626. if (gravity === void 0) { gravity = null; }
  118627. if (this._physicsEngine) {
  118628. return true;
  118629. }
  118630. // Register the component to the scene
  118631. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  118632. if (!component) {
  118633. component = new PhysicsEngineSceneComponent(this);
  118634. this._addComponent(component);
  118635. }
  118636. try {
  118637. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  118638. return true;
  118639. }
  118640. catch (e) {
  118641. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  118642. return false;
  118643. }
  118644. };
  118645. /**
  118646. * Disables and disposes the physics engine associated with the scene
  118647. */
  118648. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  118649. if (!this._physicsEngine) {
  118650. return;
  118651. }
  118652. this._physicsEngine.dispose();
  118653. this._physicsEngine = null;
  118654. };
  118655. /**
  118656. * Gets a boolean indicating if there is an active physics engine
  118657. * @returns a boolean indicating if there is an active physics engine
  118658. */
  118659. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  118660. return this._physicsEngine !== undefined;
  118661. };
  118662. /**
  118663. * Deletes a physics compound impostor
  118664. * @param compound defines the compound to delete
  118665. */
  118666. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  118667. var mesh = compound.parts[0].mesh;
  118668. if (mesh.physicsImpostor) {
  118669. mesh.physicsImpostor.dispose( /*true*/);
  118670. mesh.physicsImpostor = null;
  118671. }
  118672. };
  118673. /** @hidden */
  118674. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  118675. if (this._physicsEngine) {
  118676. this.onBeforePhysicsObservable.notifyObservers(this);
  118677. this._physicsEngine._step(step / 1000);
  118678. this.onAfterPhysicsObservable.notifyObservers(this);
  118679. }
  118680. };
  118681. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  118682. get: function () {
  118683. return this._physicsImpostor;
  118684. },
  118685. set: function (value) {
  118686. var _this = this;
  118687. if (this._physicsImpostor === value) {
  118688. return;
  118689. }
  118690. if (this._disposePhysicsObserver) {
  118691. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  118692. }
  118693. this._physicsImpostor = value;
  118694. if (value) {
  118695. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  118696. // Physics
  118697. if (_this.physicsImpostor) {
  118698. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  118699. _this.physicsImpostor = null;
  118700. }
  118701. });
  118702. }
  118703. },
  118704. enumerable: true,
  118705. configurable: true
  118706. });
  118707. /**
  118708. * Gets the current physics impostor
  118709. * @see http://doc.babylonjs.com/features/physics_engine
  118710. * @returns a physics impostor or null
  118711. */
  118712. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  118713. return this.physicsImpostor;
  118714. };
  118715. /**
  118716. * Apply a physic impulse to the mesh
  118717. * @param force defines the force to apply
  118718. * @param contactPoint defines where to apply the force
  118719. * @returns the current mesh
  118720. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  118721. */
  118722. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  118723. if (!this.physicsImpostor) {
  118724. return this;
  118725. }
  118726. this.physicsImpostor.applyImpulse(force, contactPoint);
  118727. return this;
  118728. };
  118729. /**
  118730. * Creates a physic joint between two meshes
  118731. * @param otherMesh defines the other mesh to use
  118732. * @param pivot1 defines the pivot to use on this mesh
  118733. * @param pivot2 defines the pivot to use on the other mesh
  118734. * @param options defines additional options (can be plugin dependent)
  118735. * @returns the current mesh
  118736. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  118737. */
  118738. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  118739. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  118740. return this;
  118741. }
  118742. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  118743. mainPivot: pivot1,
  118744. connectedPivot: pivot2,
  118745. nativeParams: options
  118746. });
  118747. return this;
  118748. };
  118749. /**
  118750. * Defines the physics engine scene component responsible to manage a physics engine
  118751. */
  118752. var PhysicsEngineSceneComponent = /** @class */ (function () {
  118753. /**
  118754. * Creates a new instance of the component for the given scene
  118755. * @param scene Defines the scene to register the component in
  118756. */
  118757. function PhysicsEngineSceneComponent(scene) {
  118758. var _this = this;
  118759. /**
  118760. * The component name helpful to identify the component in the list of scene components.
  118761. */
  118762. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  118763. this.scene = scene;
  118764. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  118765. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  118766. // Replace the function used to get the deterministic frame time
  118767. this.scene.getDeterministicFrameTime = function () {
  118768. if (_this.scene._physicsEngine) {
  118769. return _this.scene._physicsEngine.getTimeStep() * 1000;
  118770. }
  118771. return 1000.0 / 60.0;
  118772. };
  118773. }
  118774. /**
  118775. * Registers the component in a given scene
  118776. */
  118777. PhysicsEngineSceneComponent.prototype.register = function () {
  118778. };
  118779. /**
  118780. * Rebuilds the elements related to this component in case of
  118781. * context lost for instance.
  118782. */
  118783. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  118784. // Nothing to do for this component
  118785. };
  118786. /**
  118787. * Disposes the component and the associated ressources
  118788. */
  118789. PhysicsEngineSceneComponent.prototype.dispose = function () {
  118790. this.scene.onBeforePhysicsObservable.clear();
  118791. this.scene.onAfterPhysicsObservable.clear();
  118792. if (this.scene._physicsEngine) {
  118793. this.scene.disablePhysicsEngine();
  118794. }
  118795. };
  118796. return PhysicsEngineSceneComponent;
  118797. }());
  118798. /***/ }),
  118799. /***/ "./Physics/physicsHelper.ts":
  118800. /*!**********************************!*\
  118801. !*** ./Physics/physicsHelper.ts ***!
  118802. \**********************************/
  118803. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  118804. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118805. "use strict";
  118806. __webpack_require__.r(__webpack_exports__);
  118807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  118808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return PhysicsRadialExplosionEventOptions; });
  118809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return PhysicsUpdraftEventOptions; });
  118810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return PhysicsVortexEventOptions; });
  118811. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  118812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  118813. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118814. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  118815. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118816. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  118817. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  118818. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  118819. /**
  118820. * A helper for physics simulations
  118821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118822. */
  118823. var PhysicsHelper = /** @class */ (function () {
  118824. /**
  118825. * Initializes the Physics helper
  118826. * @param scene Babylon.js scene
  118827. */
  118828. function PhysicsHelper(scene) {
  118829. this._scene = scene;
  118830. this._physicsEngine = this._scene.getPhysicsEngine();
  118831. if (!this._physicsEngine) {
  118832. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  118833. return;
  118834. }
  118835. }
  118836. /**
  118837. * Applies a radial explosion impulse
  118838. * @param origin the origin of the explosion
  118839. * @param radiusOrEventOptions the radius or the options of radial explosion
  118840. * @param strength the explosion strength
  118841. * @param falloff possible options: Constant & Linear. Defaults to Constant
  118842. * @returns A physics radial explosion event, or null
  118843. */
  118844. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radiusOrEventOptions, strength, falloff) {
  118845. if (!this._physicsEngine) {
  118846. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  118847. return null;
  118848. }
  118849. var impostors = this._physicsEngine.getImpostors();
  118850. if (impostors.length === 0) {
  118851. return null;
  118852. }
  118853. if (typeof radiusOrEventOptions === 'number') {
  118854. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  118855. radiusOrEventOptions.radius = radiusOrEventOptions;
  118856. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  118857. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  118858. }
  118859. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  118860. var affectedImpostorsWithData = Array();
  118861. impostors.forEach(function (impostor) {
  118862. var impostorHitData = event.getImpostorHitData(impostor, origin);
  118863. if (!impostorHitData) {
  118864. return;
  118865. }
  118866. impostor.applyImpulse(impostorHitData.force, impostorHitData.contactPoint);
  118867. affectedImpostorsWithData.push({
  118868. impostor: impostor,
  118869. hitData: impostorHitData,
  118870. });
  118871. });
  118872. event.triggerAffectedImpostorsCallback(affectedImpostorsWithData);
  118873. event.dispose(false);
  118874. return event;
  118875. };
  118876. /**
  118877. * Applies a radial explosion force
  118878. * @param origin the origin of the explosion
  118879. * @param radiusOrEventOptions the radius or the options of radial explosion
  118880. * @param strength the explosion strength
  118881. * @param falloff possible options: Constant & Linear. Defaults to Constant
  118882. * @returns A physics radial explosion event, or null
  118883. */
  118884. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radiusOrEventOptions, strength, falloff) {
  118885. if (!this._physicsEngine) {
  118886. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  118887. return null;
  118888. }
  118889. var impostors = this._physicsEngine.getImpostors();
  118890. if (impostors.length === 0) {
  118891. return null;
  118892. }
  118893. if (typeof radiusOrEventOptions === 'number') {
  118894. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  118895. radiusOrEventOptions.radius = radiusOrEventOptions;
  118896. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  118897. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  118898. }
  118899. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  118900. var affectedImpostorsWithData = Array();
  118901. impostors.forEach(function (impostor) {
  118902. var impostorHitData = event.getImpostorHitData(impostor, origin);
  118903. if (!impostorHitData) {
  118904. return;
  118905. }
  118906. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  118907. affectedImpostorsWithData.push({
  118908. impostor: impostor,
  118909. hitData: impostorHitData,
  118910. });
  118911. });
  118912. event.triggerAffectedImpostorsCallback(affectedImpostorsWithData);
  118913. event.dispose(false);
  118914. return event;
  118915. };
  118916. /**
  118917. * Creates a gravitational field
  118918. * @param origin the origin of the explosion
  118919. * @param radiusOrEventOptions the radius or the options of radial explosion
  118920. * @param strength the explosion strength
  118921. * @param falloff possible options: Constant & Linear. Defaults to Constant
  118922. * @returns A physics gravitational field event, or null
  118923. */
  118924. PhysicsHelper.prototype.gravitationalField = function (origin, radiusOrEventOptions, strength, falloff) {
  118925. if (!this._physicsEngine) {
  118926. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  118927. return null;
  118928. }
  118929. var impostors = this._physicsEngine.getImpostors();
  118930. if (impostors.length === 0) {
  118931. return null;
  118932. }
  118933. if (typeof radiusOrEventOptions === 'number') {
  118934. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  118935. radiusOrEventOptions.radius = radiusOrEventOptions;
  118936. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  118937. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  118938. }
  118939. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radiusOrEventOptions);
  118940. event.dispose(false);
  118941. return event;
  118942. };
  118943. /**
  118944. * Creates a physics updraft event
  118945. * @param origin the origin of the updraft
  118946. * @param radiusOrEventOptions the radius or the options of the updraft
  118947. * @param strength the strength of the updraft
  118948. * @param height the height of the updraft
  118949. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  118950. * @returns A physics updraft event, or null
  118951. */
  118952. PhysicsHelper.prototype.updraft = function (origin, radiusOrEventOptions, strength, height, updraftMode) {
  118953. if (!this._physicsEngine) {
  118954. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  118955. return null;
  118956. }
  118957. if (this._physicsEngine.getImpostors().length === 0) {
  118958. return null;
  118959. }
  118960. if (typeof radiusOrEventOptions === 'number') {
  118961. radiusOrEventOptions = new PhysicsUpdraftEventOptions();
  118962. radiusOrEventOptions.radius = radiusOrEventOptions;
  118963. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  118964. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  118965. radiusOrEventOptions.updraftMode = updraftMode || radiusOrEventOptions.updraftMode;
  118966. }
  118967. var event = new PhysicsUpdraftEvent(this._scene, origin, radiusOrEventOptions);
  118968. event.dispose(false);
  118969. return event;
  118970. };
  118971. /**
  118972. * Creates a physics vortex event
  118973. * @param origin the of the vortex
  118974. * @param radiusOrEventOptions the radius or the options of the vortex
  118975. * @param strength the strength of the vortex
  118976. * @param height the height of the vortex
  118977. * @returns a Physics vortex event, or null
  118978. * A physics vortex event or null
  118979. */
  118980. PhysicsHelper.prototype.vortex = function (origin, radiusOrEventOptions, strength, height) {
  118981. if (!this._physicsEngine) {
  118982. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  118983. return null;
  118984. }
  118985. if (this._physicsEngine.getImpostors().length === 0) {
  118986. return null;
  118987. }
  118988. if (typeof radiusOrEventOptions === 'number') {
  118989. radiusOrEventOptions = new PhysicsVortexEventOptions();
  118990. radiusOrEventOptions.radius = radiusOrEventOptions;
  118991. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  118992. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  118993. }
  118994. var event = new PhysicsVortexEvent(this._scene, origin, radiusOrEventOptions);
  118995. event.dispose(false);
  118996. return event;
  118997. };
  118998. return PhysicsHelper;
  118999. }());
  119000. /**
  119001. * Represents a physics radial explosion event
  119002. */
  119003. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  119004. /**
  119005. * Initializes a radial explosioin event
  119006. * @param _scene BabylonJS scene
  119007. * @param _options The options for the vortex event
  119008. */
  119009. function PhysicsRadialExplosionEvent(_scene, _options) {
  119010. this._scene = _scene;
  119011. this._options = _options;
  119012. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  119013. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  119014. }
  119015. /**
  119016. * Returns the data related to the radial explosion event (sphere).
  119017. * @returns The radial explosion event data
  119018. */
  119019. PhysicsRadialExplosionEvent.prototype.getData = function () {
  119020. this._dataFetched = true;
  119021. return {
  119022. sphere: this._sphere,
  119023. };
  119024. };
  119025. /**
  119026. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  119027. * @param impostor A physics imposter
  119028. * @param origin the origin of the explosion
  119029. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  119030. */
  119031. PhysicsRadialExplosionEvent.prototype.getImpostorHitData = function (impostor, origin) {
  119032. if (impostor.mass === 0) {
  119033. return null;
  119034. }
  119035. if (!this._intersectsWithSphere(impostor, origin, this._options.radius)) {
  119036. return null;
  119037. }
  119038. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  119039. return null;
  119040. }
  119041. var impostorObjectCenter = impostor.getObjectCenter();
  119042. var direction = impostorObjectCenter.subtract(origin);
  119043. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, this._options.radius);
  119044. var hit = ray.intersectsMesh(impostor.object);
  119045. var contactPoint = hit.pickedPoint;
  119046. if (!contactPoint) {
  119047. return null;
  119048. }
  119049. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Distance(origin, contactPoint);
  119050. if (distanceFromOrigin > this._options.radius) {
  119051. return null;
  119052. }
  119053. var multiplier = this._options.falloff === PhysicsRadialImpulseFalloff.Constant
  119054. ? this._options.strength
  119055. : this._options.strength * (1 - (distanceFromOrigin / this._options.radius));
  119056. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  119057. return { force: force, contactPoint: contactPoint, distanceFromOrigin: distanceFromOrigin };
  119058. };
  119059. /**
  119060. * Triggers affecterd impostors callbacks
  119061. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  119062. */
  119063. PhysicsRadialExplosionEvent.prototype.triggerAffectedImpostorsCallback = function (affectedImpostorsWithData) {
  119064. if (this._options.affectedImpostorsCallback) {
  119065. this._options.affectedImpostorsCallback(affectedImpostorsWithData);
  119066. }
  119067. };
  119068. /**
  119069. * Disposes the sphere.
  119070. * @param force Specifies if the sphere should be disposed by force
  119071. */
  119072. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  119073. var _this = this;
  119074. if (force === void 0) { force = true; }
  119075. if (force) {
  119076. this._sphere.dispose();
  119077. }
  119078. else {
  119079. setTimeout(function () {
  119080. if (!_this._dataFetched) {
  119081. _this._sphere.dispose();
  119082. }
  119083. }, 0);
  119084. }
  119085. };
  119086. /*** Helpers ***/
  119087. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  119088. if (!this._sphere) {
  119089. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._options.sphere, this._scene);
  119090. this._sphere.isVisible = false;
  119091. }
  119092. };
  119093. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  119094. var impostorObject = impostor.object;
  119095. this._prepareSphere();
  119096. this._sphere.position = origin;
  119097. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * 2, radius * 2, radius * 2);
  119098. this._sphere._updateBoundingInfo();
  119099. this._sphere.computeWorldMatrix(true);
  119100. return this._sphere.intersectsMesh(impostorObject, true);
  119101. };
  119102. return PhysicsRadialExplosionEvent;
  119103. }());
  119104. /**
  119105. * Represents a gravitational field event
  119106. */
  119107. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  119108. /**
  119109. * Initializes the physics gravitational field event
  119110. * @param _physicsHelper A physics helper
  119111. * @param _scene BabylonJS scene
  119112. * @param _origin The origin position of the gravitational field event
  119113. * @param _options The options for the vortex event
  119114. */
  119115. function PhysicsGravitationalFieldEvent(_physicsHelper, _scene, _origin, _options) {
  119116. this._physicsHelper = _physicsHelper;
  119117. this._scene = _scene;
  119118. this._origin = _origin;
  119119. this._options = _options;
  119120. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  119121. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  119122. this._tickCallback = this._tick.bind(this);
  119123. this._options.strength = this._options.strength * -1;
  119124. }
  119125. /**
  119126. * Returns the data related to the gravitational field event (sphere).
  119127. * @returns A gravitational field event
  119128. */
  119129. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  119130. this._dataFetched = true;
  119131. return {
  119132. sphere: this._sphere,
  119133. };
  119134. };
  119135. /**
  119136. * Enables the gravitational field.
  119137. */
  119138. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  119139. this._tickCallback.call(this);
  119140. this._scene.registerBeforeRender(this._tickCallback);
  119141. };
  119142. /**
  119143. * Disables the gravitational field.
  119144. */
  119145. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  119146. this._scene.unregisterBeforeRender(this._tickCallback);
  119147. };
  119148. /**
  119149. * Disposes the sphere.
  119150. * @param force The force to dispose from the gravitational field event
  119151. */
  119152. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  119153. var _this = this;
  119154. if (force === void 0) { force = true; }
  119155. if (force) {
  119156. this._sphere.dispose();
  119157. }
  119158. else {
  119159. setTimeout(function () {
  119160. if (!_this._dataFetched) {
  119161. _this._sphere.dispose();
  119162. }
  119163. }, 0);
  119164. }
  119165. };
  119166. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  119167. // Since the params won't change, we fetch the event only once
  119168. if (this._sphere) {
  119169. this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  119170. }
  119171. else {
  119172. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  119173. if (radialExplosionEvent) {
  119174. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  119175. }
  119176. }
  119177. };
  119178. return PhysicsGravitationalFieldEvent;
  119179. }());
  119180. /**
  119181. * Represents a physics updraft event
  119182. */
  119183. var PhysicsUpdraftEvent = /** @class */ (function () {
  119184. /**
  119185. * Initializes the physics updraft event
  119186. * @param _scene BabylonJS scene
  119187. * @param _origin The origin position of the updraft
  119188. * @param _options The options for the updraft event
  119189. */
  119190. function PhysicsUpdraftEvent(_scene, _origin, _options) {
  119191. this._scene = _scene;
  119192. this._origin = _origin;
  119193. this._options = _options;
  119194. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  119195. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  119196. 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
  119197. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  119198. this._physicsEngine = this._scene.getPhysicsEngine();
  119199. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsUpdraftEventOptions()), this._options);
  119200. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  119201. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  119202. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  119203. this._originDirection = this._origin.subtract(this._originTop).normalize();
  119204. }
  119205. this._tickCallback = this._tick.bind(this);
  119206. this._prepareCylinder();
  119207. }
  119208. /**
  119209. * Returns the data related to the updraft event (cylinder).
  119210. * @returns A physics updraft event
  119211. */
  119212. PhysicsUpdraftEvent.prototype.getData = function () {
  119213. this._dataFetched = true;
  119214. return {
  119215. cylinder: this._cylinder,
  119216. };
  119217. };
  119218. /**
  119219. * Enables the updraft.
  119220. */
  119221. PhysicsUpdraftEvent.prototype.enable = function () {
  119222. this._tickCallback.call(this);
  119223. this._scene.registerBeforeRender(this._tickCallback);
  119224. };
  119225. /**
  119226. * Disables the updraft.
  119227. */
  119228. PhysicsUpdraftEvent.prototype.disable = function () {
  119229. this._scene.unregisterBeforeRender(this._tickCallback);
  119230. };
  119231. /**
  119232. * Disposes the cylinder.
  119233. * @param force Specifies if the updraft should be disposed by force
  119234. */
  119235. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  119236. var _this = this;
  119237. if (force === void 0) { force = true; }
  119238. if (!this._cylinder) {
  119239. return;
  119240. }
  119241. if (force) {
  119242. this._cylinder.dispose();
  119243. }
  119244. else {
  119245. setTimeout(function () {
  119246. if (!_this._dataFetched) {
  119247. _this._cylinder.dispose();
  119248. }
  119249. }, 0);
  119250. }
  119251. };
  119252. PhysicsUpdraftEvent.prototype.getImpostorHitData = function (impostor) {
  119253. if (impostor.mass === 0) {
  119254. return null;
  119255. }
  119256. if (!this._intersectsWithCylinder(impostor)) {
  119257. return null;
  119258. }
  119259. var impostorObjectCenter = impostor.getObjectCenter();
  119260. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  119261. var direction = this._originDirection;
  119262. }
  119263. else {
  119264. var direction = impostorObjectCenter.subtract(this._originTop);
  119265. }
  119266. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Distance(this._origin, impostorObjectCenter);
  119267. var multiplier = this._options.strength * -1;
  119268. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  119269. return { force: force, contactPoint: impostorObjectCenter, distanceFromOrigin: distanceFromOrigin };
  119270. };
  119271. PhysicsUpdraftEvent.prototype._tick = function () {
  119272. var _this = this;
  119273. this._physicsEngine.getImpostors().forEach(function (impostor) {
  119274. var impostorHitData = _this.getImpostorHitData(impostor);
  119275. if (!impostorHitData) {
  119276. return;
  119277. }
  119278. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  119279. });
  119280. };
  119281. /*** Helpers ***/
  119282. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  119283. if (!this._cylinder) {
  119284. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  119285. height: this._options.height,
  119286. diameter: this._options.radius * 2,
  119287. }, this._scene);
  119288. this._cylinder.isVisible = false;
  119289. }
  119290. };
  119291. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  119292. var impostorObject = impostor.object;
  119293. this._cylinder.position = this._cylinderPosition;
  119294. return this._cylinder.intersectsMesh(impostorObject, true);
  119295. };
  119296. return PhysicsUpdraftEvent;
  119297. }());
  119298. /**
  119299. * Represents a physics vortex event
  119300. */
  119301. var PhysicsVortexEvent = /** @class */ (function () {
  119302. /**
  119303. * Initializes the physics vortex event
  119304. * @param _scene The BabylonJS scene
  119305. * @param _origin The origin position of the vortex
  119306. * @param _options The options for the vortex event
  119307. */
  119308. function PhysicsVortexEvent(_scene, _origin, _options) {
  119309. this._scene = _scene;
  119310. this._origin = _origin;
  119311. this._options = _options;
  119312. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  119313. 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
  119314. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  119315. this._physicsEngine = this._scene.getPhysicsEngine();
  119316. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsVortexEventOptions()), this._options);
  119317. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  119318. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  119319. this._tickCallback = this._tick.bind(this);
  119320. this._prepareCylinder();
  119321. }
  119322. /**
  119323. * Returns the data related to the vortex event (cylinder).
  119324. * @returns The physics vortex event data
  119325. */
  119326. PhysicsVortexEvent.prototype.getData = function () {
  119327. this._dataFetched = true;
  119328. return {
  119329. cylinder: this._cylinder,
  119330. };
  119331. };
  119332. /**
  119333. * Enables the vortex.
  119334. */
  119335. PhysicsVortexEvent.prototype.enable = function () {
  119336. this._tickCallback.call(this);
  119337. this._scene.registerBeforeRender(this._tickCallback);
  119338. };
  119339. /**
  119340. * Disables the cortex.
  119341. */
  119342. PhysicsVortexEvent.prototype.disable = function () {
  119343. this._scene.unregisterBeforeRender(this._tickCallback);
  119344. };
  119345. /**
  119346. * Disposes the sphere.
  119347. * @param force
  119348. */
  119349. PhysicsVortexEvent.prototype.dispose = function (force) {
  119350. var _this = this;
  119351. if (force === void 0) { force = true; }
  119352. if (force) {
  119353. this._cylinder.dispose();
  119354. }
  119355. else {
  119356. setTimeout(function () {
  119357. if (!_this._dataFetched) {
  119358. _this._cylinder.dispose();
  119359. }
  119360. }, 0);
  119361. }
  119362. };
  119363. PhysicsVortexEvent.prototype.getImpostorHitData = function (impostor) {
  119364. if (impostor.mass === 0) {
  119365. return null;
  119366. }
  119367. if (!this._intersectsWithCylinder(impostor)) {
  119368. return null;
  119369. }
  119370. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  119371. return null;
  119372. }
  119373. var impostorObjectCenter = impostor.getObjectCenter();
  119374. 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)
  119375. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  119376. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](originOnPlane, originToImpostorDirection, this._options.radius);
  119377. var hit = ray.intersectsMesh(impostor.object);
  119378. var contactPoint = hit.pickedPoint;
  119379. if (!contactPoint) {
  119380. return null;
  119381. }
  119382. var absoluteDistanceFromOrigin = hit.distance / this._options.radius;
  119383. var directionToOrigin = contactPoint.normalize();
  119384. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  119385. directionToOrigin = directionToOrigin.negate();
  119386. }
  119387. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  119388. var forceX = directionToOrigin.x * this._options.centripetalForceMultiplier;
  119389. var forceY = directionToOrigin.y * this._options.updraftForceMultiplier;
  119390. var forceZ = directionToOrigin.z * this._options.centripetalForceMultiplier;
  119391. }
  119392. else {
  119393. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  119394. var forceX = (perpendicularDirection.x + directionToOrigin.x) * this._options.centrifugalForceMultiplier;
  119395. var forceY = this._originTop.y * this._options.updraftForceMultiplier;
  119396. var forceZ = (perpendicularDirection.z + directionToOrigin.z) * this._options.centrifugalForceMultiplier;
  119397. }
  119398. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](forceX, forceY, forceZ);
  119399. force = force.multiplyByFloats(this._options.strength, this._options.strength, this._options.strength);
  119400. return { force: force, contactPoint: impostorObjectCenter, distanceFromOrigin: absoluteDistanceFromOrigin };
  119401. };
  119402. PhysicsVortexEvent.prototype._tick = function () {
  119403. var _this = this;
  119404. this._physicsEngine.getImpostors().forEach(function (impostor) {
  119405. var impostorHitData = _this.getImpostorHitData(impostor);
  119406. if (!impostorHitData) {
  119407. return;
  119408. }
  119409. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  119410. });
  119411. };
  119412. /*** Helpers ***/
  119413. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  119414. if (!this._cylinder) {
  119415. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  119416. height: this._options.height,
  119417. diameter: this._options.radius * 2,
  119418. }, this._scene);
  119419. this._cylinder.isVisible = false;
  119420. }
  119421. };
  119422. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  119423. var impostorObject = impostor.object;
  119424. this._cylinder.position = this._cylinderPosition;
  119425. return this._cylinder.intersectsMesh(impostorObject, true);
  119426. };
  119427. return PhysicsVortexEvent;
  119428. }());
  119429. /**
  119430. * Options fot the radial explosion event
  119431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119432. */
  119433. var PhysicsRadialExplosionEventOptions = /** @class */ (function () {
  119434. function PhysicsRadialExplosionEventOptions() {
  119435. /**
  119436. * The radius of the sphere for the radial explosion.
  119437. */
  119438. this.radius = 5;
  119439. /**
  119440. * The strenth of the explosion.
  119441. */
  119442. this.strength = 10;
  119443. /**
  119444. * The strenght of the force in correspondence to the distance of the affected object
  119445. */
  119446. this.falloff = PhysicsRadialImpulseFalloff.Constant;
  119447. /**
  119448. * Sphere options for the radial explosion.
  119449. */
  119450. this.sphere = { segments: 32, diameter: 1 };
  119451. }
  119452. return PhysicsRadialExplosionEventOptions;
  119453. }());
  119454. /**
  119455. * Options fot the updraft event
  119456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119457. */
  119458. var PhysicsUpdraftEventOptions = /** @class */ (function () {
  119459. function PhysicsUpdraftEventOptions() {
  119460. /**
  119461. * The radius of the cylinder for the vortex
  119462. */
  119463. this.radius = 5;
  119464. /**
  119465. * The strenth of the updraft.
  119466. */
  119467. this.strength = 10;
  119468. /**
  119469. * The height of the cylinder for the updraft.
  119470. */
  119471. this.height = 10;
  119472. /**
  119473. * The mode for the the updraft.
  119474. */
  119475. this.updraftMode = PhysicsUpdraftMode.Center;
  119476. }
  119477. return PhysicsUpdraftEventOptions;
  119478. }());
  119479. /**
  119480. * Options fot the vortex event
  119481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119482. */
  119483. var PhysicsVortexEventOptions = /** @class */ (function () {
  119484. function PhysicsVortexEventOptions() {
  119485. /**
  119486. * The radius of the cylinder for the vortex
  119487. */
  119488. this.radius = 5;
  119489. /**
  119490. * The strenth of the vortex.
  119491. */
  119492. this.strength = 10;
  119493. /**
  119494. * The height of the cylinder for the vortex.
  119495. */
  119496. this.height = 10;
  119497. /**
  119498. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  119499. */
  119500. this.centripetalForceThreshold = 0.7;
  119501. /**
  119502. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  119503. */
  119504. this.centripetalForceMultiplier = 5;
  119505. /**
  119506. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  119507. */
  119508. this.centrifugalForceMultiplier = 0.5;
  119509. /**
  119510. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  119511. */
  119512. this.updraftForceMultiplier = 0.02;
  119513. }
  119514. return PhysicsVortexEventOptions;
  119515. }());
  119516. /**
  119517. * The strenght of the force in correspondence to the distance of the affected object
  119518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119519. */
  119520. var PhysicsRadialImpulseFalloff;
  119521. (function (PhysicsRadialImpulseFalloff) {
  119522. /** Defines that impulse is constant in strength across it's whole radius */
  119523. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  119524. /** Defines that impulse gets weaker if it's further from the origin */
  119525. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  119526. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  119527. /**
  119528. * The strength of the force in correspondence to the distance of the affected object
  119529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119530. */
  119531. var PhysicsUpdraftMode;
  119532. (function (PhysicsUpdraftMode) {
  119533. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  119534. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  119535. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  119536. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  119537. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  119538. /***/ }),
  119539. /***/ "./Physics/physicsImpostor.ts":
  119540. /*!************************************!*\
  119541. !*** ./Physics/physicsImpostor.ts ***!
  119542. \************************************/
  119543. /*! exports provided: PhysicsImpostor */
  119544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119545. "use strict";
  119546. __webpack_require__.r(__webpack_exports__);
  119547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  119548. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  119549. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  119550. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119551. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  119552. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  119553. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  119554. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  119555. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  119556. mass: jsonObject.physicsMass,
  119557. friction: jsonObject.physicsFriction,
  119558. restitution: jsonObject.physicsRestitution
  119559. }, scene);
  119560. };
  119561. /**
  119562. * Represents a physics imposter
  119563. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  119564. */
  119565. var PhysicsImpostor = /** @class */ (function () {
  119566. /**
  119567. * Initializes the physics imposter
  119568. * @param object The physics-enabled object used as the physics imposter
  119569. * @param type The type of the physics imposter
  119570. * @param _options The options for the physics imposter
  119571. * @param _scene The Babylon scene
  119572. */
  119573. function PhysicsImpostor(
  119574. /**
  119575. * The physics-enabled object used as the physics imposter
  119576. */
  119577. object,
  119578. /**
  119579. * The type of the physics imposter
  119580. */
  119581. type, _options, _scene) {
  119582. var _this = this;
  119583. if (_options === void 0) { _options = { mass: 0 }; }
  119584. this.object = object;
  119585. this.type = type;
  119586. this._options = _options;
  119587. this._scene = _scene;
  119588. /** @hidden */
  119589. this._pluginData = {};
  119590. this._bodyUpdateRequired = false;
  119591. this._onBeforePhysicsStepCallbacks = new Array();
  119592. this._onAfterPhysicsStepCallbacks = new Array();
  119593. /** @hidden */
  119594. this._onPhysicsCollideCallbacks = [];
  119595. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  119596. this._isDisposed = false;
  119597. /**
  119598. * @hidden
  119599. */
  119600. this.soft = false;
  119601. /**
  119602. * @hidden
  119603. */
  119604. this.segments = 0;
  119605. //temp variables for parent rotation calculations
  119606. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  119607. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  119608. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  119609. /**
  119610. * this function is executed by the physics engine.
  119611. */
  119612. this.beforeStep = function () {
  119613. if (!_this._physicsEngine) {
  119614. return;
  119615. }
  119616. _this.object.translate(_this._deltaPosition, -1);
  119617. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  119618. _this.object.computeWorldMatrix(false);
  119619. if (_this.object.parent && _this.object.rotationQuaternion) {
  119620. _this.getParentsRotation();
  119621. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  119622. }
  119623. else {
  119624. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  119625. }
  119626. if (!_this._options.disableBidirectionalTransformation) {
  119627. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  119628. }
  119629. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  119630. func(_this);
  119631. });
  119632. };
  119633. /**
  119634. * this function is executed by the physics engine
  119635. */
  119636. this.afterStep = function () {
  119637. if (!_this._physicsEngine) {
  119638. return;
  119639. }
  119640. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  119641. func(_this);
  119642. });
  119643. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  119644. // object has now its world rotation. needs to be converted to local.
  119645. if (_this.object.parent && _this.object.rotationQuaternion) {
  119646. _this.getParentsRotation();
  119647. _this._tmpQuat.conjugateInPlace();
  119648. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  119649. }
  119650. // take the position set and make it the absolute position of this object.
  119651. _this.object.setAbsolutePosition(_this.object.position);
  119652. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  119653. _this.object.translate(_this._deltaPosition, 1);
  119654. };
  119655. /**
  119656. * Legacy collision detection event support
  119657. */
  119658. this.onCollideEvent = null;
  119659. /**
  119660. * event and body object due to cannon's event-based architecture.
  119661. */
  119662. this.onCollide = function (e) {
  119663. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  119664. return;
  119665. }
  119666. if (!_this._physicsEngine) {
  119667. return;
  119668. }
  119669. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  119670. if (otherImpostor) {
  119671. // Legacy collision detection event support
  119672. if (_this.onCollideEvent) {
  119673. _this.onCollideEvent(_this, otherImpostor);
  119674. }
  119675. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  119676. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  119677. }).forEach(function (obj) {
  119678. obj.callback(_this, otherImpostor);
  119679. });
  119680. }
  119681. };
  119682. //sanity check!
  119683. if (!this.object) {
  119684. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  119685. return;
  119686. }
  119687. // Legacy support for old syntax.
  119688. if (!this._scene && object.getScene) {
  119689. this._scene = object.getScene();
  119690. }
  119691. if (!this._scene) {
  119692. return;
  119693. }
  119694. if (this.type > 100) {
  119695. this.soft = true;
  119696. }
  119697. this._physicsEngine = this._scene.getPhysicsEngine();
  119698. if (!this._physicsEngine) {
  119699. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  119700. }
  119701. else {
  119702. //set the object's quaternion, if not set
  119703. if (!this.object.rotationQuaternion) {
  119704. if (this.object.rotation) {
  119705. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  119706. }
  119707. else {
  119708. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  119709. }
  119710. }
  119711. //default options params
  119712. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  119713. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  119714. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  119715. if (this.soft) {
  119716. //softbody mass must be above 0;
  119717. this._options.mass = this._options.mass > 0 ? this._options.mass : 1;
  119718. this._options.pressure = (_options.pressure === void 0) ? 200 : _options.pressure;
  119719. this._options.stiffness = (_options.stiffness === void 0) ? 1 : _options.stiffness;
  119720. this._options.velocityIterations = (_options.velocityIterations === void 0) ? 20 : _options.velocityIterations;
  119721. this._options.positionIterations = (_options.positionIterations === void 0) ? 20 : _options.positionIterations;
  119722. this._options.fixedPoints = (_options.fixedPoints === void 0) ? 0 : _options.fixedPoints;
  119723. this._options.margin = (_options.margin === void 0) ? 0 : _options.margin;
  119724. this._options.damping = (_options.damping === void 0) ? 0 : _options.damping;
  119725. this._options.path = (_options.path === void 0) ? null : _options.path;
  119726. this._options.shape = (_options.shape === void 0) ? null : _options.shape;
  119727. }
  119728. this._joints = [];
  119729. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  119730. if (!this.object.parent || this._options.ignoreParent) {
  119731. this._init();
  119732. }
  119733. else if (this.object.parent.physicsImpostor) {
  119734. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  119735. }
  119736. }
  119737. }
  119738. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  119739. /**
  119740. * Specifies if the physics imposter is disposed
  119741. */
  119742. get: function () {
  119743. return this._isDisposed;
  119744. },
  119745. enumerable: true,
  119746. configurable: true
  119747. });
  119748. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  119749. /**
  119750. * Gets the mass of the physics imposter
  119751. */
  119752. get: function () {
  119753. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  119754. },
  119755. set: function (value) {
  119756. this.setMass(value);
  119757. },
  119758. enumerable: true,
  119759. configurable: true
  119760. });
  119761. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  119762. /**
  119763. * Gets the coefficient of friction
  119764. */
  119765. get: function () {
  119766. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  119767. },
  119768. /**
  119769. * Sets the coefficient of friction
  119770. */
  119771. set: function (value) {
  119772. if (!this._physicsEngine) {
  119773. return;
  119774. }
  119775. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  119776. },
  119777. enumerable: true,
  119778. configurable: true
  119779. });
  119780. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  119781. /**
  119782. * Gets the coefficient of restitution
  119783. */
  119784. get: function () {
  119785. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  119786. },
  119787. /**
  119788. * Sets the coefficient of restitution
  119789. */
  119790. set: function (value) {
  119791. if (!this._physicsEngine) {
  119792. return;
  119793. }
  119794. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  119795. },
  119796. enumerable: true,
  119797. configurable: true
  119798. });
  119799. Object.defineProperty(PhysicsImpostor.prototype, "pressure", {
  119800. /**
  119801. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  119802. */
  119803. get: function () {
  119804. if (!this._physicsEngine) {
  119805. return 0;
  119806. }
  119807. var plugin = this._physicsEngine.getPhysicsPlugin();
  119808. if (!plugin.setBodyPressure) {
  119809. return 0;
  119810. }
  119811. return plugin.getBodyPressure(this);
  119812. },
  119813. /**
  119814. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  119815. */
  119816. set: function (value) {
  119817. if (!this._physicsEngine) {
  119818. return;
  119819. }
  119820. var plugin = this._physicsEngine.getPhysicsPlugin();
  119821. if (!plugin.setBodyPressure) {
  119822. return;
  119823. }
  119824. plugin.setBodyPressure(this, value);
  119825. },
  119826. enumerable: true,
  119827. configurable: true
  119828. });
  119829. Object.defineProperty(PhysicsImpostor.prototype, "stiffness", {
  119830. /**
  119831. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  119832. */
  119833. get: function () {
  119834. if (!this._physicsEngine) {
  119835. return 0;
  119836. }
  119837. var plugin = this._physicsEngine.getPhysicsPlugin();
  119838. if (!plugin.getBodyStiffness) {
  119839. return 0;
  119840. }
  119841. return plugin.getBodyStiffness(this);
  119842. },
  119843. /**
  119844. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  119845. */
  119846. set: function (value) {
  119847. if (!this._physicsEngine) {
  119848. return;
  119849. }
  119850. var plugin = this._physicsEngine.getPhysicsPlugin();
  119851. if (!plugin.setBodyStiffness) {
  119852. return;
  119853. }
  119854. plugin.setBodyStiffness(this, value);
  119855. },
  119856. enumerable: true,
  119857. configurable: true
  119858. });
  119859. Object.defineProperty(PhysicsImpostor.prototype, "velocityIterations", {
  119860. /**
  119861. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  119862. */
  119863. get: function () {
  119864. if (!this._physicsEngine) {
  119865. return 0;
  119866. }
  119867. var plugin = this._physicsEngine.getPhysicsPlugin();
  119868. if (!plugin.getBodyVelocityIterations) {
  119869. return 0;
  119870. }
  119871. return plugin.getBodyVelocityIterations(this);
  119872. },
  119873. /**
  119874. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  119875. */
  119876. set: function (value) {
  119877. if (!this._physicsEngine) {
  119878. return;
  119879. }
  119880. var plugin = this._physicsEngine.getPhysicsPlugin();
  119881. if (!plugin.setBodyVelocityIterations) {
  119882. return;
  119883. }
  119884. plugin.setBodyVelocityIterations(this, value);
  119885. },
  119886. enumerable: true,
  119887. configurable: true
  119888. });
  119889. Object.defineProperty(PhysicsImpostor.prototype, "positionIterations", {
  119890. /**
  119891. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  119892. */
  119893. get: function () {
  119894. if (!this._physicsEngine) {
  119895. return 0;
  119896. }
  119897. var plugin = this._physicsEngine.getPhysicsPlugin();
  119898. if (!plugin.getBodyPositionIterations) {
  119899. return 0;
  119900. }
  119901. return plugin.getBodyPositionIterations(this);
  119902. },
  119903. /**
  119904. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  119905. */
  119906. set: function (value) {
  119907. if (!this._physicsEngine) {
  119908. return;
  119909. }
  119910. var plugin = this._physicsEngine.getPhysicsPlugin();
  119911. if (!plugin.setBodyPositionIterations) {
  119912. return;
  119913. }
  119914. plugin.setBodyPositionIterations(this, value);
  119915. },
  119916. enumerable: true,
  119917. configurable: true
  119918. });
  119919. /**
  119920. * This function will completly initialize this impostor.
  119921. * It will create a new body - but only if this mesh has no parent.
  119922. * If it has, this impostor will not be used other than to define the impostor
  119923. * of the child mesh.
  119924. * @hidden
  119925. */
  119926. PhysicsImpostor.prototype._init = function () {
  119927. if (!this._physicsEngine) {
  119928. return;
  119929. }
  119930. this._physicsEngine.removeImpostor(this);
  119931. this.physicsBody = null;
  119932. this._parent = this._parent || this._getPhysicsParent();
  119933. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  119934. this._physicsEngine.addImpostor(this);
  119935. }
  119936. };
  119937. PhysicsImpostor.prototype._getPhysicsParent = function () {
  119938. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  119939. var parentMesh = this.object.parent;
  119940. return parentMesh.physicsImpostor;
  119941. }
  119942. return null;
  119943. };
  119944. /**
  119945. * Should a new body be generated.
  119946. * @returns boolean specifying if body initialization is required
  119947. */
  119948. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  119949. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  119950. };
  119951. /**
  119952. * Sets the updated scaling
  119953. * @param updated Specifies if the scaling is updated
  119954. */
  119955. PhysicsImpostor.prototype.setScalingUpdated = function () {
  119956. this.forceUpdate();
  119957. };
  119958. /**
  119959. * Force a regeneration of this or the parent's impostor's body.
  119960. * Use under cautious - This will remove all joints already implemented.
  119961. */
  119962. PhysicsImpostor.prototype.forceUpdate = function () {
  119963. this._init();
  119964. if (this.parent && !this._options.ignoreParent) {
  119965. this.parent.forceUpdate();
  119966. }
  119967. };
  119968. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  119969. /*public get mesh(): AbstractMesh {
  119970. return this._mesh;
  119971. }*/
  119972. /**
  119973. * Gets the body that holds this impostor. Either its own, or its parent.
  119974. */
  119975. get: function () {
  119976. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  119977. },
  119978. /**
  119979. * Set the physics body. Used mainly by the physics engine/plugin
  119980. */
  119981. set: function (physicsBody) {
  119982. if (this._physicsBody && this._physicsEngine) {
  119983. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  119984. }
  119985. this._physicsBody = physicsBody;
  119986. this.resetUpdateFlags();
  119987. },
  119988. enumerable: true,
  119989. configurable: true
  119990. });
  119991. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  119992. /**
  119993. * Get the parent of the physics imposter
  119994. * @returns Physics imposter or null
  119995. */
  119996. get: function () {
  119997. return !this._options.ignoreParent && this._parent ? this._parent : null;
  119998. },
  119999. /**
  120000. * Sets the parent of the physics imposter
  120001. */
  120002. set: function (value) {
  120003. this._parent = value;
  120004. },
  120005. enumerable: true,
  120006. configurable: true
  120007. });
  120008. /**
  120009. * Resets the update flags
  120010. */
  120011. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  120012. this._bodyUpdateRequired = false;
  120013. };
  120014. /**
  120015. * Gets the object extend size
  120016. * @returns the object extend size
  120017. */
  120018. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  120019. if (this.object.getBoundingInfo) {
  120020. var q = this.object.rotationQuaternion;
  120021. //reset rotation
  120022. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  120023. //calculate the world matrix with no rotation
  120024. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  120025. var boundingInfo = this.object.getBoundingInfo();
  120026. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  120027. //bring back the rotation
  120028. this.object.rotationQuaternion = q;
  120029. //calculate the world matrix with the new rotation
  120030. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  120031. return size;
  120032. }
  120033. else {
  120034. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  120035. }
  120036. };
  120037. /**
  120038. * Gets the object center
  120039. * @returns The object center
  120040. */
  120041. PhysicsImpostor.prototype.getObjectCenter = function () {
  120042. if (this.object.getBoundingInfo) {
  120043. var boundingInfo = this.object.getBoundingInfo();
  120044. return boundingInfo.boundingBox.centerWorld;
  120045. }
  120046. else {
  120047. return this.object.position;
  120048. }
  120049. };
  120050. /**
  120051. * Get a specific parametes from the options parameter
  120052. * @param paramName The object parameter name
  120053. * @returns The object parameter
  120054. */
  120055. PhysicsImpostor.prototype.getParam = function (paramName) {
  120056. return this._options[paramName];
  120057. };
  120058. /**
  120059. * Sets a specific parameter in the options given to the physics plugin
  120060. * @param paramName The parameter name
  120061. * @param value The value of the parameter
  120062. */
  120063. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  120064. this._options[paramName] = value;
  120065. this._bodyUpdateRequired = true;
  120066. };
  120067. /**
  120068. * Specifically change the body's mass option. Won't recreate the physics body object
  120069. * @param mass The mass of the physics imposter
  120070. */
  120071. PhysicsImpostor.prototype.setMass = function (mass) {
  120072. if (this.getParam("mass") !== mass) {
  120073. this.setParam("mass", mass);
  120074. }
  120075. if (this._physicsEngine) {
  120076. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  120077. }
  120078. };
  120079. /**
  120080. * Gets the linear velocity
  120081. * @returns linear velocity or null
  120082. */
  120083. PhysicsImpostor.prototype.getLinearVelocity = function () {
  120084. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  120085. };
  120086. /**
  120087. * Sets the linear velocity
  120088. * @param velocity linear velocity or null
  120089. */
  120090. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  120091. if (this._physicsEngine) {
  120092. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  120093. }
  120094. };
  120095. /**
  120096. * Gets the angular velocity
  120097. * @returns angular velocity or null
  120098. */
  120099. PhysicsImpostor.prototype.getAngularVelocity = function () {
  120100. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  120101. };
  120102. /**
  120103. * Sets the angular velocity
  120104. * @param velocity The velocity or null
  120105. */
  120106. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  120107. if (this._physicsEngine) {
  120108. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  120109. }
  120110. };
  120111. /**
  120112. * Execute a function with the physics plugin native code
  120113. * Provide a function the will have two variables - the world object and the physics body object
  120114. * @param func The function to execute with the physics plugin native code
  120115. */
  120116. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  120117. if (this._physicsEngine) {
  120118. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  120119. }
  120120. };
  120121. /**
  120122. * Register a function that will be executed before the physics world is stepping forward
  120123. * @param func The function to execute before the physics world is stepped forward
  120124. */
  120125. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  120126. this._onBeforePhysicsStepCallbacks.push(func);
  120127. };
  120128. /**
  120129. * Unregister a function that will be executed before the physics world is stepping forward
  120130. * @param func The function to execute before the physics world is stepped forward
  120131. */
  120132. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  120133. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  120134. if (index > -1) {
  120135. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  120136. }
  120137. else {
  120138. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  120139. }
  120140. };
  120141. /**
  120142. * Register a function that will be executed after the physics step
  120143. * @param func The function to execute after physics step
  120144. */
  120145. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  120146. this._onAfterPhysicsStepCallbacks.push(func);
  120147. };
  120148. /**
  120149. * Unregisters a function that will be executed after the physics step
  120150. * @param func The function to execute after physics step
  120151. */
  120152. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  120153. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  120154. if (index > -1) {
  120155. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  120156. }
  120157. else {
  120158. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  120159. }
  120160. };
  120161. /**
  120162. * register a function that will be executed when this impostor collides against a different body
  120163. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  120164. * @param func Callback that is executed on collision
  120165. */
  120166. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  120167. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  120168. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  120169. };
  120170. /**
  120171. * Unregisters the physics imposter on contact
  120172. * @param collideAgainst The physics object to collide against
  120173. * @param func Callback to execute on collision
  120174. */
  120175. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  120176. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  120177. var index = -1;
  120178. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  120179. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  120180. // chcek the arrays match
  120181. var sameList = cbDef.otherImpostors.every(function (impostor) {
  120182. return collidedAgainstList.indexOf(impostor) > -1;
  120183. });
  120184. if (sameList) {
  120185. index = idx;
  120186. }
  120187. return sameList;
  120188. }
  120189. return false;
  120190. });
  120191. if (found) {
  120192. this._onPhysicsCollideCallbacks.splice(index, 1);
  120193. }
  120194. else {
  120195. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  120196. }
  120197. };
  120198. /**
  120199. * Get the parent rotation
  120200. * @returns The parent rotation
  120201. */
  120202. PhysicsImpostor.prototype.getParentsRotation = function () {
  120203. var parent = this.object.parent;
  120204. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  120205. while (parent) {
  120206. if (parent.rotationQuaternion) {
  120207. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  120208. }
  120209. else {
  120210. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  120211. }
  120212. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  120213. parent = parent.parent;
  120214. }
  120215. return this._tmpQuat;
  120216. };
  120217. /**
  120218. * Apply a force
  120219. * @param force The force to apply
  120220. * @param contactPoint The contact point for the force
  120221. * @returns The physics imposter
  120222. */
  120223. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  120224. if (this._physicsEngine) {
  120225. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  120226. }
  120227. return this;
  120228. };
  120229. /**
  120230. * Apply an impulse
  120231. * @param force The impulse force
  120232. * @param contactPoint The contact point for the impulse force
  120233. * @returns The physics imposter
  120234. */
  120235. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  120236. if (this._physicsEngine) {
  120237. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  120238. }
  120239. return this;
  120240. };
  120241. /**
  120242. * A help function to create a joint
  120243. * @param otherImpostor A physics imposter used to create a joint
  120244. * @param jointType The type of joint
  120245. * @param jointData The data for the joint
  120246. * @returns The physics imposter
  120247. */
  120248. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  120249. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  120250. this.addJoint(otherImpostor, joint);
  120251. return this;
  120252. };
  120253. /**
  120254. * Add a joint to this impostor with a different impostor
  120255. * @param otherImpostor A physics imposter used to add a joint
  120256. * @param joint The joint to add
  120257. * @returns The physics imposter
  120258. */
  120259. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  120260. this._joints.push({
  120261. otherImpostor: otherImpostor,
  120262. joint: joint
  120263. });
  120264. if (this._physicsEngine) {
  120265. this._physicsEngine.addJoint(this, otherImpostor, joint);
  120266. }
  120267. return this;
  120268. };
  120269. /**
  120270. * Add an anchor to a cloth impostor
  120271. * @param otherImpostor rigid impostor to anchor to
  120272. * @param width ratio across width from 0 to 1
  120273. * @param height ratio up height from 0 to 1
  120274. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  120275. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  120276. * @returns impostor the soft imposter
  120277. */
  120278. PhysicsImpostor.prototype.addAnchor = function (otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  120279. if (!this._physicsEngine) {
  120280. return this;
  120281. }
  120282. var plugin = this._physicsEngine.getPhysicsPlugin();
  120283. if (!plugin.appendAnchor) {
  120284. return this;
  120285. }
  120286. if (this._physicsEngine) {
  120287. plugin.appendAnchor(this, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies);
  120288. }
  120289. return this;
  120290. };
  120291. /**
  120292. * Add a hook to a rope impostor
  120293. * @param otherImpostor rigid impostor to anchor to
  120294. * @param length ratio across rope from 0 to 1
  120295. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  120296. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120297. * @returns impostor the rope imposter
  120298. */
  120299. PhysicsImpostor.prototype.addHook = function (otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  120300. if (!this._physicsEngine) {
  120301. return this;
  120302. }
  120303. var plugin = this._physicsEngine.getPhysicsPlugin();
  120304. if (!plugin.appendAnchor) {
  120305. return this;
  120306. }
  120307. if (this._physicsEngine) {
  120308. plugin.appendHook(this, otherImpostor, length, influence, noCollisionBetweenLinkedBodies);
  120309. }
  120310. return this;
  120311. };
  120312. /**
  120313. * Will keep this body still, in a sleep mode.
  120314. * @returns the physics imposter
  120315. */
  120316. PhysicsImpostor.prototype.sleep = function () {
  120317. if (this._physicsEngine) {
  120318. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  120319. }
  120320. return this;
  120321. };
  120322. /**
  120323. * Wake the body up.
  120324. * @returns The physics imposter
  120325. */
  120326. PhysicsImpostor.prototype.wakeUp = function () {
  120327. if (this._physicsEngine) {
  120328. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  120329. }
  120330. return this;
  120331. };
  120332. /**
  120333. * Clones the physics imposter
  120334. * @param newObject The physics imposter clones to this physics-enabled object
  120335. * @returns A nullable physics imposter
  120336. */
  120337. PhysicsImpostor.prototype.clone = function (newObject) {
  120338. if (!newObject) {
  120339. return null;
  120340. }
  120341. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  120342. };
  120343. /**
  120344. * Disposes the physics imposter
  120345. */
  120346. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  120347. var _this = this;
  120348. //no dispose if no physics engine is available.
  120349. if (!this._physicsEngine) {
  120350. return;
  120351. }
  120352. this._joints.forEach(function (j) {
  120353. if (_this._physicsEngine) {
  120354. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  120355. }
  120356. });
  120357. //dispose the physics body
  120358. this._physicsEngine.removeImpostor(this);
  120359. if (this.parent) {
  120360. this.parent.forceUpdate();
  120361. }
  120362. else {
  120363. /*this._object.getChildMeshes().forEach(function(mesh) {
  120364. if (mesh.physicsImpostor) {
  120365. if (disposeChildren) {
  120366. mesh.physicsImpostor.dispose();
  120367. mesh.physicsImpostor = null;
  120368. }
  120369. }
  120370. })*/
  120371. }
  120372. this._isDisposed = true;
  120373. };
  120374. /**
  120375. * Sets the delta position
  120376. * @param position The delta position amount
  120377. */
  120378. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  120379. this._deltaPosition.copyFrom(position);
  120380. };
  120381. /**
  120382. * Sets the delta rotation
  120383. * @param rotation The delta rotation amount
  120384. */
  120385. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  120386. if (!this._deltaRotation) {
  120387. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  120388. }
  120389. this._deltaRotation.copyFrom(rotation);
  120390. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  120391. };
  120392. /**
  120393. * Gets the box size of the physics imposter and stores the result in the input parameter
  120394. * @param result Stores the box size
  120395. * @returns The physics imposter
  120396. */
  120397. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  120398. if (this._physicsEngine) {
  120399. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  120400. }
  120401. return this;
  120402. };
  120403. /**
  120404. * Gets the radius of the physics imposter
  120405. * @returns Radius of the physics imposter
  120406. */
  120407. PhysicsImpostor.prototype.getRadius = function () {
  120408. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  120409. };
  120410. /**
  120411. * Sync a bone with this impostor
  120412. * @param bone The bone to sync to the impostor.
  120413. * @param boneMesh The mesh that the bone is influencing.
  120414. * @param jointPivot The pivot of the joint / bone in local space.
  120415. * @param distToJoint Optional distance from the impostor to the joint.
  120416. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  120417. */
  120418. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  120419. var tempVec = PhysicsImpostor._tmpVecs[0];
  120420. var mesh = this.object;
  120421. if (mesh.rotationQuaternion) {
  120422. if (adjustRotation) {
  120423. var tempQuat = PhysicsImpostor._tmpQuat;
  120424. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  120425. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  120426. }
  120427. else {
  120428. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  120429. }
  120430. }
  120431. tempVec.x = 0;
  120432. tempVec.y = 0;
  120433. tempVec.z = 0;
  120434. if (jointPivot) {
  120435. tempVec.x = jointPivot.x;
  120436. tempVec.y = jointPivot.y;
  120437. tempVec.z = jointPivot.z;
  120438. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  120439. if (distToJoint === undefined || distToJoint === null) {
  120440. distToJoint = jointPivot.length();
  120441. }
  120442. tempVec.x *= distToJoint;
  120443. tempVec.y *= distToJoint;
  120444. tempVec.z *= distToJoint;
  120445. }
  120446. if (bone.getParent()) {
  120447. tempVec.addInPlace(mesh.getAbsolutePosition());
  120448. bone.setAbsolutePosition(tempVec, boneMesh);
  120449. }
  120450. else {
  120451. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  120452. boneMesh.position.x -= tempVec.x;
  120453. boneMesh.position.y -= tempVec.y;
  120454. boneMesh.position.z -= tempVec.z;
  120455. }
  120456. };
  120457. /**
  120458. * Sync impostor to a bone
  120459. * @param bone The bone that the impostor will be synced to.
  120460. * @param boneMesh The mesh that the bone is influencing.
  120461. * @param jointPivot The pivot of the joint / bone in local space.
  120462. * @param distToJoint Optional distance from the impostor to the joint.
  120463. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  120464. * @param boneAxis Optional vector3 axis the bone is aligned with
  120465. */
  120466. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  120467. var mesh = this.object;
  120468. if (mesh.rotationQuaternion) {
  120469. if (adjustRotation) {
  120470. var tempQuat = PhysicsImpostor._tmpQuat;
  120471. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  120472. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  120473. }
  120474. else {
  120475. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  120476. }
  120477. }
  120478. var pos = PhysicsImpostor._tmpVecs[0];
  120479. var boneDir = PhysicsImpostor._tmpVecs[1];
  120480. if (!boneAxis) {
  120481. boneAxis = PhysicsImpostor._tmpVecs[2];
  120482. boneAxis.x = 0;
  120483. boneAxis.y = 1;
  120484. boneAxis.z = 0;
  120485. }
  120486. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  120487. bone.getAbsolutePositionToRef(boneMesh, pos);
  120488. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  120489. distToJoint = jointPivot.length();
  120490. }
  120491. if (distToJoint !== undefined && distToJoint !== null) {
  120492. pos.x += boneDir.x * distToJoint;
  120493. pos.y += boneDir.y * distToJoint;
  120494. pos.z += boneDir.z * distToJoint;
  120495. }
  120496. mesh.setAbsolutePosition(pos);
  120497. };
  120498. /**
  120499. * The default object size of the imposter
  120500. */
  120501. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  120502. /**
  120503. * The identity quaternion of the imposter
  120504. */
  120505. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  120506. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  120507. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  120508. //Impostor types
  120509. /**
  120510. * No-Imposter type
  120511. */
  120512. PhysicsImpostor.NoImpostor = 0;
  120513. /**
  120514. * Sphere-Imposter type
  120515. */
  120516. PhysicsImpostor.SphereImpostor = 1;
  120517. /**
  120518. * Box-Imposter type
  120519. */
  120520. PhysicsImpostor.BoxImpostor = 2;
  120521. /**
  120522. * Plane-Imposter type
  120523. */
  120524. PhysicsImpostor.PlaneImpostor = 3;
  120525. /**
  120526. * Mesh-imposter type
  120527. */
  120528. PhysicsImpostor.MeshImpostor = 4;
  120529. /**
  120530. * Cylinder-Imposter type
  120531. */
  120532. PhysicsImpostor.CylinderImpostor = 7;
  120533. /**
  120534. * Particle-Imposter type
  120535. */
  120536. PhysicsImpostor.ParticleImpostor = 8;
  120537. /**
  120538. * Heightmap-Imposter type
  120539. */
  120540. PhysicsImpostor.HeightmapImpostor = 9;
  120541. /**
  120542. * ConvexHull-Impostor type (Ammo.js plugin only)
  120543. */
  120544. PhysicsImpostor.ConvexHullImpostor = 10;
  120545. /**
  120546. * Rope-Imposter type
  120547. */
  120548. PhysicsImpostor.RopeImpostor = 101;
  120549. /**
  120550. * Cloth-Imposter type
  120551. */
  120552. PhysicsImpostor.ClothImpostor = 102;
  120553. /**
  120554. * Softbody-Imposter type
  120555. */
  120556. PhysicsImpostor.SoftbodyImpostor = 103;
  120557. return PhysicsImpostor;
  120558. }());
  120559. /***/ }),
  120560. /***/ "./Physics/physicsJoint.ts":
  120561. /*!*********************************!*\
  120562. !*** ./Physics/physicsJoint.ts ***!
  120563. \*********************************/
  120564. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  120565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120566. "use strict";
  120567. __webpack_require__.r(__webpack_exports__);
  120568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  120569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  120570. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  120571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  120572. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  120573. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120574. /**
  120575. * This is a holder class for the physics joint created by the physics plugin
  120576. * It holds a set of functions to control the underlying joint
  120577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  120578. */
  120579. var PhysicsJoint = /** @class */ (function () {
  120580. /**
  120581. * Initializes the physics joint
  120582. * @param type The type of the physics joint
  120583. * @param jointData The data for the physics joint
  120584. */
  120585. function PhysicsJoint(
  120586. /**
  120587. * The type of the physics joint
  120588. */
  120589. type,
  120590. /**
  120591. * The data for the physics joint
  120592. */
  120593. jointData) {
  120594. this.type = type;
  120595. this.jointData = jointData;
  120596. jointData.nativeParams = jointData.nativeParams || {};
  120597. }
  120598. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  120599. /**
  120600. * Gets the physics joint
  120601. */
  120602. get: function () {
  120603. return this._physicsJoint;
  120604. },
  120605. /**
  120606. * Sets the physics joint
  120607. */
  120608. set: function (newJoint) {
  120609. if (this._physicsJoint) {
  120610. //remove from the wolrd
  120611. }
  120612. this._physicsJoint = newJoint;
  120613. },
  120614. enumerable: true,
  120615. configurable: true
  120616. });
  120617. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  120618. /**
  120619. * Sets the physics plugin
  120620. */
  120621. set: function (physicsPlugin) {
  120622. this._physicsPlugin = physicsPlugin;
  120623. },
  120624. enumerable: true,
  120625. configurable: true
  120626. });
  120627. /**
  120628. * Execute a function that is physics-plugin specific.
  120629. * @param {Function} func the function that will be executed.
  120630. * It accepts two parameters: the physics world and the physics joint
  120631. */
  120632. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  120633. func(this._physicsPlugin.world, this._physicsJoint);
  120634. };
  120635. //TODO check if the native joints are the same
  120636. //Joint Types
  120637. /**
  120638. * Distance-Joint type
  120639. */
  120640. PhysicsJoint.DistanceJoint = 0;
  120641. /**
  120642. * Hinge-Joint type
  120643. */
  120644. PhysicsJoint.HingeJoint = 1;
  120645. /**
  120646. * Ball-and-Socket joint type
  120647. */
  120648. PhysicsJoint.BallAndSocketJoint = 2;
  120649. /**
  120650. * Wheel-Joint type
  120651. */
  120652. PhysicsJoint.WheelJoint = 3;
  120653. /**
  120654. * Slider-Joint type
  120655. */
  120656. PhysicsJoint.SliderJoint = 4;
  120657. //OIMO
  120658. /**
  120659. * Prismatic-Joint type
  120660. */
  120661. PhysicsJoint.PrismaticJoint = 5;
  120662. //
  120663. /**
  120664. * Universal-Joint type
  120665. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  120666. */
  120667. PhysicsJoint.UniversalJoint = 6;
  120668. /**
  120669. * Hinge-Joint 2 type
  120670. */
  120671. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  120672. //Cannon
  120673. /**
  120674. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  120675. */
  120676. PhysicsJoint.PointToPointJoint = 8;
  120677. //Cannon only at the moment
  120678. /**
  120679. * Spring-Joint type
  120680. */
  120681. PhysicsJoint.SpringJoint = 9;
  120682. /**
  120683. * Lock-Joint type
  120684. */
  120685. PhysicsJoint.LockJoint = 10;
  120686. return PhysicsJoint;
  120687. }());
  120688. /**
  120689. * A class representing a physics distance joint
  120690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  120691. */
  120692. var DistanceJoint = /** @class */ (function (_super) {
  120693. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  120694. /**
  120695. *
  120696. * @param jointData The data for the Distance-Joint
  120697. */
  120698. function DistanceJoint(jointData) {
  120699. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  120700. }
  120701. /**
  120702. * Update the predefined distance.
  120703. * @param maxDistance The maximum preferred distance
  120704. * @param minDistance The minimum preferred distance
  120705. */
  120706. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  120707. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  120708. };
  120709. return DistanceJoint;
  120710. }(PhysicsJoint));
  120711. /**
  120712. * Represents a Motor-Enabled Joint
  120713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  120714. */
  120715. var MotorEnabledJoint = /** @class */ (function (_super) {
  120716. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  120717. /**
  120718. * Initializes the Motor-Enabled Joint
  120719. * @param type The type of the joint
  120720. * @param jointData The physica joint data for the joint
  120721. */
  120722. function MotorEnabledJoint(type, jointData) {
  120723. return _super.call(this, type, jointData) || this;
  120724. }
  120725. /**
  120726. * Set the motor values.
  120727. * Attention, this function is plugin specific. Engines won't react 100% the same.
  120728. * @param force the force to apply
  120729. * @param maxForce max force for this motor.
  120730. */
  120731. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  120732. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  120733. };
  120734. /**
  120735. * Set the motor's limits.
  120736. * Attention, this function is plugin specific. Engines won't react 100% the same.
  120737. * @param upperLimit The upper limit of the motor
  120738. * @param lowerLimit The lower limit of the motor
  120739. */
  120740. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  120741. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  120742. };
  120743. return MotorEnabledJoint;
  120744. }(PhysicsJoint));
  120745. /**
  120746. * This class represents a single physics Hinge-Joint
  120747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  120748. */
  120749. var HingeJoint = /** @class */ (function (_super) {
  120750. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  120751. /**
  120752. * Initializes the Hinge-Joint
  120753. * @param jointData The joint data for the Hinge-Joint
  120754. */
  120755. function HingeJoint(jointData) {
  120756. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  120757. }
  120758. /**
  120759. * Set the motor values.
  120760. * Attention, this function is plugin specific. Engines won't react 100% the same.
  120761. * @param {number} force the force to apply
  120762. * @param {number} maxForce max force for this motor.
  120763. */
  120764. HingeJoint.prototype.setMotor = function (force, maxForce) {
  120765. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  120766. };
  120767. /**
  120768. * Set the motor's limits.
  120769. * Attention, this function is plugin specific. Engines won't react 100% the same.
  120770. * @param upperLimit The upper limit of the motor
  120771. * @param lowerLimit The lower limit of the motor
  120772. */
  120773. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  120774. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  120775. };
  120776. return HingeJoint;
  120777. }(MotorEnabledJoint));
  120778. /**
  120779. * This class represents a dual hinge physics joint (same as wheel joint)
  120780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  120781. */
  120782. var Hinge2Joint = /** @class */ (function (_super) {
  120783. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  120784. /**
  120785. * Initializes the Hinge2-Joint
  120786. * @param jointData The joint data for the Hinge2-Joint
  120787. */
  120788. function Hinge2Joint(jointData) {
  120789. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  120790. }
  120791. /**
  120792. * Set the motor values.
  120793. * Attention, this function is plugin specific. Engines won't react 100% the same.
  120794. * @param {number} targetSpeed the speed the motor is to reach
  120795. * @param {number} maxForce max force for this motor.
  120796. * @param {motorIndex} the motor's index, 0 or 1.
  120797. */
  120798. Hinge2Joint.prototype.setMotor = function (targetSpeed, maxForce, motorIndex) {
  120799. if (motorIndex === void 0) { motorIndex = 0; }
  120800. this._physicsPlugin.setMotor(this, targetSpeed || 0, maxForce, motorIndex);
  120801. };
  120802. /**
  120803. * Set the motor limits.
  120804. * Attention, this function is plugin specific. Engines won't react 100% the same.
  120805. * @param {number} upperLimit the upper limit
  120806. * @param {number} lowerLimit lower limit
  120807. * @param {motorIndex} the motor's index, 0 or 1.
  120808. */
  120809. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  120810. if (motorIndex === void 0) { motorIndex = 0; }
  120811. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  120812. };
  120813. return Hinge2Joint;
  120814. }(MotorEnabledJoint));
  120815. /***/ }),
  120816. /***/ "./Physics/physicsRaycastResult.ts":
  120817. /*!*****************************************!*\
  120818. !*** ./Physics/physicsRaycastResult.ts ***!
  120819. \*****************************************/
  120820. /*! exports provided: PhysicsRaycastResult */
  120821. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120822. "use strict";
  120823. __webpack_require__.r(__webpack_exports__);
  120824. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRaycastResult", function() { return PhysicsRaycastResult; });
  120825. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120826. /**
  120827. * Holds the data for the raycast result
  120828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  120829. */
  120830. var PhysicsRaycastResult = /** @class */ (function () {
  120831. function PhysicsRaycastResult() {
  120832. this._hasHit = false;
  120833. this._hitDistance = 0;
  120834. this._hitNormalWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  120835. this._hitPointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  120836. this._rayFromWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  120837. this._rayToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  120838. }
  120839. Object.defineProperty(PhysicsRaycastResult.prototype, "hasHit", {
  120840. /**
  120841. * Gets if there was a hit
  120842. */
  120843. get: function () {
  120844. return this._hasHit;
  120845. },
  120846. enumerable: true,
  120847. configurable: true
  120848. });
  120849. Object.defineProperty(PhysicsRaycastResult.prototype, "hitDistance", {
  120850. /**
  120851. * Gets the distance from the hit
  120852. */
  120853. get: function () {
  120854. return this._hitDistance;
  120855. },
  120856. enumerable: true,
  120857. configurable: true
  120858. });
  120859. Object.defineProperty(PhysicsRaycastResult.prototype, "hitNormalWorld", {
  120860. /**
  120861. * Gets the hit normal/direction in the world
  120862. */
  120863. get: function () {
  120864. return this._hitNormalWorld;
  120865. },
  120866. enumerable: true,
  120867. configurable: true
  120868. });
  120869. Object.defineProperty(PhysicsRaycastResult.prototype, "hitPointWorld", {
  120870. /**
  120871. * Gets the hit point in the world
  120872. */
  120873. get: function () {
  120874. return this._hitPointWorld;
  120875. },
  120876. enumerable: true,
  120877. configurable: true
  120878. });
  120879. Object.defineProperty(PhysicsRaycastResult.prototype, "rayFromWorld", {
  120880. /**
  120881. * Gets the ray "start point" of the ray in the world
  120882. */
  120883. get: function () {
  120884. return this._rayFromWorld;
  120885. },
  120886. enumerable: true,
  120887. configurable: true
  120888. });
  120889. Object.defineProperty(PhysicsRaycastResult.prototype, "rayToWorld", {
  120890. /**
  120891. * Gets the ray "end point" of the ray in the world
  120892. */
  120893. get: function () {
  120894. return this._rayToWorld;
  120895. },
  120896. enumerable: true,
  120897. configurable: true
  120898. });
  120899. /**
  120900. * Sets the hit data (normal & point in world space)
  120901. * @param hitNormalWorld defines the normal in world space
  120902. * @param hitPointWorld defines the point in world space
  120903. */
  120904. PhysicsRaycastResult.prototype.setHitData = function (hitNormalWorld, hitPointWorld) {
  120905. this._hasHit = true;
  120906. this._hitNormalWorld = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitNormalWorld.x, hitNormalWorld.y, hitNormalWorld.z);
  120907. this._hitPointWorld = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitPointWorld.x, hitPointWorld.y, hitPointWorld.z);
  120908. };
  120909. /**
  120910. * Sets the distance from the start point to the hit point
  120911. * @param distance
  120912. */
  120913. PhysicsRaycastResult.prototype.setHitDistance = function (distance) {
  120914. this._hitDistance = distance;
  120915. };
  120916. /**
  120917. * Calculates the distance manually
  120918. */
  120919. PhysicsRaycastResult.prototype.calculateHitDistance = function () {
  120920. this._hitDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._rayFromWorld, this._hitPointWorld);
  120921. };
  120922. /**
  120923. * Resets all the values to default
  120924. * @param from The from point on world space
  120925. * @param to The to point on world space
  120926. */
  120927. PhysicsRaycastResult.prototype.reset = function (from, to) {
  120928. if (from === void 0) { from = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  120929. if (to === void 0) { to = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  120930. this._rayFromWorld = from;
  120931. this._rayToWorld = to;
  120932. this._hasHit = false;
  120933. this._hitDistance = 0;
  120934. this._hitNormalWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  120935. this._hitPointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  120936. };
  120937. return PhysicsRaycastResult;
  120938. }());
  120939. /***/ }),
  120940. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  120941. /*!****************************************************************************!*\
  120942. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  120943. \****************************************************************************/
  120944. /*! exports provided: DefaultRenderingPipeline */
  120945. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120946. "use strict";
  120947. __webpack_require__.r(__webpack_exports__);
  120948. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  120949. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120950. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  120951. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  120952. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120953. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  120954. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  120955. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  120956. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  120957. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  120958. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  120959. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  120960. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  120961. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  120962. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  120963. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  120964. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  120965. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  120966. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  120967. /**
  120968. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  120969. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  120970. */
  120971. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  120972. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  120973. /**
  120974. * @constructor
  120975. * @param name - The rendering pipeline name (default: "")
  120976. * @param hdr - If high dynamic range textures should be used (default: true)
  120977. * @param scene - The scene linked to this pipeline (default: the last created scene)
  120978. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  120979. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  120980. */
  120981. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  120982. if (name === void 0) { name = ""; }
  120983. if (hdr === void 0) { hdr = true; }
  120984. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  120985. if (automaticBuild === void 0) { automaticBuild = true; }
  120986. var _this = _super.call(this, scene.getEngine(), name) || this;
  120987. _this._camerasToBeAttached = [];
  120988. /**
  120989. * ID of the sharpen post process,
  120990. */
  120991. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  120992. /**
  120993. * @ignore
  120994. * ID of the image processing post process;
  120995. */
  120996. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  120997. /**
  120998. * @ignore
  120999. * ID of the Fast Approximate Anti-Aliasing post process;
  121000. */
  121001. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  121002. /**
  121003. * ID of the chromatic aberration post process,
  121004. */
  121005. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  121006. /**
  121007. * ID of the grain post process
  121008. */
  121009. _this.GrainPostProcessId = "GrainPostProcessEffect";
  121010. /**
  121011. * Glow post process which adds a glow to emissive areas of the image
  121012. */
  121013. _this._glowLayer = null;
  121014. /**
  121015. * Animations which can be used to tweak settings over a period of time
  121016. */
  121017. _this.animations = [];
  121018. _this._imageProcessingConfigurationObserver = null;
  121019. // Values
  121020. _this._sharpenEnabled = false;
  121021. _this._bloomEnabled = false;
  121022. _this._depthOfFieldEnabled = false;
  121023. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  121024. _this._fxaaEnabled = false;
  121025. _this._imageProcessingEnabled = true;
  121026. _this._bloomScale = 0.5;
  121027. _this._chromaticAberrationEnabled = false;
  121028. _this._grainEnabled = false;
  121029. _this._buildAllowed = true;
  121030. _this._resizeObserver = null;
  121031. _this._hardwareScaleLevel = 1.0;
  121032. _this._bloomKernel = 64;
  121033. /**
  121034. * Specifies the weight of the bloom in the final rendering
  121035. */
  121036. _this._bloomWeight = 0.15;
  121037. /**
  121038. * Specifies the luma threshold for the area that will be blurred by the bloom
  121039. */
  121040. _this._bloomThreshold = 0.9;
  121041. _this._samples = 1;
  121042. _this._hasCleared = false;
  121043. _this._prevPostProcess = null;
  121044. _this._prevPrevPostProcess = null;
  121045. _this._depthOfFieldSceneObserver = null;
  121046. _this._cameras = cameras || scene.cameras;
  121047. _this._cameras = _this._cameras.slice();
  121048. _this._camerasToBeAttached = _this._cameras.slice();
  121049. _this._buildAllowed = automaticBuild;
  121050. // Initialize
  121051. _this._scene = scene;
  121052. var caps = _this._scene.getEngine().getCaps();
  121053. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  121054. // Misc
  121055. if (_this._hdr) {
  121056. if (caps.textureHalfFloatRender) {
  121057. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  121058. }
  121059. else if (caps.textureFloatRender) {
  121060. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  121061. }
  121062. }
  121063. else {
  121064. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  121065. }
  121066. // Attach
  121067. scene.postProcessRenderPipelineManager.addPipeline(_this);
  121068. var engine = _this._scene.getEngine();
  121069. // Create post processes before hand so they can be modified before enabled.
  121070. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  121071. _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);
  121072. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  121073. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  121074. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  121075. _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);
  121076. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  121077. _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);
  121078. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  121079. _this._resizeObserver = engine.onResizeObservable.add(function () {
  121080. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  121081. _this.bloomKernel = _this.bloomKernel;
  121082. });
  121083. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  121084. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  121085. });
  121086. _this._buildPipeline();
  121087. return _this;
  121088. }
  121089. Object.defineProperty(DefaultRenderingPipeline.prototype, "scene", {
  121090. /**
  121091. * Gets active scene
  121092. */
  121093. get: function () {
  121094. return this._scene;
  121095. },
  121096. enumerable: true,
  121097. configurable: true
  121098. });
  121099. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  121100. get: function () {
  121101. return this._sharpenEnabled;
  121102. },
  121103. /**
  121104. * Enable or disable the sharpen process from the pipeline
  121105. */
  121106. set: function (enabled) {
  121107. if (this._sharpenEnabled === enabled) {
  121108. return;
  121109. }
  121110. this._sharpenEnabled = enabled;
  121111. this._buildPipeline();
  121112. },
  121113. enumerable: true,
  121114. configurable: true
  121115. });
  121116. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  121117. /**
  121118. * Specifies the size of the bloom blur kernel, relative to the final output size
  121119. */
  121120. get: function () {
  121121. return this._bloomKernel;
  121122. },
  121123. set: function (value) {
  121124. this._bloomKernel = value;
  121125. this.bloom.kernel = value / this._hardwareScaleLevel;
  121126. },
  121127. enumerable: true,
  121128. configurable: true
  121129. });
  121130. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  121131. get: function () {
  121132. return this._bloomWeight;
  121133. },
  121134. /**
  121135. * The strength of the bloom.
  121136. */
  121137. set: function (value) {
  121138. if (this._bloomWeight === value) {
  121139. return;
  121140. }
  121141. this.bloom.weight = value;
  121142. this._bloomWeight = value;
  121143. },
  121144. enumerable: true,
  121145. configurable: true
  121146. });
  121147. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  121148. get: function () {
  121149. return this._bloomThreshold;
  121150. },
  121151. /**
  121152. * The strength of the bloom.
  121153. */
  121154. set: function (value) {
  121155. if (this._bloomThreshold === value) {
  121156. return;
  121157. }
  121158. this.bloom.threshold = value;
  121159. this._bloomThreshold = value;
  121160. },
  121161. enumerable: true,
  121162. configurable: true
  121163. });
  121164. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  121165. get: function () {
  121166. return this._bloomScale;
  121167. },
  121168. /**
  121169. * The scale of the bloom, lower value will provide better performance.
  121170. */
  121171. set: function (value) {
  121172. if (this._bloomScale === value) {
  121173. return;
  121174. }
  121175. this._bloomScale = value;
  121176. // recreate bloom and dispose old as this setting is not dynamic
  121177. this._rebuildBloom();
  121178. this._buildPipeline();
  121179. },
  121180. enumerable: true,
  121181. configurable: true
  121182. });
  121183. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  121184. get: function () {
  121185. return this._bloomEnabled;
  121186. },
  121187. /**
  121188. * Enable or disable the bloom from the pipeline
  121189. */
  121190. set: function (enabled) {
  121191. if (this._bloomEnabled === enabled) {
  121192. return;
  121193. }
  121194. this._bloomEnabled = enabled;
  121195. this._buildPipeline();
  121196. },
  121197. enumerable: true,
  121198. configurable: true
  121199. });
  121200. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  121201. // recreate bloom and dispose old as this setting is not dynamic
  121202. var oldBloom = this.bloom;
  121203. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  121204. this.bloom.threshold = oldBloom.threshold;
  121205. for (var i = 0; i < this._cameras.length; i++) {
  121206. oldBloom.disposeEffects(this._cameras[i]);
  121207. }
  121208. };
  121209. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  121210. /**
  121211. * If the depth of field is enabled.
  121212. */
  121213. get: function () {
  121214. return this._depthOfFieldEnabled;
  121215. },
  121216. set: function (enabled) {
  121217. if (this._depthOfFieldEnabled === enabled) {
  121218. return;
  121219. }
  121220. this._depthOfFieldEnabled = enabled;
  121221. this._buildPipeline();
  121222. },
  121223. enumerable: true,
  121224. configurable: true
  121225. });
  121226. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  121227. /**
  121228. * Blur level of the depth of field effect. (Higher blur will effect performance)
  121229. */
  121230. get: function () {
  121231. return this._depthOfFieldBlurLevel;
  121232. },
  121233. set: function (value) {
  121234. if (this._depthOfFieldBlurLevel === value) {
  121235. return;
  121236. }
  121237. this._depthOfFieldBlurLevel = value;
  121238. // recreate dof and dispose old as this setting is not dynamic
  121239. var oldDof = this.depthOfField;
  121240. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  121241. this.depthOfField.focalLength = oldDof.focalLength;
  121242. this.depthOfField.focusDistance = oldDof.focusDistance;
  121243. this.depthOfField.fStop = oldDof.fStop;
  121244. this.depthOfField.lensSize = oldDof.lensSize;
  121245. for (var i = 0; i < this._cameras.length; i++) {
  121246. oldDof.disposeEffects(this._cameras[i]);
  121247. }
  121248. this._buildPipeline();
  121249. },
  121250. enumerable: true,
  121251. configurable: true
  121252. });
  121253. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  121254. get: function () {
  121255. return this._fxaaEnabled;
  121256. },
  121257. /**
  121258. * If the anti aliasing is enabled.
  121259. */
  121260. set: function (enabled) {
  121261. if (this._fxaaEnabled === enabled) {
  121262. return;
  121263. }
  121264. this._fxaaEnabled = enabled;
  121265. this._buildPipeline();
  121266. },
  121267. enumerable: true,
  121268. configurable: true
  121269. });
  121270. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  121271. get: function () {
  121272. return this._samples;
  121273. },
  121274. /**
  121275. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  121276. */
  121277. set: function (sampleCount) {
  121278. if (this._samples === sampleCount) {
  121279. return;
  121280. }
  121281. this._samples = sampleCount;
  121282. this._buildPipeline();
  121283. },
  121284. enumerable: true,
  121285. configurable: true
  121286. });
  121287. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  121288. get: function () {
  121289. return this._imageProcessingEnabled;
  121290. },
  121291. /**
  121292. * If image processing is enabled.
  121293. */
  121294. set: function (enabled) {
  121295. if (this._imageProcessingEnabled === enabled) {
  121296. return;
  121297. }
  121298. this._imageProcessingEnabled = enabled;
  121299. this._buildPipeline();
  121300. },
  121301. enumerable: true,
  121302. configurable: true
  121303. });
  121304. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  121305. get: function () {
  121306. return this._glowLayer != null;
  121307. },
  121308. /**
  121309. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  121310. */
  121311. set: function (enabled) {
  121312. if (enabled && !this._glowLayer) {
  121313. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  121314. }
  121315. else if (!enabled && this._glowLayer) {
  121316. this._glowLayer.dispose();
  121317. this._glowLayer = null;
  121318. }
  121319. },
  121320. enumerable: true,
  121321. configurable: true
  121322. });
  121323. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayer", {
  121324. /**
  121325. * Gets the glow layer (or null if not defined)
  121326. */
  121327. get: function () {
  121328. return this._glowLayer;
  121329. },
  121330. enumerable: true,
  121331. configurable: true
  121332. });
  121333. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  121334. get: function () {
  121335. return this._chromaticAberrationEnabled;
  121336. },
  121337. /**
  121338. * Enable or disable the chromaticAberration process from the pipeline
  121339. */
  121340. set: function (enabled) {
  121341. if (this._chromaticAberrationEnabled === enabled) {
  121342. return;
  121343. }
  121344. this._chromaticAberrationEnabled = enabled;
  121345. this._buildPipeline();
  121346. },
  121347. enumerable: true,
  121348. configurable: true
  121349. });
  121350. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  121351. get: function () {
  121352. return this._grainEnabled;
  121353. },
  121354. /**
  121355. * Enable or disable the grain process from the pipeline
  121356. */
  121357. set: function (enabled) {
  121358. if (this._grainEnabled === enabled) {
  121359. return;
  121360. }
  121361. this._grainEnabled = enabled;
  121362. this._buildPipeline();
  121363. },
  121364. enumerable: true,
  121365. configurable: true
  121366. });
  121367. /**
  121368. * Get the class name
  121369. * @returns "DefaultRenderingPipeline"
  121370. */
  121371. DefaultRenderingPipeline.prototype.getClassName = function () {
  121372. return "DefaultRenderingPipeline";
  121373. };
  121374. /**
  121375. * Force the compilation of the entire pipeline.
  121376. */
  121377. DefaultRenderingPipeline.prototype.prepare = function () {
  121378. var previousState = this._buildAllowed;
  121379. this._buildAllowed = true;
  121380. this._buildPipeline();
  121381. this._buildAllowed = previousState;
  121382. };
  121383. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  121384. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  121385. if (this._hasCleared) {
  121386. postProcess.autoClear = false;
  121387. }
  121388. else {
  121389. postProcess.autoClear = true;
  121390. this._scene.autoClear = false;
  121391. this._hasCleared = true;
  121392. }
  121393. if (!skipTextureSharing) {
  121394. if (this._prevPrevPostProcess) {
  121395. postProcess.shareOutputWith(this._prevPrevPostProcess);
  121396. }
  121397. else {
  121398. postProcess.useOwnOutput();
  121399. }
  121400. if (this._prevPostProcess) {
  121401. this._prevPrevPostProcess = this._prevPostProcess;
  121402. }
  121403. this._prevPostProcess = postProcess;
  121404. }
  121405. };
  121406. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  121407. var _this = this;
  121408. if (!this._buildAllowed) {
  121409. return;
  121410. }
  121411. this._scene.autoClear = true;
  121412. var engine = this._scene.getEngine();
  121413. this._disposePostProcesses();
  121414. if (this._cameras !== null) {
  121415. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  121416. // get back cameras to be used to reattach pipeline
  121417. this._cameras = this._camerasToBeAttached.slice();
  121418. }
  121419. this._reset();
  121420. this._prevPostProcess = null;
  121421. this._prevPrevPostProcess = null;
  121422. this._hasCleared = false;
  121423. if (this.depthOfFieldEnabled) {
  121424. // Multi camera suport
  121425. if (this._cameras.length > 1) {
  121426. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  121427. var camera = _a[_i];
  121428. var depthRenderer = this._scene.enableDepthRenderer(camera);
  121429. depthRenderer.useOnlyInActiveCamera = true;
  121430. }
  121431. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  121432. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  121433. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  121434. }
  121435. });
  121436. }
  121437. else {
  121438. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  121439. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  121440. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  121441. }
  121442. if (!this.depthOfField._isReady()) {
  121443. this.depthOfField._updateEffects();
  121444. }
  121445. this.addEffect(this.depthOfField);
  121446. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  121447. }
  121448. else {
  121449. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  121450. }
  121451. if (this.bloomEnabled) {
  121452. if (!this.bloom._isReady()) {
  121453. this.bloom._updateEffects();
  121454. }
  121455. this.addEffect(this.bloom);
  121456. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  121457. }
  121458. if (this._imageProcessingEnabled) {
  121459. 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);
  121460. if (this._hdr) {
  121461. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  121462. this._setAutoClearAndTextureSharing(this.imageProcessing);
  121463. }
  121464. else {
  121465. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  121466. }
  121467. }
  121468. if (this.sharpenEnabled) {
  121469. if (!this.sharpen.isReady()) {
  121470. this.sharpen.updateEffect();
  121471. }
  121472. this.addEffect(this._sharpenEffect);
  121473. this._setAutoClearAndTextureSharing(this.sharpen);
  121474. }
  121475. if (this.grainEnabled) {
  121476. if (!this.grain.isReady()) {
  121477. this.grain.updateEffect();
  121478. }
  121479. this.addEffect(this._grainEffect);
  121480. this._setAutoClearAndTextureSharing(this.grain);
  121481. }
  121482. if (this.chromaticAberrationEnabled) {
  121483. if (!this.chromaticAberration.isReady()) {
  121484. this.chromaticAberration.updateEffect();
  121485. }
  121486. this.addEffect(this._chromaticAberrationEffect);
  121487. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  121488. }
  121489. if (this.fxaaEnabled) {
  121490. 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);
  121491. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  121492. this._setAutoClearAndTextureSharing(this.fxaa, true);
  121493. }
  121494. if (this._cameras !== null) {
  121495. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  121496. }
  121497. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  121498. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  121499. }
  121500. };
  121501. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  121502. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  121503. for (var i = 0; i < this._cameras.length; i++) {
  121504. var camera = this._cameras[i];
  121505. if (this.imageProcessing) {
  121506. this.imageProcessing.dispose(camera);
  121507. }
  121508. if (this.fxaa) {
  121509. this.fxaa.dispose(camera);
  121510. }
  121511. // These are created in the constructor and should not be disposed on every pipeline change
  121512. if (disposeNonRecreated) {
  121513. if (this.sharpen) {
  121514. this.sharpen.dispose(camera);
  121515. }
  121516. if (this.depthOfField) {
  121517. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  121518. this.depthOfField.disposeEffects(camera);
  121519. }
  121520. if (this.bloom) {
  121521. this.bloom.disposeEffects(camera);
  121522. }
  121523. if (this.chromaticAberration) {
  121524. this.chromaticAberration.dispose(camera);
  121525. }
  121526. if (this.grain) {
  121527. this.grain.dispose(camera);
  121528. }
  121529. if (this._glowLayer) {
  121530. this._glowLayer.dispose();
  121531. }
  121532. }
  121533. }
  121534. this.imageProcessing = null;
  121535. this.fxaa = null;
  121536. if (disposeNonRecreated) {
  121537. this.sharpen = null;
  121538. this._sharpenEffect = null;
  121539. this.depthOfField = null;
  121540. this.bloom = null;
  121541. this.chromaticAberration = null;
  121542. this._chromaticAberrationEffect = null;
  121543. this.grain = null;
  121544. this._grainEffect = null;
  121545. this._glowLayer = null;
  121546. }
  121547. };
  121548. /**
  121549. * Adds a camera to the pipeline
  121550. * @param camera the camera to be added
  121551. */
  121552. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  121553. this._camerasToBeAttached.push(camera);
  121554. this._buildPipeline();
  121555. };
  121556. /**
  121557. * Removes a camera from the pipeline
  121558. * @param camera the camera to remove
  121559. */
  121560. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  121561. var index = this._camerasToBeAttached.indexOf(camera);
  121562. this._camerasToBeAttached.splice(index, 1);
  121563. this._buildPipeline();
  121564. };
  121565. /**
  121566. * Dispose of the pipeline and stop all post processes
  121567. */
  121568. DefaultRenderingPipeline.prototype.dispose = function () {
  121569. this._disposePostProcesses(true);
  121570. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  121571. this._scene.autoClear = true;
  121572. if (this._resizeObserver) {
  121573. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  121574. this._resizeObserver = null;
  121575. }
  121576. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  121577. _super.prototype.dispose.call(this);
  121578. };
  121579. /**
  121580. * Serialize the rendering pipeline (Used when exporting)
  121581. * @returns the serialized object
  121582. */
  121583. DefaultRenderingPipeline.prototype.serialize = function () {
  121584. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  121585. serializationObject.customType = "DefaultRenderingPipeline";
  121586. return serializationObject;
  121587. };
  121588. /**
  121589. * Parse the serialized pipeline
  121590. * @param source Source pipeline.
  121591. * @param scene The scene to load the pipeline to.
  121592. * @param rootUrl The URL of the serialized pipeline.
  121593. * @returns An instantiated pipeline from the serialized object.
  121594. */
  121595. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  121596. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  121597. };
  121598. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121600. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  121601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121603. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  121604. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121605. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121606. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  121607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121608. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121609. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  121610. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121612. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  121613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121615. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  121616. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121617. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121618. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  121619. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121620. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121621. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  121622. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121623. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121624. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  121625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121626. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121627. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  121628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121629. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121630. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  121631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121633. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  121634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121636. ], DefaultRenderingPipeline.prototype, "samples", null);
  121637. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121639. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  121640. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121641. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121642. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  121643. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121645. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  121646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121648. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  121649. return DefaultRenderingPipeline;
  121650. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  121651. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  121652. /***/ }),
  121653. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  121654. /*!*********************************************************!*\
  121655. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  121656. \*********************************************************/
  121657. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  121658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121659. "use strict";
  121660. __webpack_require__.r(__webpack_exports__);
  121661. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  121662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  121663. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  121664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  121665. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  121666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  121667. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  121668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  121669. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  121670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  121671. /***/ }),
  121672. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  121673. /*!*************************************************************************!*\
  121674. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  121675. \*************************************************************************/
  121676. /*! exports provided: LensRenderingPipeline */
  121677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121678. "use strict";
  121679. __webpack_require__.r(__webpack_exports__);
  121680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  121681. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121682. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121683. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  121684. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  121685. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  121686. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  121687. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  121688. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  121689. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  121690. /**
  121691. * BABYLON.JS Chromatic Aberration GLSL Shader
  121692. * Author: Olivier Guyot
  121693. * Separates very slightly R, G and B colors on the edges of the screen
  121694. * Inspired by Francois Tarlier & Martins Upitis
  121695. */
  121696. var LensRenderingPipeline = /** @class */ (function (_super) {
  121697. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  121698. /**
  121699. * @constructor
  121700. *
  121701. * Effect parameters are as follow:
  121702. * {
  121703. * chromatic_aberration: number; // from 0 to x (1 for realism)
  121704. * edge_blur: number; // from 0 to x (1 for realism)
  121705. * distortion: number; // from 0 to x (1 for realism)
  121706. * grain_amount: number; // from 0 to 1
  121707. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  121708. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  121709. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  121710. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  121711. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  121712. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  121713. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  121714. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  121715. * }
  121716. * Note: if an effect parameter is unset, effect is disabled
  121717. *
  121718. * @param name The rendering pipeline name
  121719. * @param parameters - An object containing all parameters (see above)
  121720. * @param scene The scene linked to this pipeline
  121721. * @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)
  121722. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121723. */
  121724. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  121725. if (ratio === void 0) { ratio = 1.0; }
  121726. var _this = _super.call(this, scene.getEngine(), name) || this;
  121727. // Lens effects can be of the following:
  121728. // - chromatic aberration (slight shift of RGB colors)
  121729. // - blur on the edge of the lens
  121730. // - lens distortion
  121731. // - depth-of-field blur & highlights enhancing
  121732. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  121733. // - grain effect (noise or custom texture)
  121734. // Two additional texture samplers are needed:
  121735. // - depth map (for depth-of-field)
  121736. // - grain texture
  121737. /**
  121738. * @ignore
  121739. * The chromatic aberration PostProcess id in the pipeline
  121740. */
  121741. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  121742. /**
  121743. * @ignore
  121744. * The highlights enhancing PostProcess id in the pipeline
  121745. */
  121746. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  121747. /**
  121748. * @ignore
  121749. * The depth-of-field PostProcess id in the pipeline
  121750. */
  121751. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  121752. _this._pentagonBokehIsEnabled = false;
  121753. _this._scene = scene;
  121754. // Fetch texture samplers
  121755. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  121756. if (parameters.grain_texture) {
  121757. _this._grainTexture = parameters.grain_texture;
  121758. }
  121759. else {
  121760. _this._createGrainTexture();
  121761. }
  121762. // save parameters
  121763. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  121764. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  121765. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  121766. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  121767. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  121768. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  121769. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  121770. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  121771. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  121772. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  121773. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  121774. // Create effects
  121775. _this._createChromaticAberrationPostProcess(ratio);
  121776. _this._createHighlightsPostProcess(ratio);
  121777. _this._createDepthOfFieldPostProcess(ratio / 4);
  121778. // Set up pipeline
  121779. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  121780. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  121781. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  121782. if (_this._highlightsGain === -1) {
  121783. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  121784. }
  121785. // Finish
  121786. scene.postProcessRenderPipelineManager.addPipeline(_this);
  121787. if (cameras) {
  121788. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  121789. }
  121790. return _this;
  121791. }
  121792. /**
  121793. * Get the class name
  121794. * @returns "LensRenderingPipeline"
  121795. */
  121796. LensRenderingPipeline.prototype.getClassName = function () {
  121797. return "LensRenderingPipeline";
  121798. };
  121799. Object.defineProperty(LensRenderingPipeline.prototype, "scene", {
  121800. // Properties
  121801. /**
  121802. * Gets associated scene
  121803. */
  121804. get: function () {
  121805. return this._scene;
  121806. },
  121807. enumerable: true,
  121808. configurable: true
  121809. });
  121810. Object.defineProperty(LensRenderingPipeline.prototype, "edgeBlur", {
  121811. /**
  121812. * Gets or sets the edge blur
  121813. */
  121814. get: function () {
  121815. return this._edgeBlur;
  121816. },
  121817. set: function (value) {
  121818. this.setEdgeBlur(value);
  121819. },
  121820. enumerable: true,
  121821. configurable: true
  121822. });
  121823. Object.defineProperty(LensRenderingPipeline.prototype, "grainAmount", {
  121824. /**
  121825. * Gets or sets the grain amount
  121826. */
  121827. get: function () {
  121828. return this._grainAmount;
  121829. },
  121830. set: function (value) {
  121831. this.setGrainAmount(value);
  121832. },
  121833. enumerable: true,
  121834. configurable: true
  121835. });
  121836. Object.defineProperty(LensRenderingPipeline.prototype, "chromaticAberration", {
  121837. /**
  121838. * Gets or sets the chromatic aberration amount
  121839. */
  121840. get: function () {
  121841. return this._chromaticAberration;
  121842. },
  121843. set: function (value) {
  121844. this.setChromaticAberration(value);
  121845. },
  121846. enumerable: true,
  121847. configurable: true
  121848. });
  121849. Object.defineProperty(LensRenderingPipeline.prototype, "dofAperture", {
  121850. /**
  121851. * Gets or sets the depth of field aperture
  121852. */
  121853. get: function () {
  121854. return this._dofAperture;
  121855. },
  121856. set: function (value) {
  121857. this.setAperture(value);
  121858. },
  121859. enumerable: true,
  121860. configurable: true
  121861. });
  121862. Object.defineProperty(LensRenderingPipeline.prototype, "edgeDistortion", {
  121863. /**
  121864. * Gets or sets the edge distortion
  121865. */
  121866. get: function () {
  121867. return this._distortion;
  121868. },
  121869. set: function (value) {
  121870. this.setEdgeDistortion(value);
  121871. },
  121872. enumerable: true,
  121873. configurable: true
  121874. });
  121875. Object.defineProperty(LensRenderingPipeline.prototype, "dofDistortion", {
  121876. /**
  121877. * Gets or sets the depth of field distortion
  121878. */
  121879. get: function () {
  121880. return this._dofDistance;
  121881. },
  121882. set: function (value) {
  121883. this.setFocusDistance(value);
  121884. },
  121885. enumerable: true,
  121886. configurable: true
  121887. });
  121888. Object.defineProperty(LensRenderingPipeline.prototype, "darkenOutOfFocus", {
  121889. /**
  121890. * Gets or sets the darken out of focus amount
  121891. */
  121892. get: function () {
  121893. return this._dofDarken;
  121894. },
  121895. set: function (value) {
  121896. this.setDarkenOutOfFocus(value);
  121897. },
  121898. enumerable: true,
  121899. configurable: true
  121900. });
  121901. Object.defineProperty(LensRenderingPipeline.prototype, "blurNoise", {
  121902. /**
  121903. * Gets or sets a boolean indicating if blur noise is enabled
  121904. */
  121905. get: function () {
  121906. return this._blurNoise;
  121907. },
  121908. set: function (value) {
  121909. this._blurNoise = value;
  121910. },
  121911. enumerable: true,
  121912. configurable: true
  121913. });
  121914. Object.defineProperty(LensRenderingPipeline.prototype, "pentagonBokeh", {
  121915. /**
  121916. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  121917. */
  121918. get: function () {
  121919. return this._pentagonBokehIsEnabled;
  121920. },
  121921. set: function (value) {
  121922. if (value) {
  121923. this.enablePentagonBokeh();
  121924. }
  121925. else {
  121926. this.disablePentagonBokeh();
  121927. }
  121928. },
  121929. enumerable: true,
  121930. configurable: true
  121931. });
  121932. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsGain", {
  121933. /**
  121934. * Gets or sets the highlight grain amount
  121935. */
  121936. get: function () {
  121937. return this._highlightsGain;
  121938. },
  121939. set: function (value) {
  121940. this.setHighlightsGain(value);
  121941. },
  121942. enumerable: true,
  121943. configurable: true
  121944. });
  121945. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsThreshold", {
  121946. /**
  121947. * Gets or sets the highlight threshold
  121948. */
  121949. get: function () {
  121950. return this._highlightsThreshold;
  121951. },
  121952. set: function (value) {
  121953. this.setHighlightsThreshold(value);
  121954. },
  121955. enumerable: true,
  121956. configurable: true
  121957. });
  121958. // public methods (self explanatory)
  121959. /**
  121960. * Sets the amount of blur at the edges
  121961. * @param amount blur amount
  121962. */
  121963. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  121964. /**
  121965. * Sets edge blur to 0
  121966. */
  121967. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  121968. /**
  121969. * Sets the amout of grain
  121970. * @param amount Amount of grain
  121971. */
  121972. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  121973. /**
  121974. * Set grain amount to 0
  121975. */
  121976. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  121977. /**
  121978. * Sets the chromatic aberration amount
  121979. * @param amount amount of chromatic aberration
  121980. */
  121981. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  121982. /**
  121983. * Sets chromatic aberration amount to 0
  121984. */
  121985. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  121986. /**
  121987. * Sets the EdgeDistortion amount
  121988. * @param amount amount of EdgeDistortion
  121989. */
  121990. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  121991. /**
  121992. * Sets edge distortion to 0
  121993. */
  121994. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  121995. /**
  121996. * Sets the FocusDistance amount
  121997. * @param amount amount of FocusDistance
  121998. */
  121999. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  122000. /**
  122001. * Disables depth of field
  122002. */
  122003. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  122004. /**
  122005. * Sets the Aperture amount
  122006. * @param amount amount of Aperture
  122007. */
  122008. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  122009. /**
  122010. * Sets the DarkenOutOfFocus amount
  122011. * @param amount amount of DarkenOutOfFocus
  122012. */
  122013. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  122014. /**
  122015. * Creates a pentagon bokeh effect
  122016. */
  122017. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  122018. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  122019. this._pentagonBokehIsEnabled = true;
  122020. };
  122021. /**
  122022. * Disables the pentagon bokeh effect
  122023. */
  122024. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  122025. this._pentagonBokehIsEnabled = false;
  122026. this._highlightsPostProcess.updateEffect();
  122027. };
  122028. /**
  122029. * Enables noise blur
  122030. */
  122031. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  122032. /**
  122033. * Disables noise blur
  122034. */
  122035. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  122036. /**
  122037. * Sets the HighlightsGain amount
  122038. * @param amount amount of HighlightsGain
  122039. */
  122040. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  122041. this._highlightsGain = amount;
  122042. };
  122043. /**
  122044. * Sets the HighlightsThreshold amount
  122045. * @param amount amount of HighlightsThreshold
  122046. */
  122047. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  122048. if (this._highlightsGain === -1) {
  122049. this._highlightsGain = 1.0;
  122050. }
  122051. this._highlightsThreshold = amount;
  122052. };
  122053. /**
  122054. * Disables highlights
  122055. */
  122056. LensRenderingPipeline.prototype.disableHighlights = function () {
  122057. this._highlightsGain = -1;
  122058. };
  122059. /**
  122060. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  122061. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  122062. */
  122063. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  122064. if (disableDepthRender === void 0) { disableDepthRender = false; }
  122065. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  122066. this._chromaticAberrationPostProcess = null;
  122067. this._highlightsPostProcess = null;
  122068. this._depthOfFieldPostProcess = null;
  122069. this._grainTexture.dispose();
  122070. if (disableDepthRender) {
  122071. this._scene.disableDepthRenderer();
  122072. }
  122073. };
  122074. // colors shifting and distortion
  122075. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  122076. var _this = this;
  122077. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  122078. [], // samplers
  122079. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  122080. this._chromaticAberrationPostProcess.onApply = function (effect) {
  122081. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  122082. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  122083. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  122084. effect.setFloat('radialIntensity', 1);
  122085. effect.setFloat2('direction', 17, 17);
  122086. effect.setFloat2('centerPosition', 0.5, 0.5);
  122087. };
  122088. };
  122089. // highlights enhancing
  122090. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  122091. var _this = this;
  122092. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  122093. [], // samplers
  122094. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  122095. this._highlightsPostProcess.onApply = function (effect) {
  122096. effect.setFloat('gain', _this._highlightsGain);
  122097. effect.setFloat('threshold', _this._highlightsThreshold);
  122098. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  122099. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  122100. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  122101. };
  122102. };
  122103. // colors shifting and distortion
  122104. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  122105. var _this = this;
  122106. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  122107. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  122108. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  122109. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  122110. this._depthOfFieldPostProcess.onApply = function (effect) {
  122111. effect.setTexture("depthSampler", _this._depthTexture);
  122112. effect.setTexture("grainSampler", _this._grainTexture);
  122113. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  122114. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  122115. effect.setFloat('grain_amount', _this._grainAmount);
  122116. effect.setBool('blur_noise', _this._blurNoise);
  122117. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  122118. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  122119. effect.setFloat('distortion', _this._distortion);
  122120. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  122121. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  122122. effect.setFloat('aperture', _this._dofAperture);
  122123. effect.setFloat('darken', _this._dofDarken);
  122124. effect.setFloat('edge_blur', _this._edgeBlur);
  122125. effect.setBool('highlights', (_this._highlightsGain !== -1));
  122126. if (_this._scene.activeCamera) {
  122127. effect.setFloat('near', _this._scene.activeCamera.minZ);
  122128. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  122129. }
  122130. };
  122131. };
  122132. // creates a black and white random noise texture, 512x512
  122133. LensRenderingPipeline.prototype._createGrainTexture = function () {
  122134. var size = 512;
  122135. 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);
  122136. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  122137. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  122138. var context = this._grainTexture.getContext();
  122139. var rand = function (min, max) {
  122140. return Math.random() * (max - min) + min;
  122141. };
  122142. var value;
  122143. for (var x = 0; x < size; x++) {
  122144. for (var y = 0; y < size; y++) {
  122145. value = Math.floor(rand(0.42, 0.58) * 255);
  122146. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  122147. context.fillRect(x, y, 1, 1);
  122148. }
  122149. }
  122150. this._grainTexture.update(false);
  122151. };
  122152. return LensRenderingPipeline;
  122153. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  122154. /***/ }),
  122155. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  122156. /*!**************************************************************************!*\
  122157. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  122158. \**************************************************************************/
  122159. /*! exports provided: SSAO2RenderingPipeline */
  122160. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122161. "use strict";
  122162. __webpack_require__.r(__webpack_exports__);
  122163. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  122164. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122165. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  122166. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  122167. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  122168. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122169. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  122170. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  122171. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  122172. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  122173. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  122174. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  122175. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  122176. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  122177. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  122178. /**
  122179. * Render pipeline to produce ssao effect
  122180. */
  122181. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  122182. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  122183. /**
  122184. * @constructor
  122185. * @param name The rendering pipeline name
  122186. * @param scene The scene linked to this pipeline
  122187. * @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 }
  122188. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122189. */
  122190. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  122191. var _this = _super.call(this, scene.getEngine(), name) || this;
  122192. // Members
  122193. /**
  122194. * @ignore
  122195. * The PassPostProcess id in the pipeline that contains the original scene color
  122196. */
  122197. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  122198. /**
  122199. * @ignore
  122200. * The SSAO PostProcess id in the pipeline
  122201. */
  122202. _this.SSAORenderEffect = "SSAORenderEffect";
  122203. /**
  122204. * @ignore
  122205. * The horizontal blur PostProcess id in the pipeline
  122206. */
  122207. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  122208. /**
  122209. * @ignore
  122210. * The vertical blur PostProcess id in the pipeline
  122211. */
  122212. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  122213. /**
  122214. * @ignore
  122215. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  122216. */
  122217. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  122218. /**
  122219. * The output strength of the SSAO post-process. Default value is 1.0.
  122220. */
  122221. _this.totalStrength = 1.0;
  122222. /**
  122223. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  122224. */
  122225. _this.maxZ = 100.0;
  122226. /**
  122227. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  122228. */
  122229. _this.minZAspect = 0.2;
  122230. _this._samples = 8;
  122231. _this._textureSamples = 1;
  122232. _this._expensiveBlur = true;
  122233. /**
  122234. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  122235. */
  122236. _this.radius = 2.0;
  122237. /**
  122238. * The base color of the SSAO post-process
  122239. * The final result is "base + ssao" between [0, 1]
  122240. */
  122241. _this.base = 0;
  122242. _this._firstUpdate = true;
  122243. _this._bits = new Uint32Array(1);
  122244. _this._scene = scene;
  122245. _this._ratio = ratio;
  122246. if (!_this.isSupported) {
  122247. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  122248. return _this;
  122249. }
  122250. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  122251. var blurRatio = _this._ratio.blurRatio || ratio;
  122252. // Set up assets
  122253. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  122254. _this._createRandomTexture();
  122255. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  122256. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  122257. _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);
  122258. _this._originalColorPostProcess.samples = _this.textureSamples;
  122259. _this._createSSAOPostProcess(1.0);
  122260. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  122261. _this._createSSAOCombinePostProcess(blurRatio);
  122262. // Set up pipeline
  122263. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  122264. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  122265. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  122266. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  122267. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  122268. // Finish
  122269. scene.postProcessRenderPipelineManager.addPipeline(_this);
  122270. if (cameras) {
  122271. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  122272. }
  122273. return _this;
  122274. }
  122275. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  122276. get: function () {
  122277. return this._samples;
  122278. },
  122279. /**
  122280. * Number of samples used for the SSAO calculations. Default value is 8
  122281. */
  122282. set: function (n) {
  122283. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  122284. this._samples = n;
  122285. this._sampleSphere = this._generateHemisphere();
  122286. this._firstUpdate = true;
  122287. },
  122288. enumerable: true,
  122289. configurable: true
  122290. });
  122291. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  122292. get: function () {
  122293. return this._textureSamples;
  122294. },
  122295. /**
  122296. * Number of samples to use for antialiasing
  122297. */
  122298. set: function (n) {
  122299. this._textureSamples = n;
  122300. this._originalColorPostProcess.samples = n;
  122301. this._blurHPostProcess.samples = n;
  122302. this._blurVPostProcess.samples = n;
  122303. this._ssaoPostProcess.samples = n;
  122304. this._ssaoCombinePostProcess.samples = n;
  122305. },
  122306. enumerable: true,
  122307. configurable: true
  122308. });
  122309. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  122310. get: function () {
  122311. return this._expensiveBlur;
  122312. },
  122313. /**
  122314. * If bilateral blur should be used
  122315. */
  122316. set: function (b) {
  122317. 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"]);
  122318. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  122319. this._expensiveBlur = b;
  122320. this._firstUpdate = true;
  122321. },
  122322. enumerable: true,
  122323. configurable: true
  122324. });
  122325. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  122326. /**
  122327. * Support test.
  122328. */
  122329. get: function () {
  122330. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  122331. if (!engine) {
  122332. return false;
  122333. }
  122334. return engine.getCaps().drawBuffersExtension;
  122335. },
  122336. enumerable: true,
  122337. configurable: true
  122338. });
  122339. Object.defineProperty(SSAO2RenderingPipeline.prototype, "scene", {
  122340. /**
  122341. * Gets active scene
  122342. */
  122343. get: function () {
  122344. return this._scene;
  122345. },
  122346. enumerable: true,
  122347. configurable: true
  122348. });
  122349. // Public Methods
  122350. /**
  122351. * Get the class name
  122352. * @returns "SSAO2RenderingPipeline"
  122353. */
  122354. SSAO2RenderingPipeline.prototype.getClassName = function () {
  122355. return "SSAO2RenderingPipeline";
  122356. };
  122357. /**
  122358. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  122359. */
  122360. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  122361. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  122362. for (var i = 0; i < this._scene.cameras.length; i++) {
  122363. var camera = this._scene.cameras[i];
  122364. this._originalColorPostProcess.dispose(camera);
  122365. this._ssaoPostProcess.dispose(camera);
  122366. this._blurHPostProcess.dispose(camera);
  122367. this._blurVPostProcess.dispose(camera);
  122368. this._ssaoCombinePostProcess.dispose(camera);
  122369. }
  122370. this._randomTexture.dispose();
  122371. if (disableGeometryBufferRenderer) {
  122372. this._scene.disableGeometryBufferRenderer();
  122373. }
  122374. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  122375. _super.prototype.dispose.call(this);
  122376. };
  122377. // Private Methods
  122378. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  122379. var _this = this;
  122380. this._samplerOffsets = [];
  122381. var expensive = this.expensiveBlur;
  122382. for (var i = -8; i < 8; i++) {
  122383. this._samplerOffsets.push(i * 2 + 0.5);
  122384. }
  122385. 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");
  122386. this._blurHPostProcess.onApply = function (effect) {
  122387. if (!_this._scene.activeCamera) {
  122388. return;
  122389. }
  122390. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  122391. effect.setFloat("near", _this._scene.activeCamera.minZ);
  122392. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  122393. effect.setFloat("radius", _this.radius);
  122394. effect.setTexture("depthSampler", _this._depthTexture);
  122395. if (_this._firstUpdate) {
  122396. effect.setArray("samplerOffsets", _this._samplerOffsets);
  122397. }
  122398. };
  122399. 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");
  122400. this._blurVPostProcess.onApply = function (effect) {
  122401. if (!_this._scene.activeCamera) {
  122402. return;
  122403. }
  122404. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  122405. effect.setFloat("near", _this._scene.activeCamera.minZ);
  122406. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  122407. effect.setFloat("radius", _this.radius);
  122408. effect.setTexture("depthSampler", _this._depthTexture);
  122409. if (_this._firstUpdate) {
  122410. effect.setArray("samplerOffsets", _this._samplerOffsets);
  122411. _this._firstUpdate = false;
  122412. }
  122413. };
  122414. this._blurHPostProcess.samples = this.textureSamples;
  122415. this._blurVPostProcess.samples = this.textureSamples;
  122416. };
  122417. /** @hidden */
  122418. SSAO2RenderingPipeline.prototype._rebuild = function () {
  122419. this._firstUpdate = true;
  122420. _super.prototype._rebuild.call(this);
  122421. };
  122422. //Van der Corput radical inverse
  122423. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  122424. this._bits[0] = i;
  122425. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  122426. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  122427. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  122428. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  122429. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  122430. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  122431. };
  122432. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  122433. return [i / n, this._radicalInverse_VdC(i)];
  122434. };
  122435. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  122436. var phi = v * 2.0 * Math.PI;
  122437. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  122438. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  122439. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  122440. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  122441. };
  122442. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  122443. var numSamples = this.samples;
  122444. var result = [];
  122445. var vector;
  122446. var i = 0;
  122447. while (i < numSamples) {
  122448. if (numSamples < 16) {
  122449. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  122450. }
  122451. else {
  122452. var rand = this._hammersley(i, numSamples);
  122453. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  122454. }
  122455. result.push(vector.x, vector.y, vector.z);
  122456. i++;
  122457. }
  122458. return result;
  122459. };
  122460. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  122461. var _this = this;
  122462. var numSamples = this.samples;
  122463. this._sampleSphere = this._generateHemisphere();
  122464. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  122465. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  122466. "base", "range", "projection", "near", "far", "texelSize",
  122467. "xViewport", "yViewport", "maxZ", "minZAspect"
  122468. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  122469. this._ssaoPostProcess.onApply = function (effect) {
  122470. if (_this._firstUpdate) {
  122471. effect.setArray3("sampleSphere", _this._sampleSphere);
  122472. effect.setFloat("randTextureTiles", 32.0);
  122473. }
  122474. if (!_this._scene.activeCamera) {
  122475. return;
  122476. }
  122477. effect.setFloat("samplesFactor", 1 / _this.samples);
  122478. effect.setFloat("totalStrength", _this.totalStrength);
  122479. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  122480. effect.setFloat("radius", _this.radius);
  122481. effect.setFloat("maxZ", _this.maxZ);
  122482. effect.setFloat("minZAspect", _this.minZAspect);
  122483. effect.setFloat("base", _this.base);
  122484. effect.setFloat("near", _this._scene.activeCamera.minZ);
  122485. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  122486. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  122487. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  122488. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  122489. effect.setTexture("textureSampler", _this._depthTexture);
  122490. effect.setTexture("normalSampler", _this._normalTexture);
  122491. effect.setTexture("randomSampler", _this._randomTexture);
  122492. };
  122493. this._ssaoPostProcess.samples = this.textureSamples;
  122494. };
  122495. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  122496. var _this = this;
  122497. 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);
  122498. this._ssaoCombinePostProcess.onApply = function (effect) {
  122499. var viewport = _this._scene.activeCamera.viewport;
  122500. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  122501. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  122502. };
  122503. this._ssaoCombinePostProcess.samples = this.textureSamples;
  122504. };
  122505. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  122506. var size = 128;
  122507. 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);
  122508. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  122509. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  122510. var context = this._randomTexture.getContext();
  122511. var rand = function (min, max) {
  122512. return Math.random() * (max - min) + min;
  122513. };
  122514. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  122515. for (var x = 0; x < size; x++) {
  122516. for (var y = 0; y < size; y++) {
  122517. randVector.x = rand(0.0, 1.0);
  122518. randVector.y = rand(0.0, 1.0);
  122519. randVector.z = 0.0;
  122520. randVector.normalize();
  122521. randVector.scaleInPlace(255);
  122522. randVector.x = Math.floor(randVector.x);
  122523. randVector.y = Math.floor(randVector.y);
  122524. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  122525. context.fillRect(x, y, 1, 1);
  122526. }
  122527. }
  122528. this._randomTexture.update(false);
  122529. };
  122530. /**
  122531. * Serialize the rendering pipeline (Used when exporting)
  122532. * @returns the serialized object
  122533. */
  122534. SSAO2RenderingPipeline.prototype.serialize = function () {
  122535. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  122536. serializationObject.customType = "SSAO2RenderingPipeline";
  122537. return serializationObject;
  122538. };
  122539. /**
  122540. * Parse the serialized pipeline
  122541. * @param source Source pipeline.
  122542. * @param scene The scene to load the pipeline to.
  122543. * @param rootUrl The URL of the serialized pipeline.
  122544. * @returns An instantiated pipeline from the serialized object.
  122545. */
  122546. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  122547. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  122548. };
  122549. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122550. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  122551. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  122552. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122553. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  122554. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  122555. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122556. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  122557. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  122558. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122559. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  122560. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  122561. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122562. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  122563. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  122564. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122565. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  122566. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  122567. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122568. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  122569. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  122570. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122571. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  122572. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  122573. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122574. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  122575. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  122576. return SSAO2RenderingPipeline;
  122577. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  122578. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  122579. /***/ }),
  122580. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  122581. /*!*************************************************************************!*\
  122582. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  122583. \*************************************************************************/
  122584. /*! exports provided: SSAORenderingPipeline */
  122585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122586. "use strict";
  122587. __webpack_require__.r(__webpack_exports__);
  122588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  122589. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122590. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  122591. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122592. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  122593. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  122594. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  122595. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  122596. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  122597. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  122598. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  122599. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  122600. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  122601. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  122602. /**
  122603. * Render pipeline to produce ssao effect
  122604. */
  122605. var SSAORenderingPipeline = /** @class */ (function (_super) {
  122606. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  122607. /**
  122608. * @constructor
  122609. * @param name - The rendering pipeline name
  122610. * @param scene - The scene linked to this pipeline
  122611. * @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 }
  122612. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  122613. */
  122614. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  122615. var _this = _super.call(this, scene.getEngine(), name) || this;
  122616. // Members
  122617. /**
  122618. * @ignore
  122619. * The PassPostProcess id in the pipeline that contains the original scene color
  122620. */
  122621. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  122622. /**
  122623. * @ignore
  122624. * The SSAO PostProcess id in the pipeline
  122625. */
  122626. _this.SSAORenderEffect = "SSAORenderEffect";
  122627. /**
  122628. * @ignore
  122629. * The horizontal blur PostProcess id in the pipeline
  122630. */
  122631. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  122632. /**
  122633. * @ignore
  122634. * The vertical blur PostProcess id in the pipeline
  122635. */
  122636. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  122637. /**
  122638. * @ignore
  122639. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  122640. */
  122641. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  122642. /**
  122643. * The output strength of the SSAO post-process. Default value is 1.0.
  122644. */
  122645. _this.totalStrength = 1.0;
  122646. /**
  122647. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  122648. */
  122649. _this.radius = 0.0001;
  122650. /**
  122651. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  122652. * Must not be equal to fallOff and superior to fallOff.
  122653. * Default value is 0.0075
  122654. */
  122655. _this.area = 0.0075;
  122656. /**
  122657. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  122658. * Must not be equal to area and inferior to area.
  122659. * Default value is 0.000001
  122660. */
  122661. _this.fallOff = 0.000001;
  122662. /**
  122663. * The base color of the SSAO post-process
  122664. * The final result is "base + ssao" between [0, 1]
  122665. */
  122666. _this.base = 0.5;
  122667. _this._firstUpdate = true;
  122668. _this._scene = scene;
  122669. // Set up assets
  122670. _this._createRandomTexture();
  122671. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  122672. var ssaoRatio = ratio.ssaoRatio || ratio;
  122673. var combineRatio = ratio.combineRatio || ratio;
  122674. _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);
  122675. _this._createSSAOPostProcess(ssaoRatio);
  122676. _this._createBlurPostProcess(ssaoRatio);
  122677. _this._createSSAOCombinePostProcess(combineRatio);
  122678. // Set up pipeline
  122679. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  122680. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  122681. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  122682. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  122683. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  122684. // Finish
  122685. scene.postProcessRenderPipelineManager.addPipeline(_this);
  122686. if (cameras) {
  122687. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  122688. }
  122689. return _this;
  122690. }
  122691. Object.defineProperty(SSAORenderingPipeline.prototype, "scene", {
  122692. /**
  122693. * Gets active scene
  122694. */
  122695. get: function () {
  122696. return this._scene;
  122697. },
  122698. enumerable: true,
  122699. configurable: true
  122700. });
  122701. // Public Methods
  122702. /**
  122703. * Get the class name
  122704. * @returns "SSAORenderingPipeline"
  122705. */
  122706. SSAORenderingPipeline.prototype.getClassName = function () {
  122707. return "SSAORenderingPipeline";
  122708. };
  122709. /**
  122710. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  122711. */
  122712. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  122713. if (disableDepthRender === void 0) { disableDepthRender = false; }
  122714. for (var i = 0; i < this._scene.cameras.length; i++) {
  122715. var camera = this._scene.cameras[i];
  122716. this._originalColorPostProcess.dispose(camera);
  122717. this._ssaoPostProcess.dispose(camera);
  122718. this._blurHPostProcess.dispose(camera);
  122719. this._blurVPostProcess.dispose(camera);
  122720. this._ssaoCombinePostProcess.dispose(camera);
  122721. }
  122722. this._randomTexture.dispose();
  122723. if (disableDepthRender) {
  122724. this._scene.disableDepthRenderer();
  122725. }
  122726. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  122727. _super.prototype.dispose.call(this);
  122728. };
  122729. // Private Methods
  122730. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  122731. var _this = this;
  122732. var size = 16;
  122733. 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);
  122734. 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);
  122735. this._blurHPostProcess.onActivateObservable.add(function () {
  122736. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  122737. _this._blurHPostProcess.kernel = size * dw;
  122738. });
  122739. this._blurVPostProcess.onActivateObservable.add(function () {
  122740. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  122741. _this._blurVPostProcess.kernel = size * dw;
  122742. });
  122743. };
  122744. /** @hidden */
  122745. SSAORenderingPipeline.prototype._rebuild = function () {
  122746. this._firstUpdate = true;
  122747. _super.prototype._rebuild.call(this);
  122748. };
  122749. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  122750. var _this = this;
  122751. var numSamples = 16;
  122752. var sampleSphere = [
  122753. 0.5381, 0.1856, -0.4319,
  122754. 0.1379, 0.2486, 0.4430,
  122755. 0.3371, 0.5679, -0.0057,
  122756. -0.6999, -0.0451, -0.0019,
  122757. 0.0689, -0.1598, -0.8547,
  122758. 0.0560, 0.0069, -0.1843,
  122759. -0.0146, 0.1402, 0.0762,
  122760. 0.0100, -0.1924, -0.0344,
  122761. -0.3577, -0.5301, -0.4358,
  122762. -0.3169, 0.1063, 0.0158,
  122763. 0.0103, -0.5869, 0.0046,
  122764. -0.0897, -0.4940, 0.3287,
  122765. 0.7119, -0.0154, -0.0918,
  122766. -0.0533, 0.0596, -0.5411,
  122767. 0.0352, -0.0631, 0.5460,
  122768. -0.4776, 0.2847, -0.0271
  122769. ];
  122770. var samplesFactor = 1.0 / numSamples;
  122771. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  122772. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  122773. "area", "fallOff", "base", "range", "viewport"
  122774. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  122775. this._ssaoPostProcess.onApply = function (effect) {
  122776. if (_this._firstUpdate) {
  122777. effect.setArray3("sampleSphere", sampleSphere);
  122778. effect.setFloat("samplesFactor", samplesFactor);
  122779. effect.setFloat("randTextureTiles", 4.0);
  122780. }
  122781. effect.setFloat("totalStrength", _this.totalStrength);
  122782. effect.setFloat("radius", _this.radius);
  122783. effect.setFloat("area", _this.area);
  122784. effect.setFloat("fallOff", _this.fallOff);
  122785. effect.setFloat("base", _this.base);
  122786. effect.setTexture("textureSampler", _this._depthTexture);
  122787. effect.setTexture("randomSampler", _this._randomTexture);
  122788. };
  122789. };
  122790. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  122791. var _this = this;
  122792. 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);
  122793. this._ssaoCombinePostProcess.onApply = function (effect) {
  122794. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  122795. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  122796. };
  122797. };
  122798. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  122799. var size = 512;
  122800. 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);
  122801. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  122802. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  122803. var context = this._randomTexture.getContext();
  122804. var rand = function (min, max) {
  122805. return Math.random() * (max - min) + min;
  122806. };
  122807. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  122808. for (var x = 0; x < size; x++) {
  122809. for (var y = 0; y < size; y++) {
  122810. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  122811. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  122812. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  122813. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  122814. context.fillRect(x, y, 1, 1);
  122815. }
  122816. }
  122817. this._randomTexture.update(false);
  122818. };
  122819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  122821. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  122822. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122823. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  122824. ], SSAORenderingPipeline.prototype, "radius", void 0);
  122825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  122827. ], SSAORenderingPipeline.prototype, "area", void 0);
  122828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  122830. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  122831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  122833. ], SSAORenderingPipeline.prototype, "base", void 0);
  122834. return SSAORenderingPipeline;
  122835. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  122836. /***/ }),
  122837. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  122838. /*!*****************************************************************************!*\
  122839. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  122840. \*****************************************************************************/
  122841. /*! exports provided: StandardRenderingPipeline */
  122842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122843. "use strict";
  122844. __webpack_require__.r(__webpack_exports__);
  122845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  122846. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122847. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  122848. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  122849. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  122850. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  122851. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122852. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  122853. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  122854. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  122855. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  122856. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  122857. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  122858. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  122859. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  122860. /**
  122861. * Standard rendering pipeline
  122862. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122863. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  122864. */
  122865. var StandardRenderingPipeline = /** @class */ (function (_super) {
  122866. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  122867. /**
  122868. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122869. * @constructor
  122870. * @param name The rendering pipeline name
  122871. * @param scene The scene linked to this pipeline
  122872. * @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)
  122873. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  122874. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122875. */
  122876. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  122877. if (originalPostProcess === void 0) { originalPostProcess = null; }
  122878. var _this = _super.call(this, scene.getEngine(), name) || this;
  122879. /**
  122880. * Post-process used to down scale an image x4
  122881. */
  122882. _this.downSampleX4PostProcess = null;
  122883. /**
  122884. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  122885. */
  122886. _this.brightPassPostProcess = null;
  122887. /**
  122888. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  122889. */
  122890. _this.blurHPostProcesses = [];
  122891. /**
  122892. * Post-process array storing all the vertical blur post-processes used by the pipeline
  122893. */
  122894. _this.blurVPostProcesses = [];
  122895. /**
  122896. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  122897. */
  122898. _this.textureAdderPostProcess = null;
  122899. /**
  122900. * Post-process used to create volumetric lighting effect
  122901. */
  122902. _this.volumetricLightPostProcess = null;
  122903. /**
  122904. * Post-process used to smooth the previous volumetric light post-process on the X axis
  122905. */
  122906. _this.volumetricLightSmoothXPostProcess = null;
  122907. /**
  122908. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  122909. */
  122910. _this.volumetricLightSmoothYPostProcess = null;
  122911. /**
  122912. * Post-process used to merge the volumetric light effect and the real scene color
  122913. */
  122914. _this.volumetricLightMergePostProces = null;
  122915. /**
  122916. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  122917. */
  122918. _this.volumetricLightFinalPostProcess = null;
  122919. /**
  122920. * Base post-process used to calculate the average luminance of the final image for HDR
  122921. */
  122922. _this.luminancePostProcess = null;
  122923. /**
  122924. * Post-processes used to create down sample post-processes in order to get
  122925. * the average luminance of the final image for HDR
  122926. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  122927. */
  122928. _this.luminanceDownSamplePostProcesses = [];
  122929. /**
  122930. * Post-process used to create a HDR effect (light adaptation)
  122931. */
  122932. _this.hdrPostProcess = null;
  122933. /**
  122934. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  122935. */
  122936. _this.textureAdderFinalPostProcess = null;
  122937. /**
  122938. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  122939. */
  122940. _this.lensFlareFinalPostProcess = null;
  122941. /**
  122942. * Post-process used to merge the final HDR post-process and the real scene color
  122943. */
  122944. _this.hdrFinalPostProcess = null;
  122945. /**
  122946. * Post-process used to create a lens flare effect
  122947. */
  122948. _this.lensFlarePostProcess = null;
  122949. /**
  122950. * Post-process that merges the result of the lens flare post-process and the real scene color
  122951. */
  122952. _this.lensFlareComposePostProcess = null;
  122953. /**
  122954. * Post-process used to create a motion blur effect
  122955. */
  122956. _this.motionBlurPostProcess = null;
  122957. /**
  122958. * Post-process used to create a depth of field effect
  122959. */
  122960. _this.depthOfFieldPostProcess = null;
  122961. /**
  122962. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  122963. */
  122964. _this.fxaaPostProcess = null;
  122965. // Values
  122966. /**
  122967. * Represents the brightness threshold in order to configure the illuminated surfaces
  122968. */
  122969. _this.brightThreshold = 1.0;
  122970. /**
  122971. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  122972. */
  122973. _this.blurWidth = 512.0;
  122974. /**
  122975. * Sets if the blur for highlighted surfaces must be only horizontal
  122976. */
  122977. _this.horizontalBlur = false;
  122978. /**
  122979. * Texture used typically to simulate "dirty" on camera lens
  122980. */
  122981. _this.lensTexture = null;
  122982. /**
  122983. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  122984. */
  122985. _this.volumetricLightCoefficient = 0.2;
  122986. /**
  122987. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  122988. */
  122989. _this.volumetricLightPower = 4.0;
  122990. /**
  122991. * Used the set the blur intensity to smooth the volumetric lights
  122992. */
  122993. _this.volumetricLightBlurScale = 64.0;
  122994. /**
  122995. * Light (spot or directional) used to generate the volumetric lights rays
  122996. * The source light must have a shadow generate so the pipeline can get its
  122997. * depth map
  122998. */
  122999. _this.sourceLight = null;
  123000. /**
  123001. * For eye adaptation, represents the minimum luminance the eye can see
  123002. */
  123003. _this.hdrMinimumLuminance = 1.0;
  123004. /**
  123005. * For eye adaptation, represents the decrease luminance speed
  123006. */
  123007. _this.hdrDecreaseRate = 0.5;
  123008. /**
  123009. * For eye adaptation, represents the increase luminance speed
  123010. */
  123011. _this.hdrIncreaseRate = 0.5;
  123012. /**
  123013. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  123014. */
  123015. _this.lensColorTexture = null;
  123016. /**
  123017. * The overall strengh for the lens flare effect
  123018. */
  123019. _this.lensFlareStrength = 20.0;
  123020. /**
  123021. * Dispersion coefficient for lens flare ghosts
  123022. */
  123023. _this.lensFlareGhostDispersal = 1.4;
  123024. /**
  123025. * Main lens flare halo width
  123026. */
  123027. _this.lensFlareHaloWidth = 0.7;
  123028. /**
  123029. * Based on the lens distortion effect, defines how much the lens flare result
  123030. * is distorted
  123031. */
  123032. _this.lensFlareDistortionStrength = 16.0;
  123033. /**
  123034. * Lens star texture must be used to simulate rays on the flares and is available
  123035. * in the documentation
  123036. */
  123037. _this.lensStarTexture = null;
  123038. /**
  123039. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  123040. * flare effect by taking account of the dirt texture
  123041. */
  123042. _this.lensFlareDirtTexture = null;
  123043. /**
  123044. * Represents the focal length for the depth of field effect
  123045. */
  123046. _this.depthOfFieldDistance = 10.0;
  123047. /**
  123048. * Represents the blur intensity for the blurred part of the depth of field effect
  123049. */
  123050. _this.depthOfFieldBlurWidth = 64.0;
  123051. /**
  123052. * For motion blur, defines how much the image is blurred by the movement
  123053. */
  123054. _this.motionStrength = 1.0;
  123055. /**
  123056. * List of animations for the pipeline (IAnimatable implementation)
  123057. */
  123058. _this.animations = [];
  123059. _this._currentDepthOfFieldSource = null;
  123060. _this._fixedExposure = 1.0;
  123061. _this._currentExposure = 1.0;
  123062. _this._hdrAutoExposure = false;
  123063. _this._hdrCurrentLuminance = 1.0;
  123064. // Getters and setters
  123065. _this._bloomEnabled = false;
  123066. _this._depthOfFieldEnabled = false;
  123067. _this._vlsEnabled = false;
  123068. _this._lensFlareEnabled = false;
  123069. _this._hdrEnabled = false;
  123070. _this._motionBlurEnabled = false;
  123071. _this._fxaaEnabled = false;
  123072. _this._motionBlurSamples = 64.0;
  123073. _this._volumetricLightStepsCount = 50.0;
  123074. _this._samples = 1;
  123075. _this._cameras = cameras || [];
  123076. // Initialize
  123077. _this._scene = scene;
  123078. _this._basePostProcess = originalPostProcess;
  123079. _this._ratio = ratio;
  123080. // Misc
  123081. _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;
  123082. // Finish
  123083. scene.postProcessRenderPipelineManager.addPipeline(_this);
  123084. _this._buildPipeline();
  123085. return _this;
  123086. }
  123087. Object.defineProperty(StandardRenderingPipeline.prototype, "exposure", {
  123088. /**
  123089. * Gets the overall exposure used by the pipeline
  123090. */
  123091. get: function () {
  123092. return this._fixedExposure;
  123093. },
  123094. /**
  123095. * Sets the overall exposure used by the pipeline
  123096. */
  123097. set: function (value) {
  123098. this._fixedExposure = value;
  123099. this._currentExposure = value;
  123100. },
  123101. enumerable: true,
  123102. configurable: true
  123103. });
  123104. Object.defineProperty(StandardRenderingPipeline.prototype, "hdrAutoExposure", {
  123105. /**
  123106. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  123107. */
  123108. get: function () {
  123109. return this._hdrAutoExposure;
  123110. },
  123111. /**
  123112. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  123113. */
  123114. set: function (value) {
  123115. this._hdrAutoExposure = value;
  123116. if (this.hdrPostProcess) {
  123117. var defines = ["#define HDR"];
  123118. if (value) {
  123119. defines.push("#define AUTO_EXPOSURE");
  123120. }
  123121. this.hdrPostProcess.updateEffect(defines.join("\n"));
  123122. }
  123123. },
  123124. enumerable: true,
  123125. configurable: true
  123126. });
  123127. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  123128. /**
  123129. * @ignore
  123130. * Specifies if the bloom pipeline is enabled
  123131. */
  123132. get: function () {
  123133. return this._bloomEnabled;
  123134. },
  123135. set: function (enabled) {
  123136. if (this._bloomEnabled === enabled) {
  123137. return;
  123138. }
  123139. this._bloomEnabled = enabled;
  123140. this._buildPipeline();
  123141. },
  123142. enumerable: true,
  123143. configurable: true
  123144. });
  123145. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  123146. /**
  123147. * @ignore
  123148. * Specifies if the depth of field pipeline is enabed
  123149. */
  123150. get: function () {
  123151. return this._depthOfFieldEnabled;
  123152. },
  123153. set: function (enabled) {
  123154. if (this._depthOfFieldEnabled === enabled) {
  123155. return;
  123156. }
  123157. this._depthOfFieldEnabled = enabled;
  123158. this._buildPipeline();
  123159. },
  123160. enumerable: true,
  123161. configurable: true
  123162. });
  123163. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  123164. /**
  123165. * @ignore
  123166. * Specifies if the lens flare pipeline is enabed
  123167. */
  123168. get: function () {
  123169. return this._lensFlareEnabled;
  123170. },
  123171. set: function (enabled) {
  123172. if (this._lensFlareEnabled === enabled) {
  123173. return;
  123174. }
  123175. this._lensFlareEnabled = enabled;
  123176. this._buildPipeline();
  123177. },
  123178. enumerable: true,
  123179. configurable: true
  123180. });
  123181. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  123182. /**
  123183. * @ignore
  123184. * Specifies if the HDR pipeline is enabled
  123185. */
  123186. get: function () {
  123187. return this._hdrEnabled;
  123188. },
  123189. set: function (enabled) {
  123190. if (this._hdrEnabled === enabled) {
  123191. return;
  123192. }
  123193. this._hdrEnabled = enabled;
  123194. this._buildPipeline();
  123195. },
  123196. enumerable: true,
  123197. configurable: true
  123198. });
  123199. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  123200. /**
  123201. * @ignore
  123202. * Specifies if the volumetric lights scattering effect is enabled
  123203. */
  123204. get: function () {
  123205. return this._vlsEnabled;
  123206. },
  123207. set: function (enabled) {
  123208. if (this._vlsEnabled === enabled) {
  123209. return;
  123210. }
  123211. if (enabled) {
  123212. var geometry = this._scene.enableGeometryBufferRenderer();
  123213. if (!geometry) {
  123214. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  123215. return;
  123216. }
  123217. }
  123218. this._vlsEnabled = enabled;
  123219. this._buildPipeline();
  123220. },
  123221. enumerable: true,
  123222. configurable: true
  123223. });
  123224. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  123225. /**
  123226. * @ignore
  123227. * Specifies if the motion blur effect is enabled
  123228. */
  123229. get: function () {
  123230. return this._motionBlurEnabled;
  123231. },
  123232. set: function (enabled) {
  123233. if (this._motionBlurEnabled === enabled) {
  123234. return;
  123235. }
  123236. this._motionBlurEnabled = enabled;
  123237. this._buildPipeline();
  123238. },
  123239. enumerable: true,
  123240. configurable: true
  123241. });
  123242. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  123243. /**
  123244. * Specifies if anti-aliasing is enabled
  123245. */
  123246. get: function () {
  123247. return this._fxaaEnabled;
  123248. },
  123249. set: function (enabled) {
  123250. if (this._fxaaEnabled === enabled) {
  123251. return;
  123252. }
  123253. this._fxaaEnabled = enabled;
  123254. this._buildPipeline();
  123255. },
  123256. enumerable: true,
  123257. configurable: true
  123258. });
  123259. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  123260. /**
  123261. * Specifies the number of steps used to calculate the volumetric lights
  123262. * Typically in interval [50, 200]
  123263. */
  123264. get: function () {
  123265. return this._volumetricLightStepsCount;
  123266. },
  123267. set: function (count) {
  123268. if (this.volumetricLightPostProcess) {
  123269. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  123270. }
  123271. this._volumetricLightStepsCount = count;
  123272. },
  123273. enumerable: true,
  123274. configurable: true
  123275. });
  123276. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  123277. /**
  123278. * Specifies the number of samples used for the motion blur effect
  123279. * Typically in interval [16, 64]
  123280. */
  123281. get: function () {
  123282. return this._motionBlurSamples;
  123283. },
  123284. set: function (samples) {
  123285. if (this.motionBlurPostProcess) {
  123286. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  123287. }
  123288. this._motionBlurSamples = samples;
  123289. },
  123290. enumerable: true,
  123291. configurable: true
  123292. });
  123293. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  123294. /**
  123295. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  123296. */
  123297. get: function () {
  123298. return this._samples;
  123299. },
  123300. set: function (sampleCount) {
  123301. if (this._samples === sampleCount) {
  123302. return;
  123303. }
  123304. this._samples = sampleCount;
  123305. this._buildPipeline();
  123306. },
  123307. enumerable: true,
  123308. configurable: true
  123309. });
  123310. StandardRenderingPipeline.prototype._buildPipeline = function () {
  123311. var _this = this;
  123312. var ratio = this._ratio;
  123313. var scene = this._scene;
  123314. this._disposePostProcesses();
  123315. this._reset();
  123316. // Create pass post-process
  123317. if (!this._basePostProcess) {
  123318. 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);
  123319. this.originalPostProcess.onApply = function () {
  123320. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  123321. };
  123322. }
  123323. else {
  123324. this.originalPostProcess = this._basePostProcess;
  123325. }
  123326. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  123327. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  123328. }
  123329. this._currentDepthOfFieldSource = this.originalPostProcess;
  123330. if (this._bloomEnabled) {
  123331. // Create down sample X4 post-process
  123332. this._createDownSampleX4PostProcess(scene, ratio / 2);
  123333. // Create bright pass post-process
  123334. this._createBrightPassPostProcess(scene, ratio / 2);
  123335. // Create gaussian blur post-processes (down sampling blurs)
  123336. this._createBlurPostProcesses(scene, ratio / 4, 1);
  123337. // Create texture adder post-process
  123338. this._createTextureAdderPostProcess(scene, ratio);
  123339. // Create depth-of-field source post-process
  123340. 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);
  123341. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  123342. }
  123343. if (this._vlsEnabled) {
  123344. // Create volumetric light
  123345. this._createVolumetricLightPostProcess(scene, ratio);
  123346. // Create volumetric light final post-process
  123347. 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);
  123348. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  123349. }
  123350. if (this._lensFlareEnabled) {
  123351. // Create lens flare post-process
  123352. this._createLensFlarePostProcess(scene, ratio);
  123353. // Create depth-of-field source post-process post lens-flare and disable it now
  123354. 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);
  123355. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  123356. }
  123357. if (this._hdrEnabled) {
  123358. // Create luminance
  123359. this._createLuminancePostProcesses(scene, this._floatTextureType);
  123360. // Create HDR
  123361. this._createHdrPostProcess(scene, ratio);
  123362. // Create depth-of-field source post-process post hdr and disable it now
  123363. 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);
  123364. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  123365. }
  123366. if (this._depthOfFieldEnabled) {
  123367. // Create gaussian blur used by depth-of-field
  123368. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  123369. // Create depth-of-field post-process
  123370. this._createDepthOfFieldPostProcess(scene, ratio);
  123371. }
  123372. if (this._motionBlurEnabled) {
  123373. // Create motion blur post-process
  123374. this._createMotionBlurPostProcess(scene, ratio);
  123375. }
  123376. if (this._fxaaEnabled) {
  123377. // Create fxaa post-process
  123378. 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);
  123379. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  123380. }
  123381. if (this._cameras !== null) {
  123382. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  123383. }
  123384. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  123385. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  123386. }
  123387. };
  123388. // Down Sample X4 Post-Processs
  123389. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  123390. var _this = this;
  123391. var downSampleX4Offsets = new Array(32);
  123392. 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);
  123393. this.downSampleX4PostProcess.onApply = function (effect) {
  123394. var id = 0;
  123395. var width = _this.downSampleX4PostProcess.width;
  123396. var height = _this.downSampleX4PostProcess.height;
  123397. for (var i = -2; i < 2; i++) {
  123398. for (var j = -2; j < 2; j++) {
  123399. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  123400. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  123401. id += 2;
  123402. }
  123403. }
  123404. effect.setArray2("dsOffsets", downSampleX4Offsets);
  123405. };
  123406. // Add to pipeline
  123407. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  123408. };
  123409. // Brightpass Post-Process
  123410. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  123411. var _this = this;
  123412. var brightOffsets = new Array(8);
  123413. 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);
  123414. this.brightPassPostProcess.onApply = function (effect) {
  123415. var sU = (1.0 / _this.brightPassPostProcess.width);
  123416. var sV = (1.0 / _this.brightPassPostProcess.height);
  123417. brightOffsets[0] = -0.5 * sU;
  123418. brightOffsets[1] = 0.5 * sV;
  123419. brightOffsets[2] = 0.5 * sU;
  123420. brightOffsets[3] = 0.5 * sV;
  123421. brightOffsets[4] = -0.5 * sU;
  123422. brightOffsets[5] = -0.5 * sV;
  123423. brightOffsets[6] = 0.5 * sU;
  123424. brightOffsets[7] = -0.5 * sV;
  123425. effect.setArray2("dsOffsets", brightOffsets);
  123426. effect.setFloat("brightThreshold", _this.brightThreshold);
  123427. };
  123428. // Add to pipeline
  123429. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  123430. };
  123431. // Create blur H&V post-processes
  123432. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  123433. var _this = this;
  123434. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  123435. var engine = scene.getEngine();
  123436. 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);
  123437. 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);
  123438. blurX.onActivateObservable.add(function () {
  123439. var dw = blurX.width / engine.getRenderWidth();
  123440. blurX.kernel = _this[blurWidthKey] * dw;
  123441. });
  123442. blurY.onActivateObservable.add(function () {
  123443. var dw = blurY.height / engine.getRenderHeight();
  123444. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  123445. });
  123446. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  123447. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  123448. this.blurHPostProcesses.push(blurX);
  123449. this.blurVPostProcesses.push(blurY);
  123450. };
  123451. // Create texture adder post-process
  123452. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  123453. var _this = this;
  123454. 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);
  123455. this.textureAdderPostProcess.onApply = function (effect) {
  123456. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  123457. effect.setTexture("lensSampler", _this.lensTexture);
  123458. effect.setFloat("exposure", _this._currentExposure);
  123459. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  123460. };
  123461. // Add to pipeline
  123462. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  123463. };
  123464. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  123465. var _this = this;
  123466. var geometryRenderer = scene.enableGeometryBufferRenderer();
  123467. geometryRenderer.enablePosition = true;
  123468. var geometry = geometryRenderer.getGBuffer();
  123469. // Base post-process
  123470. 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));
  123471. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  123472. this.volumetricLightPostProcess.onApply = function (effect) {
  123473. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  123474. var generator = _this.sourceLight.getShadowGenerator();
  123475. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  123476. effect.setTexture("positionSampler", geometry.textures[2]);
  123477. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  123478. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  123479. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  123480. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  123481. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  123482. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  123483. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  123484. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  123485. effect.setVector2("depthValues", depthValues);
  123486. }
  123487. };
  123488. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  123489. // Smooth
  123490. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  123491. // Merge
  123492. 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");
  123493. this.volumetricLightMergePostProces.onApply = function (effect) {
  123494. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  123495. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  123496. };
  123497. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  123498. };
  123499. // Create luminance
  123500. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  123501. var _this = this;
  123502. // Create luminance
  123503. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  123504. 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);
  123505. var offsets = [];
  123506. this.luminancePostProcess.onApply = function (effect) {
  123507. var sU = (1.0 / _this.luminancePostProcess.width);
  123508. var sV = (1.0 / _this.luminancePostProcess.height);
  123509. offsets[0] = -0.5 * sU;
  123510. offsets[1] = 0.5 * sV;
  123511. offsets[2] = 0.5 * sU;
  123512. offsets[3] = 0.5 * sV;
  123513. offsets[4] = -0.5 * sU;
  123514. offsets[5] = -0.5 * sV;
  123515. offsets[6] = 0.5 * sU;
  123516. offsets[7] = -0.5 * sV;
  123517. effect.setArray2("lumOffsets", offsets);
  123518. };
  123519. // Add to pipeline
  123520. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  123521. // Create down sample luminance
  123522. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  123523. var size = Math.pow(3, i);
  123524. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  123525. if (i === 0) {
  123526. defines += "#define FINAL_DOWN_SAMPLER";
  123527. }
  123528. 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);
  123529. this.luminanceDownSamplePostProcesses.push(postProcess);
  123530. }
  123531. // Create callbacks and add effects
  123532. var lastLuminance = this.luminancePostProcess;
  123533. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  123534. var downSampleOffsets = new Array(18);
  123535. pp.onApply = function (effect) {
  123536. if (!lastLuminance) {
  123537. return;
  123538. }
  123539. var id = 0;
  123540. for (var x = -1; x < 2; x++) {
  123541. for (var y = -1; y < 2; y++) {
  123542. downSampleOffsets[id] = x / lastLuminance.width;
  123543. downSampleOffsets[id + 1] = y / lastLuminance.height;
  123544. id += 2;
  123545. }
  123546. }
  123547. effect.setArray2("dsOffsets", downSampleOffsets);
  123548. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  123549. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  123550. lastLuminance = _this.luminancePostProcess;
  123551. }
  123552. else {
  123553. lastLuminance = pp;
  123554. }
  123555. };
  123556. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  123557. pp.onAfterRender = function () {
  123558. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  123559. 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);
  123560. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  123561. };
  123562. }
  123563. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  123564. });
  123565. };
  123566. // Create HDR post-process
  123567. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  123568. var _this = this;
  123569. var defines = ["#define HDR"];
  123570. if (this._hdrAutoExposure) {
  123571. defines.push("#define AUTO_EXPOSURE");
  123572. }
  123573. 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);
  123574. var outputLiminance = 1;
  123575. var time = 0;
  123576. var lastTime = 0;
  123577. this.hdrPostProcess.onApply = function (effect) {
  123578. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  123579. time += scene.getEngine().getDeltaTime();
  123580. if (outputLiminance < 0) {
  123581. outputLiminance = _this._hdrCurrentLuminance;
  123582. }
  123583. else {
  123584. var dt = (lastTime - time) / 1000.0;
  123585. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  123586. outputLiminance += _this.hdrDecreaseRate * dt;
  123587. }
  123588. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  123589. outputLiminance -= _this.hdrIncreaseRate * dt;
  123590. }
  123591. else {
  123592. outputLiminance = _this._hdrCurrentLuminance;
  123593. }
  123594. }
  123595. if (_this.hdrAutoExposure) {
  123596. _this._currentExposure = _this._fixedExposure / outputLiminance;
  123597. }
  123598. else {
  123599. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  123600. effect.setFloat("averageLuminance", outputLiminance);
  123601. }
  123602. lastTime = time;
  123603. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  123604. };
  123605. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  123606. };
  123607. // Create lens flare post-process
  123608. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  123609. var _this = this;
  123610. 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);
  123611. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  123612. this._createBlurPostProcesses(scene, ratio / 4, 2);
  123613. 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);
  123614. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  123615. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  123616. // Lens flare
  123617. this.lensFlarePostProcess.onApply = function (effect) {
  123618. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  123619. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  123620. effect.setFloat("strength", _this.lensFlareStrength);
  123621. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  123622. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  123623. // Shift
  123624. resolution.x = _this.lensFlarePostProcess.width;
  123625. resolution.y = _this.lensFlarePostProcess.height;
  123626. effect.setVector2("resolution", resolution);
  123627. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  123628. };
  123629. // Compose
  123630. 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);
  123631. 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);
  123632. this.lensFlareComposePostProcess.onApply = function (effect) {
  123633. if (!_this._scene.activeCamera) {
  123634. return;
  123635. }
  123636. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  123637. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  123638. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  123639. // Lens start rotation matrix
  123640. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  123641. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  123642. 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));
  123643. camRot *= 4.0;
  123644. 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);
  123645. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  123646. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  123647. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  123648. };
  123649. };
  123650. // Create depth-of-field post-process
  123651. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  123652. var _this = this;
  123653. 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);
  123654. this.depthOfFieldPostProcess.onApply = function (effect) {
  123655. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  123656. effect.setTexture("depthSampler", _this._getDepthTexture());
  123657. effect.setFloat("distance", _this.depthOfFieldDistance);
  123658. };
  123659. // Add to pipeline
  123660. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  123661. };
  123662. // Create motion blur post-process
  123663. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  123664. var _this = this;
  123665. 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);
  123666. var motionScale = 0;
  123667. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  123668. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  123669. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  123670. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  123671. this.motionBlurPostProcess.onApply = function (effect) {
  123672. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  123673. viewProjection.invertToRef(invViewProjection);
  123674. effect.setMatrix("inverseViewProjection", invViewProjection);
  123675. effect.setMatrix("prevViewProjection", prevViewProjection);
  123676. prevViewProjection = viewProjection;
  123677. screenSize.x = _this.motionBlurPostProcess.width;
  123678. screenSize.y = _this.motionBlurPostProcess.height;
  123679. effect.setVector2("screenSize", screenSize);
  123680. motionScale = scene.getEngine().getFps() / 60.0;
  123681. effect.setFloat("motionScale", motionScale);
  123682. effect.setFloat("motionStrength", _this.motionStrength);
  123683. effect.setTexture("depthSampler", _this._getDepthTexture());
  123684. };
  123685. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  123686. };
  123687. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  123688. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  123689. var renderer = this._scene.enableGeometryBufferRenderer();
  123690. return renderer.getGBuffer().textures[0];
  123691. }
  123692. return this._scene.enableDepthRenderer().getDepthMap();
  123693. };
  123694. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  123695. for (var i = 0; i < this._cameras.length; i++) {
  123696. var camera = this._cameras[i];
  123697. if (this.originalPostProcess) {
  123698. this.originalPostProcess.dispose(camera);
  123699. }
  123700. if (this.downSampleX4PostProcess) {
  123701. this.downSampleX4PostProcess.dispose(camera);
  123702. }
  123703. if (this.brightPassPostProcess) {
  123704. this.brightPassPostProcess.dispose(camera);
  123705. }
  123706. if (this.textureAdderPostProcess) {
  123707. this.textureAdderPostProcess.dispose(camera);
  123708. }
  123709. if (this.textureAdderFinalPostProcess) {
  123710. this.textureAdderFinalPostProcess.dispose(camera);
  123711. }
  123712. if (this.volumetricLightPostProcess) {
  123713. this.volumetricLightPostProcess.dispose(camera);
  123714. }
  123715. if (this.volumetricLightSmoothXPostProcess) {
  123716. this.volumetricLightSmoothXPostProcess.dispose(camera);
  123717. }
  123718. if (this.volumetricLightSmoothYPostProcess) {
  123719. this.volumetricLightSmoothYPostProcess.dispose(camera);
  123720. }
  123721. if (this.volumetricLightMergePostProces) {
  123722. this.volumetricLightMergePostProces.dispose(camera);
  123723. }
  123724. if (this.volumetricLightFinalPostProcess) {
  123725. this.volumetricLightFinalPostProcess.dispose(camera);
  123726. }
  123727. if (this.lensFlarePostProcess) {
  123728. this.lensFlarePostProcess.dispose(camera);
  123729. }
  123730. if (this.lensFlareComposePostProcess) {
  123731. this.lensFlareComposePostProcess.dispose(camera);
  123732. }
  123733. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  123734. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  123735. }
  123736. if (this.luminancePostProcess) {
  123737. this.luminancePostProcess.dispose(camera);
  123738. }
  123739. if (this.hdrPostProcess) {
  123740. this.hdrPostProcess.dispose(camera);
  123741. }
  123742. if (this.hdrFinalPostProcess) {
  123743. this.hdrFinalPostProcess.dispose(camera);
  123744. }
  123745. if (this.depthOfFieldPostProcess) {
  123746. this.depthOfFieldPostProcess.dispose(camera);
  123747. }
  123748. if (this.motionBlurPostProcess) {
  123749. this.motionBlurPostProcess.dispose(camera);
  123750. }
  123751. if (this.fxaaPostProcess) {
  123752. this.fxaaPostProcess.dispose(camera);
  123753. }
  123754. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  123755. this.blurHPostProcesses[j].dispose(camera);
  123756. }
  123757. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  123758. this.blurVPostProcesses[j].dispose(camera);
  123759. }
  123760. }
  123761. this.originalPostProcess = null;
  123762. this.downSampleX4PostProcess = null;
  123763. this.brightPassPostProcess = null;
  123764. this.textureAdderPostProcess = null;
  123765. this.textureAdderFinalPostProcess = null;
  123766. this.volumetricLightPostProcess = null;
  123767. this.volumetricLightSmoothXPostProcess = null;
  123768. this.volumetricLightSmoothYPostProcess = null;
  123769. this.volumetricLightMergePostProces = null;
  123770. this.volumetricLightFinalPostProcess = null;
  123771. this.lensFlarePostProcess = null;
  123772. this.lensFlareComposePostProcess = null;
  123773. this.luminancePostProcess = null;
  123774. this.hdrPostProcess = null;
  123775. this.hdrFinalPostProcess = null;
  123776. this.depthOfFieldPostProcess = null;
  123777. this.motionBlurPostProcess = null;
  123778. this.fxaaPostProcess = null;
  123779. this.luminanceDownSamplePostProcesses = [];
  123780. this.blurHPostProcesses = [];
  123781. this.blurVPostProcesses = [];
  123782. };
  123783. /**
  123784. * Dispose of the pipeline and stop all post processes
  123785. */
  123786. StandardRenderingPipeline.prototype.dispose = function () {
  123787. this._disposePostProcesses();
  123788. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  123789. _super.prototype.dispose.call(this);
  123790. };
  123791. /**
  123792. * Serialize the rendering pipeline (Used when exporting)
  123793. * @returns the serialized object
  123794. */
  123795. StandardRenderingPipeline.prototype.serialize = function () {
  123796. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  123797. if (this.sourceLight) {
  123798. serializationObject.sourceLightId = this.sourceLight.id;
  123799. }
  123800. serializationObject.customType = "StandardRenderingPipeline";
  123801. return serializationObject;
  123802. };
  123803. /**
  123804. * Parse the serialized pipeline
  123805. * @param source Source pipeline.
  123806. * @param scene The scene to load the pipeline to.
  123807. * @param rootUrl The URL of the serialized pipeline.
  123808. * @returns An instantiated pipeline from the serialized object.
  123809. */
  123810. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  123811. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  123812. if (source.sourceLightId) {
  123813. p.sourceLight = scene.getLightByID(source.sourceLightId);
  123814. }
  123815. return p;
  123816. };
  123817. /**
  123818. * Luminance steps
  123819. */
  123820. StandardRenderingPipeline.LuminanceSteps = 6;
  123821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123823. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  123824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123826. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  123827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123829. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  123830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123832. ], StandardRenderingPipeline.prototype, "exposure", null);
  123833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  123835. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  123836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123838. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  123839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123841. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  123842. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123843. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123844. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  123845. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123847. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  123848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123850. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  123851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123853. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  123854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123856. ], StandardRenderingPipeline.prototype, "hdrAutoExposure", null);
  123857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  123859. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  123860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123862. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  123863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123865. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  123866. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123867. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123868. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  123869. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123871. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  123872. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  123874. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  123875. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  123877. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  123878. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123879. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123880. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  123881. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123882. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123883. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  123884. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123885. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123886. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  123887. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123888. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123889. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  123890. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123891. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123892. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  123893. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123894. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123895. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  123896. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123897. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123898. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  123899. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123900. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123901. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  123902. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123903. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123904. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  123905. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123906. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123907. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  123908. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123909. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123910. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  123911. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123912. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123913. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  123914. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123915. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123916. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  123917. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123918. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123919. ], StandardRenderingPipeline.prototype, "samples", null);
  123920. return StandardRenderingPipeline;
  123921. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  123922. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  123923. /***/ }),
  123924. /***/ "./PostProcesses/RenderPipeline/index.ts":
  123925. /*!***********************************************!*\
  123926. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  123927. \***********************************************/
  123928. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  123929. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123930. "use strict";
  123931. __webpack_require__.r(__webpack_exports__);
  123932. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  123933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  123934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  123935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  123936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  123937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  123938. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  123939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  123940. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  123941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  123942. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  123943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  123944. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  123945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  123946. /***/ }),
  123947. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  123948. /*!*****************************************************************!*\
  123949. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  123950. \*****************************************************************/
  123951. /*! exports provided: PostProcessRenderEffect */
  123952. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123953. "use strict";
  123954. __webpack_require__.r(__webpack_exports__);
  123955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  123956. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  123957. /**
  123958. * This represents a set of one or more post processes in Babylon.
  123959. * A post process can be used to apply a shader to a texture after it is rendered.
  123960. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123961. */
  123962. var PostProcessRenderEffect = /** @class */ (function () {
  123963. /**
  123964. * Instantiates a post process render effect.
  123965. * A post process can be used to apply a shader to a texture after it is rendered.
  123966. * @param engine The engine the effect is tied to
  123967. * @param name The name of the effect
  123968. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  123969. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  123970. */
  123971. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  123972. this._name = name;
  123973. this._singleInstance = singleInstance || true;
  123974. this._getPostProcesses = getPostProcesses;
  123975. this._cameras = {};
  123976. this._indicesForCamera = {};
  123977. this._postProcesses = {};
  123978. }
  123979. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  123980. /**
  123981. * Checks if all the post processes in the effect are supported.
  123982. */
  123983. get: function () {
  123984. for (var index in this._postProcesses) {
  123985. if (this._postProcesses.hasOwnProperty(index)) {
  123986. var pps = this._postProcesses[index];
  123987. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  123988. if (!pps[ppIndex].isSupported) {
  123989. return false;
  123990. }
  123991. }
  123992. }
  123993. }
  123994. return true;
  123995. },
  123996. enumerable: true,
  123997. configurable: true
  123998. });
  123999. /**
  124000. * Updates the current state of the effect
  124001. * @hidden
  124002. */
  124003. PostProcessRenderEffect.prototype._update = function () {
  124004. };
  124005. /**
  124006. * Attaches the effect on cameras
  124007. * @param cameras The camera to attach to.
  124008. * @hidden
  124009. */
  124010. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  124011. var _this = this;
  124012. var cameraKey;
  124013. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  124014. if (!cams) {
  124015. return;
  124016. }
  124017. for (var i = 0; i < cams.length; i++) {
  124018. var camera = cams[i];
  124019. var cameraName = camera.name;
  124020. if (this._singleInstance) {
  124021. cameraKey = 0;
  124022. }
  124023. else {
  124024. cameraKey = cameraName;
  124025. }
  124026. if (!this._postProcesses[cameraKey]) {
  124027. var postProcess = this._getPostProcesses();
  124028. if (postProcess) {
  124029. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  124030. }
  124031. }
  124032. if (!this._indicesForCamera[cameraName]) {
  124033. this._indicesForCamera[cameraName] = [];
  124034. }
  124035. this._postProcesses[cameraKey].forEach(function (postProcess) {
  124036. var index = camera.attachPostProcess(postProcess);
  124037. _this._indicesForCamera[cameraName].push(index);
  124038. });
  124039. if (!this._cameras[cameraName]) {
  124040. this._cameras[cameraName] = camera;
  124041. }
  124042. }
  124043. };
  124044. /**
  124045. * Detatches the effect on cameras
  124046. * @param cameras The camera to detatch from.
  124047. * @hidden
  124048. */
  124049. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  124050. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  124051. if (!cams) {
  124052. return;
  124053. }
  124054. for (var i = 0; i < cams.length; i++) {
  124055. var camera = cams[i];
  124056. var cameraName = camera.name;
  124057. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  124058. if (postProcesses) {
  124059. postProcesses.forEach(function (postProcess) {
  124060. camera.detachPostProcess(postProcess);
  124061. });
  124062. }
  124063. if (this._cameras[cameraName]) {
  124064. this._cameras[cameraName] = null;
  124065. }
  124066. }
  124067. };
  124068. /**
  124069. * Enables the effect on given cameras
  124070. * @param cameras The camera to enable.
  124071. * @hidden
  124072. */
  124073. PostProcessRenderEffect.prototype._enable = function (cameras) {
  124074. var _this = this;
  124075. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  124076. if (!cams) {
  124077. return;
  124078. }
  124079. for (var i = 0; i < cams.length; i++) {
  124080. var camera = cams[i];
  124081. var cameraName = camera.name;
  124082. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  124083. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  124084. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  124085. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  124086. });
  124087. }
  124088. }
  124089. }
  124090. };
  124091. /**
  124092. * Disables the effect on the given cameras
  124093. * @param cameras The camera to disable.
  124094. * @hidden
  124095. */
  124096. PostProcessRenderEffect.prototype._disable = function (cameras) {
  124097. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  124098. if (!cams) {
  124099. return;
  124100. }
  124101. for (var i = 0; i < cams.length; i++) {
  124102. var camera = cams[i];
  124103. var cameraName = camera.name;
  124104. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  124105. camera.detachPostProcess(postProcess);
  124106. });
  124107. }
  124108. };
  124109. /**
  124110. * Gets a list of the post processes contained in the effect.
  124111. * @param camera The camera to get the post processes on.
  124112. * @returns The list of the post processes in the effect.
  124113. */
  124114. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  124115. if (this._singleInstance) {
  124116. return this._postProcesses[0];
  124117. }
  124118. else {
  124119. if (!camera) {
  124120. return null;
  124121. }
  124122. return this._postProcesses[camera.name];
  124123. }
  124124. };
  124125. return PostProcessRenderEffect;
  124126. }());
  124127. /***/ }),
  124128. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  124129. /*!*******************************************************************!*\
  124130. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  124131. \*******************************************************************/
  124132. /*! exports provided: PostProcessRenderPipeline */
  124133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124134. "use strict";
  124135. __webpack_require__.r(__webpack_exports__);
  124136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  124137. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124138. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  124139. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  124140. /**
  124141. * PostProcessRenderPipeline
  124142. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124143. */
  124144. var PostProcessRenderPipeline = /** @class */ (function () {
  124145. /**
  124146. * Initializes a PostProcessRenderPipeline
  124147. * @param engine engine to add the pipeline to
  124148. * @param name name of the pipeline
  124149. */
  124150. function PostProcessRenderPipeline(engine, name) {
  124151. this.engine = engine;
  124152. this._name = name;
  124153. this._renderEffects = {};
  124154. this._renderEffectsForIsolatedPass = new Array();
  124155. this._cameras = [];
  124156. }
  124157. Object.defineProperty(PostProcessRenderPipeline.prototype, "name", {
  124158. /**
  124159. * Gets pipeline name
  124160. */
  124161. get: function () {
  124162. return this._name;
  124163. },
  124164. enumerable: true,
  124165. configurable: true
  124166. });
  124167. /**
  124168. * Gets the class name
  124169. * @returns "PostProcessRenderPipeline"
  124170. */
  124171. PostProcessRenderPipeline.prototype.getClassName = function () {
  124172. return "PostProcessRenderPipeline";
  124173. };
  124174. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  124175. /**
  124176. * If all the render effects in the pipeline are supported
  124177. */
  124178. get: function () {
  124179. for (var renderEffectName in this._renderEffects) {
  124180. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  124181. if (!this._renderEffects[renderEffectName].isSupported) {
  124182. return false;
  124183. }
  124184. }
  124185. }
  124186. return true;
  124187. },
  124188. enumerable: true,
  124189. configurable: true
  124190. });
  124191. /**
  124192. * Adds an effect to the pipeline
  124193. * @param renderEffect the effect to add
  124194. */
  124195. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  124196. this._renderEffects[renderEffect._name] = renderEffect;
  124197. };
  124198. // private
  124199. /** @hidden */
  124200. PostProcessRenderPipeline.prototype._rebuild = function () {
  124201. };
  124202. /** @hidden */
  124203. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  124204. var renderEffects = this._renderEffects[renderEffectName];
  124205. if (!renderEffects) {
  124206. return;
  124207. }
  124208. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  124209. };
  124210. /** @hidden */
  124211. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  124212. var renderEffects = this._renderEffects[renderEffectName];
  124213. if (!renderEffects) {
  124214. return;
  124215. }
  124216. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  124217. };
  124218. /** @hidden */
  124219. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  124220. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  124221. if (!cams) {
  124222. return;
  124223. }
  124224. var indicesToDelete = [];
  124225. var i;
  124226. for (i = 0; i < cams.length; i++) {
  124227. var camera = cams[i];
  124228. var cameraName = camera.name;
  124229. if (this._cameras.indexOf(camera) === -1) {
  124230. this._cameras[cameraName] = camera;
  124231. }
  124232. else if (unique) {
  124233. indicesToDelete.push(i);
  124234. }
  124235. }
  124236. for (i = 0; i < indicesToDelete.length; i++) {
  124237. cameras.splice(indicesToDelete[i], 1);
  124238. }
  124239. for (var renderEffectName in this._renderEffects) {
  124240. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  124241. this._renderEffects[renderEffectName]._attachCameras(cams);
  124242. }
  124243. }
  124244. };
  124245. /** @hidden */
  124246. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  124247. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  124248. if (!cams) {
  124249. return;
  124250. }
  124251. for (var renderEffectName in this._renderEffects) {
  124252. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  124253. this._renderEffects[renderEffectName]._detachCameras(cams);
  124254. }
  124255. }
  124256. for (var i = 0; i < cams.length; i++) {
  124257. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  124258. }
  124259. };
  124260. /** @hidden */
  124261. PostProcessRenderPipeline.prototype._update = function () {
  124262. for (var renderEffectName in this._renderEffects) {
  124263. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  124264. this._renderEffects[renderEffectName]._update();
  124265. }
  124266. }
  124267. for (var i = 0; i < this._cameras.length; i++) {
  124268. var cameraName = this._cameras[i].name;
  124269. if (this._renderEffectsForIsolatedPass[cameraName]) {
  124270. this._renderEffectsForIsolatedPass[cameraName]._update();
  124271. }
  124272. }
  124273. };
  124274. /** @hidden */
  124275. PostProcessRenderPipeline.prototype._reset = function () {
  124276. this._renderEffects = {};
  124277. this._renderEffectsForIsolatedPass = new Array();
  124278. };
  124279. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  124280. // 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)
  124281. var effectKeys = Object.keys(this._renderEffects);
  124282. if (this.engine.webGLVersion === 1) {
  124283. return false;
  124284. }
  124285. if (effectKeys.length > 0) {
  124286. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  124287. if (postProcesses) {
  124288. postProcesses[0].samples = sampleCount;
  124289. }
  124290. }
  124291. return true;
  124292. };
  124293. /**
  124294. * Disposes of the pipeline
  124295. */
  124296. PostProcessRenderPipeline.prototype.dispose = function () {
  124297. // Must be implemented by children
  124298. };
  124299. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124300. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  124301. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  124302. return PostProcessRenderPipeline;
  124303. }());
  124304. /***/ }),
  124305. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  124306. /*!**************************************************************************!*\
  124307. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  124308. \**************************************************************************/
  124309. /*! exports provided: PostProcessRenderPipelineManager */
  124310. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124311. "use strict";
  124312. __webpack_require__.r(__webpack_exports__);
  124313. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  124314. /**
  124315. * PostProcessRenderPipelineManager class
  124316. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124317. */
  124318. var PostProcessRenderPipelineManager = /** @class */ (function () {
  124319. /**
  124320. * Initializes a PostProcessRenderPipelineManager
  124321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124322. */
  124323. function PostProcessRenderPipelineManager() {
  124324. this._renderPipelines = {};
  124325. }
  124326. Object.defineProperty(PostProcessRenderPipelineManager.prototype, "supportedPipelines", {
  124327. /**
  124328. * Gets the list of supported render pipelines
  124329. */
  124330. get: function () {
  124331. var result = [];
  124332. for (var renderPipelineName in this._renderPipelines) {
  124333. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  124334. var pipeline = this._renderPipelines[renderPipelineName];
  124335. if (pipeline.isSupported) {
  124336. result.push(pipeline);
  124337. }
  124338. }
  124339. }
  124340. return result;
  124341. },
  124342. enumerable: true,
  124343. configurable: true
  124344. });
  124345. /**
  124346. * Adds a pipeline to the manager
  124347. * @param renderPipeline The pipeline to add
  124348. */
  124349. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  124350. this._renderPipelines[renderPipeline._name] = renderPipeline;
  124351. };
  124352. /**
  124353. * Attaches a camera to the pipeline
  124354. * @param renderPipelineName The name of the pipeline to attach to
  124355. * @param cameras the camera to attach
  124356. * @param unique if the camera can be attached multiple times to the pipeline
  124357. */
  124358. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  124359. if (unique === void 0) { unique = false; }
  124360. var renderPipeline = this._renderPipelines[renderPipelineName];
  124361. if (!renderPipeline) {
  124362. return;
  124363. }
  124364. renderPipeline._attachCameras(cameras, unique);
  124365. };
  124366. /**
  124367. * Detaches a camera from the pipeline
  124368. * @param renderPipelineName The name of the pipeline to detach from
  124369. * @param cameras the camera to detach
  124370. */
  124371. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  124372. var renderPipeline = this._renderPipelines[renderPipelineName];
  124373. if (!renderPipeline) {
  124374. return;
  124375. }
  124376. renderPipeline._detachCameras(cameras);
  124377. };
  124378. /**
  124379. * Enables an effect by name on a pipeline
  124380. * @param renderPipelineName the name of the pipeline to enable the effect in
  124381. * @param renderEffectName the name of the effect to enable
  124382. * @param cameras the cameras that the effect should be enabled on
  124383. */
  124384. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  124385. var renderPipeline = this._renderPipelines[renderPipelineName];
  124386. if (!renderPipeline) {
  124387. return;
  124388. }
  124389. renderPipeline._enableEffect(renderEffectName, cameras);
  124390. };
  124391. /**
  124392. * Disables an effect by name on a pipeline
  124393. * @param renderPipelineName the name of the pipeline to disable the effect in
  124394. * @param renderEffectName the name of the effect to disable
  124395. * @param cameras the cameras that the effect should be disabled on
  124396. */
  124397. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  124398. var renderPipeline = this._renderPipelines[renderPipelineName];
  124399. if (!renderPipeline) {
  124400. return;
  124401. }
  124402. renderPipeline._disableEffect(renderEffectName, cameras);
  124403. };
  124404. /**
  124405. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  124406. */
  124407. PostProcessRenderPipelineManager.prototype.update = function () {
  124408. for (var renderPipelineName in this._renderPipelines) {
  124409. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  124410. var pipeline = this._renderPipelines[renderPipelineName];
  124411. if (!pipeline.isSupported) {
  124412. pipeline.dispose();
  124413. delete this._renderPipelines[renderPipelineName];
  124414. }
  124415. else {
  124416. pipeline._update();
  124417. }
  124418. }
  124419. }
  124420. };
  124421. /** @hidden */
  124422. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  124423. for (var renderPipelineName in this._renderPipelines) {
  124424. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  124425. var pipeline = this._renderPipelines[renderPipelineName];
  124426. pipeline._rebuild();
  124427. }
  124428. }
  124429. };
  124430. /**
  124431. * Disposes of the manager and pipelines
  124432. */
  124433. PostProcessRenderPipelineManager.prototype.dispose = function () {
  124434. for (var renderPipelineName in this._renderPipelines) {
  124435. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  124436. var pipeline = this._renderPipelines[renderPipelineName];
  124437. pipeline.dispose();
  124438. }
  124439. }
  124440. };
  124441. return PostProcessRenderPipelineManager;
  124442. }());
  124443. /***/ }),
  124444. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  124445. /*!****************************************************************************************!*\
  124446. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  124447. \****************************************************************************************/
  124448. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  124449. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124450. "use strict";
  124451. __webpack_require__.r(__webpack_exports__);
  124452. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  124453. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  124454. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  124455. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  124456. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  124457. get: function () {
  124458. if (!this._postProcessRenderPipelineManager) {
  124459. // Register the G Buffer component to the scene.
  124460. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  124461. if (!component) {
  124462. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  124463. this._addComponent(component);
  124464. }
  124465. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  124466. }
  124467. return this._postProcessRenderPipelineManager;
  124468. },
  124469. enumerable: true,
  124470. configurable: true
  124471. });
  124472. /**
  124473. * Defines the Render Pipeline scene component responsible to rendering pipelines
  124474. */
  124475. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  124476. /**
  124477. * Creates a new instance of the component for the given scene
  124478. * @param scene Defines the scene to register the component in
  124479. */
  124480. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  124481. /**
  124482. * The component name helpfull to identify the component in the list of scene components.
  124483. */
  124484. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  124485. this.scene = scene;
  124486. }
  124487. /**
  124488. * Registers the component in a given scene
  124489. */
  124490. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  124491. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  124492. };
  124493. /**
  124494. * Rebuilds the elements related to this component in case of
  124495. * context lost for instance.
  124496. */
  124497. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  124498. if (this.scene._postProcessRenderPipelineManager) {
  124499. this.scene._postProcessRenderPipelineManager._rebuild();
  124500. }
  124501. };
  124502. /**
  124503. * Disposes the component and the associated ressources
  124504. */
  124505. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  124506. if (this.scene._postProcessRenderPipelineManager) {
  124507. this.scene._postProcessRenderPipelineManager.dispose();
  124508. }
  124509. };
  124510. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  124511. if (this.scene._postProcessRenderPipelineManager) {
  124512. this.scene._postProcessRenderPipelineManager.update();
  124513. }
  124514. };
  124515. return PostProcessRenderPipelineManagerSceneComponent;
  124516. }());
  124517. /***/ }),
  124518. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  124519. /*!**********************************************!*\
  124520. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  124521. \**********************************************/
  124522. /*! exports provided: AnaglyphPostProcess */
  124523. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124524. "use strict";
  124525. __webpack_require__.r(__webpack_exports__);
  124526. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  124527. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124528. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124529. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  124530. /**
  124531. * Postprocess used to generate anaglyphic rendering
  124532. */
  124533. var AnaglyphPostProcess = /** @class */ (function (_super) {
  124534. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  124535. /**
  124536. * Creates a new AnaglyphPostProcess
  124537. * @param name defines postprocess name
  124538. * @param options defines creation options or target ratio scale
  124539. * @param rigCameras defines cameras using this postprocess
  124540. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  124541. * @param engine defines hosting engine
  124542. * @param reusable defines if the postprocess will be reused multiple times per frame
  124543. */
  124544. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  124545. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  124546. _this._passedProcess = rigCameras[0]._rigPostProcess;
  124547. _this.onApplyObservable.add(function (effect) {
  124548. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  124549. });
  124550. return _this;
  124551. }
  124552. return AnaglyphPostProcess;
  124553. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  124554. /***/ }),
  124555. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  124556. /*!***************************************************!*\
  124557. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  124558. \***************************************************/
  124559. /*! exports provided: BlackAndWhitePostProcess */
  124560. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124561. "use strict";
  124562. __webpack_require__.r(__webpack_exports__);
  124563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  124564. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124565. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124566. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  124567. /**
  124568. * Post process used to render in black and white
  124569. */
  124570. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  124571. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  124572. /**
  124573. * Creates a black and white post process
  124574. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  124575. * @param name The name of the effect.
  124576. * @param options The required width/height ratio to downsize to before computing the render pass.
  124577. * @param camera The camera to apply the render pass to.
  124578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124579. * @param engine The engine which the post process will be applied. (default: current engine)
  124580. * @param reusable If the post process can be reused on the same frame. (default: false)
  124581. */
  124582. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  124583. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  124584. /**
  124585. * Linear about to convert he result to black and white (default: 1)
  124586. */
  124587. _this.degree = 1;
  124588. _this.onApplyObservable.add(function (effect) {
  124589. effect.setFloat("degree", _this.degree);
  124590. });
  124591. return _this;
  124592. }
  124593. return BlackAndWhitePostProcess;
  124594. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  124595. /***/ }),
  124596. /***/ "./PostProcesses/bloomEffect.ts":
  124597. /*!**************************************!*\
  124598. !*** ./PostProcesses/bloomEffect.ts ***!
  124599. \**************************************/
  124600. /*! exports provided: BloomEffect */
  124601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124602. "use strict";
  124603. __webpack_require__.r(__webpack_exports__);
  124604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  124605. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124606. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  124607. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  124608. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  124609. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  124610. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124611. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  124612. /**
  124613. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  124614. */
  124615. var BloomEffect = /** @class */ (function (_super) {
  124616. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  124617. /**
  124618. * Creates a new instance of @see BloomEffect
  124619. * @param scene The scene the effect belongs to.
  124620. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  124621. * @param bloomKernel The size of the kernel to be used when applying the blur.
  124622. * @param bloomWeight The the strength of bloom.
  124623. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124624. * @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)
  124625. */
  124626. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  124627. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  124628. if (blockCompilation === void 0) { blockCompilation = false; }
  124629. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  124630. return _this._effects;
  124631. }, true) || this;
  124632. _this.bloomScale = bloomScale;
  124633. /**
  124634. * @hidden Internal
  124635. */
  124636. _this._effects = [];
  124637. _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);
  124638. _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);
  124639. _this._blurX.alwaysForcePOT = true;
  124640. _this._blurX.autoClear = false;
  124641. _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);
  124642. _this._blurY.alwaysForcePOT = true;
  124643. _this._blurY.autoClear = false;
  124644. _this.kernel = bloomKernel;
  124645. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  124646. _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);
  124647. _this._merge.autoClear = false;
  124648. _this._effects.push(_this._merge);
  124649. return _this;
  124650. }
  124651. Object.defineProperty(BloomEffect.prototype, "threshold", {
  124652. /**
  124653. * The luminance threshold to find bright areas of the image to bloom.
  124654. */
  124655. get: function () {
  124656. return this._downscale.threshold;
  124657. },
  124658. set: function (value) {
  124659. this._downscale.threshold = value;
  124660. },
  124661. enumerable: true,
  124662. configurable: true
  124663. });
  124664. Object.defineProperty(BloomEffect.prototype, "weight", {
  124665. /**
  124666. * The strength of the bloom.
  124667. */
  124668. get: function () {
  124669. return this._merge.weight;
  124670. },
  124671. set: function (value) {
  124672. this._merge.weight = value;
  124673. },
  124674. enumerable: true,
  124675. configurable: true
  124676. });
  124677. Object.defineProperty(BloomEffect.prototype, "kernel", {
  124678. /**
  124679. * Specifies the size of the bloom blur kernel, relative to the final output size
  124680. */
  124681. get: function () {
  124682. return this._blurX.kernel / this.bloomScale;
  124683. },
  124684. set: function (value) {
  124685. this._blurX.kernel = value * this.bloomScale;
  124686. this._blurY.kernel = value * this.bloomScale;
  124687. },
  124688. enumerable: true,
  124689. configurable: true
  124690. });
  124691. /**
  124692. * Disposes each of the internal effects for a given camera.
  124693. * @param camera The camera to dispose the effect on.
  124694. */
  124695. BloomEffect.prototype.disposeEffects = function (camera) {
  124696. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  124697. this._effects[effectIndex].dispose(camera);
  124698. }
  124699. };
  124700. /**
  124701. * @hidden Internal
  124702. */
  124703. BloomEffect.prototype._updateEffects = function () {
  124704. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  124705. this._effects[effectIndex].updateEffect();
  124706. }
  124707. };
  124708. /**
  124709. * Internal
  124710. * @returns if all the contained post processes are ready.
  124711. * @hidden
  124712. */
  124713. BloomEffect.prototype._isReady = function () {
  124714. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  124715. if (!this._effects[effectIndex].isReady()) {
  124716. return false;
  124717. }
  124718. }
  124719. return true;
  124720. };
  124721. return BloomEffect;
  124722. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  124723. /***/ }),
  124724. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  124725. /*!************************************************!*\
  124726. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  124727. \************************************************/
  124728. /*! exports provided: BloomMergePostProcess */
  124729. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124730. "use strict";
  124731. __webpack_require__.r(__webpack_exports__);
  124732. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  124733. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124734. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124735. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124736. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  124737. /**
  124738. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124739. */
  124740. var BloomMergePostProcess = /** @class */ (function (_super) {
  124741. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  124742. /**
  124743. * Creates a new instance of @see BloomMergePostProcess
  124744. * @param name The name of the effect.
  124745. * @param originalFromInput Post process which's input will be used for the merge.
  124746. * @param blurred Blurred highlights post process which's output will be used.
  124747. * @param weight Weight of the bloom to be added to the original input.
  124748. * @param options The required width/height ratio to downsize to before computing the render pass.
  124749. * @param camera The camera to apply the render pass to.
  124750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124751. * @param engine The engine which the post process will be applied. (default: current engine)
  124752. * @param reusable If the post process can be reused on the same frame. (default: false)
  124753. * @param textureType Type of textures used when performing the post process. (default: 0)
  124754. * @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)
  124755. */
  124756. function BloomMergePostProcess(name, originalFromInput, blurred,
  124757. /** Weight of the bloom to be added to the original input. */
  124758. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  124759. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124760. if (blockCompilation === void 0) { blockCompilation = false; }
  124761. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  124762. _this.weight = weight;
  124763. _this.onApplyObservable.add(function (effect) {
  124764. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  124765. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  124766. effect.setFloat("bloomWeight", _this.weight);
  124767. });
  124768. if (!blockCompilation) {
  124769. _this.updateEffect();
  124770. }
  124771. return _this;
  124772. }
  124773. return BloomMergePostProcess;
  124774. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  124775. /***/ }),
  124776. /***/ "./PostProcesses/blurPostProcess.ts":
  124777. /*!******************************************!*\
  124778. !*** ./PostProcesses/blurPostProcess.ts ***!
  124779. \******************************************/
  124780. /*! exports provided: BlurPostProcess */
  124781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124782. "use strict";
  124783. __webpack_require__.r(__webpack_exports__);
  124784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  124785. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124786. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124787. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  124788. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124789. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  124790. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  124791. /**
  124792. * The Blur Post Process which blurs an image based on a kernel and direction.
  124793. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  124794. */
  124795. var BlurPostProcess = /** @class */ (function (_super) {
  124796. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  124797. /**
  124798. * Creates a new instance BlurPostProcess
  124799. * @param name The name of the effect.
  124800. * @param direction The direction in which to blur the image.
  124801. * @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.
  124802. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  124803. * @param camera The camera to apply the render pass to.
  124804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124805. * @param engine The engine which the post process will be applied. (default: current engine)
  124806. * @param reusable If the post process can be reused on the same frame. (default: false)
  124807. * @param textureType Type of textures used when performing the post process. (default: 0)
  124808. * @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)
  124809. */
  124810. function BlurPostProcess(name,
  124811. /** The direction in which to blur the image. */
  124812. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  124813. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  124814. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124815. if (defines === void 0) { defines = ""; }
  124816. if (blockCompilation === void 0) { blockCompilation = false; }
  124817. 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;
  124818. _this.direction = direction;
  124819. _this.blockCompilation = blockCompilation;
  124820. _this._packedFloat = false;
  124821. _this._staticDefines = "";
  124822. _this._staticDefines = defines;
  124823. _this.onApplyObservable.add(function (effect) {
  124824. if (_this._outputTexture) {
  124825. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  124826. }
  124827. else {
  124828. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  124829. }
  124830. });
  124831. _this.kernel = kernel;
  124832. return _this;
  124833. }
  124834. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  124835. /**
  124836. * Gets the length in pixels of the blur sample region
  124837. */
  124838. get: function () {
  124839. return this._idealKernel;
  124840. },
  124841. /**
  124842. * Sets the length in pixels of the blur sample region
  124843. */
  124844. set: function (v) {
  124845. if (this._idealKernel === v) {
  124846. return;
  124847. }
  124848. v = Math.max(v, 1);
  124849. this._idealKernel = v;
  124850. this._kernel = this._nearestBestKernel(v);
  124851. if (!this.blockCompilation) {
  124852. this._updateParameters();
  124853. }
  124854. },
  124855. enumerable: true,
  124856. configurable: true
  124857. });
  124858. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  124859. /**
  124860. * Gets wether or not the blur is unpacking/repacking floats
  124861. */
  124862. get: function () {
  124863. return this._packedFloat;
  124864. },
  124865. /**
  124866. * Sets wether or not the blur needs to unpack/repack floats
  124867. */
  124868. set: function (v) {
  124869. if (this._packedFloat === v) {
  124870. return;
  124871. }
  124872. this._packedFloat = v;
  124873. if (!this.blockCompilation) {
  124874. this._updateParameters();
  124875. }
  124876. },
  124877. enumerable: true,
  124878. configurable: true
  124879. });
  124880. /**
  124881. * Updates the effect with the current post process compile time values and recompiles the shader.
  124882. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  124883. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  124884. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  124885. * @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
  124886. * @param onCompiled Called when the shader has been compiled.
  124887. * @param onError Called if there is an error when compiling a shader.
  124888. */
  124889. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  124890. if (defines === void 0) { defines = null; }
  124891. if (uniforms === void 0) { uniforms = null; }
  124892. if (samplers === void 0) { samplers = null; }
  124893. this._updateParameters(onCompiled, onError);
  124894. };
  124895. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  124896. // Generate sampling offsets and weights
  124897. var N = this._kernel;
  124898. var centerIndex = (N - 1) / 2;
  124899. // Generate Gaussian sampling weights over kernel
  124900. var offsets = [];
  124901. var weights = [];
  124902. var totalWeight = 0;
  124903. for (var i = 0; i < N; i++) {
  124904. var u = i / (N - 1);
  124905. var w = this._gaussianWeight(u * 2.0 - 1);
  124906. offsets[i] = (i - centerIndex);
  124907. weights[i] = w;
  124908. totalWeight += w;
  124909. }
  124910. // Normalize weights
  124911. for (var i = 0; i < weights.length; i++) {
  124912. weights[i] /= totalWeight;
  124913. }
  124914. // Optimize: combine samples to take advantage of hardware linear sampling
  124915. // Walk from left to center, combining pairs (symmetrically)
  124916. var linearSamplingWeights = [];
  124917. var linearSamplingOffsets = [];
  124918. var linearSamplingMap = [];
  124919. for (var i = 0; i <= centerIndex; i += 2) {
  124920. var j = Math.min(i + 1, Math.floor(centerIndex));
  124921. var singleCenterSample = i === j;
  124922. if (singleCenterSample) {
  124923. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  124924. }
  124925. else {
  124926. var sharedCell = j === centerIndex;
  124927. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  124928. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  124929. if (offsetLinear === 0) {
  124930. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  124931. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  124932. }
  124933. else {
  124934. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  124935. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  124936. }
  124937. }
  124938. }
  124939. for (var i = 0; i < linearSamplingMap.length; i++) {
  124940. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  124941. linearSamplingWeights[i] = linearSamplingMap[i].w;
  124942. }
  124943. // Replace with optimized
  124944. offsets = linearSamplingOffsets;
  124945. weights = linearSamplingWeights;
  124946. // Generate shaders
  124947. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  124948. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  124949. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  124950. var defines = "";
  124951. defines += this._staticDefines;
  124952. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  124953. if (this._staticDefines.indexOf("DOF") != -1) {
  124954. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  124955. varyingCount--;
  124956. }
  124957. for (var i = 0; i < varyingCount; i++) {
  124958. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  124959. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  124960. }
  124961. var depCount = 0;
  124962. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  124963. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  124964. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  124965. depCount++;
  124966. }
  124967. if (this.packedFloat) {
  124968. defines += "#define PACKEDFLOAT 1";
  124969. }
  124970. this.blockCompilation = false;
  124971. _super.prototype.updateEffect.call(this, defines, null, null, {
  124972. varyingCount: varyingCount,
  124973. depCount: depCount
  124974. }, onCompiled, onError);
  124975. };
  124976. /**
  124977. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  124978. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  124979. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  124980. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  124981. * The gaps between physical kernels are compensated for in the weighting of the samples
  124982. * @param idealKernel Ideal blur kernel.
  124983. * @return Nearest best kernel.
  124984. */
  124985. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  124986. var v = Math.round(idealKernel);
  124987. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  124988. var k = _a[_i];
  124989. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  124990. return Math.max(k, 3);
  124991. }
  124992. }
  124993. return Math.max(v, 3);
  124994. };
  124995. /**
  124996. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  124997. * @param x The point on the Gaussian distribution to sample.
  124998. * @return the value of the Gaussian function at x.
  124999. */
  125000. BlurPostProcess.prototype._gaussianWeight = function (x) {
  125001. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  125002. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  125003. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  125004. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  125005. // truncated at around 1.3% of peak strength.
  125006. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  125007. var sigma = (1 / 3);
  125008. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  125009. var exponent = -((x * x) / (2.0 * sigma * sigma));
  125010. var weight = (1.0 / denominator) * Math.exp(exponent);
  125011. return weight;
  125012. };
  125013. /**
  125014. * Generates a string that can be used as a floating point number in GLSL.
  125015. * @param x Value to print.
  125016. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  125017. * @return GLSL float string.
  125018. */
  125019. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  125020. if (decimalFigures === void 0) { decimalFigures = 8; }
  125021. return x.toFixed(decimalFigures).replace(/0+$/, '');
  125022. };
  125023. return BlurPostProcess;
  125024. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125025. /***/ }),
  125026. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  125027. /*!*********************************************************!*\
  125028. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  125029. \*********************************************************/
  125030. /*! exports provided: ChromaticAberrationPostProcess */
  125031. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125032. "use strict";
  125033. __webpack_require__.r(__webpack_exports__);
  125034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  125035. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125036. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125037. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125038. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125039. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  125040. /**
  125041. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125042. */
  125043. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  125044. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  125045. /**
  125046. * Creates a new instance ChromaticAberrationPostProcess
  125047. * @param name The name of the effect.
  125048. * @param screenWidth The width of the screen to apply the effect on.
  125049. * @param screenHeight The height of the screen to apply the effect on.
  125050. * @param options The required width/height ratio to downsize to before computing the render pass.
  125051. * @param camera The camera to apply the render pass to.
  125052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125053. * @param engine The engine which the post process will be applied. (default: current engine)
  125054. * @param reusable If the post process can be reused on the same frame. (default: false)
  125055. * @param textureType Type of textures used when performing the post process. (default: 0)
  125056. * @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)
  125057. */
  125058. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  125059. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125060. if (blockCompilation === void 0) { blockCompilation = false; }
  125061. 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;
  125062. /**
  125063. * The amount of seperation of rgb channels (default: 30)
  125064. */
  125065. _this.aberrationAmount = 30;
  125066. /**
  125067. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125068. */
  125069. _this.radialIntensity = 0;
  125070. /**
  125071. * 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))
  125072. */
  125073. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  125074. /**
  125075. * 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))
  125076. */
  125077. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  125078. _this.onApplyObservable.add(function (effect) {
  125079. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  125080. effect.setFloat('screen_width', screenWidth);
  125081. effect.setFloat('screen_height', screenHeight);
  125082. effect.setFloat('radialIntensity', _this.radialIntensity);
  125083. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  125084. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  125085. });
  125086. return _this;
  125087. }
  125088. return ChromaticAberrationPostProcess;
  125089. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  125090. /***/ }),
  125091. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  125092. /*!*******************************************************!*\
  125093. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  125094. \*******************************************************/
  125095. /*! exports provided: CircleOfConfusionPostProcess */
  125096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125097. "use strict";
  125098. __webpack_require__.r(__webpack_exports__);
  125099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  125100. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125101. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125102. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  125103. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125104. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  125105. /**
  125106. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125107. */
  125108. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  125109. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  125110. /**
  125111. * Creates a new instance CircleOfConfusionPostProcess
  125112. * @param name The name of the effect.
  125113. * @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.
  125114. * @param options The required width/height ratio to downsize to before computing the render pass.
  125115. * @param camera The camera to apply the render pass to.
  125116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125117. * @param engine The engine which the post process will be applied. (default: current engine)
  125118. * @param reusable If the post process can be reused on the same frame. (default: false)
  125119. * @param textureType Type of textures used when performing the post process. (default: 0)
  125120. * @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)
  125121. */
  125122. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  125123. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125124. if (blockCompilation === void 0) { blockCompilation = false; }
  125125. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  125126. /**
  125127. * 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.
  125128. */
  125129. _this.lensSize = 50;
  125130. /**
  125131. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125132. */
  125133. _this.fStop = 1.4;
  125134. /**
  125135. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125136. */
  125137. _this.focusDistance = 2000;
  125138. /**
  125139. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125140. */
  125141. _this.focalLength = 50;
  125142. _this._depthTexture = null;
  125143. _this._depthTexture = depthTexture;
  125144. _this.onApplyObservable.add(function (effect) {
  125145. if (!_this._depthTexture) {
  125146. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  125147. return;
  125148. }
  125149. effect.setTexture("depthSampler", _this._depthTexture);
  125150. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  125151. var aperture = _this.lensSize / _this.fStop;
  125152. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  125153. effect.setFloat('focusDistance', _this.focusDistance);
  125154. effect.setFloat('cocPrecalculation', cocPrecalculation);
  125155. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  125156. });
  125157. return _this;
  125158. }
  125159. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  125160. /**
  125161. * 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.
  125162. */
  125163. set: function (value) {
  125164. this._depthTexture = value;
  125165. },
  125166. enumerable: true,
  125167. configurable: true
  125168. });
  125169. return CircleOfConfusionPostProcess;
  125170. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125171. /***/ }),
  125172. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  125173. /*!*****************************************************!*\
  125174. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  125175. \*****************************************************/
  125176. /*! exports provided: ColorCorrectionPostProcess */
  125177. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125178. "use strict";
  125179. __webpack_require__.r(__webpack_exports__);
  125180. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  125181. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125182. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125183. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125184. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  125185. /**
  125186. *
  125187. * This post-process allows the modification of rendered colors by using
  125188. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125189. *
  125190. * The object needs to be provided an url to a texture containing the color
  125191. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125192. * Use an image editing software to tweak the LUT to match your needs.
  125193. *
  125194. * For an example of a color LUT, see here:
  125195. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125196. * For explanations on color grading, see here:
  125197. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125198. *
  125199. */
  125200. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  125201. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  125202. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  125203. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  125204. _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);
  125205. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  125206. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  125207. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  125208. _this.onApply = function (effect) {
  125209. effect.setTexture("colorTable", _this._colorTableTexture);
  125210. };
  125211. return _this;
  125212. }
  125213. return ColorCorrectionPostProcess;
  125214. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125215. /***/ }),
  125216. /***/ "./PostProcesses/convolutionPostProcess.ts":
  125217. /*!*************************************************!*\
  125218. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  125219. \*************************************************/
  125220. /*! exports provided: ConvolutionPostProcess */
  125221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125222. "use strict";
  125223. __webpack_require__.r(__webpack_exports__);
  125224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  125225. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125226. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125227. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125228. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  125229. /**
  125230. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125231. * input texture to perform effects such as edge detection or sharpening
  125232. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125233. */
  125234. var ConvolutionPostProcess = /** @class */ (function (_super) {
  125235. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  125236. /**
  125237. * Creates a new instance ConvolutionPostProcess
  125238. * @param name The name of the effect.
  125239. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  125240. * @param options The required width/height ratio to downsize to before computing the render pass.
  125241. * @param camera The camera to apply the render pass to.
  125242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125243. * @param engine The engine which the post process will be applied. (default: current engine)
  125244. * @param reusable If the post process can be reused on the same frame. (default: false)
  125245. * @param textureType Type of textures used when performing the post process. (default: 0)
  125246. */
  125247. function ConvolutionPostProcess(name,
  125248. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  125249. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  125250. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125251. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  125252. _this.kernel = kernel;
  125253. _this.onApply = function (effect) {
  125254. effect.setFloat2("screenSize", _this.width, _this.height);
  125255. effect.setArray("kernel", _this.kernel);
  125256. };
  125257. return _this;
  125258. }
  125259. // Statics
  125260. /**
  125261. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125262. */
  125263. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  125264. /**
  125265. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125266. */
  125267. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  125268. /**
  125269. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125270. */
  125271. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  125272. /**
  125273. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125274. */
  125275. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  125276. /**
  125277. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125278. */
  125279. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  125280. /**
  125281. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125282. */
  125283. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  125284. return ConvolutionPostProcess;
  125285. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125286. /***/ }),
  125287. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  125288. /*!******************************************************!*\
  125289. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  125290. \******************************************************/
  125291. /*! exports provided: DepthOfFieldBlurPostProcess */
  125292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125293. "use strict";
  125294. __webpack_require__.r(__webpack_exports__);
  125295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  125296. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125297. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125298. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  125299. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125300. /**
  125301. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  125302. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  125303. * based on samples that have a large difference in distance than the center pixel.
  125304. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  125305. */
  125306. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  125307. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  125308. /**
  125309. * Creates a new instance CircleOfConfusionPostProcess
  125310. * @param name The name of the effect.
  125311. * @param scene The scene the effect belongs to.
  125312. * @param direction The direction the blur should be applied.
  125313. * @param kernel The size of the kernel used to blur.
  125314. * @param options The required width/height ratio to downsize to before computing the render pass.
  125315. * @param camera The camera to apply the render pass to.
  125316. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  125317. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  125318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125319. * @param engine The engine which the post process will be applied. (default: current engine)
  125320. * @param reusable If the post process can be reused on the same frame. (default: false)
  125321. * @param textureType Type of textures used when performing the post process. (default: 0)
  125322. * @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)
  125323. */
  125324. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  125325. if (imageToBlur === void 0) { imageToBlur = null; }
  125326. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  125327. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125328. if (blockCompilation === void 0) { blockCompilation = false; }
  125329. 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;
  125330. _this.direction = direction;
  125331. _this.onApplyObservable.add(function (effect) {
  125332. if (imageToBlur != null) {
  125333. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  125334. }
  125335. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  125336. if (scene.activeCamera) {
  125337. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  125338. }
  125339. });
  125340. return _this;
  125341. }
  125342. return DepthOfFieldBlurPostProcess;
  125343. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  125344. /***/ }),
  125345. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  125346. /*!*********************************************!*\
  125347. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  125348. \*********************************************/
  125349. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  125350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125351. "use strict";
  125352. __webpack_require__.r(__webpack_exports__);
  125353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  125354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  125355. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125356. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125357. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125358. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  125359. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  125360. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  125361. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  125362. /**
  125363. * Specifies the level of max blur that should be applied when using the depth of field effect
  125364. */
  125365. var DepthOfFieldEffectBlurLevel;
  125366. (function (DepthOfFieldEffectBlurLevel) {
  125367. /**
  125368. * Subtle blur
  125369. */
  125370. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  125371. /**
  125372. * Medium blur
  125373. */
  125374. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  125375. /**
  125376. * Large blur
  125377. */
  125378. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  125379. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  125380. /**
  125381. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  125382. */
  125383. var DepthOfFieldEffect = /** @class */ (function (_super) {
  125384. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  125385. /**
  125386. * Creates a new instance DepthOfFieldEffect
  125387. * @param scene The scene the effect belongs to.
  125388. * @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.
  125389. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125390. * @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)
  125391. */
  125392. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  125393. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  125394. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  125395. if (blockCompilation === void 0) { blockCompilation = false; }
  125396. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  125397. return _this._effects;
  125398. }, true) || this;
  125399. /**
  125400. * @hidden Internal post processes in depth of field effect
  125401. */
  125402. _this._effects = [];
  125403. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  125404. _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);
  125405. // 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)
  125406. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  125407. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  125408. _this._depthOfFieldBlurY = [];
  125409. _this._depthOfFieldBlurX = [];
  125410. var blurCount = 1;
  125411. var kernelSize = 15;
  125412. switch (blurLevel) {
  125413. case DepthOfFieldEffectBlurLevel.High: {
  125414. blurCount = 3;
  125415. kernelSize = 51;
  125416. break;
  125417. }
  125418. case DepthOfFieldEffectBlurLevel.Medium: {
  125419. blurCount = 2;
  125420. kernelSize = 31;
  125421. break;
  125422. }
  125423. default: {
  125424. kernelSize = 15;
  125425. blurCount = 1;
  125426. break;
  125427. }
  125428. }
  125429. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  125430. var ratio = 1.0;
  125431. for (var i = 0; i < blurCount; i++) {
  125432. 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);
  125433. blurY.autoClear = false;
  125434. ratio = 0.75 / Math.pow(2, i);
  125435. 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);
  125436. blurX.autoClear = false;
  125437. _this._depthOfFieldBlurY.push(blurY);
  125438. _this._depthOfFieldBlurX.push(blurX);
  125439. }
  125440. // Set all post processes on the effect.
  125441. _this._effects = [_this._circleOfConfusion];
  125442. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  125443. _this._effects.push(_this._depthOfFieldBlurY[i]);
  125444. _this._effects.push(_this._depthOfFieldBlurX[i]);
  125445. }
  125446. // Merge blurred images with original image based on circleOfConfusion
  125447. _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);
  125448. _this._dofMerge.autoClear = false;
  125449. _this._effects.push(_this._dofMerge);
  125450. return _this;
  125451. }
  125452. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  125453. get: function () {
  125454. return this._circleOfConfusion.focalLength;
  125455. },
  125456. /**
  125457. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  125458. */
  125459. set: function (value) {
  125460. this._circleOfConfusion.focalLength = value;
  125461. },
  125462. enumerable: true,
  125463. configurable: true
  125464. });
  125465. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  125466. get: function () {
  125467. return this._circleOfConfusion.fStop;
  125468. },
  125469. /**
  125470. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125471. */
  125472. set: function (value) {
  125473. this._circleOfConfusion.fStop = value;
  125474. },
  125475. enumerable: true,
  125476. configurable: true
  125477. });
  125478. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  125479. get: function () {
  125480. return this._circleOfConfusion.focusDistance;
  125481. },
  125482. /**
  125483. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125484. */
  125485. set: function (value) {
  125486. this._circleOfConfusion.focusDistance = value;
  125487. },
  125488. enumerable: true,
  125489. configurable: true
  125490. });
  125491. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  125492. get: function () {
  125493. return this._circleOfConfusion.lensSize;
  125494. },
  125495. /**
  125496. * 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.
  125497. */
  125498. set: function (value) {
  125499. this._circleOfConfusion.lensSize = value;
  125500. },
  125501. enumerable: true,
  125502. configurable: true
  125503. });
  125504. /**
  125505. * Get the current class name of the current effet
  125506. * @returns "DepthOfFieldEffect"
  125507. */
  125508. DepthOfFieldEffect.prototype.getClassName = function () {
  125509. return "DepthOfFieldEffect";
  125510. };
  125511. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  125512. /**
  125513. * 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.
  125514. */
  125515. set: function (value) {
  125516. this._circleOfConfusion.depthTexture = value;
  125517. },
  125518. enumerable: true,
  125519. configurable: true
  125520. });
  125521. /**
  125522. * Disposes each of the internal effects for a given camera.
  125523. * @param camera The camera to dispose the effect on.
  125524. */
  125525. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  125526. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  125527. this._effects[effectIndex].dispose(camera);
  125528. }
  125529. };
  125530. /**
  125531. * @hidden Internal
  125532. */
  125533. DepthOfFieldEffect.prototype._updateEffects = function () {
  125534. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  125535. this._effects[effectIndex].updateEffect();
  125536. }
  125537. };
  125538. /**
  125539. * Internal
  125540. * @returns if all the contained post processes are ready.
  125541. * @hidden
  125542. */
  125543. DepthOfFieldEffect.prototype._isReady = function () {
  125544. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  125545. if (!this._effects[effectIndex].isReady()) {
  125546. return false;
  125547. }
  125548. }
  125549. return true;
  125550. };
  125551. return DepthOfFieldEffect;
  125552. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  125553. /***/ }),
  125554. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  125555. /*!*******************************************************!*\
  125556. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  125557. \*******************************************************/
  125558. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  125559. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125560. "use strict";
  125561. __webpack_require__.r(__webpack_exports__);
  125562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  125563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  125564. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125565. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125566. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125567. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  125568. /**
  125569. * Options to be set when merging outputs from the default pipeline.
  125570. */
  125571. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  125572. function DepthOfFieldMergePostProcessOptions() {
  125573. }
  125574. return DepthOfFieldMergePostProcessOptions;
  125575. }());
  125576. /**
  125577. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125578. */
  125579. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  125580. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  125581. /**
  125582. * Creates a new instance of DepthOfFieldMergePostProcess
  125583. * @param name The name of the effect.
  125584. * @param originalFromInput Post process which's input will be used for the merge.
  125585. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  125586. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  125587. * @param options The required width/height ratio to downsize to before computing the render pass.
  125588. * @param camera The camera to apply the render pass to.
  125589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125590. * @param engine The engine which the post process will be applied. (default: current engine)
  125591. * @param reusable If the post process can be reused on the same frame. (default: false)
  125592. * @param textureType Type of textures used when performing the post process. (default: 0)
  125593. * @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)
  125594. */
  125595. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  125596. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125597. if (blockCompilation === void 0) { blockCompilation = false; }
  125598. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  125599. _this.blurSteps = blurSteps;
  125600. _this.onApplyObservable.add(function (effect) {
  125601. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  125602. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  125603. blurSteps.forEach(function (step, index) {
  125604. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  125605. });
  125606. });
  125607. if (!blockCompilation) {
  125608. _this.updateEffect();
  125609. }
  125610. return _this;
  125611. }
  125612. /**
  125613. * Updates the effect with the current post process compile time values and recompiles the shader.
  125614. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  125615. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  125616. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  125617. * @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
  125618. * @param onCompiled Called when the shader has been compiled.
  125619. * @param onError Called if there is an error when compiling a shader.
  125620. */
  125621. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  125622. if (defines === void 0) { defines = null; }
  125623. if (uniforms === void 0) { uniforms = null; }
  125624. if (samplers === void 0) { samplers = null; }
  125625. if (!defines) {
  125626. defines = "";
  125627. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  125628. }
  125629. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  125630. };
  125631. return DepthOfFieldMergePostProcess;
  125632. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125633. /***/ }),
  125634. /***/ "./PostProcesses/displayPassPostProcess.ts":
  125635. /*!*************************************************!*\
  125636. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  125637. \*************************************************/
  125638. /*! exports provided: DisplayPassPostProcess */
  125639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125640. "use strict";
  125641. __webpack_require__.r(__webpack_exports__);
  125642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  125643. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125644. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125645. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  125646. /**
  125647. * DisplayPassPostProcess which produces an output the same as it's input
  125648. */
  125649. var DisplayPassPostProcess = /** @class */ (function (_super) {
  125650. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  125651. /**
  125652. * Creates the DisplayPassPostProcess
  125653. * @param name The name of the effect.
  125654. * @param options The required width/height ratio to downsize to before computing the render pass.
  125655. * @param camera The camera to apply the render pass to.
  125656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125657. * @param engine The engine which the post process will be applied. (default: current engine)
  125658. * @param reusable If the post process can be reused on the same frame. (default: false)
  125659. */
  125660. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  125661. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  125662. }
  125663. return DisplayPassPostProcess;
  125664. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125665. /***/ }),
  125666. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  125667. /*!*******************************************************!*\
  125668. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  125669. \*******************************************************/
  125670. /*! exports provided: ExtractHighlightsPostProcess */
  125671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125672. "use strict";
  125673. __webpack_require__.r(__webpack_exports__);
  125674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  125675. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125676. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125677. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125678. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125679. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  125680. /**
  125681. * 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.
  125682. */
  125683. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  125684. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  125685. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  125686. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125687. if (blockCompilation === void 0) { blockCompilation = false; }
  125688. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  125689. /**
  125690. * The luminance threshold, pixels below this value will be set to black.
  125691. */
  125692. _this.threshold = 0.9;
  125693. /** @hidden */
  125694. _this._exposure = 1;
  125695. /**
  125696. * Post process which has the input texture to be used when performing highlight extraction
  125697. * @hidden
  125698. */
  125699. _this._inputPostProcess = null;
  125700. _this.onApplyObservable.add(function (effect) {
  125701. if (_this._inputPostProcess) {
  125702. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  125703. }
  125704. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  125705. effect.setFloat('exposure', _this._exposure);
  125706. });
  125707. return _this;
  125708. }
  125709. return ExtractHighlightsPostProcess;
  125710. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125711. /***/ }),
  125712. /***/ "./PostProcesses/filterPostProcess.ts":
  125713. /*!********************************************!*\
  125714. !*** ./PostProcesses/filterPostProcess.ts ***!
  125715. \********************************************/
  125716. /*! exports provided: FilterPostProcess */
  125717. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125718. "use strict";
  125719. __webpack_require__.r(__webpack_exports__);
  125720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  125721. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125722. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125723. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  125724. /**
  125725. * Applies a kernel filter to the image
  125726. */
  125727. var FilterPostProcess = /** @class */ (function (_super) {
  125728. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  125729. /**
  125730. *
  125731. * @param name The name of the effect.
  125732. * @param kernelMatrix The matrix to be applied to the image
  125733. * @param options The required width/height ratio to downsize to before computing the render pass.
  125734. * @param camera The camera to apply the render pass to.
  125735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125736. * @param engine The engine which the post process will be applied. (default: current engine)
  125737. * @param reusable If the post process can be reused on the same frame. (default: false)
  125738. */
  125739. function FilterPostProcess(name,
  125740. /** The matrix to be applied to the image */
  125741. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  125742. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  125743. _this.kernelMatrix = kernelMatrix;
  125744. _this.onApply = function (effect) {
  125745. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  125746. };
  125747. return _this;
  125748. }
  125749. return FilterPostProcess;
  125750. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125751. /***/ }),
  125752. /***/ "./PostProcesses/fxaaPostProcess.ts":
  125753. /*!******************************************!*\
  125754. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  125755. \******************************************/
  125756. /*! exports provided: FxaaPostProcess */
  125757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125758. "use strict";
  125759. __webpack_require__.r(__webpack_exports__);
  125760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  125761. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125762. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125763. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125764. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125765. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  125766. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  125767. /**
  125768. * Fxaa post process
  125769. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  125770. */
  125771. var FxaaPostProcess = /** @class */ (function (_super) {
  125772. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  125773. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  125774. if (camera === void 0) { camera = null; }
  125775. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125776. 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;
  125777. var defines = _this._getDefines();
  125778. _this.updateEffect(defines);
  125779. _this.onApplyObservable.add(function (effect) {
  125780. var texelSize = _this.texelSize;
  125781. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  125782. });
  125783. return _this;
  125784. }
  125785. FxaaPostProcess.prototype._getDefines = function () {
  125786. var engine = this.getEngine();
  125787. if (!engine) {
  125788. return null;
  125789. }
  125790. var glInfo = engine.getGlInfo();
  125791. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  125792. return "#define MALI 1\n";
  125793. }
  125794. return null;
  125795. };
  125796. return FxaaPostProcess;
  125797. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  125798. /***/ }),
  125799. /***/ "./PostProcesses/grainPostProcess.ts":
  125800. /*!*******************************************!*\
  125801. !*** ./PostProcesses/grainPostProcess.ts ***!
  125802. \*******************************************/
  125803. /*! exports provided: GrainPostProcess */
  125804. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125805. "use strict";
  125806. __webpack_require__.r(__webpack_exports__);
  125807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  125808. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125809. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125810. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125811. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  125812. /**
  125813. * The GrainPostProcess adds noise to the image at mid luminance levels
  125814. */
  125815. var GrainPostProcess = /** @class */ (function (_super) {
  125816. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  125817. /**
  125818. * Creates a new instance of @see GrainPostProcess
  125819. * @param name The name of the effect.
  125820. * @param options The required width/height ratio to downsize to before computing the render pass.
  125821. * @param camera The camera to apply the render pass to.
  125822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125823. * @param engine The engine which the post process will be applied. (default: current engine)
  125824. * @param reusable If the post process can be reused on the same frame. (default: false)
  125825. * @param textureType Type of textures used when performing the post process. (default: 0)
  125826. * @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)
  125827. */
  125828. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  125829. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125830. if (blockCompilation === void 0) { blockCompilation = false; }
  125831. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  125832. /**
  125833. * The intensity of the grain added (default: 30)
  125834. */
  125835. _this.intensity = 30;
  125836. /**
  125837. * If the grain should be randomized on every frame
  125838. */
  125839. _this.animated = false;
  125840. _this.onApplyObservable.add(function (effect) {
  125841. effect.setFloat('intensity', _this.intensity);
  125842. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  125843. });
  125844. return _this;
  125845. }
  125846. return GrainPostProcess;
  125847. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125848. /***/ }),
  125849. /***/ "./PostProcesses/highlightsPostProcess.ts":
  125850. /*!************************************************!*\
  125851. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  125852. \************************************************/
  125853. /*! exports provided: HighlightsPostProcess */
  125854. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125855. "use strict";
  125856. __webpack_require__.r(__webpack_exports__);
  125857. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  125858. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125859. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125860. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125861. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  125862. /**
  125863. * Extracts highlights from the image
  125864. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  125865. */
  125866. var HighlightsPostProcess = /** @class */ (function (_super) {
  125867. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  125868. /**
  125869. * Extracts highlights from the image
  125870. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  125871. * @param name The name of the effect.
  125872. * @param options The required width/height ratio to downsize to before computing the render pass.
  125873. * @param camera The camera to apply the render pass to.
  125874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125875. * @param engine The engine which the post process will be applied. (default: current engine)
  125876. * @param reusable If the post process can be reused on the same frame. (default: false)
  125877. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  125878. */
  125879. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  125880. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125881. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  125882. }
  125883. return HighlightsPostProcess;
  125884. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125885. /***/ }),
  125886. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  125887. /*!*****************************************************!*\
  125888. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  125889. \*****************************************************/
  125890. /*! exports provided: ImageProcessingPostProcess */
  125891. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125892. "use strict";
  125893. __webpack_require__.r(__webpack_exports__);
  125894. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  125895. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125896. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  125897. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  125898. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125899. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  125900. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125901. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  125902. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  125903. /**
  125904. * ImageProcessingPostProcess
  125905. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  125906. */
  125907. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  125908. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  125909. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  125910. if (camera === void 0) { camera = null; }
  125911. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125912. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  125913. _this._fromLinearSpace = true;
  125914. /**
  125915. * Defines cache preventing GC.
  125916. */
  125917. _this._defines = {
  125918. IMAGEPROCESSING: false,
  125919. VIGNETTE: false,
  125920. VIGNETTEBLENDMODEMULTIPLY: false,
  125921. VIGNETTEBLENDMODEOPAQUE: false,
  125922. TONEMAPPING: false,
  125923. TONEMAPPING_ACES: false,
  125924. CONTRAST: false,
  125925. COLORCURVES: false,
  125926. COLORGRADING: false,
  125927. COLORGRADING3D: false,
  125928. FROMLINEARSPACE: false,
  125929. SAMPLER3DGREENDEPTH: false,
  125930. SAMPLER3DBGRMAP: false,
  125931. IMAGEPROCESSINGPOSTPROCESS: false,
  125932. EXPOSURE: false,
  125933. };
  125934. // Setup the configuration as forced by the constructor. This would then not force the
  125935. // scene materials output in linear space and let untouched the default forward pass.
  125936. if (imageProcessingConfiguration) {
  125937. imageProcessingConfiguration.applyByPostProcess = true;
  125938. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  125939. // This will cause the shader to be compiled
  125940. _this.fromLinearSpace = false;
  125941. }
  125942. // Setup the default processing configuration to the scene.
  125943. else {
  125944. _this._attachImageProcessingConfiguration(null, true);
  125945. _this.imageProcessingConfiguration.applyByPostProcess = true;
  125946. }
  125947. _this.onApply = function (effect) {
  125948. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  125949. };
  125950. return _this;
  125951. }
  125952. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  125953. /**
  125954. * Gets the image processing configuration used either in this material.
  125955. */
  125956. get: function () {
  125957. return this._imageProcessingConfiguration;
  125958. },
  125959. /**
  125960. * Sets the Default image processing configuration used either in the this material.
  125961. *
  125962. * If sets to null, the scene one is in use.
  125963. */
  125964. set: function (value) {
  125965. this._attachImageProcessingConfiguration(value);
  125966. },
  125967. enumerable: true,
  125968. configurable: true
  125969. });
  125970. /**
  125971. * Attaches a new image processing configuration to the PBR Material.
  125972. * @param configuration
  125973. */
  125974. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  125975. var _this = this;
  125976. if (doNotBuild === void 0) { doNotBuild = false; }
  125977. if (configuration === this._imageProcessingConfiguration) {
  125978. return;
  125979. }
  125980. // Detaches observer.
  125981. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  125982. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  125983. }
  125984. // Pick the scene configuration if needed.
  125985. if (!configuration) {
  125986. var scene = null;
  125987. var engine = this.getEngine();
  125988. var camera = this.getCamera();
  125989. if (camera) {
  125990. scene = camera.getScene();
  125991. }
  125992. else if (engine && engine.scenes) {
  125993. var scenes = engine.scenes;
  125994. scene = scenes[scenes.length - 1];
  125995. }
  125996. else {
  125997. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  125998. }
  125999. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  126000. }
  126001. else {
  126002. this._imageProcessingConfiguration = configuration;
  126003. }
  126004. // Attaches observer.
  126005. if (this._imageProcessingConfiguration) {
  126006. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  126007. _this._updateParameters();
  126008. });
  126009. }
  126010. // Ensure the effect will be rebuilt.
  126011. if (!doNotBuild) {
  126012. this._updateParameters();
  126013. }
  126014. };
  126015. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  126016. /**
  126017. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  126018. */
  126019. get: function () {
  126020. return this.imageProcessingConfiguration.colorCurves;
  126021. },
  126022. /**
  126023. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  126024. */
  126025. set: function (value) {
  126026. this.imageProcessingConfiguration.colorCurves = value;
  126027. },
  126028. enumerable: true,
  126029. configurable: true
  126030. });
  126031. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  126032. /**
  126033. * Gets wether the color curves effect is enabled.
  126034. */
  126035. get: function () {
  126036. return this.imageProcessingConfiguration.colorCurvesEnabled;
  126037. },
  126038. /**
  126039. * Sets wether the color curves effect is enabled.
  126040. */
  126041. set: function (value) {
  126042. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  126043. },
  126044. enumerable: true,
  126045. configurable: true
  126046. });
  126047. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  126048. /**
  126049. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  126050. */
  126051. get: function () {
  126052. return this.imageProcessingConfiguration.colorGradingTexture;
  126053. },
  126054. /**
  126055. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  126056. */
  126057. set: function (value) {
  126058. this.imageProcessingConfiguration.colorGradingTexture = value;
  126059. },
  126060. enumerable: true,
  126061. configurable: true
  126062. });
  126063. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  126064. /**
  126065. * Gets wether the color grading effect is enabled.
  126066. */
  126067. get: function () {
  126068. return this.imageProcessingConfiguration.colorGradingEnabled;
  126069. },
  126070. /**
  126071. * Gets wether the color grading effect is enabled.
  126072. */
  126073. set: function (value) {
  126074. this.imageProcessingConfiguration.colorGradingEnabled = value;
  126075. },
  126076. enumerable: true,
  126077. configurable: true
  126078. });
  126079. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  126080. /**
  126081. * Gets exposure used in the effect.
  126082. */
  126083. get: function () {
  126084. return this.imageProcessingConfiguration.exposure;
  126085. },
  126086. /**
  126087. * Sets exposure used in the effect.
  126088. */
  126089. set: function (value) {
  126090. this.imageProcessingConfiguration.exposure = value;
  126091. },
  126092. enumerable: true,
  126093. configurable: true
  126094. });
  126095. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  126096. /**
  126097. * Gets wether tonemapping is enabled or not.
  126098. */
  126099. get: function () {
  126100. return this._imageProcessingConfiguration.toneMappingEnabled;
  126101. },
  126102. /**
  126103. * Sets wether tonemapping is enabled or not
  126104. */
  126105. set: function (value) {
  126106. this._imageProcessingConfiguration.toneMappingEnabled = value;
  126107. },
  126108. enumerable: true,
  126109. configurable: true
  126110. });
  126111. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingType", {
  126112. /**
  126113. * Gets the type of tone mapping effect.
  126114. */
  126115. get: function () {
  126116. return this._imageProcessingConfiguration.toneMappingType;
  126117. },
  126118. /**
  126119. * Sets the type of tone mapping effect.
  126120. */
  126121. set: function (value) {
  126122. this._imageProcessingConfiguration.toneMappingType = value;
  126123. },
  126124. enumerable: true,
  126125. configurable: true
  126126. });
  126127. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  126128. /**
  126129. * Gets contrast used in the effect.
  126130. */
  126131. get: function () {
  126132. return this.imageProcessingConfiguration.contrast;
  126133. },
  126134. /**
  126135. * Sets contrast used in the effect.
  126136. */
  126137. set: function (value) {
  126138. this.imageProcessingConfiguration.contrast = value;
  126139. },
  126140. enumerable: true,
  126141. configurable: true
  126142. });
  126143. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  126144. /**
  126145. * Gets Vignette stretch size.
  126146. */
  126147. get: function () {
  126148. return this.imageProcessingConfiguration.vignetteStretch;
  126149. },
  126150. /**
  126151. * Sets Vignette stretch size.
  126152. */
  126153. set: function (value) {
  126154. this.imageProcessingConfiguration.vignetteStretch = value;
  126155. },
  126156. enumerable: true,
  126157. configurable: true
  126158. });
  126159. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  126160. /**
  126161. * Gets Vignette centre X Offset.
  126162. */
  126163. get: function () {
  126164. return this.imageProcessingConfiguration.vignetteCentreX;
  126165. },
  126166. /**
  126167. * Sets Vignette centre X Offset.
  126168. */
  126169. set: function (value) {
  126170. this.imageProcessingConfiguration.vignetteCentreX = value;
  126171. },
  126172. enumerable: true,
  126173. configurable: true
  126174. });
  126175. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  126176. /**
  126177. * Gets Vignette centre Y Offset.
  126178. */
  126179. get: function () {
  126180. return this.imageProcessingConfiguration.vignetteCentreY;
  126181. },
  126182. /**
  126183. * Sets Vignette centre Y Offset.
  126184. */
  126185. set: function (value) {
  126186. this.imageProcessingConfiguration.vignetteCentreY = value;
  126187. },
  126188. enumerable: true,
  126189. configurable: true
  126190. });
  126191. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  126192. /**
  126193. * Gets Vignette weight or intensity of the vignette effect.
  126194. */
  126195. get: function () {
  126196. return this.imageProcessingConfiguration.vignetteWeight;
  126197. },
  126198. /**
  126199. * Sets Vignette weight or intensity of the vignette effect.
  126200. */
  126201. set: function (value) {
  126202. this.imageProcessingConfiguration.vignetteWeight = value;
  126203. },
  126204. enumerable: true,
  126205. configurable: true
  126206. });
  126207. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  126208. /**
  126209. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  126210. * if vignetteEnabled is set to true.
  126211. */
  126212. get: function () {
  126213. return this.imageProcessingConfiguration.vignetteColor;
  126214. },
  126215. /**
  126216. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  126217. * if vignetteEnabled is set to true.
  126218. */
  126219. set: function (value) {
  126220. this.imageProcessingConfiguration.vignetteColor = value;
  126221. },
  126222. enumerable: true,
  126223. configurable: true
  126224. });
  126225. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  126226. /**
  126227. * Gets Camera field of view used by the Vignette effect.
  126228. */
  126229. get: function () {
  126230. return this.imageProcessingConfiguration.vignetteCameraFov;
  126231. },
  126232. /**
  126233. * Sets Camera field of view used by the Vignette effect.
  126234. */
  126235. set: function (value) {
  126236. this.imageProcessingConfiguration.vignetteCameraFov = value;
  126237. },
  126238. enumerable: true,
  126239. configurable: true
  126240. });
  126241. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  126242. /**
  126243. * Gets the vignette blend mode allowing different kind of effect.
  126244. */
  126245. get: function () {
  126246. return this.imageProcessingConfiguration.vignetteBlendMode;
  126247. },
  126248. /**
  126249. * Sets the vignette blend mode allowing different kind of effect.
  126250. */
  126251. set: function (value) {
  126252. this.imageProcessingConfiguration.vignetteBlendMode = value;
  126253. },
  126254. enumerable: true,
  126255. configurable: true
  126256. });
  126257. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  126258. /**
  126259. * Gets wether the vignette effect is enabled.
  126260. */
  126261. get: function () {
  126262. return this.imageProcessingConfiguration.vignetteEnabled;
  126263. },
  126264. /**
  126265. * Sets wether the vignette effect is enabled.
  126266. */
  126267. set: function (value) {
  126268. this.imageProcessingConfiguration.vignetteEnabled = value;
  126269. },
  126270. enumerable: true,
  126271. configurable: true
  126272. });
  126273. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  126274. /**
  126275. * Gets wether the input of the processing is in Gamma or Linear Space.
  126276. */
  126277. get: function () {
  126278. return this._fromLinearSpace;
  126279. },
  126280. /**
  126281. * Sets wether the input of the processing is in Gamma or Linear Space.
  126282. */
  126283. set: function (value) {
  126284. if (this._fromLinearSpace === value) {
  126285. return;
  126286. }
  126287. this._fromLinearSpace = value;
  126288. this._updateParameters();
  126289. },
  126290. enumerable: true,
  126291. configurable: true
  126292. });
  126293. /**
  126294. * "ImageProcessingPostProcess"
  126295. * @returns "ImageProcessingPostProcess"
  126296. */
  126297. ImageProcessingPostProcess.prototype.getClassName = function () {
  126298. return "ImageProcessingPostProcess";
  126299. };
  126300. ImageProcessingPostProcess.prototype._updateParameters = function () {
  126301. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  126302. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  126303. var defines = "";
  126304. for (var define in this._defines) {
  126305. if (this._defines[define]) {
  126306. defines += "#define " + define + ";\r\n";
  126307. }
  126308. }
  126309. var samplers = ["textureSampler"];
  126310. var uniforms = ["scale"];
  126311. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  126312. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  126313. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  126314. }
  126315. this.updateEffect(defines, uniforms, samplers);
  126316. };
  126317. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  126318. _super.prototype.dispose.call(this, camera);
  126319. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  126320. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  126321. }
  126322. if (this._imageProcessingConfiguration) {
  126323. this.imageProcessingConfiguration.applyByPostProcess = false;
  126324. }
  126325. };
  126326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  126328. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  126329. return ImageProcessingPostProcess;
  126330. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  126331. /***/ }),
  126332. /***/ "./PostProcesses/index.ts":
  126333. /*!********************************!*\
  126334. !*** ./PostProcesses/index.ts ***!
  126335. \********************************/
  126336. /*! 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 */
  126337. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126338. "use strict";
  126339. __webpack_require__.r(__webpack_exports__);
  126340. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  126341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  126342. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  126343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  126344. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  126345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  126346. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  126347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  126348. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  126349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  126350. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  126351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  126352. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  126353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  126354. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  126355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  126356. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  126357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  126358. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  126359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  126360. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  126361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  126362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  126363. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  126364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  126365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  126366. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  126367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  126368. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  126369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  126370. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  126371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  126372. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  126373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  126374. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  126375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  126376. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  126377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  126378. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  126379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  126380. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  126381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  126382. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  126383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  126384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  126385. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  126386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  126387. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  126388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  126389. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  126390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  126391. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  126392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  126393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  126394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  126395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  126396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  126397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  126398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  126399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  126400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  126401. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  126402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  126403. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  126404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  126405. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  126406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  126407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  126408. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  126409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  126410. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  126411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  126412. /* harmony import */ var _vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  126413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_30__["VRMultiviewToSingleviewPostProcess"]; });
  126414. /***/ }),
  126415. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  126416. /*!************************************************!*\
  126417. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  126418. \************************************************/
  126419. /*! exports provided: MotionBlurPostProcess */
  126420. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126421. "use strict";
  126422. __webpack_require__.r(__webpack_exports__);
  126423. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  126424. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126425. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  126426. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126427. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  126428. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126429. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  126430. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Animations/animatable */ "./Animations/animatable.ts");
  126431. /* harmony import */ var _Rendering_geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  126432. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  126433. /**
  126434. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  126435. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  126436. * As an example, all you have to do is to create the post-process:
  126437. * var mb = new BABYLON.MotionBlurPostProcess(
  126438. * 'mb', // The name of the effect.
  126439. * scene, // The scene containing the objects to blur according to their velocity.
  126440. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  126441. * camera // The camera to apply the render pass to.
  126442. * );
  126443. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  126444. */
  126445. var MotionBlurPostProcess = /** @class */ (function (_super) {
  126446. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  126447. /**
  126448. * Creates a new instance MotionBlurPostProcess
  126449. * @param name The name of the effect.
  126450. * @param scene The scene containing the objects to blur according to their velocity.
  126451. * @param options The required width/height ratio to downsize to before computing the render pass.
  126452. * @param camera The camera to apply the render pass to.
  126453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126454. * @param engine The engine which the post process will be applied. (default: current engine)
  126455. * @param reusable If the post process can be reused on the same frame. (default: false)
  126456. * @param textureType Type of textures used when performing the post process. (default: 0)
  126457. * @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)
  126458. */
  126459. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  126460. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  126461. if (blockCompilation === void 0) { blockCompilation = false; }
  126462. 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;
  126463. /**
  126464. * Defines how much the image is blurred by the movement. Default value is equal to 1
  126465. */
  126466. _this.motionStrength = 1;
  126467. _this._motionBlurSamples = 32;
  126468. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  126469. if (!_this._geometryBufferRenderer) {
  126470. // Geometry buffer renderer is not supported. So, work as a passthrough.
  126471. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  126472. _this.updateEffect();
  126473. }
  126474. else {
  126475. // Geometry buffer renderer is supported.
  126476. _this._geometryBufferRenderer.enableVelocity = true;
  126477. _this.onApply = function (effect) {
  126478. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  126479. effect.setFloat("motionScale", scene.getAnimationRatio());
  126480. effect.setFloat("motionStrength", _this.motionStrength);
  126481. if (_this._geometryBufferRenderer) {
  126482. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  126483. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  126484. }
  126485. };
  126486. }
  126487. return _this;
  126488. }
  126489. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  126490. /**
  126491. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  126492. */
  126493. get: function () {
  126494. return this._motionBlurSamples;
  126495. },
  126496. /**
  126497. * Sets the number of iterations to be used for motion blur quality
  126498. */
  126499. set: function (samples) {
  126500. this._motionBlurSamples = samples;
  126501. if (this._geometryBufferRenderer) {
  126502. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  126503. }
  126504. },
  126505. enumerable: true,
  126506. configurable: true
  126507. });
  126508. /**
  126509. * Excludes the given skinned mesh from computing bones velocities.
  126510. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  126511. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  126512. */
  126513. MotionBlurPostProcess.prototype.excludeSkinnedMesh = function (skinnedMesh) {
  126514. if (this._geometryBufferRenderer && skinnedMesh.skeleton) {
  126515. this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity.push(skinnedMesh);
  126516. }
  126517. };
  126518. /**
  126519. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  126520. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  126521. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  126522. */
  126523. MotionBlurPostProcess.prototype.removeExcludedSkinnedMesh = function (skinnedMesh) {
  126524. if (this._geometryBufferRenderer && skinnedMesh.skeleton) {
  126525. var index = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity.indexOf(skinnedMesh);
  126526. if (index !== -1) {
  126527. this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity.splice(index, 1);
  126528. }
  126529. }
  126530. };
  126531. /**
  126532. * Disposes the post process.
  126533. * @param camera The camera to dispose the post process on.
  126534. */
  126535. MotionBlurPostProcess.prototype.dispose = function (camera) {
  126536. if (this._geometryBufferRenderer) {
  126537. // Clear previous transformation matrices dictionary used to compute objects velocities
  126538. this._geometryBufferRenderer._previousTransformationMatrices = {};
  126539. this._geometryBufferRenderer._previousBonesTransformationMatrices = {};
  126540. this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity = [];
  126541. }
  126542. _super.prototype.dispose.call(this, camera);
  126543. };
  126544. return MotionBlurPostProcess;
  126545. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  126546. /***/ }),
  126547. /***/ "./PostProcesses/passPostProcess.ts":
  126548. /*!******************************************!*\
  126549. !*** ./PostProcesses/passPostProcess.ts ***!
  126550. \******************************************/
  126551. /*! exports provided: PassPostProcess, PassCubePostProcess */
  126552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126553. "use strict";
  126554. __webpack_require__.r(__webpack_exports__);
  126555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  126556. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  126557. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126558. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126559. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  126560. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  126561. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  126562. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  126563. /**
  126564. * PassPostProcess which produces an output the same as it's input
  126565. */
  126566. var PassPostProcess = /** @class */ (function (_super) {
  126567. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  126568. /**
  126569. * Creates the PassPostProcess
  126570. * @param name The name of the effect.
  126571. * @param options The required width/height ratio to downsize to before computing the render pass.
  126572. * @param camera The camera to apply the render pass to.
  126573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126574. * @param engine The engine which the post process will be applied. (default: current engine)
  126575. * @param reusable If the post process can be reused on the same frame. (default: false)
  126576. * @param textureType The type of texture to be used when performing the post processing.
  126577. * @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)
  126578. */
  126579. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  126580. if (camera === void 0) { camera = null; }
  126581. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  126582. if (blockCompilation === void 0) { blockCompilation = false; }
  126583. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  126584. }
  126585. return PassPostProcess;
  126586. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  126587. /**
  126588. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  126589. */
  126590. var PassCubePostProcess = /** @class */ (function (_super) {
  126591. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  126592. /**
  126593. * Creates the PassCubePostProcess
  126594. * @param name The name of the effect.
  126595. * @param options The required width/height ratio to downsize to before computing the render pass.
  126596. * @param camera The camera to apply the render pass to.
  126597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126598. * @param engine The engine which the post process will be applied. (default: current engine)
  126599. * @param reusable If the post process can be reused on the same frame. (default: false)
  126600. * @param textureType The type of texture to be used when performing the post processing.
  126601. * @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)
  126602. */
  126603. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  126604. if (camera === void 0) { camera = null; }
  126605. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  126606. if (blockCompilation === void 0) { blockCompilation = false; }
  126607. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  126608. _this._face = 0;
  126609. return _this;
  126610. }
  126611. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  126612. /**
  126613. * Gets or sets the cube face to display.
  126614. * * 0 is +X
  126615. * * 1 is -X
  126616. * * 2 is +Y
  126617. * * 3 is -Y
  126618. * * 4 is +Z
  126619. * * 5 is -Z
  126620. */
  126621. get: function () {
  126622. return this._face;
  126623. },
  126624. set: function (value) {
  126625. if (value < 0 || value > 5) {
  126626. return;
  126627. }
  126628. this._face = value;
  126629. switch (this._face) {
  126630. case 0:
  126631. this.updateEffect("#define POSITIVEX");
  126632. break;
  126633. case 1:
  126634. this.updateEffect("#define NEGATIVEX");
  126635. break;
  126636. case 2:
  126637. this.updateEffect("#define POSITIVEY");
  126638. break;
  126639. case 3:
  126640. this.updateEffect("#define NEGATIVEY");
  126641. break;
  126642. case 4:
  126643. this.updateEffect("#define POSITIVEZ");
  126644. break;
  126645. case 5:
  126646. this.updateEffect("#define NEGATIVEZ");
  126647. break;
  126648. }
  126649. },
  126650. enumerable: true,
  126651. configurable: true
  126652. });
  126653. return PassCubePostProcess;
  126654. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  126655. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  126656. 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);
  126657. };
  126658. /***/ }),
  126659. /***/ "./PostProcesses/postProcess.ts":
  126660. /*!**************************************!*\
  126661. !*** ./PostProcesses/postProcess.ts ***!
  126662. \**************************************/
  126663. /*! exports provided: PostProcess */
  126664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126665. "use strict";
  126666. __webpack_require__.r(__webpack_exports__);
  126667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  126668. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  126669. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  126670. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  126671. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126672. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126673. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  126674. /**
  126675. * PostProcess can be used to apply a shader to a texture after it has been rendered
  126676. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126677. */
  126678. var PostProcess = /** @class */ (function () {
  126679. /**
  126680. * Creates a new instance PostProcess
  126681. * @param name The name of the PostProcess.
  126682. * @param fragmentUrl The url of the fragment shader to be used.
  126683. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  126684. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  126685. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  126686. * @param camera The camera to apply the render pass to.
  126687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126688. * @param engine The engine which the post process will be applied. (default: current engine)
  126689. * @param reusable If the post process can be reused on the same frame. (default: false)
  126690. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  126691. * @param textureType Type of textures used when performing the post process. (default: 0)
  126692. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  126693. * @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
  126694. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  126695. */
  126696. function PostProcess(
  126697. /** Name of the PostProcess. */
  126698. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  126699. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  126700. if (defines === void 0) { defines = null; }
  126701. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  126702. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  126703. if (blockCompilation === void 0) { blockCompilation = false; }
  126704. this.name = name;
  126705. /**
  126706. * Width of the texture to apply the post process on
  126707. */
  126708. this.width = -1;
  126709. /**
  126710. * Height of the texture to apply the post process on
  126711. */
  126712. this.height = -1;
  126713. /**
  126714. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  126715. * @hidden
  126716. */
  126717. this._outputTexture = null;
  126718. /**
  126719. * If the buffer needs to be cleared before applying the post process. (default: true)
  126720. * Should be set to false if shader will overwrite all previous pixels.
  126721. */
  126722. this.autoClear = true;
  126723. /**
  126724. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  126725. */
  126726. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  126727. /**
  126728. * Animations to be used for the post processing
  126729. */
  126730. this.animations = new Array();
  126731. /**
  126732. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  126733. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  126734. */
  126735. this.enablePixelPerfectMode = false;
  126736. /**
  126737. * Force the postprocess to be applied without taking in account viewport
  126738. */
  126739. this.forceFullscreenViewport = true;
  126740. /**
  126741. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  126742. *
  126743. * | Value | Type | Description |
  126744. * | ----- | ----------------------------------- | ----------- |
  126745. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  126746. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  126747. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  126748. *
  126749. */
  126750. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  126751. /**
  126752. * Force textures to be a power of two (default: false)
  126753. */
  126754. this.alwaysForcePOT = false;
  126755. this._samples = 1;
  126756. /**
  126757. * Modify the scale of the post process to be the same as the viewport (default: false)
  126758. */
  126759. this.adaptScaleToCurrentViewport = false;
  126760. this._reusable = false;
  126761. /**
  126762. * Smart array of input and output textures for the post process.
  126763. * @hidden
  126764. */
  126765. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  126766. /**
  126767. * The index in _textures that corresponds to the output texture.
  126768. * @hidden
  126769. */
  126770. this._currentRenderTextureInd = 0;
  126771. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  126772. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  126773. // Events
  126774. /**
  126775. * An event triggered when the postprocess is activated.
  126776. */
  126777. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  126778. /**
  126779. * An event triggered when the postprocess changes its size.
  126780. */
  126781. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  126782. /**
  126783. * An event triggered when the postprocess applies its effect.
  126784. */
  126785. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  126786. /**
  126787. * An event triggered before rendering the postprocess
  126788. */
  126789. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  126790. /**
  126791. * An event triggered after rendering the postprocess
  126792. */
  126793. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  126794. if (camera != null) {
  126795. this._camera = camera;
  126796. this._scene = camera.getScene();
  126797. camera.attachPostProcess(this);
  126798. this._engine = this._scene.getEngine();
  126799. this._scene.postProcesses.push(this);
  126800. this.uniqueId = this._scene.getUniqueId();
  126801. }
  126802. else if (engine) {
  126803. this._engine = engine;
  126804. this._engine.postProcesses.push(this);
  126805. }
  126806. this._options = options;
  126807. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  126808. this._reusable = reusable || false;
  126809. this._textureType = textureType;
  126810. this._samplers = samplers || [];
  126811. this._samplers.push("textureSampler");
  126812. this._fragmentUrl = fragmentUrl;
  126813. this._vertexUrl = vertexUrl;
  126814. this._parameters = parameters || [];
  126815. this._parameters.push("scale");
  126816. this._indexParameters = indexParameters;
  126817. if (!blockCompilation) {
  126818. this.updateEffect(defines);
  126819. }
  126820. }
  126821. Object.defineProperty(PostProcess.prototype, "samples", {
  126822. /**
  126823. * Number of sample textures (default: 1)
  126824. */
  126825. get: function () {
  126826. return this._samples;
  126827. },
  126828. set: function (n) {
  126829. var _this = this;
  126830. this._samples = n;
  126831. this._textures.forEach(function (texture) {
  126832. if (texture.samples !== _this._samples) {
  126833. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  126834. }
  126835. });
  126836. },
  126837. enumerable: true,
  126838. configurable: true
  126839. });
  126840. /**
  126841. * Returns the fragment url or shader name used in the post process.
  126842. * @returns the fragment url or name in the shader store.
  126843. */
  126844. PostProcess.prototype.getEffectName = function () {
  126845. return this._fragmentUrl;
  126846. };
  126847. Object.defineProperty(PostProcess.prototype, "onActivate", {
  126848. /**
  126849. * A function that is added to the onActivateObservable
  126850. */
  126851. set: function (callback) {
  126852. if (this._onActivateObserver) {
  126853. this.onActivateObservable.remove(this._onActivateObserver);
  126854. }
  126855. if (callback) {
  126856. this._onActivateObserver = this.onActivateObservable.add(callback);
  126857. }
  126858. },
  126859. enumerable: true,
  126860. configurable: true
  126861. });
  126862. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  126863. /**
  126864. * A function that is added to the onSizeChangedObservable
  126865. */
  126866. set: function (callback) {
  126867. if (this._onSizeChangedObserver) {
  126868. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  126869. }
  126870. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  126871. },
  126872. enumerable: true,
  126873. configurable: true
  126874. });
  126875. Object.defineProperty(PostProcess.prototype, "onApply", {
  126876. /**
  126877. * A function that is added to the onApplyObservable
  126878. */
  126879. set: function (callback) {
  126880. if (this._onApplyObserver) {
  126881. this.onApplyObservable.remove(this._onApplyObserver);
  126882. }
  126883. this._onApplyObserver = this.onApplyObservable.add(callback);
  126884. },
  126885. enumerable: true,
  126886. configurable: true
  126887. });
  126888. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  126889. /**
  126890. * A function that is added to the onBeforeRenderObservable
  126891. */
  126892. set: function (callback) {
  126893. if (this._onBeforeRenderObserver) {
  126894. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  126895. }
  126896. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  126897. },
  126898. enumerable: true,
  126899. configurable: true
  126900. });
  126901. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  126902. /**
  126903. * A function that is added to the onAfterRenderObservable
  126904. */
  126905. set: function (callback) {
  126906. if (this._onAfterRenderObserver) {
  126907. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  126908. }
  126909. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  126910. },
  126911. enumerable: true,
  126912. configurable: true
  126913. });
  126914. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  126915. /**
  126916. * 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
  126917. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  126918. */
  126919. get: function () {
  126920. return this._textures.data[this._currentRenderTextureInd];
  126921. },
  126922. set: function (value) {
  126923. this._forcedOutputTexture = value;
  126924. },
  126925. enumerable: true,
  126926. configurable: true
  126927. });
  126928. /**
  126929. * Gets the camera which post process is applied to.
  126930. * @returns The camera the post process is applied to.
  126931. */
  126932. PostProcess.prototype.getCamera = function () {
  126933. return this._camera;
  126934. };
  126935. Object.defineProperty(PostProcess.prototype, "texelSize", {
  126936. /**
  126937. * Gets the texel size of the postprocess.
  126938. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  126939. */
  126940. get: function () {
  126941. if (this._shareOutputWithPostProcess) {
  126942. return this._shareOutputWithPostProcess.texelSize;
  126943. }
  126944. if (this._forcedOutputTexture) {
  126945. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  126946. }
  126947. return this._texelSize;
  126948. },
  126949. enumerable: true,
  126950. configurable: true
  126951. });
  126952. /**
  126953. * Gets a string idenfifying the name of the class
  126954. * @returns "PostProcess" string
  126955. */
  126956. PostProcess.prototype.getClassName = function () {
  126957. return "PostProcess";
  126958. };
  126959. /**
  126960. * Gets the engine which this post process belongs to.
  126961. * @returns The engine the post process was enabled with.
  126962. */
  126963. PostProcess.prototype.getEngine = function () {
  126964. return this._engine;
  126965. };
  126966. /**
  126967. * The effect that is created when initializing the post process.
  126968. * @returns The created effect corrisponding the the postprocess.
  126969. */
  126970. PostProcess.prototype.getEffect = function () {
  126971. return this._effect;
  126972. };
  126973. /**
  126974. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  126975. * @param postProcess The post process to share the output with.
  126976. * @returns This post process.
  126977. */
  126978. PostProcess.prototype.shareOutputWith = function (postProcess) {
  126979. this._disposeTextures();
  126980. this._shareOutputWithPostProcess = postProcess;
  126981. return this;
  126982. };
  126983. /**
  126984. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  126985. * This should be called if the post process that shares output with this post process is disabled/disposed.
  126986. */
  126987. PostProcess.prototype.useOwnOutput = function () {
  126988. if (this._textures.length == 0) {
  126989. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  126990. }
  126991. this._shareOutputWithPostProcess = null;
  126992. };
  126993. /**
  126994. * Updates the effect with the current post process compile time values and recompiles the shader.
  126995. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  126996. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  126997. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  126998. * @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
  126999. * @param onCompiled Called when the shader has been compiled.
  127000. * @param onError Called if there is an error when compiling a shader.
  127001. */
  127002. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  127003. if (defines === void 0) { defines = null; }
  127004. if (uniforms === void 0) { uniforms = null; }
  127005. if (samplers === void 0) { samplers = null; }
  127006. 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);
  127007. };
  127008. /**
  127009. * The post process is reusable if it can be used multiple times within one frame.
  127010. * @returns If the post process is reusable
  127011. */
  127012. PostProcess.prototype.isReusable = function () {
  127013. return this._reusable;
  127014. };
  127015. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  127016. PostProcess.prototype.markTextureDirty = function () {
  127017. this.width = -1;
  127018. };
  127019. /**
  127020. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  127021. * 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.
  127022. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  127023. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  127024. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  127025. * @returns The target texture that was bound to be written to.
  127026. */
  127027. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  127028. var _this = this;
  127029. if (sourceTexture === void 0) { sourceTexture = null; }
  127030. camera = camera || this._camera;
  127031. var scene = camera.getScene();
  127032. var engine = scene.getEngine();
  127033. var maxSize = engine.getCaps().maxTextureSize;
  127034. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  127035. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  127036. // 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
  127037. var webVRCamera = camera.parent;
  127038. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  127039. requiredWidth /= 2;
  127040. }
  127041. var desiredWidth = (this._options.width || requiredWidth);
  127042. var desiredHeight = this._options.height || requiredHeight;
  127043. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  127044. if (this.adaptScaleToCurrentViewport) {
  127045. var currentViewport = engine.currentViewport;
  127046. if (currentViewport) {
  127047. desiredWidth *= currentViewport.width;
  127048. desiredHeight *= currentViewport.height;
  127049. }
  127050. }
  127051. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  127052. if (!this._options.width) {
  127053. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  127054. }
  127055. if (!this._options.height) {
  127056. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  127057. }
  127058. }
  127059. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  127060. if (this._textures.length > 0) {
  127061. for (var i = 0; i < this._textures.length; i++) {
  127062. this._engine._releaseTexture(this._textures.data[i]);
  127063. }
  127064. this._textures.reset();
  127065. }
  127066. this.width = desiredWidth;
  127067. this.height = desiredHeight;
  127068. var textureSize = { width: this.width, height: this.height };
  127069. var textureOptions = {
  127070. generateMipMaps: false,
  127071. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  127072. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  127073. samplingMode: this.renderTargetSamplingMode,
  127074. type: this._textureType
  127075. };
  127076. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  127077. if (this._reusable) {
  127078. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  127079. }
  127080. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  127081. this.onSizeChangedObservable.notifyObservers(this);
  127082. }
  127083. this._textures.forEach(function (texture) {
  127084. if (texture.samples !== _this.samples) {
  127085. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  127086. }
  127087. });
  127088. }
  127089. var target;
  127090. if (this._shareOutputWithPostProcess) {
  127091. target = this._shareOutputWithPostProcess.inputTexture;
  127092. }
  127093. else if (this._forcedOutputTexture) {
  127094. target = this._forcedOutputTexture;
  127095. this.width = this._forcedOutputTexture.width;
  127096. this.height = this._forcedOutputTexture.height;
  127097. }
  127098. else {
  127099. target = this.inputTexture;
  127100. }
  127101. // Bind the input of this post process to be used as the output of the previous post process.
  127102. if (this.enablePixelPerfectMode) {
  127103. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  127104. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  127105. }
  127106. else {
  127107. this._scaleRatio.copyFromFloats(1, 1);
  127108. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  127109. }
  127110. this.onActivateObservable.notifyObservers(camera);
  127111. // Clear
  127112. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  127113. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  127114. }
  127115. if (this._reusable) {
  127116. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  127117. }
  127118. return target;
  127119. };
  127120. Object.defineProperty(PostProcess.prototype, "isSupported", {
  127121. /**
  127122. * If the post process is supported.
  127123. */
  127124. get: function () {
  127125. return this._effect.isSupported;
  127126. },
  127127. enumerable: true,
  127128. configurable: true
  127129. });
  127130. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  127131. /**
  127132. * The aspect ratio of the output texture.
  127133. */
  127134. get: function () {
  127135. if (this._shareOutputWithPostProcess) {
  127136. return this._shareOutputWithPostProcess.aspectRatio;
  127137. }
  127138. if (this._forcedOutputTexture) {
  127139. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  127140. }
  127141. return this.width / this.height;
  127142. },
  127143. enumerable: true,
  127144. configurable: true
  127145. });
  127146. /**
  127147. * Get a value indicating if the post-process is ready to be used
  127148. * @returns true if the post-process is ready (shader is compiled)
  127149. */
  127150. PostProcess.prototype.isReady = function () {
  127151. return this._effect && this._effect.isReady();
  127152. };
  127153. /**
  127154. * Binds all textures and uniforms to the shader, this will be run on every pass.
  127155. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  127156. */
  127157. PostProcess.prototype.apply = function () {
  127158. // Check
  127159. if (!this._effect || !this._effect.isReady()) {
  127160. return null;
  127161. }
  127162. // States
  127163. this._engine.enableEffect(this._effect);
  127164. this._engine.setState(false);
  127165. this._engine.setDepthBuffer(false);
  127166. this._engine.setDepthWrite(false);
  127167. // Alpha
  127168. this._engine.setAlphaMode(this.alphaMode);
  127169. if (this.alphaConstants) {
  127170. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  127171. }
  127172. // Bind the output texture of the preivous post process as the input to this post process.
  127173. var source;
  127174. if (this._shareOutputWithPostProcess) {
  127175. source = this._shareOutputWithPostProcess.inputTexture;
  127176. }
  127177. else if (this._forcedOutputTexture) {
  127178. source = this._forcedOutputTexture;
  127179. }
  127180. else {
  127181. source = this.inputTexture;
  127182. }
  127183. this._effect._bindTexture("textureSampler", source);
  127184. // Parameters
  127185. this._effect.setVector2("scale", this._scaleRatio);
  127186. this.onApplyObservable.notifyObservers(this._effect);
  127187. return this._effect;
  127188. };
  127189. PostProcess.prototype._disposeTextures = function () {
  127190. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  127191. return;
  127192. }
  127193. if (this._textures.length > 0) {
  127194. for (var i = 0; i < this._textures.length; i++) {
  127195. this._engine._releaseTexture(this._textures.data[i]);
  127196. }
  127197. }
  127198. this._textures.dispose();
  127199. };
  127200. /**
  127201. * Disposes the post process.
  127202. * @param camera The camera to dispose the post process on.
  127203. */
  127204. PostProcess.prototype.dispose = function (camera) {
  127205. camera = camera || this._camera;
  127206. this._disposeTextures();
  127207. if (this._scene) {
  127208. var index_1 = this._scene.postProcesses.indexOf(this);
  127209. if (index_1 !== -1) {
  127210. this._scene.postProcesses.splice(index_1, 1);
  127211. }
  127212. }
  127213. else {
  127214. var index_2 = this._engine.postProcesses.indexOf(this);
  127215. if (index_2 !== -1) {
  127216. this._engine.postProcesses.splice(index_2, 1);
  127217. }
  127218. }
  127219. if (!camera) {
  127220. return;
  127221. }
  127222. camera.detachPostProcess(this);
  127223. var index = camera._postProcesses.indexOf(this);
  127224. if (index === 0 && camera._postProcesses.length > 0) {
  127225. var firstPostProcess = this._camera._getFirstPostProcess();
  127226. if (firstPostProcess) {
  127227. firstPostProcess.markTextureDirty();
  127228. }
  127229. }
  127230. this.onActivateObservable.clear();
  127231. this.onAfterRenderObservable.clear();
  127232. this.onApplyObservable.clear();
  127233. this.onBeforeRenderObservable.clear();
  127234. this.onSizeChangedObservable.clear();
  127235. };
  127236. return PostProcess;
  127237. }());
  127238. /***/ }),
  127239. /***/ "./PostProcesses/postProcessManager.ts":
  127240. /*!*********************************************!*\
  127241. !*** ./PostProcesses/postProcessManager.ts ***!
  127242. \*********************************************/
  127243. /*! exports provided: PostProcessManager */
  127244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127245. "use strict";
  127246. __webpack_require__.r(__webpack_exports__);
  127247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  127248. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  127249. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  127250. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127251. /**
  127252. * PostProcessManager is used to manage one or more post processes or post process pipelines
  127253. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127254. */
  127255. var PostProcessManager = /** @class */ (function () {
  127256. /**
  127257. * Creates a new instance PostProcess
  127258. * @param scene The scene that the post process is associated with.
  127259. */
  127260. function PostProcessManager(scene) {
  127261. this._vertexBuffers = {};
  127262. this._scene = scene;
  127263. }
  127264. PostProcessManager.prototype._prepareBuffers = function () {
  127265. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  127266. return;
  127267. }
  127268. // VBO
  127269. var vertices = [];
  127270. vertices.push(1, 1);
  127271. vertices.push(-1, 1);
  127272. vertices.push(-1, -1);
  127273. vertices.push(1, -1);
  127274. 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);
  127275. this._buildIndexBuffer();
  127276. };
  127277. PostProcessManager.prototype._buildIndexBuffer = function () {
  127278. // Indices
  127279. var indices = [];
  127280. indices.push(0);
  127281. indices.push(1);
  127282. indices.push(2);
  127283. indices.push(0);
  127284. indices.push(2);
  127285. indices.push(3);
  127286. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  127287. };
  127288. /**
  127289. * Rebuilds the vertex buffers of the manager.
  127290. * @hidden
  127291. */
  127292. PostProcessManager.prototype._rebuild = function () {
  127293. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  127294. if (!vb) {
  127295. return;
  127296. }
  127297. vb._rebuild();
  127298. this._buildIndexBuffer();
  127299. };
  127300. // Methods
  127301. /**
  127302. * Prepares a frame to be run through a post process.
  127303. * @param sourceTexture The input texture to the post procesess. (default: null)
  127304. * @param postProcesses An array of post processes to be run. (default: null)
  127305. * @returns True if the post processes were able to be run.
  127306. * @hidden
  127307. */
  127308. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  127309. if (sourceTexture === void 0) { sourceTexture = null; }
  127310. if (postProcesses === void 0) { postProcesses = null; }
  127311. var camera = this._scene.activeCamera;
  127312. if (!camera) {
  127313. return false;
  127314. }
  127315. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  127316. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  127317. return false;
  127318. }
  127319. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  127320. return true;
  127321. };
  127322. /**
  127323. * Manually render a set of post processes to a texture.
  127324. * @param postProcesses An array of post processes to be run.
  127325. * @param targetTexture The target texture to render to.
  127326. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  127327. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  127328. * @param lodLevel defines which lod of the texture to render to
  127329. */
  127330. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  127331. if (targetTexture === void 0) { targetTexture = null; }
  127332. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  127333. if (faceIndex === void 0) { faceIndex = 0; }
  127334. if (lodLevel === void 0) { lodLevel = 0; }
  127335. var engine = this._scene.getEngine();
  127336. for (var index = 0; index < postProcesses.length; index++) {
  127337. if (index < postProcesses.length - 1) {
  127338. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  127339. }
  127340. else {
  127341. if (targetTexture) {
  127342. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  127343. }
  127344. else {
  127345. engine.restoreDefaultFramebuffer();
  127346. }
  127347. }
  127348. var pp = postProcesses[index];
  127349. var effect = pp.apply();
  127350. if (effect) {
  127351. pp.onBeforeRenderObservable.notifyObservers(effect);
  127352. // VBOs
  127353. this._prepareBuffers();
  127354. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  127355. // Draw order
  127356. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  127357. pp.onAfterRenderObservable.notifyObservers(effect);
  127358. }
  127359. }
  127360. // Restore depth buffer
  127361. engine.setDepthBuffer(true);
  127362. engine.setDepthWrite(true);
  127363. };
  127364. /**
  127365. * Finalize the result of the output of the postprocesses.
  127366. * @param doNotPresent If true the result will not be displayed to the screen.
  127367. * @param targetTexture The target texture to render to.
  127368. * @param faceIndex The index of the face to bind the target texture to.
  127369. * @param postProcesses The array of post processes to render.
  127370. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  127371. * @hidden
  127372. */
  127373. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  127374. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  127375. var camera = this._scene.activeCamera;
  127376. if (!camera) {
  127377. return;
  127378. }
  127379. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  127380. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  127381. return;
  127382. }
  127383. var engine = this._scene.getEngine();
  127384. for (var index = 0, len = postProcesses.length; index < len; index++) {
  127385. var pp = postProcesses[index];
  127386. if (index < len - 1) {
  127387. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  127388. }
  127389. else {
  127390. if (targetTexture) {
  127391. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  127392. pp._outputTexture = targetTexture;
  127393. }
  127394. else {
  127395. engine.restoreDefaultFramebuffer();
  127396. pp._outputTexture = null;
  127397. }
  127398. }
  127399. if (doNotPresent) {
  127400. break;
  127401. }
  127402. var effect = pp.apply();
  127403. if (effect) {
  127404. pp.onBeforeRenderObservable.notifyObservers(effect);
  127405. // VBOs
  127406. this._prepareBuffers();
  127407. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  127408. // Draw order
  127409. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  127410. pp.onAfterRenderObservable.notifyObservers(effect);
  127411. }
  127412. }
  127413. // Restore states
  127414. engine.setDepthBuffer(true);
  127415. engine.setDepthWrite(true);
  127416. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  127417. };
  127418. /**
  127419. * Disposes of the post process manager.
  127420. */
  127421. PostProcessManager.prototype.dispose = function () {
  127422. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  127423. if (buffer) {
  127424. buffer.dispose();
  127425. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  127426. }
  127427. if (this._indexBuffer) {
  127428. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  127429. this._indexBuffer = null;
  127430. }
  127431. };
  127432. return PostProcessManager;
  127433. }());
  127434. /***/ }),
  127435. /***/ "./PostProcesses/refractionPostProcess.ts":
  127436. /*!************************************************!*\
  127437. !*** ./PostProcesses/refractionPostProcess.ts ***!
  127438. \************************************************/
  127439. /*! exports provided: RefractionPostProcess */
  127440. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127441. "use strict";
  127442. __webpack_require__.r(__webpack_exports__);
  127443. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  127444. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127445. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  127446. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  127447. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  127448. /**
  127449. * Post process which applies a refractin texture
  127450. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127451. */
  127452. var RefractionPostProcess = /** @class */ (function (_super) {
  127453. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  127454. /**
  127455. * Initializes the RefractionPostProcess
  127456. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127457. * @param name The name of the effect.
  127458. * @param refractionTextureUrl Url of the refraction texture to use
  127459. * @param color the base color of the refraction (used to taint the rendering)
  127460. * @param depth simulated refraction depth
  127461. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  127462. * @param camera The camera to apply the render pass to.
  127463. * @param options The required width/height ratio to downsize to before computing the render pass.
  127464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127465. * @param engine The engine which the post process will be applied. (default: current engine)
  127466. * @param reusable If the post process can be reused on the same frame. (default: false)
  127467. */
  127468. function RefractionPostProcess(name, refractionTextureUrl,
  127469. /** the base color of the refraction (used to taint the rendering) */
  127470. color,
  127471. /** simulated refraction depth */
  127472. depth,
  127473. /** the coefficient of the base color (0 to remove base color tainting) */
  127474. colorLevel, options, camera, samplingMode, engine, reusable) {
  127475. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  127476. _this.color = color;
  127477. _this.depth = depth;
  127478. _this.colorLevel = colorLevel;
  127479. _this._ownRefractionTexture = true;
  127480. _this.onActivateObservable.add(function (cam) {
  127481. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  127482. });
  127483. _this.onApplyObservable.add(function (effect) {
  127484. effect.setColor3("baseColor", _this.color);
  127485. effect.setFloat("depth", _this.depth);
  127486. effect.setFloat("colorLevel", _this.colorLevel);
  127487. effect.setTexture("refractionSampler", _this._refTexture);
  127488. });
  127489. return _this;
  127490. }
  127491. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  127492. /**
  127493. * Gets or sets the refraction texture
  127494. * Please note that you are responsible for disposing the texture if you set it manually
  127495. */
  127496. get: function () {
  127497. return this._refTexture;
  127498. },
  127499. set: function (value) {
  127500. if (this._refTexture && this._ownRefractionTexture) {
  127501. this._refTexture.dispose();
  127502. }
  127503. this._refTexture = value;
  127504. this._ownRefractionTexture = false;
  127505. },
  127506. enumerable: true,
  127507. configurable: true
  127508. });
  127509. // Methods
  127510. /**
  127511. * Disposes of the post process
  127512. * @param camera Camera to dispose post process on
  127513. */
  127514. RefractionPostProcess.prototype.dispose = function (camera) {
  127515. if (this._refTexture && this._ownRefractionTexture) {
  127516. this._refTexture.dispose();
  127517. this._refTexture = null;
  127518. }
  127519. _super.prototype.dispose.call(this, camera);
  127520. };
  127521. return RefractionPostProcess;
  127522. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  127523. /***/ }),
  127524. /***/ "./PostProcesses/sharpenPostProcess.ts":
  127525. /*!*********************************************!*\
  127526. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  127527. \*********************************************/
  127528. /*! exports provided: SharpenPostProcess */
  127529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127530. "use strict";
  127531. __webpack_require__.r(__webpack_exports__);
  127532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  127533. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127534. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  127535. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127536. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  127537. /**
  127538. * The SharpenPostProcess applies a sharpen kernel to every pixel
  127539. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127540. */
  127541. var SharpenPostProcess = /** @class */ (function (_super) {
  127542. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  127543. /**
  127544. * Creates a new instance ConvolutionPostProcess
  127545. * @param name The name of the effect.
  127546. * @param options The required width/height ratio to downsize to before computing the render pass.
  127547. * @param camera The camera to apply the render pass to.
  127548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127549. * @param engine The engine which the post process will be applied. (default: current engine)
  127550. * @param reusable If the post process can be reused on the same frame. (default: false)
  127551. * @param textureType Type of textures used when performing the post process. (default: 0)
  127552. * @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)
  127553. */
  127554. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  127555. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  127556. if (blockCompilation === void 0) { blockCompilation = false; }
  127557. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  127558. /**
  127559. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  127560. */
  127561. _this.colorAmount = 1.0;
  127562. /**
  127563. * How much sharpness should be applied (default: 0.3)
  127564. */
  127565. _this.edgeAmount = 0.3;
  127566. _this.onApply = function (effect) {
  127567. effect.setFloat2("screenSize", _this.width, _this.height);
  127568. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  127569. };
  127570. return _this;
  127571. }
  127572. return SharpenPostProcess;
  127573. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  127574. /***/ }),
  127575. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  127576. /*!***********************************************************!*\
  127577. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  127578. \***********************************************************/
  127579. /*! exports provided: StereoscopicInterlacePostProcess */
  127580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127581. "use strict";
  127582. __webpack_require__.r(__webpack_exports__);
  127583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  127584. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127585. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  127586. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  127587. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  127588. /**
  127589. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  127590. */
  127591. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  127592. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  127593. /**
  127594. * Initializes a StereoscopicInterlacePostProcess
  127595. * @param name The name of the effect.
  127596. * @param rigCameras The rig cameras to be appled to the post process
  127597. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  127598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127599. * @param engine The engine which the post process will be applied. (default: current engine)
  127600. * @param reusable If the post process can be reused on the same frame. (default: false)
  127601. */
  127602. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  127603. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  127604. _this._passedProcess = rigCameras[0]._rigPostProcess;
  127605. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  127606. _this.onSizeChangedObservable.add(function () {
  127607. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  127608. });
  127609. _this.onApplyObservable.add(function (effect) {
  127610. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  127611. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  127612. });
  127613. return _this;
  127614. }
  127615. return StereoscopicInterlacePostProcess;
  127616. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  127617. /***/ }),
  127618. /***/ "./PostProcesses/tonemapPostProcess.ts":
  127619. /*!*********************************************!*\
  127620. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  127621. \*********************************************/
  127622. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  127623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127624. "use strict";
  127625. __webpack_require__.r(__webpack_exports__);
  127626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  127627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  127628. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127629. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  127630. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127631. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  127632. /** Defines operator used for tonemapping */
  127633. var TonemappingOperator;
  127634. (function (TonemappingOperator) {
  127635. /** Hable */
  127636. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  127637. /** Reinhard */
  127638. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  127639. /** HejiDawson */
  127640. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  127641. /** Photographic */
  127642. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  127643. })(TonemappingOperator || (TonemappingOperator = {}));
  127644. /**
  127645. * Defines a post process to apply tone mapping
  127646. */
  127647. var TonemapPostProcess = /** @class */ (function (_super) {
  127648. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  127649. /**
  127650. * Creates a new TonemapPostProcess
  127651. * @param name defines the name of the postprocess
  127652. * @param _operator defines the operator to use
  127653. * @param exposureAdjustment defines the required exposure adjustement
  127654. * @param camera defines the camera to use (can be null)
  127655. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127656. * @param engine defines the hosting engine (can be ignore if camera is set)
  127657. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127658. */
  127659. function TonemapPostProcess(name, _operator,
  127660. /** Defines the required exposure adjustement */
  127661. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  127662. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  127663. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  127664. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  127665. _this._operator = _operator;
  127666. _this.exposureAdjustment = exposureAdjustment;
  127667. var defines = "#define ";
  127668. if (_this._operator === TonemappingOperator.Hable) {
  127669. defines += "HABLE_TONEMAPPING";
  127670. }
  127671. else if (_this._operator === TonemappingOperator.Reinhard) {
  127672. defines += "REINHARD_TONEMAPPING";
  127673. }
  127674. else if (_this._operator === TonemappingOperator.HejiDawson) {
  127675. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  127676. }
  127677. else if (_this._operator === TonemappingOperator.Photographic) {
  127678. defines += "PHOTOGRAPHIC_TONEMAPPING";
  127679. }
  127680. //sadly a second call to create the effect.
  127681. _this.updateEffect(defines);
  127682. _this.onApply = function (effect) {
  127683. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  127684. };
  127685. return _this;
  127686. }
  127687. return TonemapPostProcess;
  127688. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  127689. /***/ }),
  127690. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  127691. /*!***************************************************************!*\
  127692. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  127693. \***************************************************************/
  127694. /*! exports provided: VolumetricLightScatteringPostProcess */
  127695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127696. "use strict";
  127697. __webpack_require__.r(__webpack_exports__);
  127698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  127699. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127700. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  127701. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  127702. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  127703. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  127704. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  127705. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  127706. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  127707. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  127708. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  127709. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  127710. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  127711. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127712. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  127713. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  127714. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  127715. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  127716. /**
  127717. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127718. */
  127719. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  127720. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  127721. /**
  127722. * @constructor
  127723. * @param name The post-process name
  127724. * @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)
  127725. * @param camera The camera that the post-process will be attached to
  127726. * @param mesh The mesh used to create the light scattering
  127727. * @param samples The post-process quality, default 100
  127728. * @param samplingModeThe post-process filtering mode
  127729. * @param engine The babylon engine
  127730. * @param reusable If the post-process is reusable
  127731. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  127732. */
  127733. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  127734. if (samples === void 0) { samples = 100; }
  127735. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  127736. 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;
  127737. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  127738. /**
  127739. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127740. */
  127741. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  127742. /**
  127743. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127744. */
  127745. _this.useCustomMeshPosition = false;
  127746. /**
  127747. * If the post-process should inverse the light scattering direction
  127748. */
  127749. _this.invert = true;
  127750. /**
  127751. * Array containing the excluded meshes not rendered in the internal pass
  127752. */
  127753. _this.excludedMeshes = new Array();
  127754. /**
  127755. * Controls the overall intensity of the post-process
  127756. */
  127757. _this.exposure = 0.3;
  127758. /**
  127759. * Dissipates each sample's contribution in range [0, 1]
  127760. */
  127761. _this.decay = 0.96815;
  127762. /**
  127763. * Controls the overall intensity of each sample
  127764. */
  127765. _this.weight = 0.58767;
  127766. /**
  127767. * Controls the density of each sample
  127768. */
  127769. _this.density = 0.926;
  127770. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  127771. engine = scene.getEngine();
  127772. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  127773. // Configure mesh
  127774. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  127775. // Configure
  127776. _this._createPass(scene, ratio.passRatio || ratio);
  127777. _this.onActivate = function (camera) {
  127778. if (!_this.isSupported) {
  127779. _this.dispose(camera);
  127780. }
  127781. _this.onActivate = null;
  127782. };
  127783. _this.onApplyObservable.add(function (effect) {
  127784. _this._updateMeshScreenCoordinates(scene);
  127785. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  127786. effect.setFloat("exposure", _this.exposure);
  127787. effect.setFloat("decay", _this.decay);
  127788. effect.setFloat("weight", _this.weight);
  127789. effect.setFloat("density", _this.density);
  127790. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  127791. });
  127792. return _this;
  127793. }
  127794. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  127795. /**
  127796. * @hidden
  127797. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  127798. */
  127799. get: function () {
  127800. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  127801. return false;
  127802. },
  127803. set: function (useDiffuseColor) {
  127804. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  127805. },
  127806. enumerable: true,
  127807. configurable: true
  127808. });
  127809. /**
  127810. * Returns the string "VolumetricLightScatteringPostProcess"
  127811. * @returns "VolumetricLightScatteringPostProcess"
  127812. */
  127813. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  127814. return "VolumetricLightScatteringPostProcess";
  127815. };
  127816. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  127817. var mesh = subMesh.getMesh();
  127818. // Render this.mesh as default
  127819. if (mesh === this.mesh && mesh.material) {
  127820. return mesh.material.isReady(mesh);
  127821. }
  127822. var defines = [];
  127823. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  127824. var material = subMesh.getMaterial();
  127825. // Alpha test
  127826. if (material) {
  127827. if (material.needAlphaTesting()) {
  127828. defines.push("#define ALPHATEST");
  127829. }
  127830. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  127831. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  127832. defines.push("#define UV1");
  127833. }
  127834. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  127835. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  127836. defines.push("#define UV2");
  127837. }
  127838. }
  127839. // Bones
  127840. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  127841. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  127842. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  127843. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  127844. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  127845. }
  127846. else {
  127847. defines.push("#define NUM_BONE_INFLUENCERS 0");
  127848. }
  127849. // Instances
  127850. if (useInstances) {
  127851. defines.push("#define INSTANCES");
  127852. attribs.push("world0");
  127853. attribs.push("world1");
  127854. attribs.push("world2");
  127855. attribs.push("world3");
  127856. }
  127857. // Get correct effect
  127858. var join = defines.join("\n");
  127859. if (this._cachedDefines !== join) {
  127860. this._cachedDefines = join;
  127861. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  127862. }
  127863. return this._volumetricLightScatteringPass.isReady();
  127864. };
  127865. /**
  127866. * Sets the new light position for light scattering effect
  127867. * @param position The new custom light position
  127868. */
  127869. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  127870. this.customMeshPosition = position;
  127871. };
  127872. /**
  127873. * Returns the light position for light scattering effect
  127874. * @return Vector3 The custom light position
  127875. */
  127876. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  127877. return this.customMeshPosition;
  127878. };
  127879. /**
  127880. * Disposes the internal assets and detaches the post-process from the camera
  127881. */
  127882. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  127883. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  127884. if (rttIndex !== -1) {
  127885. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  127886. }
  127887. this._volumetricLightScatteringRTT.dispose();
  127888. _super.prototype.dispose.call(this, camera);
  127889. };
  127890. /**
  127891. * Returns the render target texture used by the post-process
  127892. * @return the render target texture used by the post-process
  127893. */
  127894. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  127895. return this._volumetricLightScatteringRTT;
  127896. };
  127897. // Private methods
  127898. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  127899. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  127900. return true;
  127901. }
  127902. return false;
  127903. };
  127904. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  127905. var _this = this;
  127906. var engine = scene.getEngine();
  127907. 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);
  127908. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  127909. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  127910. this._volumetricLightScatteringRTT.renderList = null;
  127911. this._volumetricLightScatteringRTT.renderParticles = false;
  127912. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  127913. var camera = this.getCamera();
  127914. if (camera) {
  127915. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  127916. }
  127917. else {
  127918. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  127919. }
  127920. // Custom render function for submeshes
  127921. var renderSubMesh = function (subMesh) {
  127922. var mesh = subMesh.getRenderingMesh();
  127923. if (_this._meshExcluded(mesh)) {
  127924. return;
  127925. }
  127926. var material = subMesh.getMaterial();
  127927. if (!material) {
  127928. return;
  127929. }
  127930. var scene = mesh.getScene();
  127931. var engine = scene.getEngine();
  127932. // Culling
  127933. engine.setState(material.backFaceCulling);
  127934. // Managing instances
  127935. var batch = mesh._getInstancesRenderList(subMesh._id);
  127936. if (batch.mustReturn) {
  127937. return;
  127938. }
  127939. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  127940. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  127941. var effect = _this._volumetricLightScatteringPass;
  127942. if (mesh === _this.mesh) {
  127943. if (subMesh.effect) {
  127944. effect = subMesh.effect;
  127945. }
  127946. else {
  127947. effect = material.getEffect();
  127948. }
  127949. }
  127950. engine.enableEffect(effect);
  127951. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  127952. if (mesh === _this.mesh) {
  127953. material.bind(mesh.getWorldMatrix(), mesh);
  127954. }
  127955. else {
  127956. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  127957. // Alpha test
  127958. if (material && material.needAlphaTesting()) {
  127959. var alphaTexture = material.getAlphaTestTexture();
  127960. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  127961. if (alphaTexture) {
  127962. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  127963. }
  127964. }
  127965. // Bones
  127966. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  127967. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  127968. }
  127969. }
  127970. // Draw
  127971. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  127972. }
  127973. };
  127974. // Render target texture callbacks
  127975. var savedSceneClearColor;
  127976. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  127977. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  127978. savedSceneClearColor = scene.clearColor;
  127979. scene.clearColor = sceneClearColor;
  127980. });
  127981. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  127982. scene.clearColor = savedSceneClearColor;
  127983. });
  127984. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  127985. var engine = scene.getEngine();
  127986. var index;
  127987. if (depthOnlySubMeshes.length) {
  127988. engine.setColorWrite(false);
  127989. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  127990. renderSubMesh(depthOnlySubMeshes.data[index]);
  127991. }
  127992. engine.setColorWrite(true);
  127993. }
  127994. for (index = 0; index < opaqueSubMeshes.length; index++) {
  127995. renderSubMesh(opaqueSubMeshes.data[index]);
  127996. }
  127997. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  127998. renderSubMesh(alphaTestSubMeshes.data[index]);
  127999. }
  128000. if (transparentSubMeshes.length) {
  128001. // Sort sub meshes
  128002. for (index = 0; index < transparentSubMeshes.length; index++) {
  128003. var submesh = transparentSubMeshes.data[index];
  128004. var boundingInfo = submesh.getBoundingInfo();
  128005. if (boundingInfo && scene.activeCamera) {
  128006. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  128007. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  128008. }
  128009. }
  128010. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  128011. sortedArray.sort(function (a, b) {
  128012. // Alpha index first
  128013. if (a._alphaIndex > b._alphaIndex) {
  128014. return 1;
  128015. }
  128016. if (a._alphaIndex < b._alphaIndex) {
  128017. return -1;
  128018. }
  128019. // Then distance to camera
  128020. if (a._distanceToCamera < b._distanceToCamera) {
  128021. return 1;
  128022. }
  128023. if (a._distanceToCamera > b._distanceToCamera) {
  128024. return -1;
  128025. }
  128026. return 0;
  128027. });
  128028. // Render sub meshes
  128029. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  128030. for (index = 0; index < sortedArray.length; index++) {
  128031. renderSubMesh(sortedArray[index]);
  128032. }
  128033. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  128034. }
  128035. };
  128036. };
  128037. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  128038. var transform = scene.getTransformMatrix();
  128039. var meshPosition;
  128040. if (this.useCustomMeshPosition) {
  128041. meshPosition = this.customMeshPosition;
  128042. }
  128043. else if (this.attachedNode) {
  128044. meshPosition = this.attachedNode.position;
  128045. }
  128046. else {
  128047. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  128048. }
  128049. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  128050. this._screenCoordinates.x = pos.x / this._viewPort.width;
  128051. this._screenCoordinates.y = pos.y / this._viewPort.height;
  128052. if (this.invert) {
  128053. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  128054. }
  128055. };
  128056. // Static methods
  128057. /**
  128058. * Creates a default mesh for the Volumeric Light Scattering post-process
  128059. * @param name The mesh name
  128060. * @param scene The scene where to create the mesh
  128061. * @return the default mesh
  128062. */
  128063. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  128064. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  128065. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  128066. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  128067. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  128068. mesh.material = material;
  128069. return mesh;
  128070. };
  128071. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128072. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  128073. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  128074. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128075. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  128076. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  128077. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128078. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  128079. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  128080. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128081. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  128082. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  128083. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128084. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  128085. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  128086. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128087. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  128088. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  128089. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128090. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  128091. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  128092. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  128094. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  128095. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  128097. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  128098. return VolumetricLightScatteringPostProcess;
  128099. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  128100. /***/ }),
  128101. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  128102. /*!************************************************************!*\
  128103. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  128104. \************************************************************/
  128105. /*! exports provided: VRDistortionCorrectionPostProcess */
  128106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128107. "use strict";
  128108. __webpack_require__.r(__webpack_exports__);
  128109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  128110. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  128111. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  128112. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  128113. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  128114. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  128115. /**
  128116. * VRDistortionCorrectionPostProcess used for mobile VR
  128117. */
  128118. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  128119. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  128120. /**
  128121. * Initializes the VRDistortionCorrectionPostProcess
  128122. * @param name The name of the effect.
  128123. * @param camera The camera to apply the render pass to.
  128124. * @param isRightEye If this is for the right eye distortion
  128125. * @param vrMetrics All the required metrics for the VR camera
  128126. */
  128127. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  128128. var _this = _super.call(this, name, "vrDistortionCorrection", [
  128129. 'LensCenter',
  128130. 'Scale',
  128131. 'ScaleIn',
  128132. 'HmdWarpParam'
  128133. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  128134. _this._isRightEye = isRightEye;
  128135. _this._distortionFactors = vrMetrics.distortionK;
  128136. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  128137. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  128138. _this.adaptScaleToCurrentViewport = true;
  128139. _this.onSizeChangedObservable.add(function () {
  128140. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  128141. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  128142. _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);
  128143. });
  128144. _this.onApplyObservable.add(function (effect) {
  128145. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  128146. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  128147. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  128148. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  128149. });
  128150. return _this;
  128151. }
  128152. return VRDistortionCorrectionPostProcess;
  128153. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  128154. /***/ }),
  128155. /***/ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts":
  128156. /*!*************************************************************!*\
  128157. !*** ./PostProcesses/vrMultiviewToSingleviewPostProcess.ts ***!
  128158. \*************************************************************/
  128159. /*! exports provided: VRMultiviewToSingleviewPostProcess */
  128160. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128161. "use strict";
  128162. __webpack_require__.r(__webpack_exports__);
  128163. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return VRMultiviewToSingleviewPostProcess; });
  128164. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  128165. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  128166. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  128167. /* harmony import */ var _Shaders_vrMultiviewToSingleview_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/vrMultiviewToSingleview.fragment */ "./Shaders/vrMultiviewToSingleview.fragment.ts");
  128168. /* harmony import */ var _Engines_Extensions_engine_multiview__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/Extensions/engine.multiview */ "./Engines/Extensions/engine.multiview.ts");
  128169. /**
  128170. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  128171. * This will not be used for webXR as it supports displaying texture arrays directly
  128172. */
  128173. var VRMultiviewToSingleviewPostProcess = /** @class */ (function (_super) {
  128174. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRMultiviewToSingleviewPostProcess, _super);
  128175. /**
  128176. * Initializes a VRMultiviewToSingleview
  128177. * @param name name of the post process
  128178. * @param camera camera to be applied to
  128179. * @param scaleFactor scaling factor to the size of the output texture
  128180. */
  128181. function VRMultiviewToSingleviewPostProcess(name, camera, scaleFactor) {
  128182. var _this = _super.call(this, name, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], scaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  128183. _this.onSizeChangedObservable.add(function () {
  128184. });
  128185. _this.onApplyObservable.add(function (effect) {
  128186. if (camera._scene.activeCamera && camera._scene.activeCamera.isLeftCamera) {
  128187. effect.setInt("imageIndex", 0);
  128188. }
  128189. else {
  128190. effect.setInt("imageIndex", 1);
  128191. }
  128192. effect.setTexture("multiviewSampler", camera._multiviewTexture);
  128193. });
  128194. return _this;
  128195. }
  128196. return VRMultiviewToSingleviewPostProcess;
  128197. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  128198. /***/ }),
  128199. /***/ "./Probes/index.ts":
  128200. /*!*************************!*\
  128201. !*** ./Probes/index.ts ***!
  128202. \*************************/
  128203. /*! exports provided: ReflectionProbe */
  128204. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128205. "use strict";
  128206. __webpack_require__.r(__webpack_exports__);
  128207. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  128208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  128209. /***/ }),
  128210. /***/ "./Probes/reflectionProbe.ts":
  128211. /*!***********************************!*\
  128212. !*** ./Probes/reflectionProbe.ts ***!
  128213. \***********************************/
  128214. /*! exports provided: ReflectionProbe */
  128215. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128216. "use strict";
  128217. __webpack_require__.r(__webpack_exports__);
  128218. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  128219. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  128220. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  128221. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  128222. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  128223. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  128224. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  128225. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  128226. if (!this.reflectionProbes) {
  128227. return -1;
  128228. }
  128229. var index = this.reflectionProbes.indexOf(toRemove);
  128230. if (index !== -1) {
  128231. this.reflectionProbes.splice(index, 1);
  128232. }
  128233. return index;
  128234. };
  128235. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  128236. if (!this.reflectionProbes) {
  128237. this.reflectionProbes = [];
  128238. }
  128239. this.reflectionProbes.push(newReflectionProbe);
  128240. };
  128241. /**
  128242. * Class used to generate realtime reflection / refraction cube textures
  128243. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128244. */
  128245. var ReflectionProbe = /** @class */ (function () {
  128246. /**
  128247. * Creates a new reflection probe
  128248. * @param name defines the name of the probe
  128249. * @param size defines the texture resolution (for each face)
  128250. * @param scene defines the hosting scene
  128251. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128252. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128253. */
  128254. function ReflectionProbe(
  128255. /** defines the name of the probe */
  128256. name, size, scene, generateMipMaps, useFloat) {
  128257. var _this = this;
  128258. if (generateMipMaps === void 0) { generateMipMaps = true; }
  128259. if (useFloat === void 0) { useFloat = false; }
  128260. this.name = name;
  128261. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  128262. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  128263. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  128264. this._invertYAxis = false;
  128265. /** Gets or sets probe position (center of the cube map) */
  128266. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  128267. this._scene = scene;
  128268. // Create the scene field if not exist.
  128269. if (!this._scene.reflectionProbes) {
  128270. this._scene.reflectionProbes = new Array();
  128271. }
  128272. this._scene.reflectionProbes.push(this);
  128273. 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);
  128274. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  128275. switch (faceIndex) {
  128276. case 0:
  128277. _this._add.copyFromFloats(1, 0, 0);
  128278. break;
  128279. case 1:
  128280. _this._add.copyFromFloats(-1, 0, 0);
  128281. break;
  128282. case 2:
  128283. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  128284. break;
  128285. case 3:
  128286. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  128287. break;
  128288. case 4:
  128289. _this._add.copyFromFloats(0, 0, 1);
  128290. break;
  128291. case 5:
  128292. _this._add.copyFromFloats(0, 0, -1);
  128293. break;
  128294. }
  128295. if (_this._attachedMesh) {
  128296. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  128297. }
  128298. _this.position.addToRef(_this._add, _this._target);
  128299. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  128300. if (scene.activeCamera) {
  128301. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  128302. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  128303. }
  128304. scene._forcedViewPosition = _this.position;
  128305. });
  128306. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  128307. scene._forcedViewPosition = null;
  128308. scene.updateTransformMatrix(true);
  128309. });
  128310. }
  128311. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  128312. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128313. get: function () {
  128314. return this._renderTargetTexture.samples;
  128315. },
  128316. set: function (value) {
  128317. this._renderTargetTexture.samples = value;
  128318. },
  128319. enumerable: true,
  128320. configurable: true
  128321. });
  128322. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  128323. /** Gets or sets the refresh rate to use (on every frame by default) */
  128324. get: function () {
  128325. return this._renderTargetTexture.refreshRate;
  128326. },
  128327. set: function (value) {
  128328. this._renderTargetTexture.refreshRate = value;
  128329. },
  128330. enumerable: true,
  128331. configurable: true
  128332. });
  128333. /**
  128334. * Gets the hosting scene
  128335. * @returns a Scene
  128336. */
  128337. ReflectionProbe.prototype.getScene = function () {
  128338. return this._scene;
  128339. };
  128340. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  128341. /** Gets the internal CubeTexture used to render to */
  128342. get: function () {
  128343. return this._renderTargetTexture;
  128344. },
  128345. enumerable: true,
  128346. configurable: true
  128347. });
  128348. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  128349. /** Gets the list of meshes to render */
  128350. get: function () {
  128351. return this._renderTargetTexture.renderList;
  128352. },
  128353. enumerable: true,
  128354. configurable: true
  128355. });
  128356. /**
  128357. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128358. * @param mesh defines the mesh to attach to
  128359. */
  128360. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  128361. this._attachedMesh = mesh;
  128362. };
  128363. /**
  128364. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128365. * @param renderingGroupId The rendering group id corresponding to its index
  128366. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128367. */
  128368. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  128369. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  128370. };
  128371. /**
  128372. * Clean all associated resources
  128373. */
  128374. ReflectionProbe.prototype.dispose = function () {
  128375. var index = this._scene.reflectionProbes.indexOf(this);
  128376. if (index !== -1) {
  128377. // Remove from the scene if found
  128378. this._scene.reflectionProbes.splice(index, 1);
  128379. }
  128380. if (this._renderTargetTexture) {
  128381. this._renderTargetTexture.dispose();
  128382. this._renderTargetTexture = null;
  128383. }
  128384. };
  128385. /**
  128386. * Converts the reflection probe information to a readable string for debug purpose.
  128387. * @param fullDetails Supports for multiple levels of logging within scene loading
  128388. * @returns the human readable reflection probe info
  128389. */
  128390. ReflectionProbe.prototype.toString = function (fullDetails) {
  128391. var ret = "Name: " + this.name;
  128392. if (fullDetails) {
  128393. ret += ", position: " + this.position.toString();
  128394. if (this._attachedMesh) {
  128395. ret += ", attached mesh: " + this._attachedMesh.name;
  128396. }
  128397. }
  128398. return ret;
  128399. };
  128400. /**
  128401. * Get the class name of the relfection probe.
  128402. * @returns "ReflectionProbe"
  128403. */
  128404. ReflectionProbe.prototype.getClassName = function () {
  128405. return "ReflectionProbe";
  128406. };
  128407. /**
  128408. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128409. * @returns The JSON representation of the texture
  128410. */
  128411. ReflectionProbe.prototype.serialize = function () {
  128412. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  128413. serializationObject.isReflectionProbe = true;
  128414. return serializationObject;
  128415. };
  128416. /**
  128417. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128418. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128419. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128420. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128421. * @returns The parsed reflection probe if successful
  128422. */
  128423. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  128424. var reflectionProbe = null;
  128425. if (scene.reflectionProbes) {
  128426. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  128427. var rp = scene.reflectionProbes[index];
  128428. if (rp.name === parsedReflectionProbe.name) {
  128429. reflectionProbe = rp;
  128430. break;
  128431. }
  128432. }
  128433. }
  128434. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  128435. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  128436. if (parsedReflectionProbe._attachedMesh) {
  128437. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  128438. }
  128439. return reflectionProbe;
  128440. };
  128441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  128443. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  128444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  128446. ], ReflectionProbe.prototype, "position", void 0);
  128447. return ReflectionProbe;
  128448. }());
  128449. /***/ }),
  128450. /***/ "./Rendering/boundingBoxRenderer.ts":
  128451. /*!******************************************!*\
  128452. !*** ./Rendering/boundingBoxRenderer.ts ***!
  128453. \******************************************/
  128454. /*! exports provided: BoundingBoxRenderer */
  128455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128456. "use strict";
  128457. __webpack_require__.r(__webpack_exports__);
  128458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  128459. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  128460. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  128461. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  128462. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  128463. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  128464. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  128465. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  128466. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  128467. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  128468. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  128469. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  128470. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  128471. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  128472. get: function () {
  128473. return this._forceShowBoundingBoxes || false;
  128474. },
  128475. set: function (value) {
  128476. this._forceShowBoundingBoxes = value;
  128477. // Lazyly creates a BB renderer if needed.
  128478. if (value) {
  128479. this.getBoundingBoxRenderer();
  128480. }
  128481. },
  128482. enumerable: true,
  128483. configurable: true
  128484. });
  128485. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  128486. if (!this._boundingBoxRenderer) {
  128487. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  128488. }
  128489. return this._boundingBoxRenderer;
  128490. };
  128491. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  128492. get: function () {
  128493. return this._showBoundingBox || false;
  128494. },
  128495. set: function (value) {
  128496. this._showBoundingBox = value;
  128497. // Lazyly creates a BB renderer if needed.
  128498. if (value) {
  128499. this.getScene().getBoundingBoxRenderer();
  128500. }
  128501. },
  128502. enumerable: true,
  128503. configurable: true
  128504. });
  128505. /**
  128506. * Component responsible of rendering the bounding box of the meshes in a scene.
  128507. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  128508. */
  128509. var BoundingBoxRenderer = /** @class */ (function () {
  128510. /**
  128511. * Instantiates a new bounding box renderer in a scene.
  128512. * @param scene the scene the renderer renders in
  128513. */
  128514. function BoundingBoxRenderer(scene) {
  128515. /**
  128516. * The component name helpfull to identify the component in the list of scene components.
  128517. */
  128518. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  128519. /**
  128520. * Color of the bounding box lines placed in front of an object
  128521. */
  128522. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  128523. /**
  128524. * Color of the bounding box lines placed behind an object
  128525. */
  128526. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  128527. /**
  128528. * Defines if the renderer should show the back lines or not
  128529. */
  128530. this.showBackLines = true;
  128531. /**
  128532. * @hidden
  128533. */
  128534. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  128535. this._vertexBuffers = {};
  128536. this.scene = scene;
  128537. scene._addComponent(this);
  128538. }
  128539. /**
  128540. * Registers the component in a given scene
  128541. */
  128542. BoundingBoxRenderer.prototype.register = function () {
  128543. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  128544. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  128545. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  128546. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  128547. };
  128548. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  128549. if (mesh.showSubMeshesBoundingBox) {
  128550. var boundingInfo = subMesh.getBoundingInfo();
  128551. if (boundingInfo !== null && boundingInfo !== undefined) {
  128552. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  128553. this.renderList.push(boundingInfo.boundingBox);
  128554. }
  128555. }
  128556. };
  128557. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  128558. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  128559. var boundingInfo = sourceMesh.getBoundingInfo();
  128560. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  128561. this.renderList.push(boundingInfo.boundingBox);
  128562. }
  128563. };
  128564. BoundingBoxRenderer.prototype._prepareRessources = function () {
  128565. if (this._colorShader) {
  128566. return;
  128567. }
  128568. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  128569. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  128570. uniforms: ["world", "viewProjection", "color"]
  128571. });
  128572. var engine = this.scene.getEngine();
  128573. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  128574. 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);
  128575. this._createIndexBuffer();
  128576. };
  128577. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  128578. var engine = this.scene.getEngine();
  128579. 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]);
  128580. };
  128581. /**
  128582. * Rebuilds the elements related to this component in case of
  128583. * context lost for instance.
  128584. */
  128585. BoundingBoxRenderer.prototype.rebuild = function () {
  128586. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  128587. if (vb) {
  128588. vb._rebuild();
  128589. }
  128590. this._createIndexBuffer();
  128591. };
  128592. /**
  128593. * @hidden
  128594. */
  128595. BoundingBoxRenderer.prototype.reset = function () {
  128596. this.renderList.reset();
  128597. };
  128598. /**
  128599. * Render the bounding boxes of a specific rendering group
  128600. * @param renderingGroupId defines the rendering group to render
  128601. */
  128602. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  128603. if (this.renderList.length === 0) {
  128604. return;
  128605. }
  128606. this._prepareRessources();
  128607. if (!this._colorShader.isReady()) {
  128608. return;
  128609. }
  128610. var engine = this.scene.getEngine();
  128611. engine.setDepthWrite(false);
  128612. this._colorShader._preBind();
  128613. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  128614. var boundingBox = this.renderList.data[boundingBoxIndex];
  128615. if (boundingBox._tag !== renderingGroupId) {
  128616. continue;
  128617. }
  128618. var min = boundingBox.minimum;
  128619. var max = boundingBox.maximum;
  128620. var diff = max.subtract(min);
  128621. var median = min.add(diff.scale(0.5));
  128622. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  128623. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  128624. .multiply(boundingBox.getWorldMatrix());
  128625. // VBOs
  128626. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  128627. if (this.showBackLines) {
  128628. // Back
  128629. engine.setDepthFunctionToGreaterOrEqual();
  128630. this.scene.resetCachedMaterial();
  128631. this._colorShader.setColor4("color", this.backColor.toColor4());
  128632. this._colorShader.bind(worldMatrix);
  128633. // Draw order
  128634. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  128635. }
  128636. // Front
  128637. engine.setDepthFunctionToLess();
  128638. this.scene.resetCachedMaterial();
  128639. this._colorShader.setColor4("color", this.frontColor.toColor4());
  128640. this._colorShader.bind(worldMatrix);
  128641. // Draw order
  128642. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  128643. }
  128644. this._colorShader.unbind();
  128645. engine.setDepthFunctionToLessOrEqual();
  128646. engine.setDepthWrite(true);
  128647. };
  128648. /**
  128649. * In case of occlusion queries, we can render the occlusion bounding box through this method
  128650. * @param mesh Define the mesh to render the occlusion bounding box for
  128651. */
  128652. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  128653. this._prepareRessources();
  128654. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  128655. return;
  128656. }
  128657. var engine = this.scene.getEngine();
  128658. engine.setDepthWrite(false);
  128659. engine.setColorWrite(false);
  128660. this._colorShader._preBind();
  128661. var boundingBox = mesh._boundingInfo.boundingBox;
  128662. var min = boundingBox.minimum;
  128663. var max = boundingBox.maximum;
  128664. var diff = max.subtract(min);
  128665. var median = min.add(diff.scale(0.5));
  128666. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  128667. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  128668. .multiply(boundingBox.getWorldMatrix());
  128669. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  128670. engine.setDepthFunctionToLess();
  128671. this.scene.resetCachedMaterial();
  128672. this._colorShader.bind(worldMatrix);
  128673. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  128674. this._colorShader.unbind();
  128675. engine.setDepthFunctionToLessOrEqual();
  128676. engine.setDepthWrite(true);
  128677. engine.setColorWrite(true);
  128678. };
  128679. /**
  128680. * Dispose and release the resources attached to this renderer.
  128681. */
  128682. BoundingBoxRenderer.prototype.dispose = function () {
  128683. if (!this._colorShader) {
  128684. return;
  128685. }
  128686. this.renderList.dispose();
  128687. this._colorShader.dispose();
  128688. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  128689. if (buffer) {
  128690. buffer.dispose();
  128691. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  128692. }
  128693. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  128694. };
  128695. return BoundingBoxRenderer;
  128696. }());
  128697. /***/ }),
  128698. /***/ "./Rendering/depthRenderer.ts":
  128699. /*!************************************!*\
  128700. !*** ./Rendering/depthRenderer.ts ***!
  128701. \************************************/
  128702. /*! exports provided: DepthRenderer */
  128703. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128704. "use strict";
  128705. __webpack_require__.r(__webpack_exports__);
  128706. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  128707. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  128708. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  128709. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  128710. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  128711. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  128712. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  128713. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  128714. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  128715. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  128716. /**
  128717. * This represents a depth renderer in Babylon.
  128718. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128719. */
  128720. var DepthRenderer = /** @class */ (function () {
  128721. /**
  128722. * Instantiates a depth renderer
  128723. * @param scene The scene the renderer belongs to
  128724. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128725. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128726. */
  128727. function DepthRenderer(scene, type, camera) {
  128728. var _this = this;
  128729. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  128730. if (camera === void 0) { camera = null; }
  128731. /**
  128732. * Specifiess that the depth renderer will only be used within
  128733. * the camera it is created for.
  128734. * This can help forcing its rendering during the camera processing.
  128735. */
  128736. this.useOnlyInActiveCamera = false;
  128737. this._scene = scene;
  128738. DepthRenderer._SceneComponentInitialization(this._scene);
  128739. this._camera = camera;
  128740. var engine = scene.getEngine();
  128741. // Render target
  128742. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  128743. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  128744. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  128745. this._depthMap.refreshRate = 1;
  128746. this._depthMap.renderParticles = false;
  128747. this._depthMap.renderList = null;
  128748. // Camera to get depth map from to support multiple concurrent cameras
  128749. this._depthMap.activeCamera = this._camera;
  128750. this._depthMap.ignoreCameraViewport = true;
  128751. this._depthMap.useCameraPostProcesses = false;
  128752. // set default depth value to 1.0 (far away)
  128753. this._depthMap.onClearObservable.add(function (engine) {
  128754. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  128755. });
  128756. // Custom render function
  128757. var renderSubMesh = function (subMesh) {
  128758. var mesh = subMesh.getRenderingMesh();
  128759. var scene = _this._scene;
  128760. var engine = scene.getEngine();
  128761. var material = subMesh.getMaterial();
  128762. if (!material) {
  128763. return;
  128764. }
  128765. // Culling and reverse (right handed system)
  128766. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  128767. // Managing instances
  128768. var batch = mesh._getInstancesRenderList(subMesh._id);
  128769. if (batch.mustReturn) {
  128770. return;
  128771. }
  128772. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  128773. var camera = _this._camera || scene.activeCamera;
  128774. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  128775. engine.enableEffect(_this._effect);
  128776. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  128777. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  128778. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  128779. // Alpha test
  128780. if (material && material.needAlphaTesting()) {
  128781. var alphaTexture = material.getAlphaTestTexture();
  128782. if (alphaTexture) {
  128783. _this._effect.setTexture("diffuseSampler", alphaTexture);
  128784. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  128785. }
  128786. }
  128787. // Bones
  128788. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  128789. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  128790. }
  128791. // Draw
  128792. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  128793. }
  128794. };
  128795. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  128796. var index;
  128797. if (depthOnlySubMeshes.length) {
  128798. engine.setColorWrite(false);
  128799. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  128800. renderSubMesh(depthOnlySubMeshes.data[index]);
  128801. }
  128802. engine.setColorWrite(true);
  128803. }
  128804. for (index = 0; index < opaqueSubMeshes.length; index++) {
  128805. renderSubMesh(opaqueSubMeshes.data[index]);
  128806. }
  128807. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  128808. renderSubMesh(alphaTestSubMeshes.data[index]);
  128809. }
  128810. };
  128811. }
  128812. /**
  128813. * Creates the depth rendering effect and checks if the effect is ready.
  128814. * @param subMesh The submesh to be used to render the depth map of
  128815. * @param useInstances If multiple world instances should be used
  128816. * @returns if the depth renderer is ready to render the depth map
  128817. */
  128818. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  128819. var material = subMesh.getMaterial();
  128820. if (material.disableDepthWrite) {
  128821. return false;
  128822. }
  128823. var defines = [];
  128824. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  128825. var mesh = subMesh.getMesh();
  128826. // Alpha test
  128827. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  128828. defines.push("#define ALPHATEST");
  128829. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  128830. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  128831. defines.push("#define UV1");
  128832. }
  128833. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  128834. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  128835. defines.push("#define UV2");
  128836. }
  128837. }
  128838. // Bones
  128839. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  128840. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  128841. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  128842. if (mesh.numBoneInfluencers > 4) {
  128843. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  128844. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  128845. }
  128846. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  128847. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  128848. }
  128849. else {
  128850. defines.push("#define NUM_BONE_INFLUENCERS 0");
  128851. }
  128852. // Instances
  128853. if (useInstances) {
  128854. defines.push("#define INSTANCES");
  128855. attribs.push("world0");
  128856. attribs.push("world1");
  128857. attribs.push("world2");
  128858. attribs.push("world3");
  128859. }
  128860. // Get correct effect
  128861. var join = defines.join("\n");
  128862. if (this._cachedDefines !== join) {
  128863. this._cachedDefines = join;
  128864. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  128865. }
  128866. return this._effect.isReady();
  128867. };
  128868. /**
  128869. * Gets the texture which the depth map will be written to.
  128870. * @returns The depth map texture
  128871. */
  128872. DepthRenderer.prototype.getDepthMap = function () {
  128873. return this._depthMap;
  128874. };
  128875. /**
  128876. * Disposes of the depth renderer.
  128877. */
  128878. DepthRenderer.prototype.dispose = function () {
  128879. this._depthMap.dispose();
  128880. };
  128881. /** @hidden */
  128882. DepthRenderer._SceneComponentInitialization = function (_) {
  128883. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  128884. };
  128885. return DepthRenderer;
  128886. }());
  128887. /***/ }),
  128888. /***/ "./Rendering/depthRendererSceneComponent.ts":
  128889. /*!**************************************************!*\
  128890. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  128891. \**************************************************/
  128892. /*! exports provided: DepthRendererSceneComponent */
  128893. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128894. "use strict";
  128895. __webpack_require__.r(__webpack_exports__);
  128896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  128897. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  128898. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  128899. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  128900. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  128901. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  128902. camera = camera || this.activeCamera;
  128903. if (!camera) {
  128904. throw "No camera available to enable depth renderer";
  128905. }
  128906. if (!this._depthRenderer) {
  128907. this._depthRenderer = {};
  128908. }
  128909. if (!this._depthRenderer[camera.id]) {
  128910. var textureType = 0;
  128911. if (this.getEngine().getCaps().textureHalfFloatRender) {
  128912. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  128913. }
  128914. else if (this.getEngine().getCaps().textureFloatRender) {
  128915. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  128916. }
  128917. else {
  128918. throw "Depth renderer does not support int texture type";
  128919. }
  128920. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  128921. }
  128922. return this._depthRenderer[camera.id];
  128923. };
  128924. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  128925. camera = camera || this.activeCamera;
  128926. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  128927. return;
  128928. }
  128929. this._depthRenderer[camera.id].dispose();
  128930. delete this._depthRenderer[camera.id];
  128931. };
  128932. /**
  128933. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  128934. * in several rendering techniques.
  128935. */
  128936. var DepthRendererSceneComponent = /** @class */ (function () {
  128937. /**
  128938. * Creates a new instance of the component for the given scene
  128939. * @param scene Defines the scene to register the component in
  128940. */
  128941. function DepthRendererSceneComponent(scene) {
  128942. /**
  128943. * The component name helpfull to identify the component in the list of scene components.
  128944. */
  128945. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  128946. this.scene = scene;
  128947. }
  128948. /**
  128949. * Registers the component in a given scene
  128950. */
  128951. DepthRendererSceneComponent.prototype.register = function () {
  128952. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  128953. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  128954. };
  128955. /**
  128956. * Rebuilds the elements related to this component in case of
  128957. * context lost for instance.
  128958. */
  128959. DepthRendererSceneComponent.prototype.rebuild = function () {
  128960. // Nothing to do for this component
  128961. };
  128962. /**
  128963. * Disposes the component and the associated ressources
  128964. */
  128965. DepthRendererSceneComponent.prototype.dispose = function () {
  128966. for (var key in this.scene._depthRenderer) {
  128967. this.scene._depthRenderer[key].dispose();
  128968. }
  128969. };
  128970. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  128971. if (this.scene._depthRenderer) {
  128972. for (var key in this.scene._depthRenderer) {
  128973. var depthRenderer = this.scene._depthRenderer[key];
  128974. if (!depthRenderer.useOnlyInActiveCamera) {
  128975. renderTargets.push(depthRenderer.getDepthMap());
  128976. }
  128977. }
  128978. }
  128979. };
  128980. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  128981. if (this.scene._depthRenderer) {
  128982. for (var key in this.scene._depthRenderer) {
  128983. var depthRenderer = this.scene._depthRenderer[key];
  128984. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  128985. renderTargets.push(depthRenderer.getDepthMap());
  128986. }
  128987. }
  128988. }
  128989. };
  128990. return DepthRendererSceneComponent;
  128991. }());
  128992. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  128993. // Register the G Buffer component to the scene.
  128994. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  128995. if (!component) {
  128996. component = new DepthRendererSceneComponent(scene);
  128997. scene._addComponent(component);
  128998. }
  128999. };
  129000. /***/ }),
  129001. /***/ "./Rendering/edgesRenderer.ts":
  129002. /*!************************************!*\
  129003. !*** ./Rendering/edgesRenderer.ts ***!
  129004. \************************************/
  129005. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  129006. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129007. "use strict";
  129008. __webpack_require__.r(__webpack_exports__);
  129009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  129010. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  129011. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  129012. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  129013. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  129014. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  129015. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  129016. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  129017. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  129018. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  129019. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  129020. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  129021. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  129022. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  129023. if (this._edgesRenderer) {
  129024. this._edgesRenderer.dispose();
  129025. this._edgesRenderer = null;
  129026. }
  129027. return this;
  129028. };
  129029. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  129030. if (epsilon === void 0) { epsilon = 0.95; }
  129031. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  129032. this.disableEdgesRendering();
  129033. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  129034. return this;
  129035. };
  129036. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  129037. get: function () {
  129038. return this._edgesRenderer;
  129039. },
  129040. enumerable: true,
  129041. configurable: true
  129042. });
  129043. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  129044. if (epsilon === void 0) { epsilon = 0.95; }
  129045. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  129046. this.disableEdgesRendering();
  129047. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  129048. return this;
  129049. };
  129050. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  129051. if (epsilon === void 0) { epsilon = 0.95; }
  129052. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  129053. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  129054. return this;
  129055. };
  129056. /**
  129057. * FaceAdjacencies Helper class to generate edges
  129058. */
  129059. var FaceAdjacencies = /** @class */ (function () {
  129060. function FaceAdjacencies() {
  129061. this.edges = new Array();
  129062. this.edgesConnectedCount = 0;
  129063. }
  129064. return FaceAdjacencies;
  129065. }());
  129066. /**
  129067. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  129068. */
  129069. var EdgesRenderer = /** @class */ (function () {
  129070. /**
  129071. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  129072. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  129073. * @param source Mesh used to create edges
  129074. * @param epsilon sum of angles in adjacency to check for edge
  129075. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  129076. * @param generateEdgesLines - should generate Lines or only prepare resources.
  129077. */
  129078. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  129079. var _this = this;
  129080. if (epsilon === void 0) { epsilon = 0.95; }
  129081. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  129082. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  129083. /**
  129084. * Define the size of the edges with an orthographic camera
  129085. */
  129086. this.edgesWidthScalerForOrthographic = 1000.0;
  129087. /**
  129088. * Define the size of the edges with a perspective camera
  129089. */
  129090. this.edgesWidthScalerForPerspective = 50.0;
  129091. this._linesPositions = new Array();
  129092. this._linesNormals = new Array();
  129093. this._linesIndices = new Array();
  129094. this._buffers = {};
  129095. this._checkVerticesInsteadOfIndices = false;
  129096. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  129097. this.isEnabled = true;
  129098. this._source = source;
  129099. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  129100. this._epsilon = epsilon;
  129101. this._prepareRessources();
  129102. if (generateEdgesLines) {
  129103. this._generateEdgesLines();
  129104. }
  129105. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  129106. _this._rebuild();
  129107. });
  129108. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  129109. _this.dispose();
  129110. });
  129111. }
  129112. EdgesRenderer.prototype._prepareRessources = function () {
  129113. if (this._lineShader) {
  129114. return;
  129115. }
  129116. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  129117. attributes: ["position", "normal"],
  129118. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  129119. });
  129120. this._lineShader.disableDepthWrite = true;
  129121. this._lineShader.backFaceCulling = false;
  129122. };
  129123. /** @hidden */
  129124. EdgesRenderer.prototype._rebuild = function () {
  129125. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  129126. if (buffer) {
  129127. buffer._rebuild();
  129128. }
  129129. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  129130. if (buffer) {
  129131. buffer._rebuild();
  129132. }
  129133. var scene = this._source.getScene();
  129134. var engine = scene.getEngine();
  129135. this._ib = engine.createIndexBuffer(this._linesIndices);
  129136. };
  129137. /**
  129138. * Releases the required resources for the edges renderer
  129139. */
  129140. EdgesRenderer.prototype.dispose = function () {
  129141. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  129142. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  129143. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  129144. if (buffer) {
  129145. buffer.dispose();
  129146. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  129147. }
  129148. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  129149. if (buffer) {
  129150. buffer.dispose();
  129151. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  129152. }
  129153. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  129154. this._lineShader.dispose();
  129155. };
  129156. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  129157. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  129158. return 0;
  129159. }
  129160. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  129161. return 1;
  129162. }
  129163. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  129164. return 2;
  129165. }
  129166. return -1;
  129167. };
  129168. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  129169. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  129170. return 0;
  129171. }
  129172. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  129173. return 1;
  129174. }
  129175. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  129176. return 2;
  129177. }
  129178. return -1;
  129179. };
  129180. /**
  129181. * Checks if the pair of p0 and p1 is en edge
  129182. * @param faceIndex
  129183. * @param edge
  129184. * @param faceNormals
  129185. * @param p0
  129186. * @param p1
  129187. * @private
  129188. */
  129189. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  129190. var needToCreateLine;
  129191. if (edge === undefined) {
  129192. needToCreateLine = true;
  129193. }
  129194. else {
  129195. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  129196. needToCreateLine = dotProduct < this._epsilon;
  129197. }
  129198. if (needToCreateLine) {
  129199. this.createLine(p0, p1, this._linesPositions.length / 3);
  129200. }
  129201. };
  129202. /**
  129203. * push line into the position, normal and index buffer
  129204. * @protected
  129205. */
  129206. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  129207. // Positions
  129208. 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);
  129209. // Normals
  129210. 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);
  129211. // Indices
  129212. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  129213. };
  129214. /**
  129215. * Generates lines edges from adjacencjes
  129216. * @private
  129217. */
  129218. EdgesRenderer.prototype._generateEdgesLines = function () {
  129219. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  129220. var indices = this._source.getIndices();
  129221. if (!indices || !positions) {
  129222. return;
  129223. }
  129224. // First let's find adjacencies
  129225. var adjacencies = new Array();
  129226. var faceNormals = new Array();
  129227. var index;
  129228. var faceAdjacencies;
  129229. // Prepare faces
  129230. for (index = 0; index < indices.length; index += 3) {
  129231. faceAdjacencies = new FaceAdjacencies();
  129232. var p0Index = indices[index];
  129233. var p1Index = indices[index + 1];
  129234. var p2Index = indices[index + 2];
  129235. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  129236. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  129237. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  129238. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  129239. faceNormal.normalize();
  129240. faceNormals.push(faceNormal);
  129241. adjacencies.push(faceAdjacencies);
  129242. }
  129243. // Scan
  129244. for (index = 0; index < adjacencies.length; index++) {
  129245. faceAdjacencies = adjacencies[index];
  129246. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  129247. var otherFaceAdjacencies = adjacencies[otherIndex];
  129248. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  129249. break;
  129250. }
  129251. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  129252. continue;
  129253. }
  129254. var otherP0 = indices[otherIndex * 3];
  129255. var otherP1 = indices[otherIndex * 3 + 1];
  129256. var otherP2 = indices[otherIndex * 3 + 2];
  129257. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  129258. var otherEdgeIndex = 0;
  129259. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  129260. continue;
  129261. }
  129262. switch (edgeIndex) {
  129263. case 0:
  129264. if (this._checkVerticesInsteadOfIndices) {
  129265. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  129266. }
  129267. else {
  129268. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  129269. }
  129270. break;
  129271. case 1:
  129272. if (this._checkVerticesInsteadOfIndices) {
  129273. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  129274. }
  129275. else {
  129276. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  129277. }
  129278. break;
  129279. case 2:
  129280. if (this._checkVerticesInsteadOfIndices) {
  129281. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  129282. }
  129283. else {
  129284. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  129285. }
  129286. break;
  129287. }
  129288. if (otherEdgeIndex === -1) {
  129289. continue;
  129290. }
  129291. faceAdjacencies.edges[edgeIndex] = otherIndex;
  129292. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  129293. faceAdjacencies.edgesConnectedCount++;
  129294. otherFaceAdjacencies.edgesConnectedCount++;
  129295. if (faceAdjacencies.edgesConnectedCount === 3) {
  129296. break;
  129297. }
  129298. }
  129299. }
  129300. }
  129301. // Create lines
  129302. for (index = 0; index < adjacencies.length; index++) {
  129303. // 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
  129304. var current = adjacencies[index];
  129305. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  129306. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  129307. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  129308. }
  129309. // Merge into a single mesh
  129310. var engine = this._source.getScene().getEngine();
  129311. 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);
  129312. 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);
  129313. this._ib = engine.createIndexBuffer(this._linesIndices);
  129314. this._indicesCount = this._linesIndices.length;
  129315. };
  129316. /**
  129317. * Checks wether or not the edges renderer is ready to render.
  129318. * @return true if ready, otherwise false.
  129319. */
  129320. EdgesRenderer.prototype.isReady = function () {
  129321. return this._lineShader.isReady();
  129322. };
  129323. /**
  129324. * Renders the edges of the attached mesh,
  129325. */
  129326. EdgesRenderer.prototype.render = function () {
  129327. var scene = this._source.getScene();
  129328. if (!this.isReady() || !scene.activeCamera) {
  129329. return;
  129330. }
  129331. var engine = scene.getEngine();
  129332. this._lineShader._preBind();
  129333. if (this._source.edgesColor.a !== 1) {
  129334. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  129335. }
  129336. else {
  129337. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  129338. }
  129339. // VBOs
  129340. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  129341. scene.resetCachedMaterial();
  129342. this._lineShader.setColor4("color", this._source.edgesColor);
  129343. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  129344. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  129345. }
  129346. else {
  129347. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  129348. }
  129349. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  129350. this._lineShader.bind(this._source.getWorldMatrix());
  129351. // Draw order
  129352. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  129353. this._lineShader.unbind();
  129354. };
  129355. return EdgesRenderer;
  129356. }());
  129357. /**
  129358. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  129359. */
  129360. var LineEdgesRenderer = /** @class */ (function (_super) {
  129361. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  129362. /**
  129363. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  129364. * @param source LineMesh used to generate edges
  129365. * @param epsilon not important (specified angle for edge detection)
  129366. * @param checkVerticesInsteadOfIndices not important for LineMesh
  129367. */
  129368. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  129369. if (epsilon === void 0) { epsilon = 0.95; }
  129370. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  129371. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  129372. _this._generateEdgesLines();
  129373. return _this;
  129374. }
  129375. /**
  129376. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  129377. */
  129378. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  129379. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  129380. var indices = this._source.getIndices();
  129381. if (!indices || !positions) {
  129382. return;
  129383. }
  129384. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  129385. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  129386. var len = indices.length - 1;
  129387. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  129388. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  129389. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  129390. this.createLine(p0, p1, offset);
  129391. }
  129392. // Merge into a single mesh
  129393. var engine = this._source.getScene().getEngine();
  129394. 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);
  129395. 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);
  129396. this._ib = engine.createIndexBuffer(this._linesIndices);
  129397. this._indicesCount = this._linesIndices.length;
  129398. };
  129399. return LineEdgesRenderer;
  129400. }(EdgesRenderer));
  129401. /***/ }),
  129402. /***/ "./Rendering/geometryBufferRenderer.ts":
  129403. /*!*********************************************!*\
  129404. !*** ./Rendering/geometryBufferRenderer.ts ***!
  129405. \*********************************************/
  129406. /*! exports provided: GeometryBufferRenderer */
  129407. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129408. "use strict";
  129409. __webpack_require__.r(__webpack_exports__);
  129410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  129411. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  129412. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  129413. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  129414. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  129415. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  129416. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  129417. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  129418. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  129419. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  129420. /**
  129421. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  129422. */
  129423. var GeometryBufferRenderer = /** @class */ (function () {
  129424. /**
  129425. * Creates a new G Buffer for the scene
  129426. * @param scene The scene the buffer belongs to
  129427. * @param ratio How big is the buffer related to the main canvas.
  129428. */
  129429. function GeometryBufferRenderer(scene, ratio) {
  129430. if (ratio === void 0) { ratio = 1; }
  129431. /**
  129432. * Dictionary used to store the previous transformation matrices of each rendered mesh
  129433. * in order to compute objects velocities when enableVelocity is set to "true"
  129434. * @hidden
  129435. */
  129436. this._previousTransformationMatrices = {};
  129437. /**
  129438. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  129439. * in order to compute objects velocities when enableVelocity is set to "true"
  129440. * @hidden
  129441. */
  129442. this._previousBonesTransformationMatrices = {};
  129443. /**
  129444. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  129445. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  129446. */
  129447. this.excludedSkinnedMeshesFromVelocity = [];
  129448. this._enablePosition = false;
  129449. this._enableVelocity = false;
  129450. this._positionIndex = -1;
  129451. this._velocityIndex = -1;
  129452. this._scene = scene;
  129453. this._ratio = ratio;
  129454. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  129455. // Render target
  129456. this._createRenderTargets();
  129457. }
  129458. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  129459. /**
  129460. * Set the render list (meshes to be rendered) used in the G buffer.
  129461. */
  129462. set: function (meshes) {
  129463. this._multiRenderTarget.renderList = meshes;
  129464. },
  129465. enumerable: true,
  129466. configurable: true
  129467. });
  129468. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  129469. /**
  129470. * Gets wether or not G buffer are supported by the running hardware.
  129471. * This requires draw buffer supports
  129472. */
  129473. get: function () {
  129474. return this._multiRenderTarget.isSupported;
  129475. },
  129476. enumerable: true,
  129477. configurable: true
  129478. });
  129479. /**
  129480. * Returns the index of the given texture type in the G-Buffer textures array
  129481. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  129482. * @returns the index of the given texture type in the G-Buffer textures array
  129483. */
  129484. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  129485. switch (textureType) {
  129486. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  129487. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  129488. default: return -1;
  129489. }
  129490. };
  129491. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  129492. /**
  129493. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  129494. */
  129495. get: function () {
  129496. return this._enablePosition;
  129497. },
  129498. /**
  129499. * Sets whether or not objects positions are enabled for the G buffer.
  129500. */
  129501. set: function (enable) {
  129502. this._enablePosition = enable;
  129503. this.dispose();
  129504. this._createRenderTargets();
  129505. },
  129506. enumerable: true,
  129507. configurable: true
  129508. });
  129509. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  129510. /**
  129511. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  129512. */
  129513. get: function () {
  129514. return this._enableVelocity;
  129515. },
  129516. /**
  129517. * Sets wether or not objects velocities are enabled for the G buffer.
  129518. */
  129519. set: function (enable) {
  129520. this._enableVelocity = enable;
  129521. if (!enable) {
  129522. this._previousTransformationMatrices = {};
  129523. }
  129524. this.dispose();
  129525. this._createRenderTargets();
  129526. },
  129527. enumerable: true,
  129528. configurable: true
  129529. });
  129530. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  129531. /**
  129532. * Gets the scene associated with the buffer.
  129533. */
  129534. get: function () {
  129535. return this._scene;
  129536. },
  129537. enumerable: true,
  129538. configurable: true
  129539. });
  129540. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  129541. /**
  129542. * Gets the ratio used by the buffer during its creation.
  129543. * How big is the buffer related to the main canvas.
  129544. */
  129545. get: function () {
  129546. return this._ratio;
  129547. },
  129548. enumerable: true,
  129549. configurable: true
  129550. });
  129551. /**
  129552. * Checks wether everything is ready to render a submesh to the G buffer.
  129553. * @param subMesh the submesh to check readiness for
  129554. * @param useInstances is the mesh drawn using instance or not
  129555. * @returns true if ready otherwise false
  129556. */
  129557. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  129558. var material = subMesh.getMaterial();
  129559. if (material && material.disableDepthWrite) {
  129560. return false;
  129561. }
  129562. var defines = [];
  129563. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  129564. var mesh = subMesh.getMesh();
  129565. // Alpha test
  129566. if (material && material.needAlphaTesting()) {
  129567. defines.push("#define ALPHATEST");
  129568. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  129569. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  129570. defines.push("#define UV1");
  129571. }
  129572. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  129573. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  129574. defines.push("#define UV2");
  129575. }
  129576. }
  129577. // Buffers
  129578. if (this._enablePosition) {
  129579. defines.push("#define POSITION");
  129580. defines.push("#define POSITION_INDEX " + this._positionIndex);
  129581. }
  129582. if (this._enableVelocity) {
  129583. defines.push("#define VELOCITY");
  129584. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  129585. if (this.excludedSkinnedMeshesFromVelocity.indexOf(mesh) === -1) {
  129586. defines.push("#define BONES_VELOCITY_ENABLED");
  129587. }
  129588. }
  129589. // Bones
  129590. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  129591. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  129592. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  129593. if (mesh.numBoneInfluencers > 4) {
  129594. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  129595. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  129596. }
  129597. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  129598. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  129599. }
  129600. else {
  129601. defines.push("#define NUM_BONE_INFLUENCERS 0");
  129602. }
  129603. // Instances
  129604. if (useInstances) {
  129605. defines.push("#define INSTANCES");
  129606. attribs.push("world0");
  129607. attribs.push("world1");
  129608. attribs.push("world2");
  129609. attribs.push("world3");
  129610. }
  129611. // Setup textures count
  129612. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  129613. // Get correct effect
  129614. var join = defines.join("\n");
  129615. if (this._cachedDefines !== join) {
  129616. this._cachedDefines = join;
  129617. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorld", "previousViewProjection", "mPreviousBones"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  129618. }
  129619. return this._effect.isReady();
  129620. };
  129621. /**
  129622. * Gets the current underlying G Buffer.
  129623. * @returns the buffer
  129624. */
  129625. GeometryBufferRenderer.prototype.getGBuffer = function () {
  129626. return this._multiRenderTarget;
  129627. };
  129628. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  129629. /**
  129630. * Gets the number of samples used to render the buffer (anti aliasing).
  129631. */
  129632. get: function () {
  129633. return this._multiRenderTarget.samples;
  129634. },
  129635. /**
  129636. * Sets the number of samples used to render the buffer (anti aliasing).
  129637. */
  129638. set: function (value) {
  129639. this._multiRenderTarget.samples = value;
  129640. },
  129641. enumerable: true,
  129642. configurable: true
  129643. });
  129644. /**
  129645. * Disposes the renderer and frees up associated resources.
  129646. */
  129647. GeometryBufferRenderer.prototype.dispose = function () {
  129648. this.getGBuffer().dispose();
  129649. };
  129650. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  129651. var _this = this;
  129652. var engine = this._scene.getEngine();
  129653. var count = 2;
  129654. if (this._enablePosition) {
  129655. this._positionIndex = count;
  129656. count++;
  129657. }
  129658. if (this._enableVelocity) {
  129659. this._velocityIndex = count;
  129660. count++;
  129661. }
  129662. 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 });
  129663. if (!this.isSupported) {
  129664. return;
  129665. }
  129666. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  129667. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  129668. this._multiRenderTarget.refreshRate = 1;
  129669. this._multiRenderTarget.renderParticles = false;
  129670. this._multiRenderTarget.renderList = null;
  129671. // set default depth value to 1.0 (far away)
  129672. this._multiRenderTarget.onClearObservable.add(function (engine) {
  129673. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  129674. });
  129675. // Custom render function
  129676. var renderSubMesh = function (subMesh) {
  129677. var mesh = subMesh.getRenderingMesh();
  129678. var scene = _this._scene;
  129679. var engine = scene.getEngine();
  129680. var material = subMesh.getMaterial();
  129681. if (!material) {
  129682. return;
  129683. }
  129684. // Velocity
  129685. if (_this._enableVelocity && !_this._previousTransformationMatrices[mesh.uniqueId]) {
  129686. _this._previousTransformationMatrices[mesh.uniqueId] = {
  129687. world: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(),
  129688. viewProjection: scene.getTransformMatrix()
  129689. };
  129690. if (mesh.skeleton) {
  129691. var bonesTransformations = mesh.skeleton.getTransformMatrices(mesh);
  129692. _this._previousBonesTransformationMatrices[mesh.uniqueId] = _this._copyBonesTransformationMatrices(bonesTransformations, new Float32Array(bonesTransformations.length));
  129693. }
  129694. }
  129695. // Culling
  129696. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  129697. // Managing instances
  129698. var batch = mesh._getInstancesRenderList(subMesh._id);
  129699. if (batch.mustReturn) {
  129700. return;
  129701. }
  129702. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  129703. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  129704. engine.enableEffect(_this._effect);
  129705. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  129706. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  129707. _this._effect.setMatrix("view", scene.getViewMatrix());
  129708. // Alpha test
  129709. if (material && material.needAlphaTesting()) {
  129710. var alphaTexture = material.getAlphaTestTexture();
  129711. if (alphaTexture) {
  129712. _this._effect.setTexture("diffuseSampler", alphaTexture);
  129713. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  129714. }
  129715. }
  129716. // Bones
  129717. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  129718. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  129719. if (_this._enableVelocity) {
  129720. _this._effect.setMatrices("mPreviousBones", _this._previousBonesTransformationMatrices[mesh.uniqueId]);
  129721. }
  129722. }
  129723. // Velocity
  129724. if (_this._enableVelocity) {
  129725. _this._effect.setMatrix("previousWorld", _this._previousTransformationMatrices[mesh.uniqueId].world);
  129726. _this._effect.setMatrix("previousViewProjection", _this._previousTransformationMatrices[mesh.uniqueId].viewProjection);
  129727. }
  129728. // Draw
  129729. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  129730. }
  129731. // Velocity
  129732. if (_this._enableVelocity) {
  129733. _this._previousTransformationMatrices[mesh.uniqueId].world = mesh.getWorldMatrix().clone();
  129734. _this._previousTransformationMatrices[mesh.uniqueId].viewProjection = _this._scene.getTransformMatrix().clone();
  129735. if (mesh.skeleton) {
  129736. _this._copyBonesTransformationMatrices(mesh.skeleton.getTransformMatrices(mesh), _this._previousBonesTransformationMatrices[mesh.uniqueId]);
  129737. }
  129738. }
  129739. };
  129740. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  129741. var index;
  129742. if (depthOnlySubMeshes.length) {
  129743. engine.setColorWrite(false);
  129744. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  129745. renderSubMesh(depthOnlySubMeshes.data[index]);
  129746. }
  129747. engine.setColorWrite(true);
  129748. }
  129749. for (index = 0; index < opaqueSubMeshes.length; index++) {
  129750. renderSubMesh(opaqueSubMeshes.data[index]);
  129751. }
  129752. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  129753. renderSubMesh(alphaTestSubMeshes.data[index]);
  129754. }
  129755. };
  129756. };
  129757. // Copies the bones transformation matrices into the target array and returns the target's reference
  129758. GeometryBufferRenderer.prototype._copyBonesTransformationMatrices = function (source, target) {
  129759. for (var i = 0; i < source.length; i++) {
  129760. target[i] = source[i];
  129761. }
  129762. return target;
  129763. };
  129764. /**
  129765. * Constant used to retrieve the position texture index in the G-Buffer textures array
  129766. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  129767. */
  129768. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  129769. /**
  129770. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  129771. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  129772. */
  129773. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  129774. /** @hidden */
  129775. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  129776. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  129777. };
  129778. return GeometryBufferRenderer;
  129779. }());
  129780. /***/ }),
  129781. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  129782. /*!***********************************************************!*\
  129783. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  129784. \***********************************************************/
  129785. /*! exports provided: GeometryBufferRendererSceneComponent */
  129786. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129787. "use strict";
  129788. __webpack_require__.r(__webpack_exports__);
  129789. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  129790. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  129791. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  129792. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  129793. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  129794. get: function () {
  129795. this._geometryBufferRenderer;
  129796. },
  129797. set: function (value) {
  129798. if (value && value.isSupported) {
  129799. this._geometryBufferRenderer = value;
  129800. }
  129801. },
  129802. enumerable: true,
  129803. configurable: true
  129804. });
  129805. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  129806. if (ratio === void 0) { ratio = 1; }
  129807. if (this._geometryBufferRenderer) {
  129808. return this._geometryBufferRenderer;
  129809. }
  129810. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  129811. if (!this._geometryBufferRenderer.isSupported) {
  129812. this._geometryBufferRenderer = null;
  129813. }
  129814. return this._geometryBufferRenderer;
  129815. };
  129816. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  129817. if (!this._geometryBufferRenderer) {
  129818. return;
  129819. }
  129820. this._geometryBufferRenderer.dispose();
  129821. this._geometryBufferRenderer = null;
  129822. };
  129823. /**
  129824. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  129825. * in several rendering techniques.
  129826. */
  129827. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  129828. /**
  129829. * Creates a new instance of the component for the given scene
  129830. * @param scene Defines the scene to register the component in
  129831. */
  129832. function GeometryBufferRendererSceneComponent(scene) {
  129833. /**
  129834. * The component name helpful to identify the component in the list of scene components.
  129835. */
  129836. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  129837. this.scene = scene;
  129838. }
  129839. /**
  129840. * Registers the component in a given scene
  129841. */
  129842. GeometryBufferRendererSceneComponent.prototype.register = function () {
  129843. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  129844. };
  129845. /**
  129846. * Rebuilds the elements related to this component in case of
  129847. * context lost for instance.
  129848. */
  129849. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  129850. // Nothing to do for this component
  129851. };
  129852. /**
  129853. * Disposes the component and the associated ressources
  129854. */
  129855. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  129856. // Nothing to do for this component
  129857. };
  129858. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  129859. if (this.scene._geometryBufferRenderer) {
  129860. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  129861. }
  129862. };
  129863. return GeometryBufferRendererSceneComponent;
  129864. }());
  129865. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  129866. // Register the G Buffer component to the scene.
  129867. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  129868. if (!component) {
  129869. component = new GeometryBufferRendererSceneComponent(scene);
  129870. scene._addComponent(component);
  129871. }
  129872. };
  129873. /***/ }),
  129874. /***/ "./Rendering/index.ts":
  129875. /*!****************************!*\
  129876. !*** ./Rendering/index.ts ***!
  129877. \****************************/
  129878. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  129879. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129880. "use strict";
  129881. __webpack_require__.r(__webpack_exports__);
  129882. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  129883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  129884. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  129885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  129886. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  129887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  129888. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  129889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  129890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  129891. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  129892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  129893. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  129894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  129895. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  129896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  129897. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  129898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  129899. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  129900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  129901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  129902. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  129903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  129904. /***/ }),
  129905. /***/ "./Rendering/outlineRenderer.ts":
  129906. /*!**************************************!*\
  129907. !*** ./Rendering/outlineRenderer.ts ***!
  129908. \**************************************/
  129909. /*! exports provided: OutlineRenderer */
  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__, "OutlineRenderer", function() { return OutlineRenderer; });
  129914. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  129915. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  129916. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  129917. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  129918. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  129919. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  129920. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  129921. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  129922. /**
  129923. * Gets the outline renderer associated with the scene
  129924. * @returns a OutlineRenderer
  129925. */
  129926. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  129927. if (!this._outlineRenderer) {
  129928. this._outlineRenderer = new OutlineRenderer(this);
  129929. }
  129930. return this._outlineRenderer;
  129931. };
  129932. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  129933. get: function () {
  129934. return this._renderOutline;
  129935. },
  129936. set: function (value) {
  129937. if (value) {
  129938. // Lazy Load the component.
  129939. this.getScene().getOutlineRenderer();
  129940. }
  129941. this._renderOutline = value;
  129942. },
  129943. enumerable: true,
  129944. configurable: true
  129945. });
  129946. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  129947. get: function () {
  129948. return this._renderOverlay;
  129949. },
  129950. set: function (value) {
  129951. if (value) {
  129952. // Lazy Load the component.
  129953. this.getScene().getOutlineRenderer();
  129954. }
  129955. this._renderOverlay = value;
  129956. },
  129957. enumerable: true,
  129958. configurable: true
  129959. });
  129960. /**
  129961. * This class is responsible to draw bothe outline/overlay of meshes.
  129962. * It should not be used directly but through the available method on mesh.
  129963. */
  129964. var OutlineRenderer = /** @class */ (function () {
  129965. /**
  129966. * Instantiates a new outline renderer. (There could be only one per scene).
  129967. * @param scene Defines the scene it belongs to
  129968. */
  129969. function OutlineRenderer(scene) {
  129970. /**
  129971. * The name of the component. Each component must have a unique name.
  129972. */
  129973. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  129974. /**
  129975. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  129976. */
  129977. this.zOffset = 1;
  129978. this.scene = scene;
  129979. this._engine = scene.getEngine();
  129980. this.scene._addComponent(this);
  129981. }
  129982. /**
  129983. * Register the component to one instance of a scene.
  129984. */
  129985. OutlineRenderer.prototype.register = function () {
  129986. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  129987. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  129988. };
  129989. /**
  129990. * Rebuilds the elements related to this component in case of
  129991. * context lost for instance.
  129992. */
  129993. OutlineRenderer.prototype.rebuild = function () {
  129994. // Nothing to do here.
  129995. };
  129996. /**
  129997. * Disposes the component and the associated ressources.
  129998. */
  129999. OutlineRenderer.prototype.dispose = function () {
  130000. // Nothing to do here.
  130001. };
  130002. /**
  130003. * Renders the outline in the canvas.
  130004. * @param subMesh Defines the sumesh to render
  130005. * @param batch Defines the batch of meshes in case of instances
  130006. * @param useOverlay Defines if the rendering is for the overlay or the outline
  130007. */
  130008. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  130009. var _this = this;
  130010. if (useOverlay === void 0) { useOverlay = false; }
  130011. var scene = this.scene;
  130012. var engine = scene.getEngine();
  130013. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  130014. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  130015. return;
  130016. }
  130017. var mesh = subMesh.getRenderingMesh();
  130018. var material = subMesh.getMaterial();
  130019. if (!material || !scene.activeCamera) {
  130020. return;
  130021. }
  130022. engine.enableEffect(this._effect);
  130023. // Logarithmic depth
  130024. if (material.useLogarithmicDepth) {
  130025. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  130026. }
  130027. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  130028. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  130029. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  130030. // Bones
  130031. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  130032. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  130033. }
  130034. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  130035. // Alpha test
  130036. if (material && material.needAlphaTesting()) {
  130037. var alphaTexture = material.getAlphaTestTexture();
  130038. if (alphaTexture) {
  130039. this._effect.setTexture("diffuseSampler", alphaTexture);
  130040. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  130041. }
  130042. }
  130043. engine.setZOffset(-this.zOffset);
  130044. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  130045. engine.setZOffset(0);
  130046. };
  130047. /**
  130048. * Returns whether or not the outline renderer is ready for a given submesh.
  130049. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  130050. * @param subMesh Defines the submesh to check readyness for
  130051. * @param useInstances Defines wheter wee are trying to render instances or not
  130052. * @returns true if ready otherwise false
  130053. */
  130054. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  130055. var defines = [];
  130056. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  130057. var mesh = subMesh.getMesh();
  130058. var material = subMesh.getMaterial();
  130059. if (material) {
  130060. // Alpha test
  130061. if (material.needAlphaTesting()) {
  130062. defines.push("#define ALPHATEST");
  130063. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  130064. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  130065. defines.push("#define UV1");
  130066. }
  130067. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  130068. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  130069. defines.push("#define UV2");
  130070. }
  130071. }
  130072. //Logarithmic depth
  130073. if (material.useLogarithmicDepth) {
  130074. defines.push("#define LOGARITHMICDEPTH");
  130075. }
  130076. }
  130077. // Bones
  130078. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  130079. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  130080. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  130081. if (mesh.numBoneInfluencers > 4) {
  130082. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  130083. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  130084. }
  130085. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  130086. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  130087. }
  130088. else {
  130089. defines.push("#define NUM_BONE_INFLUENCERS 0");
  130090. }
  130091. // Instances
  130092. if (useInstances) {
  130093. defines.push("#define INSTANCES");
  130094. attribs.push("world0");
  130095. attribs.push("world1");
  130096. attribs.push("world2");
  130097. attribs.push("world3");
  130098. }
  130099. // Get correct effect
  130100. var join = defines.join("\n");
  130101. if (this._cachedDefines !== join) {
  130102. this._cachedDefines = join;
  130103. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  130104. }
  130105. return this._effect.isReady();
  130106. };
  130107. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  130108. // Outline - step 1
  130109. this._savedDepthWrite = this._engine.getDepthWrite();
  130110. if (mesh.renderOutline) {
  130111. var material = subMesh.getMaterial();
  130112. if (material && material.needAlphaBlending) {
  130113. this._engine.cacheStencilState();
  130114. // Draw only to stencil buffer for the original mesh
  130115. // The resulting stencil buffer will be used so the outline is not visible inside the mesh when the mesh is transparent
  130116. this._engine.setDepthWrite(false);
  130117. this._engine.setColorWrite(false);
  130118. this._engine.setStencilBuffer(true);
  130119. this._engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].REPLACE);
  130120. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALWAYS);
  130121. this._engine.setStencilMask(OutlineRenderer._StencilReference);
  130122. this._engine.setStencilFunctionReference(OutlineRenderer._StencilReference);
  130123. this.render(subMesh, batch, /* This sets offset to 0 */ true);
  130124. this._engine.setColorWrite(true);
  130125. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].NOTEQUAL);
  130126. }
  130127. // Draw the outline using the above stencil if needed to avoid drawing within the mesh
  130128. this._engine.setDepthWrite(false);
  130129. this.render(subMesh, batch);
  130130. this._engine.setDepthWrite(this._savedDepthWrite);
  130131. if (material && material.needAlphaBlending) {
  130132. this._engine.restoreStencilState();
  130133. }
  130134. }
  130135. };
  130136. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  130137. // Overlay
  130138. if (mesh.renderOverlay) {
  130139. var currentMode = this._engine.getAlphaMode();
  130140. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  130141. this.render(subMesh, batch, true);
  130142. this._engine.setAlphaMode(currentMode);
  130143. }
  130144. // Outline - step 2
  130145. if (mesh.renderOutline && this._savedDepthWrite) {
  130146. this._engine.setDepthWrite(true);
  130147. this._engine.setColorWrite(false);
  130148. this.render(subMesh, batch);
  130149. this._engine.setColorWrite(true);
  130150. }
  130151. };
  130152. /**
  130153. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  130154. */
  130155. OutlineRenderer._StencilReference = 0x04;
  130156. return OutlineRenderer;
  130157. }());
  130158. /***/ }),
  130159. /***/ "./Rendering/renderingGroup.ts":
  130160. /*!*************************************!*\
  130161. !*** ./Rendering/renderingGroup.ts ***!
  130162. \*************************************/
  130163. /*! exports provided: RenderingGroup */
  130164. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130165. "use strict";
  130166. __webpack_require__.r(__webpack_exports__);
  130167. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  130168. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  130169. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  130170. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  130171. /**
  130172. * This represents the object necessary to create a rendering group.
  130173. * This is exclusively used and created by the rendering manager.
  130174. * To modify the behavior, you use the available helpers in your scene or meshes.
  130175. * @hidden
  130176. */
  130177. var RenderingGroup = /** @class */ (function () {
  130178. /**
  130179. * Creates a new rendering group.
  130180. * @param index The rendering group index
  130181. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  130182. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  130183. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  130184. */
  130185. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  130186. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  130187. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  130188. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  130189. this.index = index;
  130190. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  130191. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  130192. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  130193. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  130194. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  130195. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  130196. /** @hidden */
  130197. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  130198. this._scene = scene;
  130199. this.opaqueSortCompareFn = opaqueSortCompareFn;
  130200. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  130201. this.transparentSortCompareFn = transparentSortCompareFn;
  130202. }
  130203. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  130204. /**
  130205. * Set the opaque sort comparison function.
  130206. * If null the sub meshes will be render in the order they were created
  130207. */
  130208. set: function (value) {
  130209. this._opaqueSortCompareFn = value;
  130210. if (value) {
  130211. this._renderOpaque = this.renderOpaqueSorted;
  130212. }
  130213. else {
  130214. this._renderOpaque = RenderingGroup.renderUnsorted;
  130215. }
  130216. },
  130217. enumerable: true,
  130218. configurable: true
  130219. });
  130220. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  130221. /**
  130222. * Set the alpha test sort comparison function.
  130223. * If null the sub meshes will be render in the order they were created
  130224. */
  130225. set: function (value) {
  130226. this._alphaTestSortCompareFn = value;
  130227. if (value) {
  130228. this._renderAlphaTest = this.renderAlphaTestSorted;
  130229. }
  130230. else {
  130231. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  130232. }
  130233. },
  130234. enumerable: true,
  130235. configurable: true
  130236. });
  130237. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  130238. /**
  130239. * Set the transparent sort comparison function.
  130240. * If null the sub meshes will be render in the order they were created
  130241. */
  130242. set: function (value) {
  130243. if (value) {
  130244. this._transparentSortCompareFn = value;
  130245. }
  130246. else {
  130247. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  130248. }
  130249. this._renderTransparent = this.renderTransparentSorted;
  130250. },
  130251. enumerable: true,
  130252. configurable: true
  130253. });
  130254. /**
  130255. * Render all the sub meshes contained in the group.
  130256. * @param customRenderFunction Used to override the default render behaviour of the group.
  130257. * @returns true if rendered some submeshes.
  130258. */
  130259. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  130260. if (customRenderFunction) {
  130261. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  130262. return;
  130263. }
  130264. var engine = this._scene.getEngine();
  130265. // Depth only
  130266. if (this._depthOnlySubMeshes.length !== 0) {
  130267. engine.setColorWrite(false);
  130268. this._renderAlphaTest(this._depthOnlySubMeshes);
  130269. engine.setColorWrite(true);
  130270. }
  130271. // Opaque
  130272. if (this._opaqueSubMeshes.length !== 0) {
  130273. this._renderOpaque(this._opaqueSubMeshes);
  130274. }
  130275. // Alpha test
  130276. if (this._alphaTestSubMeshes.length !== 0) {
  130277. this._renderAlphaTest(this._alphaTestSubMeshes);
  130278. }
  130279. var stencilState = engine.getStencilBuffer();
  130280. engine.setStencilBuffer(false);
  130281. // Sprites
  130282. if (renderSprites) {
  130283. this._renderSprites();
  130284. }
  130285. // Particles
  130286. if (renderParticles) {
  130287. this._renderParticles(activeMeshes);
  130288. }
  130289. if (this.onBeforeTransparentRendering) {
  130290. this.onBeforeTransparentRendering();
  130291. }
  130292. // Transparent
  130293. if (this._transparentSubMeshes.length !== 0) {
  130294. this._renderTransparent(this._transparentSubMeshes);
  130295. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  130296. }
  130297. // Set back stencil to false in case it changes before the edge renderer.
  130298. engine.setStencilBuffer(false);
  130299. // Edges
  130300. if (this._edgesRenderers.length) {
  130301. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  130302. this._edgesRenderers.data[edgesRendererIndex].render();
  130303. }
  130304. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  130305. }
  130306. // Restore Stencil state.
  130307. engine.setStencilBuffer(stencilState);
  130308. };
  130309. /**
  130310. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  130311. * @param subMeshes The submeshes to render
  130312. */
  130313. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  130314. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  130315. };
  130316. /**
  130317. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  130318. * @param subMeshes The submeshes to render
  130319. */
  130320. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  130321. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  130322. };
  130323. /**
  130324. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  130325. * @param subMeshes The submeshes to render
  130326. */
  130327. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  130328. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  130329. };
  130330. /**
  130331. * Renders the submeshes in a specified order.
  130332. * @param subMeshes The submeshes to sort before render
  130333. * @param sortCompareFn The comparison function use to sort
  130334. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  130335. * @param transparent Specifies to activate blending if true
  130336. */
  130337. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  130338. var subIndex = 0;
  130339. var subMesh;
  130340. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  130341. for (; subIndex < subMeshes.length; subIndex++) {
  130342. subMesh = subMeshes.data[subIndex];
  130343. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  130344. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  130345. }
  130346. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  130347. if (sortCompareFn) {
  130348. sortedArray.sort(sortCompareFn);
  130349. }
  130350. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  130351. subMesh = sortedArray[subIndex];
  130352. if (transparent) {
  130353. var material = subMesh.getMaterial();
  130354. if (material && material.needDepthPrePass) {
  130355. var engine = material.getScene().getEngine();
  130356. engine.setColorWrite(false);
  130357. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  130358. subMesh.render(false);
  130359. engine.setColorWrite(true);
  130360. }
  130361. }
  130362. subMesh.render(transparent);
  130363. }
  130364. };
  130365. /**
  130366. * Renders the submeshes in the order they were dispatched (no sort applied).
  130367. * @param subMeshes The submeshes to render
  130368. */
  130369. RenderingGroup.renderUnsorted = function (subMeshes) {
  130370. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  130371. var submesh = subMeshes.data[subIndex];
  130372. submesh.render(false);
  130373. }
  130374. };
  130375. /**
  130376. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  130377. * are rendered back to front if in the same alpha index.
  130378. *
  130379. * @param a The first submesh
  130380. * @param b The second submesh
  130381. * @returns The result of the comparison
  130382. */
  130383. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  130384. // Alpha index first
  130385. if (a._alphaIndex > b._alphaIndex) {
  130386. return 1;
  130387. }
  130388. if (a._alphaIndex < b._alphaIndex) {
  130389. return -1;
  130390. }
  130391. // Then distance to camera
  130392. return RenderingGroup.backToFrontSortCompare(a, b);
  130393. };
  130394. /**
  130395. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  130396. * are rendered back to front.
  130397. *
  130398. * @param a The first submesh
  130399. * @param b The second submesh
  130400. * @returns The result of the comparison
  130401. */
  130402. RenderingGroup.backToFrontSortCompare = function (a, b) {
  130403. // Then distance to camera
  130404. if (a._distanceToCamera < b._distanceToCamera) {
  130405. return 1;
  130406. }
  130407. if (a._distanceToCamera > b._distanceToCamera) {
  130408. return -1;
  130409. }
  130410. return 0;
  130411. };
  130412. /**
  130413. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  130414. * are rendered front to back (prevent overdraw).
  130415. *
  130416. * @param a The first submesh
  130417. * @param b The second submesh
  130418. * @returns The result of the comparison
  130419. */
  130420. RenderingGroup.frontToBackSortCompare = function (a, b) {
  130421. // Then distance to camera
  130422. if (a._distanceToCamera < b._distanceToCamera) {
  130423. return -1;
  130424. }
  130425. if (a._distanceToCamera > b._distanceToCamera) {
  130426. return 1;
  130427. }
  130428. return 0;
  130429. };
  130430. /**
  130431. * Resets the different lists of submeshes to prepare a new frame.
  130432. */
  130433. RenderingGroup.prototype.prepare = function () {
  130434. this._opaqueSubMeshes.reset();
  130435. this._transparentSubMeshes.reset();
  130436. this._alphaTestSubMeshes.reset();
  130437. this._depthOnlySubMeshes.reset();
  130438. this._particleSystems.reset();
  130439. this._spriteManagers.reset();
  130440. this._edgesRenderers.reset();
  130441. };
  130442. RenderingGroup.prototype.dispose = function () {
  130443. this._opaqueSubMeshes.dispose();
  130444. this._transparentSubMeshes.dispose();
  130445. this._alphaTestSubMeshes.dispose();
  130446. this._depthOnlySubMeshes.dispose();
  130447. this._particleSystems.dispose();
  130448. this._spriteManagers.dispose();
  130449. this._edgesRenderers.dispose();
  130450. };
  130451. /**
  130452. * Inserts the submesh in its correct queue depending on its material.
  130453. * @param subMesh The submesh to dispatch
  130454. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  130455. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  130456. */
  130457. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  130458. // Get mesh and materials if not provided
  130459. if (mesh === undefined) {
  130460. mesh = subMesh.getMesh();
  130461. }
  130462. if (material === undefined) {
  130463. material = subMesh.getMaterial();
  130464. }
  130465. if (material === null || material === undefined) {
  130466. return;
  130467. }
  130468. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  130469. this._transparentSubMeshes.push(subMesh);
  130470. }
  130471. else if (material.needAlphaTesting()) { // Alpha test
  130472. if (material.needDepthPrePass) {
  130473. this._depthOnlySubMeshes.push(subMesh);
  130474. }
  130475. this._alphaTestSubMeshes.push(subMesh);
  130476. }
  130477. else {
  130478. if (material.needDepthPrePass) {
  130479. this._depthOnlySubMeshes.push(subMesh);
  130480. }
  130481. this._opaqueSubMeshes.push(subMesh); // Opaque
  130482. }
  130483. mesh._renderingGroup = this;
  130484. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  130485. this._edgesRenderers.push(mesh._edgesRenderer);
  130486. }
  130487. };
  130488. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  130489. this._spriteManagers.push(spriteManager);
  130490. };
  130491. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  130492. this._particleSystems.push(particleSystem);
  130493. };
  130494. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  130495. if (this._particleSystems.length === 0) {
  130496. return;
  130497. }
  130498. // Particles
  130499. var activeCamera = this._scene.activeCamera;
  130500. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  130501. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  130502. var particleSystem = this._particleSystems.data[particleIndex];
  130503. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  130504. continue;
  130505. }
  130506. var emitter = particleSystem.emitter;
  130507. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  130508. this._scene._activeParticles.addCount(particleSystem.render(), false);
  130509. }
  130510. }
  130511. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  130512. };
  130513. RenderingGroup.prototype._renderSprites = function () {
  130514. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  130515. return;
  130516. }
  130517. // Sprites
  130518. var activeCamera = this._scene.activeCamera;
  130519. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  130520. for (var id = 0; id < this._spriteManagers.length; id++) {
  130521. var spriteManager = this._spriteManagers.data[id];
  130522. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  130523. spriteManager.render();
  130524. }
  130525. }
  130526. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  130527. };
  130528. return RenderingGroup;
  130529. }());
  130530. /***/ }),
  130531. /***/ "./Rendering/renderingManager.ts":
  130532. /*!***************************************!*\
  130533. !*** ./Rendering/renderingManager.ts ***!
  130534. \***************************************/
  130535. /*! exports provided: RenderingGroupInfo, RenderingManager */
  130536. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130537. "use strict";
  130538. __webpack_require__.r(__webpack_exports__);
  130539. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  130540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  130541. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  130542. /**
  130543. * This class is used by the onRenderingGroupObservable
  130544. */
  130545. var RenderingGroupInfo = /** @class */ (function () {
  130546. function RenderingGroupInfo() {
  130547. }
  130548. return RenderingGroupInfo;
  130549. }());
  130550. /**
  130551. * This is the manager responsible of all the rendering for meshes sprites and particles.
  130552. * It is enable to manage the different groups as well as the different necessary sort functions.
  130553. * This should not be used directly aside of the few static configurations
  130554. */
  130555. var RenderingManager = /** @class */ (function () {
  130556. /**
  130557. * Instantiates a new rendering group for a particular scene
  130558. * @param scene Defines the scene the groups belongs to
  130559. */
  130560. function RenderingManager(scene) {
  130561. /**
  130562. * @hidden
  130563. */
  130564. this._useSceneAutoClearSetup = false;
  130565. this._renderingGroups = new Array();
  130566. this._autoClearDepthStencil = {};
  130567. this._customOpaqueSortCompareFn = {};
  130568. this._customAlphaTestSortCompareFn = {};
  130569. this._customTransparentSortCompareFn = {};
  130570. this._renderingGroupInfo = new RenderingGroupInfo();
  130571. this._scene = scene;
  130572. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  130573. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  130574. }
  130575. }
  130576. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  130577. if (depth === void 0) { depth = true; }
  130578. if (stencil === void 0) { stencil = true; }
  130579. if (this._depthStencilBufferAlreadyCleaned) {
  130580. return;
  130581. }
  130582. this._scene.getEngine().clear(null, false, depth, stencil);
  130583. this._depthStencilBufferAlreadyCleaned = true;
  130584. };
  130585. /**
  130586. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  130587. * @hidden
  130588. */
  130589. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  130590. // Update the observable context (not null as it only goes away on dispose)
  130591. var info = this._renderingGroupInfo;
  130592. info.scene = this._scene;
  130593. info.camera = this._scene.activeCamera;
  130594. // Dispatch sprites
  130595. if (this._scene.spriteManagers && renderSprites) {
  130596. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  130597. var manager = this._scene.spriteManagers[index];
  130598. this.dispatchSprites(manager);
  130599. }
  130600. }
  130601. // Render
  130602. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  130603. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  130604. var renderingGroup = this._renderingGroups[index];
  130605. if (!renderingGroup) {
  130606. continue;
  130607. }
  130608. var renderingGroupMask = Math.pow(2, index);
  130609. info.renderingGroupId = index;
  130610. // Before Observable
  130611. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  130612. // Clear depth/stencil if needed
  130613. if (RenderingManager.AUTOCLEAR) {
  130614. var autoClear = this._useSceneAutoClearSetup ?
  130615. this._scene.getAutoClearDepthStencilSetup(index) :
  130616. this._autoClearDepthStencil[index];
  130617. if (autoClear && autoClear.autoClear) {
  130618. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  130619. }
  130620. }
  130621. // Render
  130622. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  130623. var step = _a[_i];
  130624. step.action(index);
  130625. }
  130626. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  130627. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  130628. var step = _c[_b];
  130629. step.action(index);
  130630. }
  130631. // After Observable
  130632. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  130633. }
  130634. };
  130635. /**
  130636. * Resets the different information of the group to prepare a new frame
  130637. * @hidden
  130638. */
  130639. RenderingManager.prototype.reset = function () {
  130640. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  130641. var renderingGroup = this._renderingGroups[index];
  130642. if (renderingGroup) {
  130643. renderingGroup.prepare();
  130644. }
  130645. }
  130646. };
  130647. /**
  130648. * Dispose and release the group and its associated resources.
  130649. * @hidden
  130650. */
  130651. RenderingManager.prototype.dispose = function () {
  130652. this.freeRenderingGroups();
  130653. this._renderingGroups.length = 0;
  130654. this._renderingGroupInfo = null;
  130655. };
  130656. /**
  130657. * Clear the info related to rendering groups preventing retention points during dispose.
  130658. */
  130659. RenderingManager.prototype.freeRenderingGroups = function () {
  130660. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  130661. var renderingGroup = this._renderingGroups[index];
  130662. if (renderingGroup) {
  130663. renderingGroup.dispose();
  130664. }
  130665. }
  130666. };
  130667. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  130668. if (this._renderingGroups[renderingGroupId] === undefined) {
  130669. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  130670. }
  130671. };
  130672. /**
  130673. * Add a sprite manager to the rendering manager in order to render it this frame.
  130674. * @param spriteManager Define the sprite manager to render
  130675. */
  130676. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  130677. var renderingGroupId = spriteManager.renderingGroupId || 0;
  130678. this._prepareRenderingGroup(renderingGroupId);
  130679. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  130680. };
  130681. /**
  130682. * Add a particle system to the rendering manager in order to render it this frame.
  130683. * @param particleSystem Define the particle system to render
  130684. */
  130685. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  130686. var renderingGroupId = particleSystem.renderingGroupId || 0;
  130687. this._prepareRenderingGroup(renderingGroupId);
  130688. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  130689. };
  130690. /**
  130691. * Add a submesh to the manager in order to render it this frame
  130692. * @param subMesh The submesh to dispatch
  130693. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  130694. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  130695. */
  130696. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  130697. if (mesh === undefined) {
  130698. mesh = subMesh.getMesh();
  130699. }
  130700. var renderingGroupId = mesh.renderingGroupId || 0;
  130701. this._prepareRenderingGroup(renderingGroupId);
  130702. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  130703. };
  130704. /**
  130705. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  130706. * This allowed control for front to back rendering or reversly depending of the special needs.
  130707. *
  130708. * @param renderingGroupId The rendering group id corresponding to its index
  130709. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  130710. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  130711. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  130712. */
  130713. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  130714. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  130715. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  130716. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  130717. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  130718. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  130719. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  130720. if (this._renderingGroups[renderingGroupId]) {
  130721. var group = this._renderingGroups[renderingGroupId];
  130722. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  130723. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  130724. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  130725. }
  130726. };
  130727. /**
  130728. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  130729. *
  130730. * @param renderingGroupId The rendering group id corresponding to its index
  130731. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  130732. * @param depth Automatically clears depth between groups if true and autoClear is true.
  130733. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  130734. */
  130735. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  130736. if (depth === void 0) { depth = true; }
  130737. if (stencil === void 0) { stencil = true; }
  130738. this._autoClearDepthStencil[renderingGroupId] = {
  130739. autoClear: autoClearDepthStencil,
  130740. depth: depth,
  130741. stencil: stencil
  130742. };
  130743. };
  130744. /**
  130745. * Gets the current auto clear configuration for one rendering group of the rendering
  130746. * manager.
  130747. * @param index the rendering group index to get the information for
  130748. * @returns The auto clear setup for the requested rendering group
  130749. */
  130750. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  130751. return this._autoClearDepthStencil[index];
  130752. };
  130753. /**
  130754. * The max id used for rendering groups (not included)
  130755. */
  130756. RenderingManager.MAX_RENDERINGGROUPS = 4;
  130757. /**
  130758. * The min id used for rendering groups (included)
  130759. */
  130760. RenderingManager.MIN_RENDERINGGROUPS = 0;
  130761. /**
  130762. * Used to globally prevent autoclearing scenes.
  130763. */
  130764. RenderingManager.AUTOCLEAR = true;
  130765. return RenderingManager;
  130766. }());
  130767. /***/ }),
  130768. /***/ "./Rendering/utilityLayerRenderer.ts":
  130769. /*!*******************************************!*\
  130770. !*** ./Rendering/utilityLayerRenderer.ts ***!
  130771. \*******************************************/
  130772. /*! exports provided: UtilityLayerRenderer */
  130773. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130774. "use strict";
  130775. __webpack_require__.r(__webpack_exports__);
  130776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  130777. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  130778. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  130779. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  130780. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  130781. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  130782. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  130783. /**
  130784. * Renders a layer on top of an existing scene
  130785. */
  130786. var UtilityLayerRenderer = /** @class */ (function () {
  130787. /**
  130788. * Instantiates a UtilityLayerRenderer
  130789. * @param originalScene the original scene that will be rendered on top of
  130790. * @param handleEvents boolean indicating if the utility layer should handle events
  130791. */
  130792. function UtilityLayerRenderer(
  130793. /** the original scene that will be rendered on top of */
  130794. originalScene, handleEvents) {
  130795. var _this = this;
  130796. if (handleEvents === void 0) { handleEvents = true; }
  130797. this.originalScene = originalScene;
  130798. this._pointerCaptures = {};
  130799. this._lastPointerEvents = {};
  130800. this._sharedGizmoLight = null;
  130801. /**
  130802. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  130803. */
  130804. this.pickUtilitySceneFirst = true;
  130805. /**
  130806. * If the utility layer should automatically be rendered on top of existing scene
  130807. */
  130808. this.shouldRender = true;
  130809. /**
  130810. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  130811. */
  130812. this.onlyCheckPointerDownEvents = true;
  130813. /**
  130814. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  130815. */
  130816. this.processAllEvents = false;
  130817. /**
  130818. * Observable raised when the pointer move from the utility layer scene to the main scene
  130819. */
  130820. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  130821. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  130822. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine(), { virtual: true });
  130823. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  130824. this.utilityLayerScene._allowPostProcessClearColor = false;
  130825. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  130826. this.utilityLayerScene.detachControl();
  130827. if (handleEvents) {
  130828. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  130829. if (!_this.utilityLayerScene.activeCamera) {
  130830. return;
  130831. }
  130832. if (!_this.processAllEvents) {
  130833. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  130834. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  130835. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  130836. return;
  130837. }
  130838. }
  130839. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  130840. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  130841. var pointerEvent = (prePointerInfo.event);
  130842. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  130843. _this._pointerCaptures[pointerEvent.pointerId] = false;
  130844. return;
  130845. }
  130846. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  130847. if (!prePointerInfo.ray && utilityScenePick) {
  130848. prePointerInfo.ray = utilityScenePick.ray;
  130849. }
  130850. // always fire the prepointer oversvable
  130851. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  130852. // allow every non pointer down event to flow to the utility layer
  130853. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  130854. if (!prePointerInfo.skipOnPointerObservable) {
  130855. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  130856. }
  130857. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  130858. _this._pointerCaptures[pointerEvent.pointerId] = false;
  130859. }
  130860. return;
  130861. }
  130862. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  130863. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  130864. if (utilityScenePick && utilityScenePick.hit) {
  130865. if (!prePointerInfo.skipOnPointerObservable) {
  130866. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  130867. }
  130868. prePointerInfo.skipOnPointerObservable = true;
  130869. }
  130870. }
  130871. else {
  130872. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  130873. var pointerEvent_1 = (prePointerInfo.event);
  130874. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  130875. if (originalScenePick && utilityScenePick) {
  130876. // No pick in utility scene
  130877. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  130878. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  130879. // We touched an utility mesh present in the main scene
  130880. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  130881. prePointerInfo.skipOnPointerObservable = true;
  130882. }
  130883. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  130884. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  130885. }
  130886. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  130887. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  130888. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  130889. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  130890. }
  130891. }
  130892. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  130893. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  130894. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  130895. // If a previous utility layer set this, do not unset this
  130896. if (!prePointerInfo.skipOnPointerObservable) {
  130897. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  130898. }
  130899. }
  130900. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  130901. // We have a pick in both scenes but main is closer than utility
  130902. // We touched an utility mesh present in the main scene
  130903. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  130904. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  130905. prePointerInfo.skipOnPointerObservable = true;
  130906. }
  130907. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  130908. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  130909. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  130910. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  130911. }
  130912. }
  130913. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  130914. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  130915. }
  130916. }
  130917. }
  130918. });
  130919. // As a newly added utility layer will be rendered over the screen last, it's pointer events should be processed first
  130920. if (this._originalPointerObserver) {
  130921. originalScene.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver);
  130922. }
  130923. }
  130924. // Render directly on top of existing scene without clearing
  130925. this.utilityLayerScene.autoClear = false;
  130926. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  130927. if (_this.shouldRender) {
  130928. _this.render();
  130929. }
  130930. });
  130931. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  130932. _this.dispose();
  130933. });
  130934. this._updateCamera();
  130935. }
  130936. /**
  130937. * @hidden
  130938. * Light which used by gizmos to get light shading
  130939. */
  130940. UtilityLayerRenderer.prototype._getSharedGizmoLight = function () {
  130941. if (!this._sharedGizmoLight) {
  130942. 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);
  130943. this._sharedGizmoLight.intensity = 2;
  130944. this._sharedGizmoLight.groundColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].Gray();
  130945. }
  130946. return this._sharedGizmoLight;
  130947. };
  130948. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  130949. /**
  130950. * 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)
  130951. */
  130952. get: function () {
  130953. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  130954. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  130955. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  130956. UtilityLayerRenderer._DefaultUtilityLayer = null;
  130957. });
  130958. }
  130959. return UtilityLayerRenderer._DefaultUtilityLayer;
  130960. },
  130961. enumerable: true,
  130962. configurable: true
  130963. });
  130964. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  130965. /**
  130966. * 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)
  130967. */
  130968. get: function () {
  130969. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  130970. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  130971. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  130972. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  130973. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  130974. });
  130975. }
  130976. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  130977. },
  130978. enumerable: true,
  130979. configurable: true
  130980. });
  130981. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  130982. if (!prePointerInfo.skipOnPointerObservable) {
  130983. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  130984. this._lastPointerEvents[pointerEvent.pointerId] = true;
  130985. }
  130986. };
  130987. /**
  130988. * Renders the utility layers scene on top of the original scene
  130989. */
  130990. UtilityLayerRenderer.prototype.render = function () {
  130991. this._updateCamera();
  130992. if (this.utilityLayerScene.activeCamera) {
  130993. // Set the camera's scene to utility layers scene
  130994. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  130995. var camera = this.utilityLayerScene.activeCamera;
  130996. camera._scene = this.utilityLayerScene;
  130997. if (camera.leftCamera) {
  130998. camera.leftCamera._scene = this.utilityLayerScene;
  130999. }
  131000. if (camera.rightCamera) {
  131001. camera.rightCamera._scene = this.utilityLayerScene;
  131002. }
  131003. this.utilityLayerScene.render(false);
  131004. // Reset camera's scene back to original
  131005. camera._scene = oldScene;
  131006. if (camera.leftCamera) {
  131007. camera.leftCamera._scene = oldScene;
  131008. }
  131009. if (camera.rightCamera) {
  131010. camera.rightCamera._scene = oldScene;
  131011. }
  131012. }
  131013. };
  131014. /**
  131015. * Disposes of the renderer
  131016. */
  131017. UtilityLayerRenderer.prototype.dispose = function () {
  131018. this.onPointerOutObservable.clear();
  131019. if (this._afterRenderObserver) {
  131020. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  131021. }
  131022. if (this._sceneDisposeObserver) {
  131023. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  131024. }
  131025. if (this._originalPointerObserver) {
  131026. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  131027. }
  131028. this.utilityLayerScene.dispose();
  131029. };
  131030. UtilityLayerRenderer.prototype._updateCamera = function () {
  131031. if (this.originalScene.activeCameras.length > 1) {
  131032. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  131033. }
  131034. else {
  131035. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  131036. }
  131037. };
  131038. UtilityLayerRenderer._DefaultUtilityLayer = null;
  131039. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  131040. return UtilityLayerRenderer;
  131041. }());
  131042. /***/ }),
  131043. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  131044. /*!*****************************************************************!*\
  131045. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  131046. \*****************************************************************/
  131047. /*! exports provided: backgroundFragmentDeclaration */
  131048. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131049. "use strict";
  131050. __webpack_require__.r(__webpack_exports__);
  131051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  131052. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131053. var name = 'backgroundFragmentDeclaration';
  131054. 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";
  131055. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131056. /** @hidden */
  131057. var backgroundFragmentDeclaration = { name: name, shader: shader };
  131058. /***/ }),
  131059. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  131060. /*!************************************************************!*\
  131061. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  131062. \************************************************************/
  131063. /*! exports provided: backgroundUboDeclaration */
  131064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131065. "use strict";
  131066. __webpack_require__.r(__webpack_exports__);
  131067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  131068. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131069. var name = 'backgroundUboDeclaration';
  131070. 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};";
  131071. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131072. /** @hidden */
  131073. var backgroundUboDeclaration = { name: name, shader: shader };
  131074. /***/ }),
  131075. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  131076. /*!***************************************************************!*\
  131077. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  131078. \***************************************************************/
  131079. /*! exports provided: backgroundVertexDeclaration */
  131080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131081. "use strict";
  131082. __webpack_require__.r(__webpack_exports__);
  131083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  131084. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131085. var name = 'backgroundVertexDeclaration';
  131086. 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";
  131087. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131088. /** @hidden */
  131089. var backgroundVertexDeclaration = { name: name, shader: shader };
  131090. /***/ }),
  131091. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  131092. /*!****************************************************!*\
  131093. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  131094. \****************************************************/
  131095. /*! exports provided: bonesDeclaration */
  131096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131097. "use strict";
  131098. __webpack_require__.r(__webpack_exports__);
  131099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  131100. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131101. var name = 'bonesDeclaration';
  131102. 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";
  131103. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131104. /** @hidden */
  131105. var bonesDeclaration = { name: name, shader: shader };
  131106. /***/ }),
  131107. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  131108. /*!***********************************************!*\
  131109. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  131110. \***********************************************/
  131111. /*! exports provided: bonesVertex */
  131112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131113. "use strict";
  131114. __webpack_require__.r(__webpack_exports__);
  131115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  131116. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131117. var name = 'bonesVertex';
  131118. 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";
  131119. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131120. /** @hidden */
  131121. var bonesVertex = { name: name, shader: shader };
  131122. /***/ }),
  131123. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  131124. /*!************************************************!*\
  131125. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  131126. \************************************************/
  131127. /*! exports provided: bumpFragment */
  131128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131129. "use strict";
  131130. __webpack_require__.r(__webpack_exports__);
  131131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  131132. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131133. var name = 'bumpFragment';
  131134. 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";
  131135. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131136. /** @hidden */
  131137. var bumpFragment = { name: name, shader: shader };
  131138. /***/ }),
  131139. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  131140. /*!*********************************************************!*\
  131141. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  131142. \*********************************************************/
  131143. /*! exports provided: bumpFragmentFunctions */
  131144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131145. "use strict";
  131146. __webpack_require__.r(__webpack_exports__);
  131147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  131148. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131149. var name = 'bumpFragmentFunctions';
  131150. 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";
  131151. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131152. /** @hidden */
  131153. var bumpFragmentFunctions = { name: name, shader: shader };
  131154. /***/ }),
  131155. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  131156. /*!**********************************************!*\
  131157. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  131158. \**********************************************/
  131159. /*! exports provided: bumpVertex */
  131160. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131161. "use strict";
  131162. __webpack_require__.r(__webpack_exports__);
  131163. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  131164. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131165. var name = 'bumpVertex';
  131166. 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";
  131167. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131168. /** @hidden */
  131169. var bumpVertex = { name: name, shader: shader };
  131170. /***/ }),
  131171. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  131172. /*!*********************************************************!*\
  131173. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  131174. \*********************************************************/
  131175. /*! exports provided: bumpVertexDeclaration */
  131176. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131177. "use strict";
  131178. __webpack_require__.r(__webpack_exports__);
  131179. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  131180. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131181. var name = 'bumpVertexDeclaration';
  131182. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  131183. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131184. /** @hidden */
  131185. var bumpVertexDeclaration = { name: name, shader: shader };
  131186. /***/ }),
  131187. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  131188. /*!*****************************************************!*\
  131189. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  131190. \*****************************************************/
  131191. /*! exports provided: clipPlaneFragment */
  131192. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131193. "use strict";
  131194. __webpack_require__.r(__webpack_exports__);
  131195. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  131196. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131197. var name = 'clipPlaneFragment';
  131198. 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";
  131199. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131200. /** @hidden */
  131201. var clipPlaneFragment = { name: name, shader: shader };
  131202. /***/ }),
  131203. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  131204. /*!****************************************************************!*\
  131205. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  131206. \****************************************************************/
  131207. /*! exports provided: clipPlaneFragmentDeclaration */
  131208. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131209. "use strict";
  131210. __webpack_require__.r(__webpack_exports__);
  131211. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  131212. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131213. var name = 'clipPlaneFragmentDeclaration';
  131214. 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";
  131215. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131216. /** @hidden */
  131217. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  131218. /***/ }),
  131219. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  131220. /*!*****************************************************************!*\
  131221. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  131222. \*****************************************************************/
  131223. /*! exports provided: clipPlaneFragmentDeclaration2 */
  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__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  131228. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131229. var name = 'clipPlaneFragmentDeclaration2';
  131230. 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";
  131231. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131232. /** @hidden */
  131233. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  131234. /***/ }),
  131235. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  131236. /*!***************************************************!*\
  131237. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  131238. \***************************************************/
  131239. /*! exports provided: clipPlaneVertex */
  131240. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131241. "use strict";
  131242. __webpack_require__.r(__webpack_exports__);
  131243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  131244. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131245. var name = 'clipPlaneVertex';
  131246. 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";
  131247. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131248. /** @hidden */
  131249. var clipPlaneVertex = { name: name, shader: shader };
  131250. /***/ }),
  131251. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  131252. /*!**************************************************************!*\
  131253. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  131254. \**************************************************************/
  131255. /*! exports provided: clipPlaneVertexDeclaration */
  131256. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131257. "use strict";
  131258. __webpack_require__.r(__webpack_exports__);
  131259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  131260. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131261. var name = 'clipPlaneVertexDeclaration';
  131262. 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";
  131263. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131264. /** @hidden */
  131265. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  131266. /***/ }),
  131267. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  131268. /*!***************************************************************!*\
  131269. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  131270. \***************************************************************/
  131271. /*! exports provided: clipPlaneVertexDeclaration2 */
  131272. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131273. "use strict";
  131274. __webpack_require__.r(__webpack_exports__);
  131275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  131276. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131277. var name = 'clipPlaneVertexDeclaration2';
  131278. 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";
  131279. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131280. /** @hidden */
  131281. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  131282. /***/ }),
  131283. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  131284. /*!**************************************************************!*\
  131285. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  131286. \**************************************************************/
  131287. /*! exports provided: defaultFragmentDeclaration */
  131288. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131289. "use strict";
  131290. __webpack_require__.r(__webpack_exports__);
  131291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  131292. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131293. var name = 'defaultFragmentDeclaration';
  131294. 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#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)\nuniform mat4 reflectionMatrix;\n#endif\n#ifndef REFLECTIONMAP_SKYBOX\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif";
  131295. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131296. /** @hidden */
  131297. var defaultFragmentDeclaration = { name: name, shader: shader };
  131298. /***/ }),
  131299. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  131300. /*!*********************************************************!*\
  131301. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  131302. \*********************************************************/
  131303. /*! exports provided: defaultUboDeclaration */
  131304. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131305. "use strict";
  131306. __webpack_require__.r(__webpack_exports__);
  131307. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  131308. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131309. var name = 'defaultUboDeclaration';
  131310. 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";
  131311. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131312. /** @hidden */
  131313. var defaultUboDeclaration = { name: name, shader: shader };
  131314. /***/ }),
  131315. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  131316. /*!************************************************************!*\
  131317. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  131318. \************************************************************/
  131319. /*! exports provided: defaultVertexDeclaration */
  131320. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131321. "use strict";
  131322. __webpack_require__.r(__webpack_exports__);
  131323. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  131324. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131325. var name = 'defaultVertexDeclaration';
  131326. 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";
  131327. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131328. /** @hidden */
  131329. var defaultVertexDeclaration = { name: name, shader: shader };
  131330. /***/ }),
  131331. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  131332. /*!************************************************!*\
  131333. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  131334. \************************************************/
  131335. /*! exports provided: depthPrePass */
  131336. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131337. "use strict";
  131338. __webpack_require__.r(__webpack_exports__);
  131339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  131340. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131341. var name = 'depthPrePass';
  131342. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  131343. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131344. /** @hidden */
  131345. var depthPrePass = { name: name, shader: shader };
  131346. /***/ }),
  131347. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  131348. /*!***********************************************!*\
  131349. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  131350. \***********************************************/
  131351. /*! exports provided: fogFragment */
  131352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131353. "use strict";
  131354. __webpack_require__.r(__webpack_exports__);
  131355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  131356. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131357. var name = 'fogFragment';
  131358. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  131359. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131360. /** @hidden */
  131361. var fogFragment = { name: name, shader: shader };
  131362. /***/ }),
  131363. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  131364. /*!**********************************************************!*\
  131365. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  131366. \**********************************************************/
  131367. /*! exports provided: fogFragmentDeclaration */
  131368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131369. "use strict";
  131370. __webpack_require__.r(__webpack_exports__);
  131371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  131372. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131373. var name = 'fogFragmentDeclaration';
  131374. 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";
  131375. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131376. /** @hidden */
  131377. var fogFragmentDeclaration = { name: name, shader: shader };
  131378. /***/ }),
  131379. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  131380. /*!*********************************************!*\
  131381. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  131382. \*********************************************/
  131383. /*! exports provided: fogVertex */
  131384. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131385. "use strict";
  131386. __webpack_require__.r(__webpack_exports__);
  131387. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  131388. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131389. var name = 'fogVertex';
  131390. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  131391. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131392. /** @hidden */
  131393. var fogVertex = { name: name, shader: shader };
  131394. /***/ }),
  131395. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  131396. /*!********************************************************!*\
  131397. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  131398. \********************************************************/
  131399. /*! exports provided: fogVertexDeclaration */
  131400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131401. "use strict";
  131402. __webpack_require__.r(__webpack_exports__);
  131403. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  131404. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131405. var name = 'fogVertexDeclaration';
  131406. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  131407. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131408. /** @hidden */
  131409. var fogVertexDeclaration = { name: name, shader: shader };
  131410. /***/ }),
  131411. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  131412. /*!***************************************************!*\
  131413. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  131414. \***************************************************/
  131415. /*! exports provided: fresnelFunction */
  131416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131417. "use strict";
  131418. __webpack_require__.r(__webpack_exports__);
  131419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  131420. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131421. var name = 'fresnelFunction';
  131422. 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";
  131423. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131424. /** @hidden */
  131425. var fresnelFunction = { name: name, shader: shader };
  131426. /***/ }),
  131427. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  131428. /*!******************************************************!*\
  131429. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  131430. \******************************************************/
  131431. /*! exports provided: harmonicsFunctions */
  131432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131433. "use strict";
  131434. __webpack_require__.r(__webpack_exports__);
  131435. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  131436. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131437. var name = 'harmonicsFunctions';
  131438. var shader = "#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;\nuniform vec3 vSphericalL1_1;\nuniform vec3 vSphericalL10;\nuniform vec3 vSphericalL11;\nuniform vec3 vSphericalL2_2;\nuniform vec3 vSphericalL2_1;\nuniform vec3 vSphericalL20;\nuniform vec3 vSphericalL21;\nuniform vec3 vSphericalL22;\n\n\n\n\n\n\n\nvec3 computeEnvironmentIrradiance(vec3 normal) {\nreturn vSphericalL00\n+vSphericalL1_1*(normal.y)\n+vSphericalL10*(normal.z)\n+vSphericalL11*(normal.x)\n+vSphericalL2_2*(normal.y*normal.x)\n+vSphericalL2_1*(normal.y*normal.z)\n+vSphericalL20*((3.0*normal.z*normal.z)-1.0)\n+vSphericalL21*(normal.z*normal.x)\n+vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));\n}\n#else\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\n\nvec3 computeEnvironmentIrradiance(vec3 normal) {\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\n#endif";
  131439. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131440. /** @hidden */
  131441. var harmonicsFunctions = { name: name, shader: shader };
  131442. /***/ }),
  131443. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  131444. /*!***************************************************!*\
  131445. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  131446. \***************************************************/
  131447. /*! exports provided: helperFunctions */
  131448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131449. "use strict";
  131450. __webpack_require__.r(__webpack_exports__);
  131451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  131452. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131453. var name = 'helperFunctions';
  131454. 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}";
  131455. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131456. /** @hidden */
  131457. var helperFunctions = { name: name, shader: shader };
  131458. /***/ }),
  131459. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  131460. /*!**************************************************************!*\
  131461. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  131462. \**************************************************************/
  131463. /*! exports provided: imageProcessingDeclaration */
  131464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131465. "use strict";
  131466. __webpack_require__.r(__webpack_exports__);
  131467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  131468. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131469. var name = 'imageProcessingDeclaration';
  131470. 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";
  131471. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131472. /** @hidden */
  131473. var imageProcessingDeclaration = { name: name, shader: shader };
  131474. /***/ }),
  131475. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  131476. /*!************************************************************!*\
  131477. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  131478. \************************************************************/
  131479. /*! exports provided: imageProcessingFunctions */
  131480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131481. "use strict";
  131482. __webpack_require__.r(__webpack_exports__);
  131483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  131484. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131485. var name = 'imageProcessingFunctions';
  131486. 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}";
  131487. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131488. /** @hidden */
  131489. var imageProcessingFunctions = { name: name, shader: shader };
  131490. /***/ }),
  131491. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  131492. /*!********************************************************!*\
  131493. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  131494. \********************************************************/
  131495. /*! exports provided: instancesDeclaration */
  131496. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131497. "use strict";
  131498. __webpack_require__.r(__webpack_exports__);
  131499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  131500. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131501. var name = 'instancesDeclaration';
  131502. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  131503. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131504. /** @hidden */
  131505. var instancesDeclaration = { name: name, shader: shader };
  131506. /***/ }),
  131507. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  131508. /*!***************************************************!*\
  131509. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  131510. \***************************************************/
  131511. /*! exports provided: instancesVertex */
  131512. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131513. "use strict";
  131514. __webpack_require__.r(__webpack_exports__);
  131515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  131516. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131517. var name = 'instancesVertex';
  131518. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  131519. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131520. /** @hidden */
  131521. var instancesVertex = { name: name, shader: shader };
  131522. /***/ }),
  131523. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  131524. /*!******************************************************!*\
  131525. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  131526. \******************************************************/
  131527. /*! exports provided: kernelBlurFragment */
  131528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131529. "use strict";
  131530. __webpack_require__.r(__webpack_exports__);
  131531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  131532. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131533. var name = 'kernelBlurFragment';
  131534. 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";
  131535. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131536. /** @hidden */
  131537. var kernelBlurFragment = { name: name, shader: shader };
  131538. /***/ }),
  131539. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  131540. /*!*******************************************************!*\
  131541. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  131542. \*******************************************************/
  131543. /*! exports provided: kernelBlurFragment2 */
  131544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131545. "use strict";
  131546. __webpack_require__.r(__webpack_exports__);
  131547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  131548. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131549. var name = 'kernelBlurFragment2';
  131550. 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";
  131551. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131552. /** @hidden */
  131553. var kernelBlurFragment2 = { name: name, shader: shader };
  131554. /***/ }),
  131555. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  131556. /*!****************************************************************!*\
  131557. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  131558. \****************************************************************/
  131559. /*! exports provided: kernelBlurVaryingDeclaration */
  131560. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131561. "use strict";
  131562. __webpack_require__.r(__webpack_exports__);
  131563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  131564. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131565. var name = 'kernelBlurVaryingDeclaration';
  131566. var shader = "varying vec2 sampleCoord{X};";
  131567. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131568. /** @hidden */
  131569. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  131570. /***/ }),
  131571. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  131572. /*!****************************************************!*\
  131573. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  131574. \****************************************************/
  131575. /*! exports provided: kernelBlurVertex */
  131576. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131577. "use strict";
  131578. __webpack_require__.r(__webpack_exports__);
  131579. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  131580. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131581. var name = 'kernelBlurVertex';
  131582. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  131583. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131584. /** @hidden */
  131585. var kernelBlurVertex = { name: name, shader: shader };
  131586. /***/ }),
  131587. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  131588. /*!*************************************************!*\
  131589. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  131590. \*************************************************/
  131591. /*! exports provided: lightFragment */
  131592. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131593. "use strict";
  131594. __webpack_require__.r(__webpack_exports__);
  131595. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  131596. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131597. var name = 'lightFragment';
  131598. 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";
  131599. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131600. /** @hidden */
  131601. var lightFragment = { name: name, shader: shader };
  131602. /***/ }),
  131603. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  131604. /*!************************************************************!*\
  131605. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  131606. \************************************************************/
  131607. /*! exports provided: lightFragmentDeclaration */
  131608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131609. "use strict";
  131610. __webpack_require__.r(__webpack_exports__);
  131611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  131612. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131613. var name = 'lightFragmentDeclaration';
  131614. 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";
  131615. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131616. /** @hidden */
  131617. var lightFragmentDeclaration = { name: name, shader: shader };
  131618. /***/ }),
  131619. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  131620. /*!*******************************************************!*\
  131621. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  131622. \*******************************************************/
  131623. /*! exports provided: lightUboDeclaration */
  131624. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131625. "use strict";
  131626. __webpack_require__.r(__webpack_exports__);
  131627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  131628. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131629. var name = 'lightUboDeclaration';
  131630. 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";
  131631. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131632. /** @hidden */
  131633. var lightUboDeclaration = { name: name, shader: shader };
  131634. /***/ }),
  131635. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  131636. /*!***********************************************************!*\
  131637. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  131638. \***********************************************************/
  131639. /*! exports provided: lightsFragmentFunctions */
  131640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131641. "use strict";
  131642. __webpack_require__.r(__webpack_exports__);
  131643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  131644. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131645. var name = 'lightsFragmentFunctions';
  131646. 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}";
  131647. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131648. /** @hidden */
  131649. var lightsFragmentFunctions = { name: name, shader: shader };
  131650. /***/ }),
  131651. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  131652. /*!*******************************************************!*\
  131653. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  131654. \*******************************************************/
  131655. /*! exports provided: logDepthDeclaration */
  131656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131657. "use strict";
  131658. __webpack_require__.r(__webpack_exports__);
  131659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  131660. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131661. var name = 'logDepthDeclaration';
  131662. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  131663. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131664. /** @hidden */
  131665. var logDepthDeclaration = { name: name, shader: shader };
  131666. /***/ }),
  131667. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  131668. /*!****************************************************!*\
  131669. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  131670. \****************************************************/
  131671. /*! exports provided: logDepthFragment */
  131672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131673. "use strict";
  131674. __webpack_require__.r(__webpack_exports__);
  131675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  131676. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131677. var name = 'logDepthFragment';
  131678. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  131679. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131680. /** @hidden */
  131681. var logDepthFragment = { name: name, shader: shader };
  131682. /***/ }),
  131683. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  131684. /*!**************************************************!*\
  131685. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  131686. \**************************************************/
  131687. /*! exports provided: logDepthVertex */
  131688. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131689. "use strict";
  131690. __webpack_require__.r(__webpack_exports__);
  131691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  131692. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131693. var name = 'logDepthVertex';
  131694. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  131695. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131696. /** @hidden */
  131697. var logDepthVertex = { name: name, shader: shader };
  131698. /***/ }),
  131699. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  131700. /*!******************************************************!*\
  131701. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  131702. \******************************************************/
  131703. /*! exports provided: morphTargetsVertex */
  131704. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131705. "use strict";
  131706. __webpack_require__.r(__webpack_exports__);
  131707. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  131708. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131709. var name = 'morphTargetsVertex';
  131710. 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";
  131711. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131712. /** @hidden */
  131713. var morphTargetsVertex = { name: name, shader: shader };
  131714. /***/ }),
  131715. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  131716. /*!*****************************************************************!*\
  131717. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  131718. \*****************************************************************/
  131719. /*! exports provided: morphTargetsVertexDeclaration */
  131720. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131721. "use strict";
  131722. __webpack_require__.r(__webpack_exports__);
  131723. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  131724. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131725. var name = 'morphTargetsVertexDeclaration';
  131726. 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";
  131727. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131728. /** @hidden */
  131729. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  131730. /***/ }),
  131731. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  131732. /*!***********************************************************************!*\
  131733. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  131734. \***********************************************************************/
  131735. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  131736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131737. "use strict";
  131738. __webpack_require__.r(__webpack_exports__);
  131739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  131740. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131741. var name = 'morphTargetsVertexGlobalDeclaration';
  131742. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  131743. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131744. /** @hidden */
  131745. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  131746. /***/ }),
  131747. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  131748. /*!**********************************************************!*\
  131749. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  131750. \**********************************************************/
  131751. /*! exports provided: mrtFragmentDeclaration */
  131752. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131753. "use strict";
  131754. __webpack_require__.r(__webpack_exports__);
  131755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  131756. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131757. var name = 'mrtFragmentDeclaration';
  131758. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  131759. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131760. /** @hidden */
  131761. var mrtFragmentDeclaration = { name: name, shader: shader };
  131762. /***/ }),
  131763. /***/ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts":
  131764. /*!****************************************************!*\
  131765. !*** ./Shaders/ShadersInclude/pbrBRDFFunctions.ts ***!
  131766. \****************************************************/
  131767. /*! exports provided: pbrBRDFFunctions */
  131768. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131769. "use strict";
  131770. __webpack_require__.r(__webpack_exports__);
  131771. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrBRDFFunctions", function() { return pbrBRDFFunctions; });
  131772. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131773. var name = 'pbrBRDFFunctions';
  131774. 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";
  131775. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131776. /** @hidden */
  131777. var pbrBRDFFunctions = { name: name, shader: shader };
  131778. /***/ }),
  131779. /***/ "./Shaders/ShadersInclude/pbrDebug.ts":
  131780. /*!********************************************!*\
  131781. !*** ./Shaders/ShadersInclude/pbrDebug.ts ***!
  131782. \********************************************/
  131783. /*! exports provided: pbrDebug */
  131784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131785. "use strict";
  131786. __webpack_require__.r(__webpack_exports__);
  131787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDebug", function() { return pbrDebug; });
  131788. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131789. var name = 'pbrDebug';
  131790. 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=vec3(clearCoatMapData.rg,0.0);\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";
  131791. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131792. /** @hidden */
  131793. var pbrDebug = { name: name, shader: shader };
  131794. /***/ }),
  131795. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts":
  131796. /*!*********************************************************************!*\
  131797. !*** ./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts ***!
  131798. \*********************************************************************/
  131799. /*! exports provided: pbrDirectLightingFalloffFunctions */
  131800. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131801. "use strict";
  131802. __webpack_require__.r(__webpack_exports__);
  131803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFalloffFunctions", function() { return pbrDirectLightingFalloffFunctions; });
  131804. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131805. var name = 'pbrDirectLightingFalloffFunctions';
  131806. 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}";
  131807. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131808. /** @hidden */
  131809. var pbrDirectLightingFalloffFunctions = { name: name, shader: shader };
  131810. /***/ }),
  131811. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts":
  131812. /*!**************************************************************!*\
  131813. !*** ./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts ***!
  131814. \**************************************************************/
  131815. /*! exports provided: pbrDirectLightingFunctions */
  131816. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131817. "use strict";
  131818. __webpack_require__.r(__webpack_exports__);
  131819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFunctions", function() { return pbrDirectLightingFunctions; });
  131820. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131821. var name = 'pbrDirectLightingFunctions';
  131822. 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";
  131823. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131824. /** @hidden */
  131825. var pbrDirectLightingFunctions = { name: name, shader: shader };
  131826. /***/ }),
  131827. /***/ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts":
  131828. /*!*******************************************************************!*\
  131829. !*** ./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts ***!
  131830. \*******************************************************************/
  131831. /*! exports provided: pbrDirectLightingSetupFunctions */
  131832. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131833. "use strict";
  131834. __webpack_require__.r(__webpack_exports__);
  131835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingSetupFunctions", function() { return pbrDirectLightingSetupFunctions; });
  131836. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131837. var name = 'pbrDirectLightingSetupFunctions';
  131838. 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}";
  131839. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131840. /** @hidden */
  131841. var pbrDirectLightingSetupFunctions = { name: name, shader: shader };
  131842. /***/ }),
  131843. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  131844. /*!**********************************************************!*\
  131845. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  131846. \**********************************************************/
  131847. /*! exports provided: pbrFragmentDeclaration */
  131848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131849. "use strict";
  131850. __webpack_require__.r(__webpack_exports__);
  131851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  131852. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131853. var name = 'pbrFragmentDeclaration';
  131854. 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";
  131855. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131856. /** @hidden */
  131857. var pbrFragmentDeclaration = { name: name, shader: shader };
  131858. /***/ }),
  131859. /***/ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts":
  131860. /*!***************************************************************!*\
  131861. !*** ./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts ***!
  131862. \***************************************************************/
  131863. /*! exports provided: pbrFragmentExtraDeclaration */
  131864. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131865. "use strict";
  131866. __webpack_require__.r(__webpack_exports__);
  131867. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentExtraDeclaration", function() { return pbrFragmentExtraDeclaration; });
  131868. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131869. var name = 'pbrFragmentExtraDeclaration';
  131870. 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";
  131871. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131872. /** @hidden */
  131873. var pbrFragmentExtraDeclaration = { name: name, shader: shader };
  131874. /***/ }),
  131875. /***/ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts":
  131876. /*!******************************************************************!*\
  131877. !*** ./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts ***!
  131878. \******************************************************************/
  131879. /*! exports provided: pbrFragmentSamplersDeclaration */
  131880. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131881. "use strict";
  131882. __webpack_require__.r(__webpack_exports__);
  131883. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentSamplersDeclaration", function() { return pbrFragmentSamplersDeclaration; });
  131884. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131885. var name = 'pbrFragmentSamplersDeclaration';
  131886. 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";
  131887. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131888. /** @hidden */
  131889. var pbrFragmentSamplersDeclaration = { name: name, shader: shader };
  131890. /***/ }),
  131891. /***/ "./Shaders/ShadersInclude/pbrHelperFunctions.ts":
  131892. /*!******************************************************!*\
  131893. !*** ./Shaders/ShadersInclude/pbrHelperFunctions.ts ***!
  131894. \******************************************************/
  131895. /*! exports provided: pbrHelperFunctions */
  131896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131897. "use strict";
  131898. __webpack_require__.r(__webpack_exports__);
  131899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrHelperFunctions", function() { return pbrHelperFunctions; });
  131900. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131901. var name = 'pbrHelperFunctions';
  131902. 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";
  131903. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131904. /** @hidden */
  131905. var pbrHelperFunctions = { name: name, shader: shader };
  131906. /***/ }),
  131907. /***/ "./Shaders/ShadersInclude/pbrIBLFunctions.ts":
  131908. /*!***************************************************!*\
  131909. !*** ./Shaders/ShadersInclude/pbrIBLFunctions.ts ***!
  131910. \***************************************************/
  131911. /*! exports provided: pbrIBLFunctions */
  131912. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131913. "use strict";
  131914. __webpack_require__.r(__webpack_exports__);
  131915. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrIBLFunctions", function() { return pbrIBLFunctions; });
  131916. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131917. var name = 'pbrIBLFunctions';
  131918. 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";
  131919. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131920. /** @hidden */
  131921. var pbrIBLFunctions = { name: name, shader: shader };
  131922. /***/ }),
  131923. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  131924. /*!*****************************************************!*\
  131925. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  131926. \*****************************************************/
  131927. /*! exports provided: pbrUboDeclaration */
  131928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131929. "use strict";
  131930. __webpack_require__.r(__webpack_exports__);
  131931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  131932. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131933. var name = 'pbrUboDeclaration';
  131934. 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};";
  131935. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131936. /** @hidden */
  131937. var pbrUboDeclaration = { name: name, shader: shader };
  131938. /***/ }),
  131939. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  131940. /*!********************************************************!*\
  131941. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  131942. \********************************************************/
  131943. /*! exports provided: pbrVertexDeclaration */
  131944. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131945. "use strict";
  131946. __webpack_require__.r(__webpack_exports__);
  131947. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  131948. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131949. var name = 'pbrVertexDeclaration';
  131950. 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";
  131951. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131952. /** @hidden */
  131953. var pbrVertexDeclaration = { name: name, shader: shader };
  131954. /***/ }),
  131955. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  131956. /*!****************************************************!*\
  131957. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  131958. \****************************************************/
  131959. /*! exports provided: pointCloudVertex */
  131960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131961. "use strict";
  131962. __webpack_require__.r(__webpack_exports__);
  131963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  131964. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131965. var name = 'pointCloudVertex';
  131966. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  131967. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131968. /** @hidden */
  131969. var pointCloudVertex = { name: name, shader: shader };
  131970. /***/ }),
  131971. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  131972. /*!******************************************************!*\
  131973. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  131974. \******************************************************/
  131975. /*! exports provided: reflectionFunction */
  131976. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131977. "use strict";
  131978. __webpack_require__.r(__webpack_exports__);
  131979. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  131980. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131981. var name = 'reflectionFunction';
  131982. 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));\nr=vec3(reflectionMatrix*vec4(r,0));\nfloat lon=atan(r.z,r.x);\nfloat lat=acos(r.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\nreturn vec3(s,t,0);\n#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=vec3(reflectionMatrix*vec4(r,0));\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n#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 vec3(reflectionMatrix*vec4(vPositionUVW,0));\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}";
  131983. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  131984. /** @hidden */
  131985. var reflectionFunction = { name: name, shader: shader };
  131986. /***/ }),
  131987. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  131988. /*!************************************************************!*\
  131989. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  131990. \************************************************************/
  131991. /*! exports provided: shadowsFragmentFunctions */
  131992. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131993. "use strict";
  131994. __webpack_require__.r(__webpack_exports__);
  131995. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  131996. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  131997. var name = 'shadowsFragmentFunctions';
  131998. 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";
  131999. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  132000. /** @hidden */
  132001. var shadowsFragmentFunctions = { name: name, shader: shader };
  132002. /***/ }),
  132003. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  132004. /*!*************************************************!*\
  132005. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  132006. \*************************************************/
  132007. /*! exports provided: shadowsVertex */
  132008. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132009. "use strict";
  132010. __webpack_require__.r(__webpack_exports__);
  132011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  132012. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  132013. var name = 'shadowsVertex';
  132014. 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";
  132015. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  132016. /** @hidden */
  132017. var shadowsVertex = { name: name, shader: shader };
  132018. /***/ }),
  132019. /***/ "./Shaders/anaglyph.fragment.ts":
  132020. /*!**************************************!*\
  132021. !*** ./Shaders/anaglyph.fragment.ts ***!
  132022. \**************************************/
  132023. /*! exports provided: anaglyphPixelShader */
  132024. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132025. "use strict";
  132026. __webpack_require__.r(__webpack_exports__);
  132027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  132028. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132029. var name = 'anaglyphPixelShader';
  132030. 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}";
  132031. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132032. /** @hidden */
  132033. var anaglyphPixelShader = { name: name, shader: shader };
  132034. /***/ }),
  132035. /***/ "./Shaders/background.fragment.ts":
  132036. /*!****************************************!*\
  132037. !*** ./Shaders/background.fragment.ts ***!
  132038. \****************************************/
  132039. /*! exports provided: backgroundPixelShader */
  132040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132041. "use strict";
  132042. __webpack_require__.r(__webpack_exports__);
  132043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  132044. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132045. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  132046. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  132047. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  132048. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  132049. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  132050. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  132051. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  132052. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  132053. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  132054. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  132055. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  132056. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  132057. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  132058. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  132059. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  132060. var name = 'backgroundPixelShader';
  132061. 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";
  132062. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132063. /** @hidden */
  132064. var backgroundPixelShader = { name: name, shader: shader };
  132065. /***/ }),
  132066. /***/ "./Shaders/background.vertex.ts":
  132067. /*!**************************************!*\
  132068. !*** ./Shaders/background.vertex.ts ***!
  132069. \**************************************/
  132070. /*! exports provided: backgroundVertexShader */
  132071. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132072. "use strict";
  132073. __webpack_require__.r(__webpack_exports__);
  132074. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  132075. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132076. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  132077. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  132078. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  132079. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  132080. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  132081. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  132082. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  132083. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  132084. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  132085. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  132086. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  132087. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  132088. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  132089. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  132090. var name = 'backgroundVertexShader';
  132091. 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";
  132092. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132093. /** @hidden */
  132094. var backgroundVertexShader = { name: name, shader: shader };
  132095. /***/ }),
  132096. /***/ "./Shaders/blackAndWhite.fragment.ts":
  132097. /*!*******************************************!*\
  132098. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  132099. \*******************************************/
  132100. /*! exports provided: blackAndWhitePixelShader */
  132101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132102. "use strict";
  132103. __webpack_require__.r(__webpack_exports__);
  132104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  132105. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132106. var name = 'blackAndWhitePixelShader';
  132107. 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}";
  132108. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132109. /** @hidden */
  132110. var blackAndWhitePixelShader = { name: name, shader: shader };
  132111. /***/ }),
  132112. /***/ "./Shaders/bloomMerge.fragment.ts":
  132113. /*!****************************************!*\
  132114. !*** ./Shaders/bloomMerge.fragment.ts ***!
  132115. \****************************************/
  132116. /*! exports provided: bloomMergePixelShader */
  132117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132118. "use strict";
  132119. __webpack_require__.r(__webpack_exports__);
  132120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  132121. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132122. var name = 'bloomMergePixelShader';
  132123. 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";
  132124. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132125. /** @hidden */
  132126. var bloomMergePixelShader = { name: name, shader: shader };
  132127. /***/ }),
  132128. /***/ "./Shaders/chromaticAberration.fragment.ts":
  132129. /*!*************************************************!*\
  132130. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  132131. \*************************************************/
  132132. /*! exports provided: chromaticAberrationPixelShader */
  132133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132134. "use strict";
  132135. __webpack_require__.r(__webpack_exports__);
  132136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  132137. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132138. var name = 'chromaticAberrationPixelShader';
  132139. 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}";
  132140. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132141. /** @hidden */
  132142. var chromaticAberrationPixelShader = { name: name, shader: shader };
  132143. /***/ }),
  132144. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  132145. /*!***********************************************!*\
  132146. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  132147. \***********************************************/
  132148. /*! exports provided: circleOfConfusionPixelShader */
  132149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132150. "use strict";
  132151. __webpack_require__.r(__webpack_exports__);
  132152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  132153. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132154. var name = 'circleOfConfusionPixelShader';
  132155. 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";
  132156. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132157. /** @hidden */
  132158. var circleOfConfusionPixelShader = { name: name, shader: shader };
  132159. /***/ }),
  132160. /***/ "./Shaders/color.fragment.ts":
  132161. /*!***********************************!*\
  132162. !*** ./Shaders/color.fragment.ts ***!
  132163. \***********************************/
  132164. /*! exports provided: colorPixelShader */
  132165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132166. "use strict";
  132167. __webpack_require__.r(__webpack_exports__);
  132168. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  132169. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132170. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  132171. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  132172. var name = 'colorPixelShader';
  132173. 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}";
  132174. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132175. /** @hidden */
  132176. var colorPixelShader = { name: name, shader: shader };
  132177. /***/ }),
  132178. /***/ "./Shaders/color.vertex.ts":
  132179. /*!*********************************!*\
  132180. !*** ./Shaders/color.vertex.ts ***!
  132181. \*********************************/
  132182. /*! exports provided: colorVertexShader */
  132183. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132184. "use strict";
  132185. __webpack_require__.r(__webpack_exports__);
  132186. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  132187. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132188. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  132189. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  132190. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  132191. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  132192. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  132193. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  132194. var name = 'colorVertexShader';
  132195. 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}";
  132196. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132197. /** @hidden */
  132198. var colorVertexShader = { name: name, shader: shader };
  132199. /***/ }),
  132200. /***/ "./Shaders/colorCorrection.fragment.ts":
  132201. /*!*********************************************!*\
  132202. !*** ./Shaders/colorCorrection.fragment.ts ***!
  132203. \*********************************************/
  132204. /*! exports provided: colorCorrectionPixelShader */
  132205. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132206. "use strict";
  132207. __webpack_require__.r(__webpack_exports__);
  132208. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  132209. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132210. var name = 'colorCorrectionPixelShader';
  132211. 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}";
  132212. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132213. /** @hidden */
  132214. var colorCorrectionPixelShader = { name: name, shader: shader };
  132215. /***/ }),
  132216. /***/ "./Shaders/convolution.fragment.ts":
  132217. /*!*****************************************!*\
  132218. !*** ./Shaders/convolution.fragment.ts ***!
  132219. \*****************************************/
  132220. /*! exports provided: convolutionPixelShader */
  132221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132222. "use strict";
  132223. __webpack_require__.r(__webpack_exports__);
  132224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  132225. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132226. var name = 'convolutionPixelShader';
  132227. 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}";
  132228. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132229. /** @hidden */
  132230. var convolutionPixelShader = { name: name, shader: shader };
  132231. /***/ }),
  132232. /***/ "./Shaders/default.fragment.ts":
  132233. /*!*************************************!*\
  132234. !*** ./Shaders/default.fragment.ts ***!
  132235. \*************************************/
  132236. /*! exports provided: defaultPixelShader */
  132237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132238. "use strict";
  132239. __webpack_require__.r(__webpack_exports__);
  132240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  132241. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132242. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  132243. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  132244. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  132245. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  132246. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  132247. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  132248. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  132249. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  132250. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  132251. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  132252. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  132253. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  132254. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  132255. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  132256. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  132257. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  132258. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  132259. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  132260. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  132261. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  132262. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  132263. var name = 'defaultPixelShader';
  132264. 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";
  132265. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132266. /** @hidden */
  132267. var defaultPixelShader = { name: name, shader: shader };
  132268. /***/ }),
  132269. /***/ "./Shaders/default.vertex.ts":
  132270. /*!***********************************!*\
  132271. !*** ./Shaders/default.vertex.ts ***!
  132272. \***********************************/
  132273. /*! exports provided: defaultVertexShader */
  132274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132275. "use strict";
  132276. __webpack_require__.r(__webpack_exports__);
  132277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  132278. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132279. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  132280. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  132281. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  132282. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  132283. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  132284. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  132285. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  132286. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  132287. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  132288. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  132289. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  132290. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  132291. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  132292. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  132293. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  132294. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  132295. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  132296. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  132297. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  132298. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  132299. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  132300. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  132301. var name = 'defaultVertexShader';
  132302. 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";
  132303. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132304. /** @hidden */
  132305. var defaultVertexShader = { name: name, shader: shader };
  132306. /***/ }),
  132307. /***/ "./Shaders/depth.fragment.ts":
  132308. /*!***********************************!*\
  132309. !*** ./Shaders/depth.fragment.ts ***!
  132310. \***********************************/
  132311. /*! exports provided: depthPixelShader */
  132312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132313. "use strict";
  132314. __webpack_require__.r(__webpack_exports__);
  132315. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  132316. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132317. var name = 'depthPixelShader';
  132318. 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}";
  132319. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132320. /** @hidden */
  132321. var depthPixelShader = { name: name, shader: shader };
  132322. /***/ }),
  132323. /***/ "./Shaders/depth.vertex.ts":
  132324. /*!*********************************!*\
  132325. !*** ./Shaders/depth.vertex.ts ***!
  132326. \*********************************/
  132327. /*! exports provided: depthVertexShader */
  132328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132329. "use strict";
  132330. __webpack_require__.r(__webpack_exports__);
  132331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  132332. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132333. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  132334. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  132335. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  132336. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  132337. var name = 'depthVertexShader';
  132338. 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}";
  132339. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132340. /** @hidden */
  132341. var depthVertexShader = { name: name, shader: shader };
  132342. /***/ }),
  132343. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  132344. /*!******************************************!*\
  132345. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  132346. \******************************************/
  132347. /*! exports provided: depthBoxBlurPixelShader */
  132348. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132349. "use strict";
  132350. __webpack_require__.r(__webpack_exports__);
  132351. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  132352. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132353. var name = 'depthBoxBlurPixelShader';
  132354. 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}";
  132355. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132356. /** @hidden */
  132357. var depthBoxBlurPixelShader = { name: name, shader: shader };
  132358. /***/ }),
  132359. /***/ "./Shaders/depthOfField.fragment.ts":
  132360. /*!******************************************!*\
  132361. !*** ./Shaders/depthOfField.fragment.ts ***!
  132362. \******************************************/
  132363. /*! exports provided: depthOfFieldPixelShader */
  132364. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132365. "use strict";
  132366. __webpack_require__.r(__webpack_exports__);
  132367. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  132368. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132369. var name = 'depthOfFieldPixelShader';
  132370. 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";
  132371. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132372. /** @hidden */
  132373. var depthOfFieldPixelShader = { name: name, shader: shader };
  132374. /***/ }),
  132375. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  132376. /*!***********************************************!*\
  132377. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  132378. \***********************************************/
  132379. /*! exports provided: depthOfFieldMergePixelShader */
  132380. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132381. "use strict";
  132382. __webpack_require__.r(__webpack_exports__);
  132383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  132384. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132385. var name = 'depthOfFieldMergePixelShader';
  132386. 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";
  132387. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132388. /** @hidden */
  132389. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  132390. /***/ }),
  132391. /***/ "./Shaders/displayPass.fragment.ts":
  132392. /*!*****************************************!*\
  132393. !*** ./Shaders/displayPass.fragment.ts ***!
  132394. \*****************************************/
  132395. /*! exports provided: displayPassPixelShader */
  132396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132397. "use strict";
  132398. __webpack_require__.r(__webpack_exports__);
  132399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  132400. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132401. var name = 'displayPassPixelShader';
  132402. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  132403. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132404. /** @hidden */
  132405. var displayPassPixelShader = { name: name, shader: shader };
  132406. /***/ }),
  132407. /***/ "./Shaders/extractHighlights.fragment.ts":
  132408. /*!***********************************************!*\
  132409. !*** ./Shaders/extractHighlights.fragment.ts ***!
  132410. \***********************************************/
  132411. /*! exports provided: extractHighlightsPixelShader */
  132412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132413. "use strict";
  132414. __webpack_require__.r(__webpack_exports__);
  132415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  132416. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132417. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  132418. var name = 'extractHighlightsPixelShader';
  132419. 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}";
  132420. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132421. /** @hidden */
  132422. var extractHighlightsPixelShader = { name: name, shader: shader };
  132423. /***/ }),
  132424. /***/ "./Shaders/filter.fragment.ts":
  132425. /*!************************************!*\
  132426. !*** ./Shaders/filter.fragment.ts ***!
  132427. \************************************/
  132428. /*! exports provided: filterPixelShader */
  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__, "filterPixelShader", function() { return filterPixelShader; });
  132433. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132434. var name = 'filterPixelShader';
  132435. 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}";
  132436. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132437. /** @hidden */
  132438. var filterPixelShader = { name: name, shader: shader };
  132439. /***/ }),
  132440. /***/ "./Shaders/fxaa.fragment.ts":
  132441. /*!**********************************!*\
  132442. !*** ./Shaders/fxaa.fragment.ts ***!
  132443. \**********************************/
  132444. /*! exports provided: fxaaPixelShader */
  132445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132446. "use strict";
  132447. __webpack_require__.r(__webpack_exports__);
  132448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  132449. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132450. var name = 'fxaaPixelShader';
  132451. 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}";
  132452. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132453. /** @hidden */
  132454. var fxaaPixelShader = { name: name, shader: shader };
  132455. /***/ }),
  132456. /***/ "./Shaders/fxaa.vertex.ts":
  132457. /*!********************************!*\
  132458. !*** ./Shaders/fxaa.vertex.ts ***!
  132459. \********************************/
  132460. /*! exports provided: fxaaVertexShader */
  132461. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132462. "use strict";
  132463. __webpack_require__.r(__webpack_exports__);
  132464. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  132465. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132466. var name = 'fxaaVertexShader';
  132467. 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}";
  132468. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132469. /** @hidden */
  132470. var fxaaVertexShader = { name: name, shader: shader };
  132471. /***/ }),
  132472. /***/ "./Shaders/geometry.fragment.ts":
  132473. /*!**************************************!*\
  132474. !*** ./Shaders/geometry.fragment.ts ***!
  132475. \**************************************/
  132476. /*! exports provided: geometryPixelShader */
  132477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132478. "use strict";
  132479. __webpack_require__.r(__webpack_exports__);
  132480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  132481. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132482. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  132483. var name = 'geometryPixelShader';
  132484. 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=abs(a-b);\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\ngl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n}";
  132485. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132486. /** @hidden */
  132487. var geometryPixelShader = { name: name, shader: shader };
  132488. /***/ }),
  132489. /***/ "./Shaders/geometry.vertex.ts":
  132490. /*!************************************!*\
  132491. !*** ./Shaders/geometry.vertex.ts ***!
  132492. \************************************/
  132493. /*! exports provided: geometryVertexShader */
  132494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132495. "use strict";
  132496. __webpack_require__.r(__webpack_exports__);
  132497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  132498. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132499. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  132500. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  132501. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  132502. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  132503. var name = 'geometryVertexShader';
  132504. 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 previousWorld;\nuniform mat4 previousViewProjection;\n#ifdef BONES_VELOCITY_ENABLED\n#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mPreviousBones[BonesPerMesh];\n#endif\n#endif\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\nvoid main(void)\n{\n#include<instancesVertex>\n#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\n\nvCurrentPosition=viewProjection*finalWorld*vec4(position,1.0);\nvPreviousPosition=previousViewProjection*previousWorld*vec4(position,1.0);\n#endif\n#include<bonesVertex>\nvec4 pos=vec4(finalWorld*vec4(position,1.0));\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normal,0.0)));\nvViewPos=view*pos;\n#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(position,1.0);\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;\npreviousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(position,1.0);\n#else\nvPreviousPosition=previousViewProjection*previousWorld*vec4(position,1.0);\n#endif\n#endif\n#ifdef POSITION\nvPosition=pos.xyz/pos.w;\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}";
  132505. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132506. /** @hidden */
  132507. var geometryVertexShader = { name: name, shader: shader };
  132508. /***/ }),
  132509. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  132510. /*!*************************************************!*\
  132511. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  132512. \*************************************************/
  132513. /*! exports provided: glowBlurPostProcessPixelShader */
  132514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132515. "use strict";
  132516. __webpack_require__.r(__webpack_exports__);
  132517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  132518. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132519. var name = 'glowBlurPostProcessPixelShader';
  132520. 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}";
  132521. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132522. /** @hidden */
  132523. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  132524. /***/ }),
  132525. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  132526. /*!***********************************************!*\
  132527. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  132528. \***********************************************/
  132529. /*! exports provided: glowMapGenerationPixelShader */
  132530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132531. "use strict";
  132532. __webpack_require__.r(__webpack_exports__);
  132533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  132534. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132535. var name = 'glowMapGenerationPixelShader';
  132536. 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\n#ifdef VERTEXALPHA\nvarying vec4 vColor;\n#endif\nuniform vec4 glowColor;\nvoid main(void)\n{\nvec4 finalColor=glowColor;\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}";
  132537. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132538. /** @hidden */
  132539. var glowMapGenerationPixelShader = { name: name, shader: shader };
  132540. /***/ }),
  132541. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  132542. /*!*********************************************!*\
  132543. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  132544. \*********************************************/
  132545. /*! exports provided: glowMapGenerationVertexShader */
  132546. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132547. "use strict";
  132548. __webpack_require__.r(__webpack_exports__);
  132549. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  132550. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132551. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  132552. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  132553. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  132554. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  132555. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  132556. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  132557. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  132558. var name = 'glowMapGenerationVertexShader';
  132559. 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}";
  132560. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132561. /** @hidden */
  132562. var glowMapGenerationVertexShader = { name: name, shader: shader };
  132563. /***/ }),
  132564. /***/ "./Shaders/glowMapMerge.fragment.ts":
  132565. /*!******************************************!*\
  132566. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  132567. \******************************************/
  132568. /*! exports provided: glowMapMergePixelShader */
  132569. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132570. "use strict";
  132571. __webpack_require__.r(__webpack_exports__);
  132572. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  132573. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132574. var name = 'glowMapMergePixelShader';
  132575. 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}";
  132576. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132577. /** @hidden */
  132578. var glowMapMergePixelShader = { name: name, shader: shader };
  132579. /***/ }),
  132580. /***/ "./Shaders/glowMapMerge.vertex.ts":
  132581. /*!****************************************!*\
  132582. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  132583. \****************************************/
  132584. /*! exports provided: glowMapMergeVertexShader */
  132585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132586. "use strict";
  132587. __webpack_require__.r(__webpack_exports__);
  132588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  132589. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132590. var name = 'glowMapMergeVertexShader';
  132591. 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}";
  132592. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132593. /** @hidden */
  132594. var glowMapMergeVertexShader = { name: name, shader: shader };
  132595. /***/ }),
  132596. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  132597. /*!************************************************!*\
  132598. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  132599. \************************************************/
  132600. /*! exports provided: gpuRenderParticlesPixelShader */
  132601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132602. "use strict";
  132603. __webpack_require__.r(__webpack_exports__);
  132604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  132605. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132606. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  132607. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  132608. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  132609. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  132610. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  132611. var name = 'gpuRenderParticlesPixelShader';
  132612. 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";
  132613. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132614. /** @hidden */
  132615. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  132616. /***/ }),
  132617. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  132618. /*!**********************************************!*\
  132619. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  132620. \**********************************************/
  132621. /*! exports provided: gpuRenderParticlesVertexShader */
  132622. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132623. "use strict";
  132624. __webpack_require__.r(__webpack_exports__);
  132625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  132626. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132627. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  132628. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  132629. var name = 'gpuRenderParticlesVertexShader';
  132630. 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}";
  132631. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132632. /** @hidden */
  132633. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  132634. /***/ }),
  132635. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  132636. /*!************************************************!*\
  132637. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  132638. \************************************************/
  132639. /*! exports provided: gpuUpdateParticlesPixelShader */
  132640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132641. "use strict";
  132642. __webpack_require__.r(__webpack_exports__);
  132643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  132644. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132645. var name = 'gpuUpdateParticlesPixelShader';
  132646. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  132647. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132648. /** @hidden */
  132649. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  132650. /***/ }),
  132651. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  132652. /*!**********************************************!*\
  132653. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  132654. \**********************************************/
  132655. /*! exports provided: gpuUpdateParticlesVertexShader */
  132656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132657. "use strict";
  132658. __webpack_require__.r(__webpack_exports__);
  132659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  132660. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132661. var name = 'gpuUpdateParticlesVertexShader';
  132662. 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}";
  132663. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132664. /** @hidden */
  132665. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  132666. /***/ }),
  132667. /***/ "./Shaders/grain.fragment.ts":
  132668. /*!***********************************!*\
  132669. !*** ./Shaders/grain.fragment.ts ***!
  132670. \***********************************/
  132671. /*! exports provided: grainPixelShader */
  132672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132673. "use strict";
  132674. __webpack_require__.r(__webpack_exports__);
  132675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  132676. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132677. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  132678. var name = 'grainPixelShader';
  132679. 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}";
  132680. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132681. /** @hidden */
  132682. var grainPixelShader = { name: name, shader: shader };
  132683. /***/ }),
  132684. /***/ "./Shaders/highlights.fragment.ts":
  132685. /*!****************************************!*\
  132686. !*** ./Shaders/highlights.fragment.ts ***!
  132687. \****************************************/
  132688. /*! exports provided: highlightsPixelShader */
  132689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132690. "use strict";
  132691. __webpack_require__.r(__webpack_exports__);
  132692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  132693. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132694. var name = 'highlightsPixelShader';
  132695. 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}";
  132696. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132697. /** @hidden */
  132698. var highlightsPixelShader = { name: name, shader: shader };
  132699. /***/ }),
  132700. /***/ "./Shaders/imageProcessing.fragment.ts":
  132701. /*!*********************************************!*\
  132702. !*** ./Shaders/imageProcessing.fragment.ts ***!
  132703. \*********************************************/
  132704. /*! exports provided: imageProcessingPixelShader */
  132705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132706. "use strict";
  132707. __webpack_require__.r(__webpack_exports__);
  132708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  132709. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132710. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  132711. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  132712. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  132713. var name = 'imageProcessingPixelShader';
  132714. 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}";
  132715. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132716. /** @hidden */
  132717. var imageProcessingPixelShader = { name: name, shader: shader };
  132718. /***/ }),
  132719. /***/ "./Shaders/kernelBlur.fragment.ts":
  132720. /*!****************************************!*\
  132721. !*** ./Shaders/kernelBlur.fragment.ts ***!
  132722. \****************************************/
  132723. /*! exports provided: kernelBlurPixelShader */
  132724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132725. "use strict";
  132726. __webpack_require__.r(__webpack_exports__);
  132727. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  132728. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132729. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  132730. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  132731. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  132732. var name = 'kernelBlurPixelShader';
  132733. 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}";
  132734. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132735. /** @hidden */
  132736. var kernelBlurPixelShader = { name: name, shader: shader };
  132737. /***/ }),
  132738. /***/ "./Shaders/kernelBlur.vertex.ts":
  132739. /*!**************************************!*\
  132740. !*** ./Shaders/kernelBlur.vertex.ts ***!
  132741. \**************************************/
  132742. /*! exports provided: kernelBlurVertexShader */
  132743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132744. "use strict";
  132745. __webpack_require__.r(__webpack_exports__);
  132746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  132747. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132748. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  132749. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  132750. var name = 'kernelBlurVertexShader';
  132751. 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}";
  132752. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132753. /** @hidden */
  132754. var kernelBlurVertexShader = { name: name, shader: shader };
  132755. /***/ }),
  132756. /***/ "./Shaders/layer.fragment.ts":
  132757. /*!***********************************!*\
  132758. !*** ./Shaders/layer.fragment.ts ***!
  132759. \***********************************/
  132760. /*! exports provided: layerPixelShader */
  132761. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132762. "use strict";
  132763. __webpack_require__.r(__webpack_exports__);
  132764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  132765. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132766. var name = 'layerPixelShader';
  132767. 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}";
  132768. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132769. /** @hidden */
  132770. var layerPixelShader = { name: name, shader: shader };
  132771. /***/ }),
  132772. /***/ "./Shaders/layer.vertex.ts":
  132773. /*!*********************************!*\
  132774. !*** ./Shaders/layer.vertex.ts ***!
  132775. \*********************************/
  132776. /*! exports provided: layerVertexShader */
  132777. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132778. "use strict";
  132779. __webpack_require__.r(__webpack_exports__);
  132780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  132781. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132782. var name = 'layerVertexShader';
  132783. 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}";
  132784. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132785. /** @hidden */
  132786. var layerVertexShader = { name: name, shader: shader };
  132787. /***/ }),
  132788. /***/ "./Shaders/lensFlare.fragment.ts":
  132789. /*!***************************************!*\
  132790. !*** ./Shaders/lensFlare.fragment.ts ***!
  132791. \***************************************/
  132792. /*! exports provided: lensFlarePixelShader */
  132793. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132794. "use strict";
  132795. __webpack_require__.r(__webpack_exports__);
  132796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  132797. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132798. var name = 'lensFlarePixelShader';
  132799. 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}";
  132800. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132801. /** @hidden */
  132802. var lensFlarePixelShader = { name: name, shader: shader };
  132803. /***/ }),
  132804. /***/ "./Shaders/lensFlare.vertex.ts":
  132805. /*!*************************************!*\
  132806. !*** ./Shaders/lensFlare.vertex.ts ***!
  132807. \*************************************/
  132808. /*! exports provided: lensFlareVertexShader */
  132809. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132810. "use strict";
  132811. __webpack_require__.r(__webpack_exports__);
  132812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  132813. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132814. var name = 'lensFlareVertexShader';
  132815. 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}";
  132816. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132817. /** @hidden */
  132818. var lensFlareVertexShader = { name: name, shader: shader };
  132819. /***/ }),
  132820. /***/ "./Shaders/lensHighlights.fragment.ts":
  132821. /*!********************************************!*\
  132822. !*** ./Shaders/lensHighlights.fragment.ts ***!
  132823. \********************************************/
  132824. /*! exports provided: lensHighlightsPixelShader */
  132825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132826. "use strict";
  132827. __webpack_require__.r(__webpack_exports__);
  132828. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  132829. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132830. var name = 'lensHighlightsPixelShader';
  132831. 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}";
  132832. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132833. /** @hidden */
  132834. var lensHighlightsPixelShader = { name: name, shader: shader };
  132835. /***/ }),
  132836. /***/ "./Shaders/line.fragment.ts":
  132837. /*!**********************************!*\
  132838. !*** ./Shaders/line.fragment.ts ***!
  132839. \**********************************/
  132840. /*! exports provided: linePixelShader */
  132841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132842. "use strict";
  132843. __webpack_require__.r(__webpack_exports__);
  132844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  132845. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132846. var name = 'linePixelShader';
  132847. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  132848. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132849. /** @hidden */
  132850. var linePixelShader = { name: name, shader: shader };
  132851. /***/ }),
  132852. /***/ "./Shaders/line.vertex.ts":
  132853. /*!********************************!*\
  132854. !*** ./Shaders/line.vertex.ts ***!
  132855. \********************************/
  132856. /*! exports provided: lineVertexShader */
  132857. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132858. "use strict";
  132859. __webpack_require__.r(__webpack_exports__);
  132860. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  132861. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132862. var name = 'lineVertexShader';
  132863. 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}";
  132864. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132865. /** @hidden */
  132866. var lineVertexShader = { name: name, shader: shader };
  132867. /***/ }),
  132868. /***/ "./Shaders/motionBlur.fragment.ts":
  132869. /*!****************************************!*\
  132870. !*** ./Shaders/motionBlur.fragment.ts ***!
  132871. \****************************************/
  132872. /*! exports provided: motionBlurPixelShader */
  132873. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132874. "use strict";
  132875. __webpack_require__.r(__webpack_exports__);
  132876. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  132877. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132878. var name = 'motionBlurPixelShader';
  132879. 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*2.0-1.0;\nvec2 velocity=vec2(pow(velocityColor.r,3.0),pow(velocityColor.g,3.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);\ngl_FragColor.a=1.0;\n#else\ngl_FragColor=texture2D(textureSampler,vUV);\n#endif\n}\n";
  132880. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132881. /** @hidden */
  132882. var motionBlurPixelShader = { name: name, shader: shader };
  132883. /***/ }),
  132884. /***/ "./Shaders/noise.fragment.ts":
  132885. /*!***********************************!*\
  132886. !*** ./Shaders/noise.fragment.ts ***!
  132887. \***********************************/
  132888. /*! exports provided: noisePixelShader */
  132889. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132890. "use strict";
  132891. __webpack_require__.r(__webpack_exports__);
  132892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  132893. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132894. var name = 'noisePixelShader';
  132895. 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";
  132896. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132897. /** @hidden */
  132898. var noisePixelShader = { name: name, shader: shader };
  132899. /***/ }),
  132900. /***/ "./Shaders/outline.fragment.ts":
  132901. /*!*************************************!*\
  132902. !*** ./Shaders/outline.fragment.ts ***!
  132903. \*************************************/
  132904. /*! exports provided: outlinePixelShader */
  132905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132906. "use strict";
  132907. __webpack_require__.r(__webpack_exports__);
  132908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  132909. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132910. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  132911. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  132912. var name = 'outlinePixelShader';
  132913. 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}";
  132914. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132915. /** @hidden */
  132916. var outlinePixelShader = { name: name, shader: shader };
  132917. /***/ }),
  132918. /***/ "./Shaders/outline.vertex.ts":
  132919. /*!***********************************!*\
  132920. !*** ./Shaders/outline.vertex.ts ***!
  132921. \***********************************/
  132922. /*! exports provided: outlineVertexShader */
  132923. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132924. "use strict";
  132925. __webpack_require__.r(__webpack_exports__);
  132926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  132927. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132928. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  132929. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  132930. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  132931. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  132932. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  132933. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  132934. var name = 'outlineVertexShader';
  132935. 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";
  132936. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132937. /** @hidden */
  132938. var outlineVertexShader = { name: name, shader: shader };
  132939. /***/ }),
  132940. /***/ "./Shaders/particles.fragment.ts":
  132941. /*!***************************************!*\
  132942. !*** ./Shaders/particles.fragment.ts ***!
  132943. \***************************************/
  132944. /*! exports provided: particlesPixelShader */
  132945. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132946. "use strict";
  132947. __webpack_require__.r(__webpack_exports__);
  132948. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  132949. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132950. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  132951. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  132952. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  132953. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  132954. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  132955. var name = 'particlesPixelShader';
  132956. 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}";
  132957. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132958. /** @hidden */
  132959. var particlesPixelShader = { name: name, shader: shader };
  132960. /***/ }),
  132961. /***/ "./Shaders/particles.vertex.ts":
  132962. /*!*************************************!*\
  132963. !*** ./Shaders/particles.vertex.ts ***!
  132964. \*************************************/
  132965. /*! exports provided: particlesVertexShader */
  132966. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132967. "use strict";
  132968. __webpack_require__.r(__webpack_exports__);
  132969. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  132970. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132971. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  132972. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  132973. var name = 'particlesVertexShader';
  132974. 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}";
  132975. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132976. /** @hidden */
  132977. var particlesVertexShader = { name: name, shader: shader };
  132978. /***/ }),
  132979. /***/ "./Shaders/pass.fragment.ts":
  132980. /*!**********************************!*\
  132981. !*** ./Shaders/pass.fragment.ts ***!
  132982. \**********************************/
  132983. /*! exports provided: passPixelShader */
  132984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132985. "use strict";
  132986. __webpack_require__.r(__webpack_exports__);
  132987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  132988. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  132989. var name = 'passPixelShader';
  132990. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  132991. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  132992. /** @hidden */
  132993. var passPixelShader = { name: name, shader: shader };
  132994. /***/ }),
  132995. /***/ "./Shaders/passCube.fragment.ts":
  132996. /*!**************************************!*\
  132997. !*** ./Shaders/passCube.fragment.ts ***!
  132998. \**************************************/
  132999. /*! exports provided: passCubePixelShader */
  133000. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133001. "use strict";
  133002. __webpack_require__.r(__webpack_exports__);
  133003. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  133004. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133005. var name = 'passCubePixelShader';
  133006. 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}";
  133007. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133008. /** @hidden */
  133009. var passCubePixelShader = { name: name, shader: shader };
  133010. /***/ }),
  133011. /***/ "./Shaders/pbr.fragment.ts":
  133012. /*!*********************************!*\
  133013. !*** ./Shaders/pbr.fragment.ts ***!
  133014. \*********************************/
  133015. /*! exports provided: pbrPixelShader */
  133016. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133017. "use strict";
  133018. __webpack_require__.r(__webpack_exports__);
  133019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  133020. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133021. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  133022. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  133023. /* harmony import */ var _ShadersInclude_pbrFragmentExtraDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentExtraDeclaration */ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts");
  133024. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  133025. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  133026. /* harmony import */ var _ShadersInclude_pbrFragmentSamplersDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentSamplersDeclaration */ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts");
  133027. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  133028. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  133029. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  133030. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  133031. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  133032. /* harmony import */ var _ShadersInclude_pbrHelperFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrHelperFunctions */ "./Shaders/ShadersInclude/pbrHelperFunctions.ts");
  133033. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  133034. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  133035. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  133036. /* harmony import */ var _ShadersInclude_pbrDirectLightingSetupFunctions__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingSetupFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts");
  133037. /* harmony import */ var _ShadersInclude_pbrDirectLightingFalloffFunctions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFalloffFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts");
  133038. /* harmony import */ var _ShadersInclude_pbrBRDFFunctions__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/pbrBRDFFunctions */ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts");
  133039. /* harmony import */ var _ShadersInclude_pbrDirectLightingFunctions__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts");
  133040. /* harmony import */ var _ShadersInclude_pbrIBLFunctions__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/pbrIBLFunctions */ "./Shaders/ShadersInclude/pbrIBLFunctions.ts");
  133041. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  133042. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  133043. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  133044. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  133045. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  133046. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  133047. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  133048. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  133049. /* harmony import */ var _ShadersInclude_pbrDebug__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./ShadersInclude/pbrDebug */ "./Shaders/ShadersInclude/pbrDebug.ts");
  133050. var name = 'pbrPixelShader';
  133051. 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#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS\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#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE\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=computeEnvironmentIrradiance(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\nvec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);\nrefractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);\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=computeEnvironmentIrradiance(-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";
  133052. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133053. /** @hidden */
  133054. var pbrPixelShader = { name: name, shader: shader };
  133055. /***/ }),
  133056. /***/ "./Shaders/pbr.vertex.ts":
  133057. /*!*******************************!*\
  133058. !*** ./Shaders/pbr.vertex.ts ***!
  133059. \*******************************/
  133060. /*! exports provided: pbrVertexShader */
  133061. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133062. "use strict";
  133063. __webpack_require__.r(__webpack_exports__);
  133064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  133065. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133066. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  133067. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  133068. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  133069. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  133070. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  133071. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  133072. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  133073. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  133074. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  133075. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  133076. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  133077. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  133078. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  133079. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  133080. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  133081. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  133082. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  133083. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  133084. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  133085. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  133086. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  133087. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  133088. var name = 'pbrVertexShader';
  133089. 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=computeEnvironmentIrradiance(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}";
  133090. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133091. /** @hidden */
  133092. var pbrVertexShader = { name: name, shader: shader };
  133093. /***/ }),
  133094. /***/ "./Shaders/postprocess.vertex.ts":
  133095. /*!***************************************!*\
  133096. !*** ./Shaders/postprocess.vertex.ts ***!
  133097. \***************************************/
  133098. /*! exports provided: postprocessVertexShader */
  133099. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133100. "use strict";
  133101. __webpack_require__.r(__webpack_exports__);
  133102. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  133103. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133104. var name = 'postprocessVertexShader';
  133105. 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}";
  133106. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133107. /** @hidden */
  133108. var postprocessVertexShader = { name: name, shader: shader };
  133109. /***/ }),
  133110. /***/ "./Shaders/procedural.vertex.ts":
  133111. /*!**************************************!*\
  133112. !*** ./Shaders/procedural.vertex.ts ***!
  133113. \**************************************/
  133114. /*! exports provided: proceduralVertexShader */
  133115. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133116. "use strict";
  133117. __webpack_require__.r(__webpack_exports__);
  133118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  133119. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133120. var name = 'proceduralVertexShader';
  133121. 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}";
  133122. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133123. /** @hidden */
  133124. var proceduralVertexShader = { name: name, shader: shader };
  133125. /***/ }),
  133126. /***/ "./Shaders/refraction.fragment.ts":
  133127. /*!****************************************!*\
  133128. !*** ./Shaders/refraction.fragment.ts ***!
  133129. \****************************************/
  133130. /*! exports provided: refractionPixelShader */
  133131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133132. "use strict";
  133133. __webpack_require__.r(__webpack_exports__);
  133134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  133135. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133136. var name = 'refractionPixelShader';
  133137. 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}";
  133138. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133139. /** @hidden */
  133140. var refractionPixelShader = { name: name, shader: shader };
  133141. /***/ }),
  133142. /***/ "./Shaders/rgbdDecode.fragment.ts":
  133143. /*!****************************************!*\
  133144. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  133145. \****************************************/
  133146. /*! exports provided: rgbdDecodePixelShader */
  133147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133148. "use strict";
  133149. __webpack_require__.r(__webpack_exports__);
  133150. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  133151. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133152. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  133153. var name = 'rgbdDecodePixelShader';
  133154. 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}";
  133155. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133156. /** @hidden */
  133157. var rgbdDecodePixelShader = { name: name, shader: shader };
  133158. /***/ }),
  133159. /***/ "./Shaders/rgbdEncode.fragment.ts":
  133160. /*!****************************************!*\
  133161. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  133162. \****************************************/
  133163. /*! exports provided: rgbdEncodePixelShader */
  133164. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133165. "use strict";
  133166. __webpack_require__.r(__webpack_exports__);
  133167. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  133168. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133169. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  133170. var name = 'rgbdEncodePixelShader';
  133171. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  133172. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133173. /** @hidden */
  133174. var rgbdEncodePixelShader = { name: name, shader: shader };
  133175. /***/ }),
  133176. /***/ "./Shaders/shadowMap.fragment.ts":
  133177. /*!***************************************!*\
  133178. !*** ./Shaders/shadowMap.fragment.ts ***!
  133179. \***************************************/
  133180. /*! exports provided: shadowMapPixelShader */
  133181. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133182. "use strict";
  133183. __webpack_require__.r(__webpack_exports__);
  133184. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  133185. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133186. var name = 'shadowMapPixelShader';
  133187. 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}";
  133188. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133189. /** @hidden */
  133190. var shadowMapPixelShader = { name: name, shader: shader };
  133191. /***/ }),
  133192. /***/ "./Shaders/shadowMap.vertex.ts":
  133193. /*!*************************************!*\
  133194. !*** ./Shaders/shadowMap.vertex.ts ***!
  133195. \*************************************/
  133196. /*! exports provided: shadowMapVertexShader */
  133197. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133198. "use strict";
  133199. __webpack_require__.r(__webpack_exports__);
  133200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  133201. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133202. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  133203. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  133204. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  133205. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  133206. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  133207. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  133208. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  133209. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  133210. var name = 'shadowMapVertexShader';
  133211. 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}";
  133212. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133213. /** @hidden */
  133214. var shadowMapVertexShader = { name: name, shader: shader };
  133215. /***/ }),
  133216. /***/ "./Shaders/sharpen.fragment.ts":
  133217. /*!*************************************!*\
  133218. !*** ./Shaders/sharpen.fragment.ts ***!
  133219. \*************************************/
  133220. /*! exports provided: sharpenPixelShader */
  133221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133222. "use strict";
  133223. __webpack_require__.r(__webpack_exports__);
  133224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  133225. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133226. var name = 'sharpenPixelShader';
  133227. 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}";
  133228. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133229. /** @hidden */
  133230. var sharpenPixelShader = { name: name, shader: shader };
  133231. /***/ }),
  133232. /***/ "./Shaders/sprites.fragment.ts":
  133233. /*!*************************************!*\
  133234. !*** ./Shaders/sprites.fragment.ts ***!
  133235. \*************************************/
  133236. /*! exports provided: spritesPixelShader */
  133237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133238. "use strict";
  133239. __webpack_require__.r(__webpack_exports__);
  133240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  133241. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133242. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  133243. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  133244. var name = 'spritesPixelShader';
  133245. 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}";
  133246. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133247. /** @hidden */
  133248. var spritesPixelShader = { name: name, shader: shader };
  133249. /***/ }),
  133250. /***/ "./Shaders/sprites.vertex.ts":
  133251. /*!***********************************!*\
  133252. !*** ./Shaders/sprites.vertex.ts ***!
  133253. \***********************************/
  133254. /*! exports provided: spritesVertexShader */
  133255. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133256. "use strict";
  133257. __webpack_require__.r(__webpack_exports__);
  133258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  133259. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133260. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  133261. var name = 'spritesVertexShader';
  133262. 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}";
  133263. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133264. /** @hidden */
  133265. var spritesVertexShader = { name: name, shader: shader };
  133266. /***/ }),
  133267. /***/ "./Shaders/ssao.fragment.ts":
  133268. /*!**********************************!*\
  133269. !*** ./Shaders/ssao.fragment.ts ***!
  133270. \**********************************/
  133271. /*! exports provided: ssaoPixelShader */
  133272. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133273. "use strict";
  133274. __webpack_require__.r(__webpack_exports__);
  133275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  133276. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133277. var name = 'ssaoPixelShader';
  133278. 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";
  133279. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133280. /** @hidden */
  133281. var ssaoPixelShader = { name: name, shader: shader };
  133282. /***/ }),
  133283. /***/ "./Shaders/ssao2.fragment.ts":
  133284. /*!***********************************!*\
  133285. !*** ./Shaders/ssao2.fragment.ts ***!
  133286. \***********************************/
  133287. /*! exports provided: ssao2PixelShader */
  133288. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133289. "use strict";
  133290. __webpack_require__.r(__webpack_exports__);
  133291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  133292. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133293. var name = 'ssao2PixelShader';
  133294. 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";
  133295. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133296. /** @hidden */
  133297. var ssao2PixelShader = { name: name, shader: shader };
  133298. /***/ }),
  133299. /***/ "./Shaders/ssaoCombine.fragment.ts":
  133300. /*!*****************************************!*\
  133301. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  133302. \*****************************************/
  133303. /*! exports provided: ssaoCombinePixelShader */
  133304. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133305. "use strict";
  133306. __webpack_require__.r(__webpack_exports__);
  133307. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  133308. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133309. var name = 'ssaoCombinePixelShader';
  133310. 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";
  133311. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133312. /** @hidden */
  133313. var ssaoCombinePixelShader = { name: name, shader: shader };
  133314. /***/ }),
  133315. /***/ "./Shaders/standard.fragment.ts":
  133316. /*!**************************************!*\
  133317. !*** ./Shaders/standard.fragment.ts ***!
  133318. \**************************************/
  133319. /*! exports provided: standardPixelShader */
  133320. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133321. "use strict";
  133322. __webpack_require__.r(__webpack_exports__);
  133323. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  133324. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133325. var name = 'standardPixelShader';
  133326. 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";
  133327. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133328. /** @hidden */
  133329. var standardPixelShader = { name: name, shader: shader };
  133330. /***/ }),
  133331. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  133332. /*!***************************************************!*\
  133333. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  133334. \***************************************************/
  133335. /*! exports provided: stereoscopicInterlacePixelShader */
  133336. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133337. "use strict";
  133338. __webpack_require__.r(__webpack_exports__);
  133339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  133340. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133341. var name = 'stereoscopicInterlacePixelShader';
  133342. 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}";
  133343. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133344. /** @hidden */
  133345. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  133346. /***/ }),
  133347. /***/ "./Shaders/tonemap.fragment.ts":
  133348. /*!*************************************!*\
  133349. !*** ./Shaders/tonemap.fragment.ts ***!
  133350. \*************************************/
  133351. /*! exports provided: tonemapPixelShader */
  133352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133353. "use strict";
  133354. __webpack_require__.r(__webpack_exports__);
  133355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  133356. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133357. var name = 'tonemapPixelShader';
  133358. 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}";
  133359. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133360. /** @hidden */
  133361. var tonemapPixelShader = { name: name, shader: shader };
  133362. /***/ }),
  133363. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  133364. /*!*******************************************************!*\
  133365. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  133366. \*******************************************************/
  133367. /*! exports provided: volumetricLightScatteringPixelShader */
  133368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133369. "use strict";
  133370. __webpack_require__.r(__webpack_exports__);
  133371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  133372. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133373. var name = 'volumetricLightScatteringPixelShader';
  133374. 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";
  133375. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133376. /** @hidden */
  133377. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  133378. /***/ }),
  133379. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  133380. /*!***********************************************************!*\
  133381. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  133382. \***********************************************************/
  133383. /*! exports provided: volumetricLightScatteringPassPixelShader */
  133384. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133385. "use strict";
  133386. __webpack_require__.r(__webpack_exports__);
  133387. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  133388. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133389. var name = 'volumetricLightScatteringPassPixelShader';
  133390. 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";
  133391. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133392. /** @hidden */
  133393. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  133394. /***/ }),
  133395. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  133396. /*!****************************************************!*\
  133397. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  133398. \****************************************************/
  133399. /*! exports provided: vrDistortionCorrectionPixelShader */
  133400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133401. "use strict";
  133402. __webpack_require__.r(__webpack_exports__);
  133403. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  133404. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133405. var name = 'vrDistortionCorrectionPixelShader';
  133406. 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}";
  133407. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133408. /** @hidden */
  133409. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  133410. /***/ }),
  133411. /***/ "./Shaders/vrMultiviewToSingleview.fragment.ts":
  133412. /*!*****************************************************!*\
  133413. !*** ./Shaders/vrMultiviewToSingleview.fragment.ts ***!
  133414. \*****************************************************/
  133415. /*! exports provided: vrMultiviewToSingleviewPixelShader */
  133416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133417. "use strict";
  133418. __webpack_require__.r(__webpack_exports__);
  133419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrMultiviewToSingleviewPixelShader", function() { return vrMultiviewToSingleviewPixelShader; });
  133420. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  133421. var name = 'vrMultiviewToSingleviewPixelShader';
  133422. 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}";
  133423. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  133424. /** @hidden */
  133425. var vrMultiviewToSingleviewPixelShader = { name: name, shader: shader };
  133426. /***/ }),
  133427. /***/ "./Sprites/index.ts":
  133428. /*!**************************!*\
  133429. !*** ./Sprites/index.ts ***!
  133430. \**************************/
  133431. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  133432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133433. "use strict";
  133434. __webpack_require__.r(__webpack_exports__);
  133435. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  133436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  133437. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  133438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  133439. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  133440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  133441. /***/ }),
  133442. /***/ "./Sprites/sprite.ts":
  133443. /*!***************************!*\
  133444. !*** ./Sprites/sprite.ts ***!
  133445. \***************************/
  133446. /*! exports provided: Sprite */
  133447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133448. "use strict";
  133449. __webpack_require__.r(__webpack_exports__);
  133450. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  133451. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  133452. /**
  133453. * Class used to represent a sprite
  133454. * @see http://doc.babylonjs.com/babylon101/sprites
  133455. */
  133456. var Sprite = /** @class */ (function () {
  133457. /**
  133458. * Creates a new Sprite
  133459. * @param name defines the name
  133460. * @param manager defines the manager
  133461. */
  133462. function Sprite(
  133463. /** defines the name */
  133464. name, manager) {
  133465. this.name = name;
  133466. /** Gets or sets the main color */
  133467. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  133468. /** Gets or sets the width */
  133469. this.width = 1.0;
  133470. /** Gets or sets the height */
  133471. this.height = 1.0;
  133472. /** Gets or sets rotation angle */
  133473. this.angle = 0;
  133474. /** Gets or sets the cell index in the sprite sheet */
  133475. this.cellIndex = 0;
  133476. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  133477. this.invertU = 0;
  133478. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  133479. this.invertV = 0;
  133480. /** Gets the list of attached animations */
  133481. this.animations = new Array();
  133482. /** Gets or sets a boolean indicating if the sprite can be picked */
  133483. this.isPickable = false;
  133484. this._animationStarted = false;
  133485. this._loopAnimation = false;
  133486. this._fromIndex = 0;
  133487. this._toIndex = 0;
  133488. this._delay = 0;
  133489. this._direction = 1;
  133490. this._time = 0;
  133491. /**
  133492. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  133493. */
  133494. this.isVisible = true;
  133495. this._manager = manager;
  133496. this._manager.sprites.push(this);
  133497. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  133498. }
  133499. Object.defineProperty(Sprite.prototype, "size", {
  133500. /**
  133501. * Gets or sets the sprite size
  133502. */
  133503. get: function () {
  133504. return this.width;
  133505. },
  133506. set: function (value) {
  133507. this.width = value;
  133508. this.height = value;
  133509. },
  133510. enumerable: true,
  133511. configurable: true
  133512. });
  133513. /**
  133514. * Starts an animation
  133515. * @param from defines the initial key
  133516. * @param to defines the end key
  133517. * @param loop defines if the animation must loop
  133518. * @param delay defines the start delay (in ms)
  133519. * @param onAnimationEnd defines a callback to call when animation ends
  133520. */
  133521. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  133522. this._fromIndex = from;
  133523. this._toIndex = to;
  133524. this._loopAnimation = loop;
  133525. this._delay = delay;
  133526. this._animationStarted = true;
  133527. if (from < to) {
  133528. this._direction = 1;
  133529. }
  133530. else {
  133531. this._direction = -1;
  133532. this._toIndex = from;
  133533. this._fromIndex = to;
  133534. }
  133535. this.cellIndex = from;
  133536. this._time = 0;
  133537. this._onAnimationEnd = onAnimationEnd;
  133538. };
  133539. /** Stops current animation (if any) */
  133540. Sprite.prototype.stopAnimation = function () {
  133541. this._animationStarted = false;
  133542. };
  133543. /** @hidden */
  133544. Sprite.prototype._animate = function (deltaTime) {
  133545. if (!this._animationStarted) {
  133546. return;
  133547. }
  133548. this._time += deltaTime;
  133549. if (this._time > this._delay) {
  133550. this._time = this._time % this._delay;
  133551. this.cellIndex += this._direction;
  133552. if (this._direction > 0 && this.cellIndex > this._toIndex || this._direction < 0 && this.cellIndex < this._fromIndex) {
  133553. if (this._loopAnimation) {
  133554. this.cellIndex = this._direction > 0 ? this._fromIndex : this._toIndex;
  133555. }
  133556. else {
  133557. this.cellIndex = this._toIndex;
  133558. this._animationStarted = false;
  133559. if (this._onAnimationEnd) {
  133560. this._onAnimationEnd();
  133561. }
  133562. if (this.disposeWhenFinishedAnimating) {
  133563. this.dispose();
  133564. }
  133565. }
  133566. }
  133567. }
  133568. };
  133569. /** Release associated resources */
  133570. Sprite.prototype.dispose = function () {
  133571. for (var i = 0; i < this._manager.sprites.length; i++) {
  133572. if (this._manager.sprites[i] == this) {
  133573. this._manager.sprites.splice(i, 1);
  133574. }
  133575. }
  133576. };
  133577. return Sprite;
  133578. }());
  133579. /***/ }),
  133580. /***/ "./Sprites/spriteManager.ts":
  133581. /*!**********************************!*\
  133582. !*** ./Sprites/spriteManager.ts ***!
  133583. \**********************************/
  133584. /*! exports provided: SpriteManager */
  133585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133586. "use strict";
  133587. __webpack_require__.r(__webpack_exports__);
  133588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  133589. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  133590. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  133591. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  133592. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  133593. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  133594. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  133595. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  133596. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  133597. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  133598. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  133599. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  133600. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  133601. /**
  133602. * Class used to manage multiple sprites on the same spritesheet
  133603. * @see http://doc.babylonjs.com/babylon101/sprites
  133604. */
  133605. var SpriteManager = /** @class */ (function () {
  133606. /**
  133607. * Creates a new sprite manager
  133608. * @param name defines the manager's name
  133609. * @param imgUrl defines the sprite sheet url
  133610. * @param capacity defines the maximum allowed number of sprites
  133611. * @param cellSize defines the size of a sprite cell
  133612. * @param scene defines the hosting scene
  133613. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  133614. * @param samplingMode defines the smapling mode to use with spritesheet
  133615. */
  133616. function SpriteManager(
  133617. /** defines the manager's name */
  133618. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  133619. if (epsilon === void 0) { epsilon = 0.01; }
  133620. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  133621. this.name = name;
  133622. /** Gets the list of sprites */
  133623. this.sprites = new Array();
  133624. /** Gets or sets the rendering group id (0 by default) */
  133625. this.renderingGroupId = 0;
  133626. /** Gets or sets camera layer mask */
  133627. this.layerMask = 0x0FFFFFFF;
  133628. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  133629. this.fogEnabled = true;
  133630. /** Gets or sets a boolean indicating if the sprites are pickable */
  133631. this.isPickable = false;
  133632. /**
  133633. * An event triggered when the manager is disposed.
  133634. */
  133635. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  133636. this._vertexBuffers = {};
  133637. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  133638. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  133639. }
  133640. this._capacity = capacity;
  133641. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  133642. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  133643. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  133644. if (cellSize.width && cellSize.height) {
  133645. this.cellWidth = cellSize.width;
  133646. this.cellHeight = cellSize.height;
  133647. }
  133648. else if (cellSize !== undefined) {
  133649. this.cellWidth = cellSize;
  133650. this.cellHeight = cellSize;
  133651. }
  133652. else {
  133653. return;
  133654. }
  133655. this._epsilon = epsilon;
  133656. this._scene = scene;
  133657. this._scene.spriteManagers.push(this);
  133658. var indices = [];
  133659. var index = 0;
  133660. for (var count = 0; count < capacity; count++) {
  133661. indices.push(index);
  133662. indices.push(index + 1);
  133663. indices.push(index + 2);
  133664. indices.push(index);
  133665. indices.push(index + 2);
  133666. indices.push(index + 3);
  133667. index += 4;
  133668. }
  133669. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  133670. // VBO
  133671. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  133672. this._vertexData = new Float32Array(capacity * 16 * 4);
  133673. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  133674. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  133675. var options = this._buffer.createVertexBuffer("options", 4, 4);
  133676. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  133677. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  133678. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  133679. this._vertexBuffers["options"] = options;
  133680. this._vertexBuffers["cellInfo"] = cellInfo;
  133681. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  133682. // Effects
  133683. 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"], "");
  133684. 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");
  133685. }
  133686. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  133687. /**
  133688. * Callback called when the manager is disposed
  133689. */
  133690. set: function (callback) {
  133691. if (this._onDisposeObserver) {
  133692. this.onDisposeObservable.remove(this._onDisposeObserver);
  133693. }
  133694. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  133695. },
  133696. enumerable: true,
  133697. configurable: true
  133698. });
  133699. Object.defineProperty(SpriteManager.prototype, "texture", {
  133700. /**
  133701. * Gets or sets the spritesheet texture
  133702. */
  133703. get: function () {
  133704. return this._spriteTexture;
  133705. },
  133706. set: function (value) {
  133707. this._spriteTexture = value;
  133708. },
  133709. enumerable: true,
  133710. configurable: true
  133711. });
  133712. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  133713. var arrayOffset = index * 16;
  133714. if (offsetX === 0) {
  133715. offsetX = this._epsilon;
  133716. }
  133717. else if (offsetX === 1) {
  133718. offsetX = 1 - this._epsilon;
  133719. }
  133720. if (offsetY === 0) {
  133721. offsetY = this._epsilon;
  133722. }
  133723. else if (offsetY === 1) {
  133724. offsetY = 1 - this._epsilon;
  133725. }
  133726. this._vertexData[arrayOffset] = sprite.position.x;
  133727. this._vertexData[arrayOffset + 1] = sprite.position.y;
  133728. this._vertexData[arrayOffset + 2] = sprite.position.z;
  133729. this._vertexData[arrayOffset + 3] = sprite.angle;
  133730. this._vertexData[arrayOffset + 4] = sprite.width;
  133731. this._vertexData[arrayOffset + 5] = sprite.height;
  133732. this._vertexData[arrayOffset + 6] = offsetX;
  133733. this._vertexData[arrayOffset + 7] = offsetY;
  133734. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  133735. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  133736. var offset = (sprite.cellIndex / rowSize) >> 0;
  133737. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  133738. this._vertexData[arrayOffset + 11] = offset;
  133739. // Color
  133740. this._vertexData[arrayOffset + 12] = sprite.color.r;
  133741. this._vertexData[arrayOffset + 13] = sprite.color.g;
  133742. this._vertexData[arrayOffset + 14] = sprite.color.b;
  133743. this._vertexData[arrayOffset + 15] = sprite.color.a;
  133744. };
  133745. /**
  133746. * Intersects the sprites with a ray
  133747. * @param ray defines the ray to intersect with
  133748. * @param camera defines the current active camera
  133749. * @param predicate defines a predicate used to select candidate sprites
  133750. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  133751. * @returns null if no hit or a PickingInfo
  133752. */
  133753. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  133754. var count = Math.min(this._capacity, this.sprites.length);
  133755. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  133756. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  133757. var distance = Number.MAX_VALUE;
  133758. var currentSprite = null;
  133759. var pickedPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  133760. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  133761. var cameraView = camera.getViewMatrix();
  133762. for (var index = 0; index < count; index++) {
  133763. var sprite = this.sprites[index];
  133764. if (!sprite) {
  133765. continue;
  133766. }
  133767. if (predicate) {
  133768. if (!predicate(sprite)) {
  133769. continue;
  133770. }
  133771. }
  133772. else if (!sprite.isPickable) {
  133773. continue;
  133774. }
  133775. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  133776. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  133777. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  133778. if (ray.intersectsBoxMinMax(min, max)) {
  133779. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  133780. if (distance > currentDistance) {
  133781. distance = currentDistance;
  133782. currentSprite = sprite;
  133783. if (fastCheck) {
  133784. break;
  133785. }
  133786. }
  133787. }
  133788. }
  133789. if (currentSprite) {
  133790. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  133791. cameraView.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  133792. result.hit = true;
  133793. result.pickedSprite = currentSprite;
  133794. result.distance = distance;
  133795. // Get picked point
  133796. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  133797. direction.copyFrom(ray.direction);
  133798. direction.normalize();
  133799. direction.scaleInPlace(distance);
  133800. ray.origin.addToRef(direction, pickedPoint);
  133801. result.pickedPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(pickedPoint, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  133802. return result;
  133803. }
  133804. return null;
  133805. };
  133806. /**
  133807. * Render all child sprites
  133808. */
  133809. SpriteManager.prototype.render = function () {
  133810. // Check
  133811. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  133812. || !this._spriteTexture.isReady() || !this.sprites.length) {
  133813. return;
  133814. }
  133815. var engine = this._scene.getEngine();
  133816. var baseSize = this._spriteTexture.getBaseSize();
  133817. // Sprites
  133818. var deltaTime = engine.getDeltaTime();
  133819. var max = Math.min(this._capacity, this.sprites.length);
  133820. var rowSize = baseSize.width / this.cellWidth;
  133821. var offset = 0;
  133822. var noSprite = true;
  133823. for (var index = 0; index < max; index++) {
  133824. var sprite = this.sprites[index];
  133825. if (!sprite || !sprite.isVisible) {
  133826. continue;
  133827. }
  133828. noSprite = false;
  133829. sprite._animate(deltaTime);
  133830. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  133831. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  133832. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  133833. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  133834. }
  133835. if (noSprite) {
  133836. return;
  133837. }
  133838. this._buffer.update(this._vertexData);
  133839. // Render
  133840. var effect = this._effectBase;
  133841. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  133842. effect = this._effectFog;
  133843. }
  133844. engine.enableEffect(effect);
  133845. var viewMatrix = this._scene.getViewMatrix();
  133846. effect.setTexture("diffuseSampler", this._spriteTexture);
  133847. effect.setMatrix("view", viewMatrix);
  133848. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  133849. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  133850. // Fog
  133851. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  133852. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  133853. effect.setColor3("vFogColor", this._scene.fogColor);
  133854. }
  133855. // VBOs
  133856. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  133857. // Draw order
  133858. engine.setDepthFunctionToLessOrEqual();
  133859. effect.setBool("alphaTest", true);
  133860. engine.setColorWrite(false);
  133861. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  133862. engine.setColorWrite(true);
  133863. effect.setBool("alphaTest", false);
  133864. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  133865. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  133866. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  133867. };
  133868. /**
  133869. * Release associated resources
  133870. */
  133871. SpriteManager.prototype.dispose = function () {
  133872. if (this._buffer) {
  133873. this._buffer.dispose();
  133874. this._buffer = null;
  133875. }
  133876. if (this._indexBuffer) {
  133877. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  133878. this._indexBuffer = null;
  133879. }
  133880. if (this._spriteTexture) {
  133881. this._spriteTexture.dispose();
  133882. this._spriteTexture = null;
  133883. }
  133884. // Remove from scene
  133885. var index = this._scene.spriteManagers.indexOf(this);
  133886. this._scene.spriteManagers.splice(index, 1);
  133887. // Callback
  133888. this.onDisposeObservable.notifyObservers(this);
  133889. this.onDisposeObservable.clear();
  133890. };
  133891. return SpriteManager;
  133892. }());
  133893. /***/ }),
  133894. /***/ "./Sprites/spriteSceneComponent.ts":
  133895. /*!*****************************************!*\
  133896. !*** ./Sprites/spriteSceneComponent.ts ***!
  133897. \*****************************************/
  133898. /*! exports provided: SpriteSceneComponent */
  133899. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133900. "use strict";
  133901. __webpack_require__.r(__webpack_exports__);
  133902. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  133903. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  133904. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  133905. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  133906. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  133907. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  133908. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  133909. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  133910. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  133911. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  133912. return null;
  133913. }
  133914. var pickingInfo = null;
  133915. if (!camera) {
  133916. if (!this.activeCamera) {
  133917. return null;
  133918. }
  133919. camera = this.activeCamera;
  133920. }
  133921. if (this.spriteManagers.length > 0) {
  133922. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  133923. var spriteManager = this.spriteManagers[spriteIndex];
  133924. if (!spriteManager.isPickable) {
  133925. continue;
  133926. }
  133927. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  133928. if (!result || !result.hit) {
  133929. continue;
  133930. }
  133931. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  133932. continue;
  133933. }
  133934. pickingInfo = result;
  133935. if (fastCheck) {
  133936. break;
  133937. }
  133938. }
  133939. }
  133940. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  133941. };
  133942. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  133943. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  133944. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  133945. };
  133946. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  133947. if (!this._tempSpritePickingRay) {
  133948. return null;
  133949. }
  133950. if (!camera) {
  133951. if (!this.activeCamera) {
  133952. return null;
  133953. }
  133954. camera = this.activeCamera;
  133955. }
  133956. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  133957. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  133958. };
  133959. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  133960. if (this._pointerOverSprite === sprite) {
  133961. return;
  133962. }
  133963. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  133964. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  133965. }
  133966. this._pointerOverSprite = sprite;
  133967. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  133968. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  133969. }
  133970. };
  133971. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  133972. return this._pointerOverSprite;
  133973. };
  133974. /**
  133975. * Defines the sprite scene component responsible to manage sprites
  133976. * in a given scene.
  133977. */
  133978. var SpriteSceneComponent = /** @class */ (function () {
  133979. /**
  133980. * Creates a new instance of the component for the given scene
  133981. * @param scene Defines the scene to register the component in
  133982. */
  133983. function SpriteSceneComponent(scene) {
  133984. /**
  133985. * The component name helpfull to identify the component in the list of scene components.
  133986. */
  133987. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  133988. this.scene = scene;
  133989. this.scene.spriteManagers = new Array();
  133990. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  133991. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  133992. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  133993. this._spritePredicate = function (sprite) {
  133994. if (!sprite.actionManager) {
  133995. return false;
  133996. }
  133997. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  133998. };
  133999. }
  134000. /**
  134001. * Registers the component in a given scene
  134002. */
  134003. SpriteSceneComponent.prototype.register = function () {
  134004. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  134005. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  134006. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  134007. };
  134008. /**
  134009. * Rebuilds the elements related to this component in case of
  134010. * context lost for instance.
  134011. */
  134012. SpriteSceneComponent.prototype.rebuild = function () {
  134013. /** Nothing to do for sprites */
  134014. };
  134015. /**
  134016. * Disposes the component and the associated ressources.
  134017. */
  134018. SpriteSceneComponent.prototype.dispose = function () {
  134019. this.scene.onBeforeSpritesRenderingObservable.clear();
  134020. this.scene.onAfterSpritesRenderingObservable.clear();
  134021. var spriteManagers = this.scene.spriteManagers;
  134022. while (spriteManagers.length) {
  134023. spriteManagers[0].dispose();
  134024. }
  134025. };
  134026. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  134027. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  134028. if (result) {
  134029. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  134030. }
  134031. return result;
  134032. };
  134033. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  134034. var scene = this.scene;
  134035. if (isMeshPicked) {
  134036. scene.setPointerOverSprite(null);
  134037. }
  134038. else {
  134039. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  134040. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  134041. scene.setPointerOverSprite(pickResult.pickedSprite);
  134042. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  134043. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  134044. }
  134045. else {
  134046. canvas.style.cursor = scene.hoverCursor;
  134047. }
  134048. }
  134049. else {
  134050. scene.setPointerOverSprite(null);
  134051. }
  134052. }
  134053. return pickResult;
  134054. };
  134055. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  134056. var scene = this.scene;
  134057. scene._pickedDownSprite = null;
  134058. if (scene.spriteManagers.length > 0) {
  134059. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  134060. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  134061. if (pickResult.pickedSprite.actionManager) {
  134062. scene._pickedDownSprite = pickResult.pickedSprite;
  134063. switch (evt.button) {
  134064. case 0:
  134065. 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));
  134066. break;
  134067. case 1:
  134068. 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));
  134069. break;
  134070. case 2:
  134071. 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));
  134072. break;
  134073. }
  134074. if (pickResult.pickedSprite.actionManager) {
  134075. 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));
  134076. }
  134077. }
  134078. }
  134079. }
  134080. return pickResult;
  134081. };
  134082. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  134083. var scene = this.scene;
  134084. if (scene.spriteManagers.length > 0) {
  134085. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  134086. if (spritePickResult) {
  134087. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  134088. if (spritePickResult.pickedSprite.actionManager) {
  134089. 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));
  134090. if (spritePickResult.pickedSprite.actionManager) {
  134091. if (!this.scene._inputManager._isPointerSwiping()) {
  134092. 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));
  134093. }
  134094. }
  134095. }
  134096. }
  134097. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  134098. 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));
  134099. }
  134100. }
  134101. }
  134102. return pickResult;
  134103. };
  134104. return SpriteSceneComponent;
  134105. }());
  134106. /***/ }),
  134107. /***/ "./States/alphaCullingState.ts":
  134108. /*!*************************************!*\
  134109. !*** ./States/alphaCullingState.ts ***!
  134110. \*************************************/
  134111. /*! exports provided: _AlphaState */
  134112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134113. "use strict";
  134114. __webpack_require__.r(__webpack_exports__);
  134115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  134116. /**
  134117. * @hidden
  134118. **/
  134119. var _AlphaState = /** @class */ (function () {
  134120. /**
  134121. * Initializes the state.
  134122. */
  134123. function _AlphaState() {
  134124. this._isAlphaBlendDirty = false;
  134125. this._isBlendFunctionParametersDirty = false;
  134126. this._isBlendEquationParametersDirty = false;
  134127. this._isBlendConstantsDirty = false;
  134128. this._alphaBlend = false;
  134129. this._blendFunctionParameters = new Array(4);
  134130. this._blendEquationParameters = new Array(2);
  134131. this._blendConstants = new Array(4);
  134132. this.reset();
  134133. }
  134134. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  134135. get: function () {
  134136. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  134137. },
  134138. enumerable: true,
  134139. configurable: true
  134140. });
  134141. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  134142. get: function () {
  134143. return this._alphaBlend;
  134144. },
  134145. set: function (value) {
  134146. if (this._alphaBlend === value) {
  134147. return;
  134148. }
  134149. this._alphaBlend = value;
  134150. this._isAlphaBlendDirty = true;
  134151. },
  134152. enumerable: true,
  134153. configurable: true
  134154. });
  134155. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  134156. if (this._blendConstants[0] === r &&
  134157. this._blendConstants[1] === g &&
  134158. this._blendConstants[2] === b &&
  134159. this._blendConstants[3] === a) {
  134160. return;
  134161. }
  134162. this._blendConstants[0] = r;
  134163. this._blendConstants[1] = g;
  134164. this._blendConstants[2] = b;
  134165. this._blendConstants[3] = a;
  134166. this._isBlendConstantsDirty = true;
  134167. };
  134168. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  134169. if (this._blendFunctionParameters[0] === value0 &&
  134170. this._blendFunctionParameters[1] === value1 &&
  134171. this._blendFunctionParameters[2] === value2 &&
  134172. this._blendFunctionParameters[3] === value3) {
  134173. return;
  134174. }
  134175. this._blendFunctionParameters[0] = value0;
  134176. this._blendFunctionParameters[1] = value1;
  134177. this._blendFunctionParameters[2] = value2;
  134178. this._blendFunctionParameters[3] = value3;
  134179. this._isBlendFunctionParametersDirty = true;
  134180. };
  134181. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  134182. if (this._blendEquationParameters[0] === rgb &&
  134183. this._blendEquationParameters[1] === alpha) {
  134184. return;
  134185. }
  134186. this._blendEquationParameters[0] = rgb;
  134187. this._blendEquationParameters[1] = alpha;
  134188. this._isBlendEquationParametersDirty = true;
  134189. };
  134190. _AlphaState.prototype.reset = function () {
  134191. this._alphaBlend = false;
  134192. this._blendFunctionParameters[0] = null;
  134193. this._blendFunctionParameters[1] = null;
  134194. this._blendFunctionParameters[2] = null;
  134195. this._blendFunctionParameters[3] = null;
  134196. this._blendEquationParameters[0] = null;
  134197. this._blendEquationParameters[1] = null;
  134198. this._blendConstants[0] = null;
  134199. this._blendConstants[1] = null;
  134200. this._blendConstants[2] = null;
  134201. this._blendConstants[3] = null;
  134202. this._isAlphaBlendDirty = true;
  134203. this._isBlendFunctionParametersDirty = false;
  134204. this._isBlendEquationParametersDirty = false;
  134205. this._isBlendConstantsDirty = false;
  134206. };
  134207. _AlphaState.prototype.apply = function (gl) {
  134208. if (!this.isDirty) {
  134209. return;
  134210. }
  134211. // Alpha blend
  134212. if (this._isAlphaBlendDirty) {
  134213. if (this._alphaBlend) {
  134214. gl.enable(gl.BLEND);
  134215. }
  134216. else {
  134217. gl.disable(gl.BLEND);
  134218. }
  134219. this._isAlphaBlendDirty = false;
  134220. }
  134221. // Alpha function
  134222. if (this._isBlendFunctionParametersDirty) {
  134223. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  134224. this._isBlendFunctionParametersDirty = false;
  134225. }
  134226. // Alpha equation
  134227. if (this._isBlendEquationParametersDirty) {
  134228. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  134229. this._isBlendEquationParametersDirty = false;
  134230. }
  134231. // Constants
  134232. if (this._isBlendConstantsDirty) {
  134233. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  134234. this._isBlendConstantsDirty = false;
  134235. }
  134236. };
  134237. return _AlphaState;
  134238. }());
  134239. /***/ }),
  134240. /***/ "./States/depthCullingState.ts":
  134241. /*!*************************************!*\
  134242. !*** ./States/depthCullingState.ts ***!
  134243. \*************************************/
  134244. /*! exports provided: _DepthCullingState */
  134245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134246. "use strict";
  134247. __webpack_require__.r(__webpack_exports__);
  134248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  134249. /**
  134250. * @hidden
  134251. **/
  134252. var _DepthCullingState = /** @class */ (function () {
  134253. /**
  134254. * Initializes the state.
  134255. */
  134256. function _DepthCullingState() {
  134257. this._isDepthTestDirty = false;
  134258. this._isDepthMaskDirty = false;
  134259. this._isDepthFuncDirty = false;
  134260. this._isCullFaceDirty = false;
  134261. this._isCullDirty = false;
  134262. this._isZOffsetDirty = false;
  134263. this._isFrontFaceDirty = false;
  134264. this.reset();
  134265. }
  134266. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  134267. get: function () {
  134268. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  134269. },
  134270. enumerable: true,
  134271. configurable: true
  134272. });
  134273. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  134274. get: function () {
  134275. return this._zOffset;
  134276. },
  134277. set: function (value) {
  134278. if (this._zOffset === value) {
  134279. return;
  134280. }
  134281. this._zOffset = value;
  134282. this._isZOffsetDirty = true;
  134283. },
  134284. enumerable: true,
  134285. configurable: true
  134286. });
  134287. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  134288. get: function () {
  134289. return this._cullFace;
  134290. },
  134291. set: function (value) {
  134292. if (this._cullFace === value) {
  134293. return;
  134294. }
  134295. this._cullFace = value;
  134296. this._isCullFaceDirty = true;
  134297. },
  134298. enumerable: true,
  134299. configurable: true
  134300. });
  134301. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  134302. get: function () {
  134303. return this._cull;
  134304. },
  134305. set: function (value) {
  134306. if (this._cull === value) {
  134307. return;
  134308. }
  134309. this._cull = value;
  134310. this._isCullDirty = true;
  134311. },
  134312. enumerable: true,
  134313. configurable: true
  134314. });
  134315. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  134316. get: function () {
  134317. return this._depthFunc;
  134318. },
  134319. set: function (value) {
  134320. if (this._depthFunc === value) {
  134321. return;
  134322. }
  134323. this._depthFunc = value;
  134324. this._isDepthFuncDirty = true;
  134325. },
  134326. enumerable: true,
  134327. configurable: true
  134328. });
  134329. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  134330. get: function () {
  134331. return this._depthMask;
  134332. },
  134333. set: function (value) {
  134334. if (this._depthMask === value) {
  134335. return;
  134336. }
  134337. this._depthMask = value;
  134338. this._isDepthMaskDirty = true;
  134339. },
  134340. enumerable: true,
  134341. configurable: true
  134342. });
  134343. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  134344. get: function () {
  134345. return this._depthTest;
  134346. },
  134347. set: function (value) {
  134348. if (this._depthTest === value) {
  134349. return;
  134350. }
  134351. this._depthTest = value;
  134352. this._isDepthTestDirty = true;
  134353. },
  134354. enumerable: true,
  134355. configurable: true
  134356. });
  134357. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  134358. get: function () {
  134359. return this._frontFace;
  134360. },
  134361. set: function (value) {
  134362. if (this._frontFace === value) {
  134363. return;
  134364. }
  134365. this._frontFace = value;
  134366. this._isFrontFaceDirty = true;
  134367. },
  134368. enumerable: true,
  134369. configurable: true
  134370. });
  134371. _DepthCullingState.prototype.reset = function () {
  134372. this._depthMask = true;
  134373. this._depthTest = true;
  134374. this._depthFunc = null;
  134375. this._cullFace = null;
  134376. this._cull = null;
  134377. this._zOffset = 0;
  134378. this._frontFace = null;
  134379. this._isDepthTestDirty = true;
  134380. this._isDepthMaskDirty = true;
  134381. this._isDepthFuncDirty = false;
  134382. this._isCullFaceDirty = false;
  134383. this._isCullDirty = false;
  134384. this._isZOffsetDirty = false;
  134385. this._isFrontFaceDirty = false;
  134386. };
  134387. _DepthCullingState.prototype.apply = function (gl) {
  134388. if (!this.isDirty) {
  134389. return;
  134390. }
  134391. // Cull
  134392. if (this._isCullDirty) {
  134393. if (this.cull) {
  134394. gl.enable(gl.CULL_FACE);
  134395. }
  134396. else {
  134397. gl.disable(gl.CULL_FACE);
  134398. }
  134399. this._isCullDirty = false;
  134400. }
  134401. // Cull face
  134402. if (this._isCullFaceDirty) {
  134403. gl.cullFace(this.cullFace);
  134404. this._isCullFaceDirty = false;
  134405. }
  134406. // Depth mask
  134407. if (this._isDepthMaskDirty) {
  134408. gl.depthMask(this.depthMask);
  134409. this._isDepthMaskDirty = false;
  134410. }
  134411. // Depth test
  134412. if (this._isDepthTestDirty) {
  134413. if (this.depthTest) {
  134414. gl.enable(gl.DEPTH_TEST);
  134415. }
  134416. else {
  134417. gl.disable(gl.DEPTH_TEST);
  134418. }
  134419. this._isDepthTestDirty = false;
  134420. }
  134421. // Depth func
  134422. if (this._isDepthFuncDirty) {
  134423. gl.depthFunc(this.depthFunc);
  134424. this._isDepthFuncDirty = false;
  134425. }
  134426. // zOffset
  134427. if (this._isZOffsetDirty) {
  134428. if (this.zOffset) {
  134429. gl.enable(gl.POLYGON_OFFSET_FILL);
  134430. gl.polygonOffset(this.zOffset, 0);
  134431. }
  134432. else {
  134433. gl.disable(gl.POLYGON_OFFSET_FILL);
  134434. }
  134435. this._isZOffsetDirty = false;
  134436. }
  134437. // Front face
  134438. if (this._isFrontFaceDirty) {
  134439. gl.frontFace(this.frontFace);
  134440. this._isFrontFaceDirty = false;
  134441. }
  134442. };
  134443. return _DepthCullingState;
  134444. }());
  134445. /***/ }),
  134446. /***/ "./States/index.ts":
  134447. /*!*************************!*\
  134448. !*** ./States/index.ts ***!
  134449. \*************************/
  134450. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  134451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134452. "use strict";
  134453. __webpack_require__.r(__webpack_exports__);
  134454. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  134455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  134456. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  134457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  134458. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  134459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  134460. /***/ }),
  134461. /***/ "./States/stencilState.ts":
  134462. /*!********************************!*\
  134463. !*** ./States/stencilState.ts ***!
  134464. \********************************/
  134465. /*! exports provided: _StencilState */
  134466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134467. "use strict";
  134468. __webpack_require__.r(__webpack_exports__);
  134469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  134470. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  134471. /**
  134472. * @hidden
  134473. **/
  134474. var _StencilState = /** @class */ (function () {
  134475. function _StencilState() {
  134476. this._isStencilTestDirty = false;
  134477. this._isStencilMaskDirty = false;
  134478. this._isStencilFuncDirty = false;
  134479. this._isStencilOpDirty = false;
  134480. this.reset();
  134481. }
  134482. Object.defineProperty(_StencilState.prototype, "isDirty", {
  134483. get: function () {
  134484. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  134485. },
  134486. enumerable: true,
  134487. configurable: true
  134488. });
  134489. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  134490. get: function () {
  134491. return this._stencilFunc;
  134492. },
  134493. set: function (value) {
  134494. if (this._stencilFunc === value) {
  134495. return;
  134496. }
  134497. this._stencilFunc = value;
  134498. this._isStencilFuncDirty = true;
  134499. },
  134500. enumerable: true,
  134501. configurable: true
  134502. });
  134503. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  134504. get: function () {
  134505. return this._stencilFuncRef;
  134506. },
  134507. set: function (value) {
  134508. if (this._stencilFuncRef === value) {
  134509. return;
  134510. }
  134511. this._stencilFuncRef = value;
  134512. this._isStencilFuncDirty = true;
  134513. },
  134514. enumerable: true,
  134515. configurable: true
  134516. });
  134517. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  134518. get: function () {
  134519. return this._stencilFuncMask;
  134520. },
  134521. set: function (value) {
  134522. if (this._stencilFuncMask === value) {
  134523. return;
  134524. }
  134525. this._stencilFuncMask = value;
  134526. this._isStencilFuncDirty = true;
  134527. },
  134528. enumerable: true,
  134529. configurable: true
  134530. });
  134531. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  134532. get: function () {
  134533. return this._stencilOpStencilFail;
  134534. },
  134535. set: function (value) {
  134536. if (this._stencilOpStencilFail === value) {
  134537. return;
  134538. }
  134539. this._stencilOpStencilFail = value;
  134540. this._isStencilOpDirty = true;
  134541. },
  134542. enumerable: true,
  134543. configurable: true
  134544. });
  134545. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  134546. get: function () {
  134547. return this._stencilOpDepthFail;
  134548. },
  134549. set: function (value) {
  134550. if (this._stencilOpDepthFail === value) {
  134551. return;
  134552. }
  134553. this._stencilOpDepthFail = value;
  134554. this._isStencilOpDirty = true;
  134555. },
  134556. enumerable: true,
  134557. configurable: true
  134558. });
  134559. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  134560. get: function () {
  134561. return this._stencilOpStencilDepthPass;
  134562. },
  134563. set: function (value) {
  134564. if (this._stencilOpStencilDepthPass === value) {
  134565. return;
  134566. }
  134567. this._stencilOpStencilDepthPass = value;
  134568. this._isStencilOpDirty = true;
  134569. },
  134570. enumerable: true,
  134571. configurable: true
  134572. });
  134573. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  134574. get: function () {
  134575. return this._stencilMask;
  134576. },
  134577. set: function (value) {
  134578. if (this._stencilMask === value) {
  134579. return;
  134580. }
  134581. this._stencilMask = value;
  134582. this._isStencilMaskDirty = true;
  134583. },
  134584. enumerable: true,
  134585. configurable: true
  134586. });
  134587. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  134588. get: function () {
  134589. return this._stencilTest;
  134590. },
  134591. set: function (value) {
  134592. if (this._stencilTest === value) {
  134593. return;
  134594. }
  134595. this._stencilTest = value;
  134596. this._isStencilTestDirty = true;
  134597. },
  134598. enumerable: true,
  134599. configurable: true
  134600. });
  134601. _StencilState.prototype.reset = function () {
  134602. this._stencilTest = false;
  134603. this._stencilMask = 0xFF;
  134604. this._stencilFunc = _StencilState.ALWAYS;
  134605. this._stencilFuncRef = 1;
  134606. this._stencilFuncMask = 0xFF;
  134607. this._stencilOpStencilFail = _StencilState.KEEP;
  134608. this._stencilOpDepthFail = _StencilState.KEEP;
  134609. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  134610. this._isStencilTestDirty = true;
  134611. this._isStencilMaskDirty = true;
  134612. this._isStencilFuncDirty = true;
  134613. this._isStencilOpDirty = true;
  134614. };
  134615. _StencilState.prototype.apply = function (gl) {
  134616. if (!this.isDirty) {
  134617. return;
  134618. }
  134619. // Stencil test
  134620. if (this._isStencilTestDirty) {
  134621. if (this.stencilTest) {
  134622. gl.enable(gl.STENCIL_TEST);
  134623. }
  134624. else {
  134625. gl.disable(gl.STENCIL_TEST);
  134626. }
  134627. this._isStencilTestDirty = false;
  134628. }
  134629. // Stencil mask
  134630. if (this._isStencilMaskDirty) {
  134631. gl.stencilMask(this.stencilMask);
  134632. this._isStencilMaskDirty = false;
  134633. }
  134634. // Stencil func
  134635. if (this._isStencilFuncDirty) {
  134636. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  134637. this._isStencilFuncDirty = false;
  134638. }
  134639. // Stencil op
  134640. if (this._isStencilOpDirty) {
  134641. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  134642. this._isStencilOpDirty = false;
  134643. }
  134644. };
  134645. /** 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 */
  134646. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  134647. /** Passed to stencilOperation to specify that stencil value must be kept */
  134648. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  134649. /** Passed to stencilOperation to specify that stencil value must be replaced */
  134650. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  134651. return _StencilState;
  134652. }());
  134653. /***/ }),
  134654. /***/ "./abstractScene.ts":
  134655. /*!**************************!*\
  134656. !*** ./abstractScene.ts ***!
  134657. \**************************/
  134658. /*! exports provided: AbstractScene */
  134659. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134660. "use strict";
  134661. __webpack_require__.r(__webpack_exports__);
  134662. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  134663. /**
  134664. * Base class of the scene acting as a container for the different elements composing a scene.
  134665. * This class is dynamically extended by the different components of the scene increasing
  134666. * flexibility and reducing coupling
  134667. */
  134668. var AbstractScene = /** @class */ (function () {
  134669. function AbstractScene() {
  134670. /**
  134671. * Gets the list of root nodes (ie. nodes with no parent)
  134672. */
  134673. this.rootNodes = new Array();
  134674. /** All of the cameras added to this scene
  134675. * @see http://doc.babylonjs.com/babylon101/cameras
  134676. */
  134677. this.cameras = new Array();
  134678. /**
  134679. * All of the lights added to this scene
  134680. * @see http://doc.babylonjs.com/babylon101/lights
  134681. */
  134682. this.lights = new Array();
  134683. /**
  134684. * All of the (abstract) meshes added to this scene
  134685. */
  134686. this.meshes = new Array();
  134687. /**
  134688. * The list of skeletons added to the scene
  134689. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  134690. */
  134691. this.skeletons = new Array();
  134692. /**
  134693. * All of the particle systems added to this scene
  134694. * @see http://doc.babylonjs.com/babylon101/particles
  134695. */
  134696. this.particleSystems = new Array();
  134697. /**
  134698. * Gets a list of Animations associated with the scene
  134699. */
  134700. this.animations = [];
  134701. /**
  134702. * All of the animation groups added to this scene
  134703. * @see http://doc.babylonjs.com/how_to/group
  134704. */
  134705. this.animationGroups = new Array();
  134706. /**
  134707. * All of the multi-materials added to this scene
  134708. * @see http://doc.babylonjs.com/how_to/multi_materials
  134709. */
  134710. this.multiMaterials = new Array();
  134711. /**
  134712. * All of the materials added to this scene
  134713. * In the context of a Scene, it is not supposed to be modified manually.
  134714. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  134715. * Note also that the order of the Material wihin the array is not significant and might change.
  134716. * @see http://doc.babylonjs.com/babylon101/materials
  134717. */
  134718. this.materials = new Array();
  134719. /**
  134720. * The list of morph target managers added to the scene
  134721. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  134722. */
  134723. this.morphTargetManagers = new Array();
  134724. /**
  134725. * The list of geometries used in the scene.
  134726. */
  134727. this.geometries = new Array();
  134728. /**
  134729. * All of the tranform nodes added to this scene
  134730. * In the context of a Scene, it is not supposed to be modified manually.
  134731. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  134732. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  134733. * @see http://doc.babylonjs.com/how_to/transformnode
  134734. */
  134735. this.transformNodes = new Array();
  134736. /**
  134737. * ActionManagers available on the scene.
  134738. */
  134739. this.actionManagers = new Array();
  134740. /**
  134741. * Textures to keep.
  134742. */
  134743. this.textures = new Array();
  134744. /**
  134745. * Environment texture for the scene
  134746. */
  134747. this.environmentTexture = null;
  134748. }
  134749. /**
  134750. * Adds a parser in the list of available ones
  134751. * @param name Defines the name of the parser
  134752. * @param parser Defines the parser to add
  134753. */
  134754. AbstractScene.AddParser = function (name, parser) {
  134755. this._BabylonFileParsers[name] = parser;
  134756. };
  134757. /**
  134758. * Gets a general parser from the list of avaialble ones
  134759. * @param name Defines the name of the parser
  134760. * @returns the requested parser or null
  134761. */
  134762. AbstractScene.GetParser = function (name) {
  134763. if (this._BabylonFileParsers[name]) {
  134764. return this._BabylonFileParsers[name];
  134765. }
  134766. return null;
  134767. };
  134768. /**
  134769. * Adds n individual parser in the list of available ones
  134770. * @param name Defines the name of the parser
  134771. * @param parser Defines the parser to add
  134772. */
  134773. AbstractScene.AddIndividualParser = function (name, parser) {
  134774. this._IndividualBabylonFileParsers[name] = parser;
  134775. };
  134776. /**
  134777. * Gets an individual parser from the list of avaialble ones
  134778. * @param name Defines the name of the parser
  134779. * @returns the requested parser or null
  134780. */
  134781. AbstractScene.GetIndividualParser = function (name) {
  134782. if (this._IndividualBabylonFileParsers[name]) {
  134783. return this._IndividualBabylonFileParsers[name];
  134784. }
  134785. return null;
  134786. };
  134787. /**
  134788. * Parser json data and populate both a scene and its associated container object
  134789. * @param jsonData Defines the data to parse
  134790. * @param scene Defines the scene to parse the data for
  134791. * @param container Defines the container attached to the parsing sequence
  134792. * @param rootUrl Defines the root url of the data
  134793. */
  134794. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  134795. for (var parserName in this._BabylonFileParsers) {
  134796. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  134797. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  134798. }
  134799. }
  134800. };
  134801. /**
  134802. * Stores the list of available parsers in the application.
  134803. */
  134804. AbstractScene._BabylonFileParsers = {};
  134805. /**
  134806. * Stores the list of available individual parsers in the application.
  134807. */
  134808. AbstractScene._IndividualBabylonFileParsers = {};
  134809. return AbstractScene;
  134810. }());
  134811. /***/ }),
  134812. /***/ "./assetContainer.ts":
  134813. /*!***************************!*\
  134814. !*** ./assetContainer.ts ***!
  134815. \***************************/
  134816. /*! exports provided: KeepAssets, AssetContainer */
  134817. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134818. "use strict";
  134819. __webpack_require__.r(__webpack_exports__);
  134820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  134821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  134822. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  134823. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  134824. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  134825. /**
  134826. * Set of assets to keep when moving a scene into an asset container.
  134827. */
  134828. var KeepAssets = /** @class */ (function (_super) {
  134829. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  134830. function KeepAssets() {
  134831. return _super !== null && _super.apply(this, arguments) || this;
  134832. }
  134833. return KeepAssets;
  134834. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  134835. /**
  134836. * Container with a set of assets that can be added or removed from a scene.
  134837. */
  134838. var AssetContainer = /** @class */ (function (_super) {
  134839. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  134840. /**
  134841. * Instantiates an AssetContainer.
  134842. * @param scene The scene the AssetContainer belongs to.
  134843. */
  134844. function AssetContainer(scene) {
  134845. var _this = _super.call(this) || this;
  134846. _this.scene = scene;
  134847. _this["sounds"] = [];
  134848. _this["effectLayers"] = [];
  134849. _this["layers"] = [];
  134850. _this["lensFlareSystems"] = [];
  134851. _this["proceduralTextures"] = [];
  134852. _this["reflectionProbes"] = [];
  134853. return _this;
  134854. }
  134855. /**
  134856. * Adds all the assets from the container to the scene.
  134857. */
  134858. AssetContainer.prototype.addAllToScene = function () {
  134859. var _this = this;
  134860. this.cameras.forEach(function (o) {
  134861. _this.scene.addCamera(o);
  134862. });
  134863. this.lights.forEach(function (o) {
  134864. _this.scene.addLight(o);
  134865. });
  134866. this.meshes.forEach(function (o) {
  134867. _this.scene.addMesh(o);
  134868. });
  134869. this.skeletons.forEach(function (o) {
  134870. _this.scene.addSkeleton(o);
  134871. });
  134872. this.animations.forEach(function (o) {
  134873. _this.scene.addAnimation(o);
  134874. });
  134875. this.animationGroups.forEach(function (o) {
  134876. _this.scene.addAnimationGroup(o);
  134877. });
  134878. this.multiMaterials.forEach(function (o) {
  134879. _this.scene.addMultiMaterial(o);
  134880. });
  134881. this.materials.forEach(function (o) {
  134882. _this.scene.addMaterial(o);
  134883. });
  134884. this.morphTargetManagers.forEach(function (o) {
  134885. _this.scene.addMorphTargetManager(o);
  134886. });
  134887. this.geometries.forEach(function (o) {
  134888. _this.scene.addGeometry(o);
  134889. });
  134890. this.transformNodes.forEach(function (o) {
  134891. _this.scene.addTransformNode(o);
  134892. });
  134893. this.actionManagers.forEach(function (o) {
  134894. _this.scene.addActionManager(o);
  134895. });
  134896. this.textures.forEach(function (o) {
  134897. _this.scene.addTexture(o);
  134898. });
  134899. this.reflectionProbes.forEach(function (o) {
  134900. _this.scene.addReflectionProbe(o);
  134901. });
  134902. if (this.environmentTexture) {
  134903. this.scene.environmentTexture = this.environmentTexture;
  134904. }
  134905. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  134906. var component = _a[_i];
  134907. component.addFromContainer(this);
  134908. }
  134909. };
  134910. /**
  134911. * Removes all the assets in the container from the scene
  134912. */
  134913. AssetContainer.prototype.removeAllFromScene = function () {
  134914. var _this = this;
  134915. this.cameras.forEach(function (o) {
  134916. _this.scene.removeCamera(o);
  134917. });
  134918. this.lights.forEach(function (o) {
  134919. _this.scene.removeLight(o);
  134920. });
  134921. this.meshes.forEach(function (o) {
  134922. _this.scene.removeMesh(o);
  134923. });
  134924. this.skeletons.forEach(function (o) {
  134925. _this.scene.removeSkeleton(o);
  134926. });
  134927. this.animations.forEach(function (o) {
  134928. _this.scene.removeAnimation(o);
  134929. });
  134930. this.animationGroups.forEach(function (o) {
  134931. _this.scene.removeAnimationGroup(o);
  134932. });
  134933. this.multiMaterials.forEach(function (o) {
  134934. _this.scene.removeMultiMaterial(o);
  134935. });
  134936. this.materials.forEach(function (o) {
  134937. _this.scene.removeMaterial(o);
  134938. });
  134939. this.morphTargetManagers.forEach(function (o) {
  134940. _this.scene.removeMorphTargetManager(o);
  134941. });
  134942. this.geometries.forEach(function (o) {
  134943. _this.scene.removeGeometry(o);
  134944. });
  134945. this.transformNodes.forEach(function (o) {
  134946. _this.scene.removeTransformNode(o);
  134947. });
  134948. this.actionManagers.forEach(function (o) {
  134949. _this.scene.removeActionManager(o);
  134950. });
  134951. this.textures.forEach(function (o) {
  134952. _this.scene.removeTexture(o);
  134953. });
  134954. this.reflectionProbes.forEach(function (o) {
  134955. _this.scene.removeReflectionProbe(o);
  134956. });
  134957. if (this.environmentTexture === this.scene.environmentTexture) {
  134958. this.scene.environmentTexture = null;
  134959. }
  134960. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  134961. var component = _a[_i];
  134962. component.removeFromContainer(this);
  134963. }
  134964. };
  134965. /**
  134966. * Disposes all the assets in the container
  134967. */
  134968. AssetContainer.prototype.dispose = function () {
  134969. this.cameras.forEach(function (o) {
  134970. o.dispose();
  134971. });
  134972. this.cameras = [];
  134973. this.lights.forEach(function (o) {
  134974. o.dispose();
  134975. });
  134976. this.lights = [];
  134977. this.meshes.forEach(function (o) {
  134978. o.dispose();
  134979. });
  134980. this.meshes = [];
  134981. this.skeletons.forEach(function (o) {
  134982. o.dispose();
  134983. });
  134984. this.skeletons = [];
  134985. this.animationGroups.forEach(function (o) {
  134986. o.dispose();
  134987. });
  134988. this.animationGroups = [];
  134989. this.multiMaterials.forEach(function (o) {
  134990. o.dispose();
  134991. });
  134992. this.multiMaterials = [];
  134993. this.materials.forEach(function (o) {
  134994. o.dispose();
  134995. });
  134996. this.materials = [];
  134997. this.geometries.forEach(function (o) {
  134998. o.dispose();
  134999. });
  135000. this.geometries = [];
  135001. this.transformNodes.forEach(function (o) {
  135002. o.dispose();
  135003. });
  135004. this.transformNodes = [];
  135005. this.actionManagers.forEach(function (o) {
  135006. o.dispose();
  135007. });
  135008. this.actionManagers = [];
  135009. this.textures.forEach(function (o) {
  135010. o.dispose();
  135011. });
  135012. this.textures = [];
  135013. this.reflectionProbes.forEach(function (o) {
  135014. o.dispose();
  135015. });
  135016. this.reflectionProbes = [];
  135017. if (this.environmentTexture) {
  135018. this.environmentTexture.dispose();
  135019. this.environmentTexture = null;
  135020. }
  135021. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  135022. var component = _a[_i];
  135023. component.removeFromContainer(this, true);
  135024. }
  135025. };
  135026. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  135027. if (!sourceAssets) {
  135028. return;
  135029. }
  135030. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  135031. var asset = sourceAssets_1[_i];
  135032. var move = true;
  135033. if (keepAssets) {
  135034. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  135035. var keepAsset = keepAssets_1[_a];
  135036. if (asset === keepAsset) {
  135037. move = false;
  135038. break;
  135039. }
  135040. }
  135041. }
  135042. if (move) {
  135043. targetAssets.push(asset);
  135044. }
  135045. }
  135046. };
  135047. /**
  135048. * Removes all the assets contained in the scene and adds them to the container.
  135049. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  135050. */
  135051. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  135052. if (keepAssets === undefined) {
  135053. keepAssets = new KeepAssets();
  135054. }
  135055. for (var key in this) {
  135056. if (this.hasOwnProperty(key)) {
  135057. this[key] = this[key] || [];
  135058. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  135059. }
  135060. }
  135061. this.removeAllFromScene();
  135062. };
  135063. /**
  135064. * 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.
  135065. * @returns the root mesh
  135066. */
  135067. AssetContainer.prototype.createRootMesh = function () {
  135068. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  135069. this.meshes.forEach(function (m) {
  135070. if (!m.parent) {
  135071. rootMesh.addChild(m);
  135072. }
  135073. });
  135074. this.meshes.unshift(rootMesh);
  135075. return rootMesh;
  135076. };
  135077. return AssetContainer;
  135078. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  135079. /***/ }),
  135080. /***/ "./index.ts":
  135081. /*!******************!*\
  135082. !*** ./index.ts ***!
  135083. \******************/
  135084. /*! 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, AutoRotationBehavior, BouncingBehavior, FramingBehavior, PointerDragBehavior, 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, _MeshCollisionData, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, WebGLPipelineContext, 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, 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, SphericalHarmonics, SphericalPolynomial, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, MeshLODLevel, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DataBuffer, WebGLDataBuffer, 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, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, 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, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, HtmlElementTexture, 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 */
  135085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  135086. "use strict";
  135087. __webpack_require__.r(__webpack_exports__);
  135088. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  135089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  135090. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  135091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  135092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  135093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  135094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  135095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  135096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  135097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  135098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  135099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  135100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  135101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  135102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  135103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  135104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  135105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  135106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  135107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  135108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  135109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  135110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  135111. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  135112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  135113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["_IAnimationState"]; });
  135114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  135115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  135116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  135117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  135118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  135119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  135120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  135121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  135122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  135123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  135124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  135125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  135126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  135127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  135128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  135129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  135130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  135131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  135132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  135133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  135134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  135135. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  135136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  135137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  135138. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  135139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  135140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  135141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  135142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  135143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  135144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  135145. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  135146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  135147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  135148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  135149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  135150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  135151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  135152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  135153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  135154. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  135155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  135156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  135157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  135158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  135159. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  135160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  135161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  135162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  135163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  135164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  135165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  135166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  135167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  135168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  135169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  135170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  135171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  135172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  135173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  135174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  135175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  135176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  135177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  135178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  135179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  135180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  135181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  135182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  135183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  135184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  135185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraMouseWheelInput"]; });
  135186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraPointersInput"]; });
  135187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  135188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  135189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  135190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  135191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  135192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  135193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  135194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  135195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  135196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  135197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  135198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  135199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  135200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  135201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  135202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  135203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  135204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  135205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["OnAfterEnteringVRObservableEvent"]; });
  135206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  135207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  135208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  135209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  135210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  135211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  135212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  135213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  135214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  135215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  135216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  135217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  135218. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  135219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  135220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  135221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  135222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  135223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_MeshCollisionData", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["_MeshCollisionData"]; });
  135224. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  135225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  135226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  135227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  135228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  135229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  135230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  135231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  135232. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  135233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  135234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  135235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  135236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  135237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  135238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  135239. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  135240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  135241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  135242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  135243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  135244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  135245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  135246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  135247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  135248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGLPipelineContext", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["WebGLPipelineContext"]; });
  135249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  135250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  135251. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  135252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  135253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  135254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  135255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  135256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  135257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  135258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  135259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  135260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  135261. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  135262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  135263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  135264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  135265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  135266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  135267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  135268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  135269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  135270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  135271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  135272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  135273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  135274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  135275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  135276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  135277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  135278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  135279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  135280. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  135281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  135282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  135283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  135284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  135285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  135286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  135287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  135288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  135289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  135290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["LightGizmo"]; });
  135291. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  135292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  135293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  135294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  135295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  135296. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  135297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  135298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  135299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  135300. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  135301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  135302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  135303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  135304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  135305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  135306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  135307. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  135308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  135309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  135310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  135311. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  135312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  135313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  135314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  135315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  135316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  135317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  135318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  135319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  135320. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  135321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  135322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  135323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  135324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  135325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  135326. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  135327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  135328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  135329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  135330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  135331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  135332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  135333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  135334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  135335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  135336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  135337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  135338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  135339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  135340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  135341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  135342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  135343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  135344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EquiRectangularCubeTexture"]; });
  135345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  135346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  135347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  135348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  135349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  135350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  135351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  135352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  135353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  135354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterialDefines"]; });
  135355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  135356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  135357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  135358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  135359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  135360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  135361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  135362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  135363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  135364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  135365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  135366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  135367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  135368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HtmlElementTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HtmlElementTexture"]; });
  135369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  135370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  135371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  135372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  135373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  135374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  135375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  135376. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  135377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  135378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  135379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  135380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  135381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  135382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  135383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  135384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  135385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  135386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  135387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  135388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  135389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  135390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  135391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  135392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  135393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  135394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  135395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  135396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  135397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  135398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  135399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  135400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  135401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  135402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  135403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  135404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  135405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  135406. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  135407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  135408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  135409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  135410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  135411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  135412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  135413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TrailMesh"]; });
  135414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  135415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  135416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  135417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  135418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  135419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  135420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  135421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  135422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  135423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  135424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  135425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  135426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  135427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  135428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  135429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  135430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  135431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  135432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  135433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  135434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  135435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  135436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  135437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DataBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DataBuffer"]; });
  135438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGLDataBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["WebGLDataBuffer"]; });
  135439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  135440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  135441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  135442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["HemisphereBuilder"]; });
  135443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  135444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  135445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  135446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  135447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  135448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  135449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  135450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  135451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  135452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  135453. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  135454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  135455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  135456. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  135457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  135458. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  135459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  135460. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  135461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  135462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  135463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  135464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  135465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  135466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  135467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  135468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  135469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  135470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  135471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  135472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  135473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  135474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  135475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  135476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  135477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  135478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  135479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  135480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  135481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  135482. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  135483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  135484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  135485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  135486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEventOptions"]; });
  135487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEventOptions"]; });
  135488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEventOptions"]; });
  135489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  135490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  135491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  135492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  135493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  135494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  135495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  135496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  135497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  135498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  135499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  135500. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  135501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  135502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  135503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  135504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  135505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  135506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  135507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  135508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  135509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  135510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  135511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  135512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  135513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  135514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  135515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  135516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  135517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  135518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  135519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  135520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  135521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  135522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  135523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  135524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  135525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  135526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  135527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  135528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  135529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  135530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  135531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  135532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  135533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  135534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRMultiviewToSingleviewPostProcess"]; });
  135535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  135536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  135537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  135538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  135539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  135540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  135541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  135542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  135543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  135544. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  135545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  135546. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  135547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  135548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  135549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  135550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  135551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  135552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  135553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  135554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  135555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  135556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  135557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  135558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  135559. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  135560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  135561. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  135562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  135563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  135564. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  135565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  135566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  135567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  135568. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  135569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  135570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  135571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  135572. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  135573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  135574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  135575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  135576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  135577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  135578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  135579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  135580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  135581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  135582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  135583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  135584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EquiRectangularCubeTextureAssetTask"]; });
  135585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  135586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  135587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  135588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  135589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  135590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  135591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  135592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  135593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  135594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  135595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  135596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  135597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  135598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  135599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMatrix"]; });
  135600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  135601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  135602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  135603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  135604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshExploder"]; });
  135605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  135606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  135607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  135608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  135609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  135610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  135611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  135612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  135613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  135614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  135615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  135616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  135617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  135618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  135619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  135620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  135621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  135622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  135623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  135624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  135625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  135626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  135627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  135628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  135629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  135630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  135631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  135632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  135633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  135634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  135635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  135636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  135637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  135638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  135639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  135640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  135641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  135642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  135643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  135644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  135645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  135646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  135647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  135648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  135649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  135650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  135651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  135652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  135653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WebRequest"]; });
  135654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["InspectableType"]; });
  135655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  135656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  135657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  135658. /***/ }),
  135659. /***/ "./node.ts":
  135660. /*!*****************!*\
  135661. !*** ./node.ts ***!
  135662. \*****************/
  135663. /*! exports provided: Node */
  135664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  135665. "use strict";
  135666. __webpack_require__.r(__webpack_exports__);
  135667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  135668. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  135669. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  135670. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  135671. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  135672. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  135673. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  135674. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  135675. /**
  135676. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  135677. */
  135678. var Node = /** @class */ (function () {
  135679. /**
  135680. * Creates a new Node
  135681. * @param name the name and id to be given to this node
  135682. * @param scene the scene this node will be added to
  135683. * @param addToRootNodes the node will be added to scene.rootNodes
  135684. */
  135685. function Node(name, scene, addToRootNodes) {
  135686. if (scene === void 0) { scene = null; }
  135687. if (addToRootNodes === void 0) { addToRootNodes = true; }
  135688. /**
  135689. * Gets or sets a string used to store user defined state for the node
  135690. */
  135691. this.state = "";
  135692. /**
  135693. * Gets or sets an object used to store user defined information for the node
  135694. */
  135695. this.metadata = null;
  135696. /**
  135697. * For internal use only. Please do not use.
  135698. */
  135699. this.reservedDataStore = null;
  135700. /**
  135701. * Gets or sets a boolean used to define if the node must be serialized
  135702. */
  135703. this.doNotSerialize = false;
  135704. /** @hidden */
  135705. this._isDisposed = false;
  135706. /**
  135707. * Gets a list of Animations associated with the node
  135708. */
  135709. this.animations = new Array();
  135710. this._ranges = {};
  135711. /**
  135712. * Callback raised when the node is ready to be used
  135713. */
  135714. this.onReady = null;
  135715. this._isEnabled = true;
  135716. this._isParentEnabled = true;
  135717. this._isReady = true;
  135718. /** @hidden */
  135719. this._currentRenderId = -1;
  135720. this._parentUpdateId = -1;
  135721. /** @hidden */
  135722. this._childUpdateId = -1;
  135723. /** @hidden */
  135724. this._waitingParentId = null;
  135725. /** @hidden */
  135726. this._cache = {};
  135727. this._parentNode = null;
  135728. this._children = null;
  135729. /** @hidden */
  135730. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  135731. /** @hidden */
  135732. this._worldMatrixDeterminant = 0;
  135733. /** @hidden */
  135734. this._worldMatrixDeterminantIsDirty = true;
  135735. /** @hidden */
  135736. this._sceneRootNodesIndex = -1;
  135737. this._animationPropertiesOverride = null;
  135738. /** @hidden */
  135739. this._isNode = true;
  135740. /**
  135741. * An event triggered when the mesh is disposed
  135742. */
  135743. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  135744. this._onDisposeObserver = null;
  135745. // Behaviors
  135746. this._behaviors = new Array();
  135747. this.name = name;
  135748. this.id = name;
  135749. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  135750. this.uniqueId = this._scene.getUniqueId();
  135751. this._initCache();
  135752. if (addToRootNodes) {
  135753. this.addToSceneRootNodes();
  135754. }
  135755. }
  135756. /**
  135757. * Add a new node constructor
  135758. * @param type defines the type name of the node to construct
  135759. * @param constructorFunc defines the constructor function
  135760. */
  135761. Node.AddNodeConstructor = function (type, constructorFunc) {
  135762. this._NodeConstructors[type] = constructorFunc;
  135763. };
  135764. /**
  135765. * Returns a node constructor based on type name
  135766. * @param type defines the type name
  135767. * @param name defines the new node name
  135768. * @param scene defines the hosting scene
  135769. * @param options defines optional options to transmit to constructors
  135770. * @returns the new constructor or null
  135771. */
  135772. Node.Construct = function (type, name, scene, options) {
  135773. var constructorFunc = this._NodeConstructors[type];
  135774. if (!constructorFunc) {
  135775. return null;
  135776. }
  135777. return constructorFunc(name, scene, options);
  135778. };
  135779. /**
  135780. * Gets a boolean indicating if the node has been disposed
  135781. * @returns true if the node was disposed
  135782. */
  135783. Node.prototype.isDisposed = function () {
  135784. return this._isDisposed;
  135785. };
  135786. Object.defineProperty(Node.prototype, "parent", {
  135787. get: function () {
  135788. return this._parentNode;
  135789. },
  135790. /**
  135791. * Gets or sets the parent of the node (without keeping the current position in the scene)
  135792. * @see https://doc.babylonjs.com/how_to/parenting
  135793. */
  135794. set: function (parent) {
  135795. if (this._parentNode === parent) {
  135796. return;
  135797. }
  135798. var previousParentNode = this._parentNode;
  135799. // Remove self from list of children of parent
  135800. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  135801. var index = this._parentNode._children.indexOf(this);
  135802. if (index !== -1) {
  135803. this._parentNode._children.splice(index, 1);
  135804. }
  135805. if (!parent && !this._isDisposed) {
  135806. this.addToSceneRootNodes();
  135807. }
  135808. }
  135809. // Store new parent
  135810. this._parentNode = parent;
  135811. // Add as child to new parent
  135812. if (this._parentNode) {
  135813. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  135814. this._parentNode._children = new Array();
  135815. }
  135816. this._parentNode._children.push(this);
  135817. if (!previousParentNode) {
  135818. this.removeFromSceneRootNodes();
  135819. }
  135820. }
  135821. // Enabled state
  135822. this._syncParentEnabledState();
  135823. },
  135824. enumerable: true,
  135825. configurable: true
  135826. });
  135827. Node.prototype.addToSceneRootNodes = function () {
  135828. if (this._sceneRootNodesIndex === -1) {
  135829. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  135830. this._scene.rootNodes.push(this);
  135831. }
  135832. };
  135833. Node.prototype.removeFromSceneRootNodes = function () {
  135834. if (this._sceneRootNodesIndex !== -1) {
  135835. var rootNodes = this._scene.rootNodes;
  135836. var lastIdx = rootNodes.length - 1;
  135837. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  135838. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  135839. this._scene.rootNodes.pop();
  135840. this._sceneRootNodesIndex = -1;
  135841. }
  135842. };
  135843. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  135844. /**
  135845. * Gets or sets the animation properties override
  135846. */
  135847. get: function () {
  135848. if (!this._animationPropertiesOverride) {
  135849. return this._scene.animationPropertiesOverride;
  135850. }
  135851. return this._animationPropertiesOverride;
  135852. },
  135853. set: function (value) {
  135854. this._animationPropertiesOverride = value;
  135855. },
  135856. enumerable: true,
  135857. configurable: true
  135858. });
  135859. /**
  135860. * Gets a string idenfifying the name of the class
  135861. * @returns "Node" string
  135862. */
  135863. Node.prototype.getClassName = function () {
  135864. return "Node";
  135865. };
  135866. Object.defineProperty(Node.prototype, "onDispose", {
  135867. /**
  135868. * Sets a callback that will be raised when the node will be disposed
  135869. */
  135870. set: function (callback) {
  135871. if (this._onDisposeObserver) {
  135872. this.onDisposeObservable.remove(this._onDisposeObserver);
  135873. }
  135874. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  135875. },
  135876. enumerable: true,
  135877. configurable: true
  135878. });
  135879. /**
  135880. * Gets the scene of the node
  135881. * @returns a scene
  135882. */
  135883. Node.prototype.getScene = function () {
  135884. return this._scene;
  135885. };
  135886. /**
  135887. * Gets the engine of the node
  135888. * @returns a Engine
  135889. */
  135890. Node.prototype.getEngine = function () {
  135891. return this._scene.getEngine();
  135892. };
  135893. /**
  135894. * Attach a behavior to the node
  135895. * @see http://doc.babylonjs.com/features/behaviour
  135896. * @param behavior defines the behavior to attach
  135897. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  135898. * @returns the current Node
  135899. */
  135900. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  135901. var _this = this;
  135902. if (attachImmediately === void 0) { attachImmediately = false; }
  135903. var index = this._behaviors.indexOf(behavior);
  135904. if (index !== -1) {
  135905. return this;
  135906. }
  135907. behavior.init();
  135908. if (this._scene.isLoading && !attachImmediately) {
  135909. // We defer the attach when the scene will be loaded
  135910. this._scene.onDataLoadedObservable.addOnce(function () {
  135911. behavior.attach(_this);
  135912. });
  135913. }
  135914. else {
  135915. behavior.attach(this);
  135916. }
  135917. this._behaviors.push(behavior);
  135918. return this;
  135919. };
  135920. /**
  135921. * Remove an attached behavior
  135922. * @see http://doc.babylonjs.com/features/behaviour
  135923. * @param behavior defines the behavior to attach
  135924. * @returns the current Node
  135925. */
  135926. Node.prototype.removeBehavior = function (behavior) {
  135927. var index = this._behaviors.indexOf(behavior);
  135928. if (index === -1) {
  135929. return this;
  135930. }
  135931. this._behaviors[index].detach();
  135932. this._behaviors.splice(index, 1);
  135933. return this;
  135934. };
  135935. Object.defineProperty(Node.prototype, "behaviors", {
  135936. /**
  135937. * Gets the list of attached behaviors
  135938. * @see http://doc.babylonjs.com/features/behaviour
  135939. */
  135940. get: function () {
  135941. return this._behaviors;
  135942. },
  135943. enumerable: true,
  135944. configurable: true
  135945. });
  135946. /**
  135947. * Gets an attached behavior by name
  135948. * @param name defines the name of the behavior to look for
  135949. * @see http://doc.babylonjs.com/features/behaviour
  135950. * @returns null if behavior was not found else the requested behavior
  135951. */
  135952. Node.prototype.getBehaviorByName = function (name) {
  135953. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  135954. var behavior = _a[_i];
  135955. if (behavior.name === name) {
  135956. return behavior;
  135957. }
  135958. }
  135959. return null;
  135960. };
  135961. /**
  135962. * Returns the latest update of the World matrix
  135963. * @returns a Matrix
  135964. */
  135965. Node.prototype.getWorldMatrix = function () {
  135966. if (this._currentRenderId !== this._scene.getRenderId()) {
  135967. this.computeWorldMatrix();
  135968. }
  135969. return this._worldMatrix;
  135970. };
  135971. /** @hidden */
  135972. Node.prototype._getWorldMatrixDeterminant = function () {
  135973. if (this._worldMatrixDeterminantIsDirty) {
  135974. this._worldMatrixDeterminantIsDirty = false;
  135975. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  135976. }
  135977. return this._worldMatrixDeterminant;
  135978. };
  135979. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  135980. /**
  135981. * Returns directly the latest state of the mesh World matrix.
  135982. * A Matrix is returned.
  135983. */
  135984. get: function () {
  135985. return this._worldMatrix;
  135986. },
  135987. enumerable: true,
  135988. configurable: true
  135989. });
  135990. // override it in derived class if you add new variables to the cache
  135991. // and call the parent class method
  135992. /** @hidden */
  135993. Node.prototype._initCache = function () {
  135994. this._cache = {};
  135995. this._cache.parent = undefined;
  135996. };
  135997. /** @hidden */
  135998. Node.prototype.updateCache = function (force) {
  135999. if (!force && this.isSynchronized()) {
  136000. return;
  136001. }
  136002. this._cache.parent = this.parent;
  136003. this._updateCache();
  136004. };
  136005. /** @hidden */
  136006. Node.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  136007. if (initialCall === void 0) { initialCall = true; }
  136008. if (!this.parent) {
  136009. return null;
  136010. }
  136011. return this.parent._getActionManagerForTrigger(trigger, false);
  136012. };
  136013. // override it in derived class if you add new variables to the cache
  136014. // and call the parent class method if !ignoreParentClass
  136015. /** @hidden */
  136016. Node.prototype._updateCache = function (ignoreParentClass) {
  136017. };
  136018. // override it in derived class if you add new variables to the cache
  136019. /** @hidden */
  136020. Node.prototype._isSynchronized = function () {
  136021. return true;
  136022. };
  136023. /** @hidden */
  136024. Node.prototype._markSyncedWithParent = function () {
  136025. if (this._parentNode) {
  136026. this._parentUpdateId = this._parentNode._childUpdateId;
  136027. }
  136028. };
  136029. /** @hidden */
  136030. Node.prototype.isSynchronizedWithParent = function () {
  136031. if (!this._parentNode) {
  136032. return true;
  136033. }
  136034. if (this._parentUpdateId !== this._parentNode._childUpdateId) {
  136035. return false;
  136036. }
  136037. return this._parentNode.isSynchronized();
  136038. };
  136039. /** @hidden */
  136040. Node.prototype.isSynchronized = function () {
  136041. if (this._cache.parent != this._parentNode) {
  136042. this._cache.parent = this._parentNode;
  136043. return false;
  136044. }
  136045. if (this._parentNode && !this.isSynchronizedWithParent()) {
  136046. return false;
  136047. }
  136048. return this._isSynchronized();
  136049. };
  136050. /**
  136051. * Is this node ready to be used/rendered
  136052. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  136053. * @return true if the node is ready
  136054. */
  136055. Node.prototype.isReady = function (completeCheck) {
  136056. if (completeCheck === void 0) { completeCheck = false; }
  136057. return this._isReady;
  136058. };
  136059. /**
  136060. * Is this node enabled?
  136061. * 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
  136062. * @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
  136063. * @return whether this node (and its parent) is enabled
  136064. */
  136065. Node.prototype.isEnabled = function (checkAncestors) {
  136066. if (checkAncestors === void 0) { checkAncestors = true; }
  136067. if (checkAncestors === false) {
  136068. return this._isEnabled;
  136069. }
  136070. if (!this._isEnabled) {
  136071. return false;
  136072. }
  136073. return this._isParentEnabled;
  136074. };
  136075. /** @hidden */
  136076. Node.prototype._syncParentEnabledState = function () {
  136077. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  136078. if (this._children) {
  136079. this._children.forEach(function (c) {
  136080. c._syncParentEnabledState(); // Force children to update accordingly
  136081. });
  136082. }
  136083. };
  136084. /**
  136085. * Set the enabled state of this node
  136086. * @param value defines the new enabled state
  136087. */
  136088. Node.prototype.setEnabled = function (value) {
  136089. this._isEnabled = value;
  136090. this._syncParentEnabledState();
  136091. };
  136092. /**
  136093. * Is this node a descendant of the given node?
  136094. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  136095. * @param ancestor defines the parent node to inspect
  136096. * @returns a boolean indicating if this node is a descendant of the given node
  136097. */
  136098. Node.prototype.isDescendantOf = function (ancestor) {
  136099. if (this.parent) {
  136100. if (this.parent === ancestor) {
  136101. return true;
  136102. }
  136103. return this.parent.isDescendantOf(ancestor);
  136104. }
  136105. return false;
  136106. };
  136107. /** @hidden */
  136108. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  136109. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  136110. if (!this._children) {
  136111. return;
  136112. }
  136113. for (var index = 0; index < this._children.length; index++) {
  136114. var item = this._children[index];
  136115. if (!predicate || predicate(item)) {
  136116. results.push(item);
  136117. }
  136118. if (!directDescendantsOnly) {
  136119. item._getDescendants(results, false, predicate);
  136120. }
  136121. }
  136122. };
  136123. /**
  136124. * Will return all nodes that have this node as ascendant
  136125. * @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
  136126. * @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
  136127. * @return all children nodes of all types
  136128. */
  136129. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  136130. var results = new Array();
  136131. this._getDescendants(results, directDescendantsOnly, predicate);
  136132. return results;
  136133. };
  136134. /**
  136135. * Get all child-meshes of this node
  136136. * @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)
  136137. * @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
  136138. * @returns an array of AbstractMesh
  136139. */
  136140. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  136141. var results = [];
  136142. this._getDescendants(results, directDescendantsOnly, function (node) {
  136143. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  136144. });
  136145. return results;
  136146. };
  136147. /**
  136148. * Get all direct children of this node
  136149. * @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
  136150. * @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)
  136151. * @returns an array of Node
  136152. */
  136153. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  136154. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  136155. return this.getDescendants(directDescendantsOnly, predicate);
  136156. };
  136157. /** @hidden */
  136158. Node.prototype._setReady = function (state) {
  136159. if (state === this._isReady) {
  136160. return;
  136161. }
  136162. if (!state) {
  136163. this._isReady = false;
  136164. return;
  136165. }
  136166. if (this.onReady) {
  136167. this.onReady(this);
  136168. }
  136169. this._isReady = true;
  136170. };
  136171. /**
  136172. * Get an animation by name
  136173. * @param name defines the name of the animation to look for
  136174. * @returns null if not found else the requested animation
  136175. */
  136176. Node.prototype.getAnimationByName = function (name) {
  136177. for (var i = 0; i < this.animations.length; i++) {
  136178. var animation = this.animations[i];
  136179. if (animation.name === name) {
  136180. return animation;
  136181. }
  136182. }
  136183. return null;
  136184. };
  136185. /**
  136186. * Creates an animation range for this node
  136187. * @param name defines the name of the range
  136188. * @param from defines the starting key
  136189. * @param to defines the end key
  136190. */
  136191. Node.prototype.createAnimationRange = function (name, from, to) {
  136192. // check name not already in use
  136193. if (!this._ranges[name]) {
  136194. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  136195. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  136196. if (this.animations[i]) {
  136197. this.animations[i].createRange(name, from, to);
  136198. }
  136199. }
  136200. }
  136201. };
  136202. /**
  136203. * Delete a specific animation range
  136204. * @param name defines the name of the range to delete
  136205. * @param deleteFrames defines if animation frames from the range must be deleted as well
  136206. */
  136207. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  136208. if (deleteFrames === void 0) { deleteFrames = true; }
  136209. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  136210. if (this.animations[i]) {
  136211. this.animations[i].deleteRange(name, deleteFrames);
  136212. }
  136213. }
  136214. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  136215. };
  136216. /**
  136217. * Get an animation range by name
  136218. * @param name defines the name of the animation range to look for
  136219. * @returns null if not found else the requested animation range
  136220. */
  136221. Node.prototype.getAnimationRange = function (name) {
  136222. return this._ranges[name];
  136223. };
  136224. /**
  136225. * Gets the list of all animation ranges defined on this node
  136226. * @returns an array
  136227. */
  136228. Node.prototype.getAnimationRanges = function () {
  136229. var animationRanges = [];
  136230. var name;
  136231. for (name in this._ranges) {
  136232. animationRanges.push(this._ranges[name]);
  136233. }
  136234. return animationRanges;
  136235. };
  136236. /**
  136237. * Will start the animation sequence
  136238. * @param name defines the range frames for animation sequence
  136239. * @param loop defines if the animation should loop (false by default)
  136240. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  136241. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  136242. * @returns the object created for this animation. If range does not exist, it will return null
  136243. */
  136244. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  136245. var range = this.getAnimationRange(name);
  136246. if (!range) {
  136247. return null;
  136248. }
  136249. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  136250. };
  136251. /**
  136252. * Serialize animation ranges into a JSON compatible object
  136253. * @returns serialization object
  136254. */
  136255. Node.prototype.serializeAnimationRanges = function () {
  136256. var serializationRanges = [];
  136257. for (var name in this._ranges) {
  136258. var localRange = this._ranges[name];
  136259. if (!localRange) {
  136260. continue;
  136261. }
  136262. var range = {};
  136263. range.name = name;
  136264. range.from = localRange.from;
  136265. range.to = localRange.to;
  136266. serializationRanges.push(range);
  136267. }
  136268. return serializationRanges;
  136269. };
  136270. /**
  136271. * Computes the world matrix of the node
  136272. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  136273. * @returns the world matrix
  136274. */
  136275. Node.prototype.computeWorldMatrix = function (force) {
  136276. if (!this._worldMatrix) {
  136277. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  136278. }
  136279. return this._worldMatrix;
  136280. };
  136281. /**
  136282. * Releases resources associated with this node.
  136283. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  136284. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  136285. */
  136286. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  136287. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  136288. this._isDisposed = true;
  136289. if (!doNotRecurse) {
  136290. var nodes = this.getDescendants(true);
  136291. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  136292. var node = nodes_1[_i];
  136293. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  136294. }
  136295. }
  136296. if (!this.parent) {
  136297. this.removeFromSceneRootNodes();
  136298. }
  136299. else {
  136300. this.parent = null;
  136301. }
  136302. // Callback
  136303. this.onDisposeObservable.notifyObservers(this);
  136304. this.onDisposeObservable.clear();
  136305. // Behaviors
  136306. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  136307. var behavior = _b[_a];
  136308. behavior.detach();
  136309. }
  136310. this._behaviors = [];
  136311. };
  136312. /**
  136313. * Parse animation range data from a serialization object and store them into a given node
  136314. * @param node defines where to store the animation ranges
  136315. * @param parsedNode defines the serialization object to read data from
  136316. * @param scene defines the hosting scene
  136317. */
  136318. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  136319. if (parsedNode.ranges) {
  136320. for (var index = 0; index < parsedNode.ranges.length; index++) {
  136321. var data = parsedNode.ranges[index];
  136322. node.createAnimationRange(data.name, data.from, data.to);
  136323. }
  136324. }
  136325. };
  136326. /**
  136327. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  136328. * @param includeDescendants Include bounding info from descendants as well (true by default)
  136329. * @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
  136330. * @returns the new bounding vectors
  136331. */
  136332. Node.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  136333. if (includeDescendants === void 0) { includeDescendants = true; }
  136334. if (predicate === void 0) { predicate = null; }
  136335. // Ensures that all world matrix will be recomputed.
  136336. this.getScene().incrementRenderId();
  136337. this.computeWorldMatrix(true);
  136338. var min;
  136339. var max;
  136340. var thisAbstractMesh = this;
  136341. if (thisAbstractMesh.getBoundingInfo && thisAbstractMesh.subMeshes) {
  136342. // If this is an abstract mesh get its bounding info
  136343. var boundingInfo = thisAbstractMesh.getBoundingInfo();
  136344. min = boundingInfo.boundingBox.minimumWorld;
  136345. max = boundingInfo.boundingBox.maximumWorld;
  136346. }
  136347. else {
  136348. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  136349. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  136350. }
  136351. if (includeDescendants) {
  136352. var descendants = this.getDescendants(false);
  136353. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  136354. var descendant = descendants_1[_i];
  136355. var childMesh = descendant;
  136356. childMesh.computeWorldMatrix(true);
  136357. // Filters meshes based on custom predicate function.
  136358. if (predicate && !predicate(childMesh)) {
  136359. continue;
  136360. }
  136361. //make sure we have the needed params to get mix and max
  136362. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  136363. continue;
  136364. }
  136365. var childBoundingInfo = childMesh.getBoundingInfo();
  136366. var boundingBox = childBoundingInfo.boundingBox;
  136367. var minBox = boundingBox.minimumWorld;
  136368. var maxBox = boundingBox.maximumWorld;
  136369. _Misc_tools__WEBPACK_IMPORTED_MODULE_6__["Tools"].CheckExtends(minBox, min, max);
  136370. _Misc_tools__WEBPACK_IMPORTED_MODULE_6__["Tools"].CheckExtends(maxBox, min, max);
  136371. }
  136372. }
  136373. return {
  136374. min: min,
  136375. max: max
  136376. };
  136377. };
  136378. /** @hidden */
  136379. Node._AnimationRangeFactory = function (name, from, to) {
  136380. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  136381. };
  136382. Node._NodeConstructors = {};
  136383. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  136384. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  136385. ], Node.prototype, "name", void 0);
  136386. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  136387. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  136388. ], Node.prototype, "id", void 0);
  136389. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  136390. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  136391. ], Node.prototype, "uniqueId", void 0);
  136392. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  136393. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  136394. ], Node.prototype, "state", void 0);
  136395. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  136396. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  136397. ], Node.prototype, "metadata", void 0);
  136398. return Node;
  136399. }());
  136400. /***/ }),
  136401. /***/ "./scene.ts":
  136402. /*!******************!*\
  136403. !*** ./scene.ts ***!
  136404. \******************/
  136405. /*! exports provided: Scene */
  136406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  136407. "use strict";
  136408. __webpack_require__.r(__webpack_exports__);
  136409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  136410. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  136411. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  136412. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  136413. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  136414. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  136415. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  136416. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  136417. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  136418. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/transformNode */ "./Meshes/transformNode.ts");
  136419. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  136420. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  136421. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  136422. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  136423. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  136424. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  136425. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  136426. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  136427. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  136428. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  136429. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  136430. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  136431. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  136432. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  136433. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  136434. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  136435. /* harmony import */ var _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Inputs/scene.inputManager */ "./Inputs/scene.inputManager.ts");
  136436. /**
  136437. * Represents a scene to be rendered by the engine.
  136438. * @see http://doc.babylonjs.com/features/scene
  136439. */
  136440. var Scene = /** @class */ (function (_super) {
  136441. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  136442. /**
  136443. * Creates a new Scene
  136444. * @param engine defines the engine to use to render this scene
  136445. * @param options defines the scene options
  136446. */
  136447. function Scene(engine, options) {
  136448. var _this = _super.call(this) || this;
  136449. // Members
  136450. /** @hidden */
  136451. _this._inputManager = new _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"](_this);
  136452. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  136453. _this.cameraToUseForPointers = null;
  136454. /** @hidden */
  136455. _this._isScene = true;
  136456. /**
  136457. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  136458. */
  136459. _this.autoClear = true;
  136460. /**
  136461. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  136462. */
  136463. _this.autoClearDepthAndStencil = true;
  136464. /**
  136465. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  136466. */
  136467. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  136468. /**
  136469. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  136470. */
  136471. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  136472. _this._forceWireframe = false;
  136473. _this._forcePointsCloud = false;
  136474. /**
  136475. * Gets or sets a boolean indicating if animations are enabled
  136476. */
  136477. _this.animationsEnabled = true;
  136478. _this._animationPropertiesOverride = null;
  136479. /**
  136480. * Gets or sets a boolean indicating if a constant deltatime has to be used
  136481. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  136482. */
  136483. _this.useConstantAnimationDeltaTime = false;
  136484. /**
  136485. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  136486. * Please note that it requires to run a ray cast through the scene on every frame
  136487. */
  136488. _this.constantlyUpdateMeshUnderPointer = false;
  136489. /**
  136490. * Defines the HTML cursor to use when hovering over interactive elements
  136491. */
  136492. _this.hoverCursor = "pointer";
  136493. /**
  136494. * Defines the HTML default cursor to use (empty by default)
  136495. */
  136496. _this.defaultCursor = "";
  136497. /**
  136498. * This is used to call preventDefault() on pointer down
  136499. * in order to block unwanted artifacts like system double clicks
  136500. */
  136501. _this.preventDefaultOnPointerDown = true;
  136502. /**
  136503. * This is used to call preventDefault() on pointer up
  136504. * in order to block unwanted artifacts like system double clicks
  136505. */
  136506. _this.preventDefaultOnPointerUp = true;
  136507. // Metadata
  136508. /**
  136509. * Gets or sets user defined metadata
  136510. */
  136511. _this.metadata = null;
  136512. /**
  136513. * For internal use only. Please do not use.
  136514. */
  136515. _this.reservedDataStore = null;
  136516. /**
  136517. * Use this array to add regular expressions used to disable offline support for specific urls
  136518. */
  136519. _this.disableOfflineSupportExceptionRules = new Array();
  136520. /**
  136521. * An event triggered when the scene is disposed.
  136522. */
  136523. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136524. _this._onDisposeObserver = null;
  136525. /**
  136526. * An event triggered before rendering the scene (right after animations and physics)
  136527. */
  136528. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136529. _this._onBeforeRenderObserver = null;
  136530. /**
  136531. * An event triggered after rendering the scene
  136532. */
  136533. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136534. _this._onAfterRenderObserver = null;
  136535. /**
  136536. * An event triggered before animating the scene
  136537. */
  136538. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136539. /**
  136540. * An event triggered after animations processing
  136541. */
  136542. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136543. /**
  136544. * An event triggered before draw calls are ready to be sent
  136545. */
  136546. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136547. /**
  136548. * An event triggered after draw calls have been sent
  136549. */
  136550. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136551. /**
  136552. * An event triggered when the scene is ready
  136553. */
  136554. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136555. /**
  136556. * An event triggered before rendering a camera
  136557. */
  136558. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136559. _this._onBeforeCameraRenderObserver = null;
  136560. /**
  136561. * An event triggered after rendering a camera
  136562. */
  136563. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136564. _this._onAfterCameraRenderObserver = null;
  136565. /**
  136566. * An event triggered when active meshes evaluation is about to start
  136567. */
  136568. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136569. /**
  136570. * An event triggered when active meshes evaluation is done
  136571. */
  136572. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136573. /**
  136574. * An event triggered when particles rendering is about to start
  136575. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  136576. */
  136577. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136578. /**
  136579. * An event triggered when particles rendering is done
  136580. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  136581. */
  136582. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136583. /**
  136584. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  136585. */
  136586. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136587. /**
  136588. * An event triggered when a camera is created
  136589. */
  136590. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136591. /**
  136592. * An event triggered when a camera is removed
  136593. */
  136594. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136595. /**
  136596. * An event triggered when a light is created
  136597. */
  136598. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136599. /**
  136600. * An event triggered when a light is removed
  136601. */
  136602. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136603. /**
  136604. * An event triggered when a geometry is created
  136605. */
  136606. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136607. /**
  136608. * An event triggered when a geometry is removed
  136609. */
  136610. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136611. /**
  136612. * An event triggered when a transform node is created
  136613. */
  136614. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136615. /**
  136616. * An event triggered when a transform node is removed
  136617. */
  136618. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136619. /**
  136620. * An event triggered when a mesh is created
  136621. */
  136622. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136623. /**
  136624. * An event triggered when a mesh is removed
  136625. */
  136626. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136627. /**
  136628. * An event triggered when a skeleton is created
  136629. */
  136630. _this.onNewSkeletonAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136631. /**
  136632. * An event triggered when a skeleton is removed
  136633. */
  136634. _this.onSkeletonRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136635. /**
  136636. * An event triggered when a material is created
  136637. */
  136638. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136639. /**
  136640. * An event triggered when a material is removed
  136641. */
  136642. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136643. /**
  136644. * An event triggered when a texture is created
  136645. */
  136646. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136647. /**
  136648. * An event triggered when a texture is removed
  136649. */
  136650. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136651. /**
  136652. * An event triggered when render targets are about to be rendered
  136653. * Can happen multiple times per frame.
  136654. */
  136655. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136656. /**
  136657. * An event triggered when render targets were rendered.
  136658. * Can happen multiple times per frame.
  136659. */
  136660. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136661. /**
  136662. * An event triggered before calculating deterministic simulation step
  136663. */
  136664. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136665. /**
  136666. * An event triggered after calculating deterministic simulation step
  136667. */
  136668. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136669. /**
  136670. * An event triggered when the activeCamera property is updated
  136671. */
  136672. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136673. /**
  136674. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  136675. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  136676. * 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)
  136677. */
  136678. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136679. /**
  136680. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  136681. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  136682. * 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)
  136683. */
  136684. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136685. /**
  136686. * This Observable will when a mesh has been imported into the scene.
  136687. */
  136688. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136689. // Animations
  136690. /** @hidden */
  136691. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  136692. /**
  136693. * 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).
  136694. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  136695. */
  136696. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136697. /**
  136698. * Observable event triggered each time an input event is received from the rendering canvas
  136699. */
  136700. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136701. // Keyboard
  136702. /**
  136703. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  136704. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  136705. */
  136706. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136707. /**
  136708. * Observable event triggered each time an keyboard event is received from the hosting window
  136709. */
  136710. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  136711. // Coordinates system
  136712. _this._useRightHandedSystem = false;
  136713. // Deterministic lockstep
  136714. _this._timeAccumulator = 0;
  136715. _this._currentStepId = 0;
  136716. _this._currentInternalStep = 0;
  136717. // Fog
  136718. _this._fogEnabled = true;
  136719. _this._fogMode = Scene.FOGMODE_NONE;
  136720. /**
  136721. * Gets or sets the fog color to use
  136722. * @see http://doc.babylonjs.com/babylon101/environment#fog
  136723. * (Default is Color3(0.2, 0.2, 0.3))
  136724. */
  136725. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  136726. /**
  136727. * Gets or sets the fog density to use
  136728. * @see http://doc.babylonjs.com/babylon101/environment#fog
  136729. * (Default is 0.1)
  136730. */
  136731. _this.fogDensity = 0.1;
  136732. /**
  136733. * Gets or sets the fog start distance to use
  136734. * @see http://doc.babylonjs.com/babylon101/environment#fog
  136735. * (Default is 0)
  136736. */
  136737. _this.fogStart = 0;
  136738. /**
  136739. * Gets or sets the fog end distance to use
  136740. * @see http://doc.babylonjs.com/babylon101/environment#fog
  136741. * (Default is 1000)
  136742. */
  136743. _this.fogEnd = 1000.0;
  136744. // Lights
  136745. _this._shadowsEnabled = true;
  136746. _this._lightsEnabled = true;
  136747. /** All of the active cameras added to this scene. */
  136748. _this.activeCameras = new Array();
  136749. // Textures
  136750. _this._texturesEnabled = true;
  136751. // Particles
  136752. /**
  136753. * Gets or sets a boolean indicating if particles are enabled on this scene
  136754. */
  136755. _this.particlesEnabled = true;
  136756. // Sprites
  136757. /**
  136758. * Gets or sets a boolean indicating if sprites are enabled on this scene
  136759. */
  136760. _this.spritesEnabled = true;
  136761. // Skeletons
  136762. _this._skeletonsEnabled = true;
  136763. // Lens flares
  136764. /**
  136765. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  136766. */
  136767. _this.lensFlaresEnabled = true;
  136768. // Collisions
  136769. /**
  136770. * Gets or sets a boolean indicating if collisions are enabled on this scene
  136771. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  136772. */
  136773. _this.collisionsEnabled = true;
  136774. /**
  136775. * Defines the gravity applied to this scene (used only for collisions)
  136776. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  136777. */
  136778. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  136779. // Postprocesses
  136780. /**
  136781. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  136782. */
  136783. _this.postProcessesEnabled = true;
  136784. /**
  136785. * The list of postprocesses added to the scene
  136786. */
  136787. _this.postProcesses = new Array();
  136788. // Customs render targets
  136789. /**
  136790. * Gets or sets a boolean indicating if render targets are enabled on this scene
  136791. */
  136792. _this.renderTargetsEnabled = true;
  136793. /**
  136794. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  136795. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  136796. */
  136797. _this.dumpNextRenderTargets = false;
  136798. /**
  136799. * The list of user defined render targets added to the scene
  136800. */
  136801. _this.customRenderTargets = new Array();
  136802. /**
  136803. * Gets the list of meshes imported to the scene through SceneLoader
  136804. */
  136805. _this.importedMeshesFiles = new Array();
  136806. // Probes
  136807. /**
  136808. * Gets or sets a boolean indicating if probes are enabled on this scene
  136809. */
  136810. _this.probesEnabled = true;
  136811. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  136812. // Procedural textures
  136813. /**
  136814. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  136815. */
  136816. _this.proceduralTexturesEnabled = true;
  136817. // Performance counters
  136818. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  136819. /** @hidden */
  136820. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  136821. /** @hidden */
  136822. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  136823. /** @hidden */
  136824. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  136825. /** @hidden */
  136826. _this._animationTime = 0;
  136827. /**
  136828. * Gets or sets a general scale for animation speed
  136829. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  136830. */
  136831. _this.animationTimeScale = 1;
  136832. _this._renderId = 0;
  136833. _this._frameId = 0;
  136834. _this._executeWhenReadyTimeoutId = -1;
  136835. _this._intermediateRendering = false;
  136836. _this._viewUpdateFlag = -1;
  136837. _this._projectionUpdateFlag = -1;
  136838. /** @hidden */
  136839. _this._toBeDisposed = new Array(256);
  136840. _this._activeRequests = new Array();
  136841. /** @hidden */
  136842. _this._pendingData = new Array();
  136843. _this._isDisposed = false;
  136844. /**
  136845. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  136846. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  136847. */
  136848. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  136849. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  136850. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  136851. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  136852. /** @hidden */
  136853. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  136854. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  136855. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  136856. /** @hidden */
  136857. _this._activeAnimatables = new Array();
  136858. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  136859. /**
  136860. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  136861. * This is useful if there are more lights that the maximum simulteanous authorized
  136862. */
  136863. _this.requireLightSorting = false;
  136864. /**
  136865. * @hidden
  136866. * Backing store of defined scene components.
  136867. */
  136868. _this._components = [];
  136869. /**
  136870. * @hidden
  136871. * Backing store of defined scene components.
  136872. */
  136873. _this._serializableComponents = [];
  136874. /**
  136875. * List of components to register on the next registration step.
  136876. */
  136877. _this._transientComponents = [];
  136878. /**
  136879. * @hidden
  136880. * Defines the actions happening before camera updates.
  136881. */
  136882. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136883. /**
  136884. * @hidden
  136885. * Defines the actions happening before clear the canvas.
  136886. */
  136887. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136888. /**
  136889. * @hidden
  136890. * Defines the actions when collecting render targets for the frame.
  136891. */
  136892. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136893. /**
  136894. * @hidden
  136895. * Defines the actions happening for one camera in the frame.
  136896. */
  136897. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136898. /**
  136899. * @hidden
  136900. * Defines the actions happening during the per mesh ready checks.
  136901. */
  136902. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136903. /**
  136904. * @hidden
  136905. * Defines the actions happening before evaluate active mesh checks.
  136906. */
  136907. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136908. /**
  136909. * @hidden
  136910. * Defines the actions happening during the evaluate sub mesh checks.
  136911. */
  136912. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136913. /**
  136914. * @hidden
  136915. * Defines the actions happening during the active mesh stage.
  136916. */
  136917. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136918. /**
  136919. * @hidden
  136920. * Defines the actions happening during the per camera render target step.
  136921. */
  136922. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136923. /**
  136924. * @hidden
  136925. * Defines the actions happening just before the active camera is drawing.
  136926. */
  136927. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136928. /**
  136929. * @hidden
  136930. * Defines the actions happening just before a render target is drawing.
  136931. */
  136932. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136933. /**
  136934. * @hidden
  136935. * Defines the actions happening just before a rendering group is drawing.
  136936. */
  136937. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136938. /**
  136939. * @hidden
  136940. * Defines the actions happening just before a mesh is drawing.
  136941. */
  136942. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136943. /**
  136944. * @hidden
  136945. * Defines the actions happening just after a mesh has been drawn.
  136946. */
  136947. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136948. /**
  136949. * @hidden
  136950. * Defines the actions happening just after a rendering group has been drawn.
  136951. */
  136952. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136953. /**
  136954. * @hidden
  136955. * Defines the actions happening just after the active camera has been drawn.
  136956. */
  136957. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136958. /**
  136959. * @hidden
  136960. * Defines the actions happening just after a render target has been drawn.
  136961. */
  136962. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136963. /**
  136964. * @hidden
  136965. * Defines the actions happening just after rendering all cameras and computing intersections.
  136966. */
  136967. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136968. /**
  136969. * @hidden
  136970. * Defines the actions happening when a pointer move event happens.
  136971. */
  136972. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136973. /**
  136974. * @hidden
  136975. * Defines the actions happening when a pointer down event happens.
  136976. */
  136977. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136978. /**
  136979. * @hidden
  136980. * Defines the actions happening when a pointer up event happens.
  136981. */
  136982. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_19__["Stage"].Create();
  136983. /**
  136984. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  136985. */
  136986. _this.geometriesByUniqueId = null;
  136987. _this._defaultMeshCandidates = {
  136988. data: [],
  136989. length: 0
  136990. };
  136991. _this._defaultSubMeshCandidates = {
  136992. data: [],
  136993. length: 0
  136994. };
  136995. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  136996. _this._activeMeshesFrozen = false;
  136997. /** @hidden */
  136998. _this._allowPostProcessClearColor = true;
  136999. /**
  137000. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  137001. */
  137002. _this.getDeterministicFrameTime = function () {
  137003. return 1000.0 / 60.0; // frame time in ms
  137004. };
  137005. _this._blockMaterialDirtyMechanism = false;
  137006. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_23__["EngineStore"].LastCreatedEngine;
  137007. if (!options || !options.virtual) {
  137008. _Engines_engineStore__WEBPACK_IMPORTED_MODULE_23__["EngineStore"]._LastCreatedScene = _this;
  137009. _this._engine.scenes.push(_this);
  137010. }
  137011. _this._uid = null;
  137012. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_18__["RenderingManager"](_this);
  137013. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_17__["PostProcessManager"]) {
  137014. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_17__["PostProcessManager"](_this);
  137015. }
  137016. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_21__["DomManagement"].IsWindowObjectExist()) {
  137017. _this.attachControl();
  137018. }
  137019. // Uniform Buffer
  137020. _this._createUbo();
  137021. // Default Image processing definition
  137022. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  137023. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]();
  137024. }
  137025. _this.setDefaultCandidateProviders();
  137026. if (options && options.useGeometryUniqueIdsMap === true) {
  137027. _this.geometriesByUniqueId = {};
  137028. }
  137029. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  137030. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  137031. if (!options || !options.virtual) {
  137032. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  137033. }
  137034. return _this;
  137035. }
  137036. /**
  137037. * Factory used to create the default material.
  137038. * @param name The name of the material to create
  137039. * @param scene The scene to create the material for
  137040. * @returns The default material
  137041. */
  137042. Scene.DefaultMaterialFactory = function (scene) {
  137043. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("StandardMaterial");
  137044. };
  137045. /**
  137046. * Factory used to create the a collision coordinator.
  137047. * @returns The collision coordinator
  137048. */
  137049. Scene.CollisionCoordinatorFactory = function () {
  137050. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  137051. };
  137052. Object.defineProperty(Scene.prototype, "environmentTexture", {
  137053. /**
  137054. * Texture used in all pbr material as the reflection texture.
  137055. * As in the majority of the scene they are the same (exception for multi room and so on),
  137056. * this is easier to reference from here than from all the materials.
  137057. */
  137058. get: function () {
  137059. return this._environmentTexture;
  137060. },
  137061. /**
  137062. * Texture used in all pbr material as the reflection texture.
  137063. * As in the majority of the scene they are the same (exception for multi room and so on),
  137064. * this is easier to set here than in all the materials.
  137065. */
  137066. set: function (value) {
  137067. if (this._environmentTexture === value) {
  137068. return;
  137069. }
  137070. this._environmentTexture = value;
  137071. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_TextureDirtyFlag);
  137072. },
  137073. enumerable: true,
  137074. configurable: true
  137075. });
  137076. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  137077. /**
  137078. * Default image processing configuration used either in the rendering
  137079. * Forward main pass or through the imageProcessingPostProcess if present.
  137080. * As in the majority of the scene they are the same (exception for multi camera),
  137081. * this is easier to reference from here than from all the materials and post process.
  137082. *
  137083. * No setter as we it is a shared configuration, you can set the values instead.
  137084. */
  137085. get: function () {
  137086. return this._imageProcessingConfiguration;
  137087. },
  137088. enumerable: true,
  137089. configurable: true
  137090. });
  137091. Object.defineProperty(Scene.prototype, "forceWireframe", {
  137092. get: function () {
  137093. return this._forceWireframe;
  137094. },
  137095. /**
  137096. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  137097. */
  137098. set: function (value) {
  137099. if (this._forceWireframe === value) {
  137100. return;
  137101. }
  137102. this._forceWireframe = value;
  137103. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_MiscDirtyFlag);
  137104. },
  137105. enumerable: true,
  137106. configurable: true
  137107. });
  137108. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  137109. get: function () {
  137110. return this._forcePointsCloud;
  137111. },
  137112. /**
  137113. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  137114. */
  137115. set: function (value) {
  137116. if (this._forcePointsCloud === value) {
  137117. return;
  137118. }
  137119. this._forcePointsCloud = value;
  137120. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_MiscDirtyFlag);
  137121. },
  137122. enumerable: true,
  137123. configurable: true
  137124. });
  137125. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  137126. /**
  137127. * Gets or sets the animation properties override
  137128. */
  137129. get: function () {
  137130. return this._animationPropertiesOverride;
  137131. },
  137132. set: function (value) {
  137133. this._animationPropertiesOverride = value;
  137134. },
  137135. enumerable: true,
  137136. configurable: true
  137137. });
  137138. Object.defineProperty(Scene.prototype, "onDispose", {
  137139. /** Sets a function to be executed when this scene is disposed. */
  137140. set: function (callback) {
  137141. if (this._onDisposeObserver) {
  137142. this.onDisposeObservable.remove(this._onDisposeObserver);
  137143. }
  137144. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  137145. },
  137146. enumerable: true,
  137147. configurable: true
  137148. });
  137149. Object.defineProperty(Scene.prototype, "beforeRender", {
  137150. /** Sets a function to be executed before rendering this scene */
  137151. set: function (callback) {
  137152. if (this._onBeforeRenderObserver) {
  137153. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  137154. }
  137155. if (callback) {
  137156. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  137157. }
  137158. },
  137159. enumerable: true,
  137160. configurable: true
  137161. });
  137162. Object.defineProperty(Scene.prototype, "afterRender", {
  137163. /** Sets a function to be executed after rendering this scene */
  137164. set: function (callback) {
  137165. if (this._onAfterRenderObserver) {
  137166. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  137167. }
  137168. if (callback) {
  137169. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  137170. }
  137171. },
  137172. enumerable: true,
  137173. configurable: true
  137174. });
  137175. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  137176. /** Sets a function to be executed before rendering a camera*/
  137177. set: function (callback) {
  137178. if (this._onBeforeCameraRenderObserver) {
  137179. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  137180. }
  137181. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  137182. },
  137183. enumerable: true,
  137184. configurable: true
  137185. });
  137186. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  137187. /** Sets a function to be executed after rendering a camera*/
  137188. set: function (callback) {
  137189. if (this._onAfterCameraRenderObserver) {
  137190. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  137191. }
  137192. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  137193. },
  137194. enumerable: true,
  137195. configurable: true
  137196. });
  137197. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  137198. /**
  137199. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  137200. */
  137201. get: function () {
  137202. return this._inputManager.unTranslatedPointer;
  137203. },
  137204. enumerable: true,
  137205. configurable: true
  137206. });
  137207. Object.defineProperty(Scene, "DragMovementThreshold", {
  137208. /**
  137209. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  137210. */
  137211. get: function () {
  137212. return _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].DragMovementThreshold;
  137213. },
  137214. set: function (value) {
  137215. _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].DragMovementThreshold = value;
  137216. },
  137217. enumerable: true,
  137218. configurable: true
  137219. });
  137220. Object.defineProperty(Scene, "LongPressDelay", {
  137221. /**
  137222. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  137223. */
  137224. get: function () {
  137225. return _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].LongPressDelay;
  137226. },
  137227. set: function (value) {
  137228. _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].LongPressDelay = value;
  137229. },
  137230. enumerable: true,
  137231. configurable: true
  137232. });
  137233. Object.defineProperty(Scene, "DoubleClickDelay", {
  137234. /**
  137235. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  137236. */
  137237. get: function () {
  137238. return _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].DoubleClickDelay;
  137239. },
  137240. set: function (value) {
  137241. _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].DoubleClickDelay = value;
  137242. },
  137243. enumerable: true,
  137244. configurable: true
  137245. });
  137246. Object.defineProperty(Scene, "ExclusiveDoubleClickMode", {
  137247. /** If you need to check double click without raising a single click at first click, enable this flag */
  137248. get: function () {
  137249. return _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].ExclusiveDoubleClickMode;
  137250. },
  137251. set: function (value) {
  137252. _Inputs_scene_inputManager__WEBPACK_IMPORTED_MODULE_25__["InputManager"].ExclusiveDoubleClickMode = value;
  137253. },
  137254. enumerable: true,
  137255. configurable: true
  137256. });
  137257. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  137258. get: function () {
  137259. return this._useRightHandedSystem;
  137260. },
  137261. /**
  137262. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  137263. */
  137264. set: function (value) {
  137265. if (this._useRightHandedSystem === value) {
  137266. return;
  137267. }
  137268. this._useRightHandedSystem = value;
  137269. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_MiscDirtyFlag);
  137270. },
  137271. enumerable: true,
  137272. configurable: true
  137273. });
  137274. /**
  137275. * Sets the step Id used by deterministic lock step
  137276. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137277. * @param newStepId defines the step Id
  137278. */
  137279. Scene.prototype.setStepId = function (newStepId) {
  137280. this._currentStepId = newStepId;
  137281. };
  137282. /**
  137283. * Gets the step Id used by deterministic lock step
  137284. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137285. * @returns the step Id
  137286. */
  137287. Scene.prototype.getStepId = function () {
  137288. return this._currentStepId;
  137289. };
  137290. /**
  137291. * Gets the internal step used by deterministic lock step
  137292. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137293. * @returns the internal step
  137294. */
  137295. Scene.prototype.getInternalStep = function () {
  137296. return this._currentInternalStep;
  137297. };
  137298. Object.defineProperty(Scene.prototype, "fogEnabled", {
  137299. get: function () {
  137300. return this._fogEnabled;
  137301. },
  137302. /**
  137303. * Gets or sets a boolean indicating if fog is enabled on this scene
  137304. * @see http://doc.babylonjs.com/babylon101/environment#fog
  137305. * (Default is true)
  137306. */
  137307. set: function (value) {
  137308. if (this._fogEnabled === value) {
  137309. return;
  137310. }
  137311. this._fogEnabled = value;
  137312. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_MiscDirtyFlag);
  137313. },
  137314. enumerable: true,
  137315. configurable: true
  137316. });
  137317. Object.defineProperty(Scene.prototype, "fogMode", {
  137318. get: function () {
  137319. return this._fogMode;
  137320. },
  137321. /**
  137322. * Gets or sets the fog mode to use
  137323. * @see http://doc.babylonjs.com/babylon101/environment#fog
  137324. * | mode | value |
  137325. * | --- | --- |
  137326. * | FOGMODE_NONE | 0 |
  137327. * | FOGMODE_EXP | 1 |
  137328. * | FOGMODE_EXP2 | 2 |
  137329. * | FOGMODE_LINEAR | 3 |
  137330. */
  137331. set: function (value) {
  137332. if (this._fogMode === value) {
  137333. return;
  137334. }
  137335. this._fogMode = value;
  137336. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_MiscDirtyFlag);
  137337. },
  137338. enumerable: true,
  137339. configurable: true
  137340. });
  137341. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  137342. get: function () {
  137343. return this._shadowsEnabled;
  137344. },
  137345. /**
  137346. * Gets or sets a boolean indicating if shadows are enabled on this scene
  137347. */
  137348. set: function (value) {
  137349. if (this._shadowsEnabled === value) {
  137350. return;
  137351. }
  137352. this._shadowsEnabled = value;
  137353. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_LightDirtyFlag);
  137354. },
  137355. enumerable: true,
  137356. configurable: true
  137357. });
  137358. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  137359. get: function () {
  137360. return this._lightsEnabled;
  137361. },
  137362. /**
  137363. * Gets or sets a boolean indicating if lights are enabled on this scene
  137364. */
  137365. set: function (value) {
  137366. if (this._lightsEnabled === value) {
  137367. return;
  137368. }
  137369. this._lightsEnabled = value;
  137370. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_LightDirtyFlag);
  137371. },
  137372. enumerable: true,
  137373. configurable: true
  137374. });
  137375. Object.defineProperty(Scene.prototype, "activeCamera", {
  137376. /** Gets or sets the current active camera */
  137377. get: function () {
  137378. return this._activeCamera;
  137379. },
  137380. set: function (value) {
  137381. if (value === this._activeCamera) {
  137382. return;
  137383. }
  137384. this._activeCamera = value;
  137385. this.onActiveCameraChanged.notifyObservers(this);
  137386. },
  137387. enumerable: true,
  137388. configurable: true
  137389. });
  137390. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  137391. /** The default material used on meshes when no material is affected */
  137392. get: function () {
  137393. if (!this._defaultMaterial) {
  137394. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  137395. }
  137396. return this._defaultMaterial;
  137397. },
  137398. /** The default material used on meshes when no material is affected */
  137399. set: function (value) {
  137400. this._defaultMaterial = value;
  137401. },
  137402. enumerable: true,
  137403. configurable: true
  137404. });
  137405. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  137406. get: function () {
  137407. return this._texturesEnabled;
  137408. },
  137409. /**
  137410. * Gets or sets a boolean indicating if textures are enabled on this scene
  137411. */
  137412. set: function (value) {
  137413. if (this._texturesEnabled === value) {
  137414. return;
  137415. }
  137416. this._texturesEnabled = value;
  137417. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_TextureDirtyFlag);
  137418. },
  137419. enumerable: true,
  137420. configurable: true
  137421. });
  137422. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  137423. get: function () {
  137424. return this._skeletonsEnabled;
  137425. },
  137426. /**
  137427. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  137428. */
  137429. set: function (value) {
  137430. if (this._skeletonsEnabled === value) {
  137431. return;
  137432. }
  137433. this._skeletonsEnabled = value;
  137434. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_AttributesDirtyFlag);
  137435. },
  137436. enumerable: true,
  137437. configurable: true
  137438. });
  137439. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  137440. /** @hidden */
  137441. get: function () {
  137442. if (!this._collisionCoordinator) {
  137443. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  137444. this._collisionCoordinator.init(this);
  137445. }
  137446. return this._collisionCoordinator;
  137447. },
  137448. enumerable: true,
  137449. configurable: true
  137450. });
  137451. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  137452. /**
  137453. * Gets the list of frustum planes (built from the active camera)
  137454. */
  137455. get: function () {
  137456. return this._frustumPlanes;
  137457. },
  137458. enumerable: true,
  137459. configurable: true
  137460. });
  137461. /**
  137462. * Registers the transient components if needed.
  137463. */
  137464. Scene.prototype._registerTransientComponents = function () {
  137465. // Register components that have been associated lately to the scene.
  137466. if (this._transientComponents.length > 0) {
  137467. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  137468. var component = _a[_i];
  137469. component.register();
  137470. }
  137471. this._transientComponents = [];
  137472. }
  137473. };
  137474. /**
  137475. * @hidden
  137476. * Add a component to the scene.
  137477. * Note that the ccomponent could be registered on th next frame if this is called after
  137478. * the register component stage.
  137479. * @param component Defines the component to add to the scene
  137480. */
  137481. Scene.prototype._addComponent = function (component) {
  137482. this._components.push(component);
  137483. this._transientComponents.push(component);
  137484. var serializableComponent = component;
  137485. if (serializableComponent.addFromContainer) {
  137486. this._serializableComponents.push(serializableComponent);
  137487. }
  137488. };
  137489. /**
  137490. * @hidden
  137491. * Gets a component from the scene.
  137492. * @param name defines the name of the component to retrieve
  137493. * @returns the component or null if not present
  137494. */
  137495. Scene.prototype._getComponent = function (name) {
  137496. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  137497. var component = _a[_i];
  137498. if (component.name === name) {
  137499. return component;
  137500. }
  137501. }
  137502. return null;
  137503. };
  137504. /**
  137505. * Gets a string idenfifying the name of the class
  137506. * @returns "Scene" string
  137507. */
  137508. Scene.prototype.getClassName = function () {
  137509. return "Scene";
  137510. };
  137511. /**
  137512. * @hidden
  137513. */
  137514. Scene.prototype._getDefaultMeshCandidates = function () {
  137515. this._defaultMeshCandidates.data = this.meshes;
  137516. this._defaultMeshCandidates.length = this.meshes.length;
  137517. return this._defaultMeshCandidates;
  137518. };
  137519. /**
  137520. * @hidden
  137521. */
  137522. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  137523. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  137524. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  137525. return this._defaultSubMeshCandidates;
  137526. };
  137527. /**
  137528. * Sets the default candidate providers for the scene.
  137529. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  137530. * and getCollidingSubMeshCandidates to their default function
  137531. */
  137532. Scene.prototype.setDefaultCandidateProviders = function () {
  137533. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  137534. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  137535. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  137536. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  137537. };
  137538. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  137539. /**
  137540. * Gets the mesh that is currently under the pointer
  137541. */
  137542. get: function () {
  137543. return this._inputManager.meshUnderPointer;
  137544. },
  137545. enumerable: true,
  137546. configurable: true
  137547. });
  137548. Object.defineProperty(Scene.prototype, "pointerX", {
  137549. /**
  137550. * Gets or sets the current on-screen X position of the pointer
  137551. */
  137552. get: function () {
  137553. return this._inputManager.pointerX;
  137554. },
  137555. set: function (value) {
  137556. this._inputManager.pointerX = value;
  137557. },
  137558. enumerable: true,
  137559. configurable: true
  137560. });
  137561. Object.defineProperty(Scene.prototype, "pointerY", {
  137562. /**
  137563. * Gets or sets the current on-screen Y position of the pointer
  137564. */
  137565. get: function () {
  137566. return this._inputManager.pointerY;
  137567. },
  137568. set: function (value) {
  137569. this._inputManager.pointerY = value;
  137570. },
  137571. enumerable: true,
  137572. configurable: true
  137573. });
  137574. /**
  137575. * Gets the cached material (ie. the latest rendered one)
  137576. * @returns the cached material
  137577. */
  137578. Scene.prototype.getCachedMaterial = function () {
  137579. return this._cachedMaterial;
  137580. };
  137581. /**
  137582. * Gets the cached effect (ie. the latest rendered one)
  137583. * @returns the cached effect
  137584. */
  137585. Scene.prototype.getCachedEffect = function () {
  137586. return this._cachedEffect;
  137587. };
  137588. /**
  137589. * Gets the cached visibility state (ie. the latest rendered one)
  137590. * @returns the cached visibility state
  137591. */
  137592. Scene.prototype.getCachedVisibility = function () {
  137593. return this._cachedVisibility;
  137594. };
  137595. /**
  137596. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  137597. * @param material defines the current material
  137598. * @param effect defines the current effect
  137599. * @param visibility defines the current visibility state
  137600. * @returns true if one parameter is not cached
  137601. */
  137602. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  137603. if (visibility === void 0) { visibility = 1; }
  137604. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  137605. };
  137606. /**
  137607. * Gets the engine associated with the scene
  137608. * @returns an Engine
  137609. */
  137610. Scene.prototype.getEngine = function () {
  137611. return this._engine;
  137612. };
  137613. /**
  137614. * Gets the total number of vertices rendered per frame
  137615. * @returns the total number of vertices rendered per frame
  137616. */
  137617. Scene.prototype.getTotalVertices = function () {
  137618. return this._totalVertices.current;
  137619. };
  137620. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  137621. /**
  137622. * Gets the performance counter for total vertices
  137623. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  137624. */
  137625. get: function () {
  137626. return this._totalVertices;
  137627. },
  137628. enumerable: true,
  137629. configurable: true
  137630. });
  137631. /**
  137632. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  137633. * @returns the total number of active indices rendered per frame
  137634. */
  137635. Scene.prototype.getActiveIndices = function () {
  137636. return this._activeIndices.current;
  137637. };
  137638. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  137639. /**
  137640. * Gets the performance counter for active indices
  137641. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  137642. */
  137643. get: function () {
  137644. return this._activeIndices;
  137645. },
  137646. enumerable: true,
  137647. configurable: true
  137648. });
  137649. /**
  137650. * Gets the total number of active particles rendered per frame
  137651. * @returns the total number of active particles rendered per frame
  137652. */
  137653. Scene.prototype.getActiveParticles = function () {
  137654. return this._activeParticles.current;
  137655. };
  137656. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  137657. /**
  137658. * Gets the performance counter for active particles
  137659. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  137660. */
  137661. get: function () {
  137662. return this._activeParticles;
  137663. },
  137664. enumerable: true,
  137665. configurable: true
  137666. });
  137667. /**
  137668. * Gets the total number of active bones rendered per frame
  137669. * @returns the total number of active bones rendered per frame
  137670. */
  137671. Scene.prototype.getActiveBones = function () {
  137672. return this._activeBones.current;
  137673. };
  137674. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  137675. /**
  137676. * Gets the performance counter for active bones
  137677. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  137678. */
  137679. get: function () {
  137680. return this._activeBones;
  137681. },
  137682. enumerable: true,
  137683. configurable: true
  137684. });
  137685. /**
  137686. * Gets the array of active meshes
  137687. * @returns an array of AbstractMesh
  137688. */
  137689. Scene.prototype.getActiveMeshes = function () {
  137690. return this._activeMeshes;
  137691. };
  137692. /**
  137693. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  137694. * @returns a number
  137695. */
  137696. Scene.prototype.getAnimationRatio = function () {
  137697. return this._animationRatio !== undefined ? this._animationRatio : 1;
  137698. };
  137699. /**
  137700. * Gets an unique Id for the current render phase
  137701. * @returns a number
  137702. */
  137703. Scene.prototype.getRenderId = function () {
  137704. return this._renderId;
  137705. };
  137706. /**
  137707. * Gets an unique Id for the current frame
  137708. * @returns a number
  137709. */
  137710. Scene.prototype.getFrameId = function () {
  137711. return this._frameId;
  137712. };
  137713. /** Call this function if you want to manually increment the render Id*/
  137714. Scene.prototype.incrementRenderId = function () {
  137715. this._renderId++;
  137716. };
  137717. Scene.prototype._createUbo = function () {
  137718. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_13__["UniformBuffer"](this._engine, undefined, true);
  137719. this._sceneUbo.addUniform("viewProjection", 16);
  137720. this._sceneUbo.addUniform("view", 16);
  137721. };
  137722. /**
  137723. * Use this method to simulate a pointer move on a mesh
  137724. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  137725. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  137726. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  137727. * @returns the current scene
  137728. */
  137729. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  137730. this._inputManager.simulatePointerMove(pickResult, pointerEventInit);
  137731. return this;
  137732. };
  137733. /**
  137734. * Use this method to simulate a pointer down on a mesh
  137735. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  137736. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  137737. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  137738. * @returns the current scene
  137739. */
  137740. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  137741. this._inputManager.simulatePointerDown(pickResult, pointerEventInit);
  137742. return this;
  137743. };
  137744. /**
  137745. * Use this method to simulate a pointer up on a mesh
  137746. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  137747. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  137748. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  137749. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  137750. * @returns the current scene
  137751. */
  137752. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  137753. this._inputManager.simulatePointerUp(pickResult, pointerEventInit, doubleTap);
  137754. return this;
  137755. };
  137756. /**
  137757. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  137758. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  137759. * @returns true if the pointer was captured
  137760. */
  137761. Scene.prototype.isPointerCaptured = function (pointerId) {
  137762. if (pointerId === void 0) { pointerId = 0; }
  137763. return this._inputManager.isPointerCaptured(pointerId);
  137764. };
  137765. /**
  137766. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  137767. * @param attachUp defines if you want to attach events to pointerup
  137768. * @param attachDown defines if you want to attach events to pointerdown
  137769. * @param attachMove defines if you want to attach events to pointermove
  137770. */
  137771. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  137772. if (attachUp === void 0) { attachUp = true; }
  137773. if (attachDown === void 0) { attachDown = true; }
  137774. if (attachMove === void 0) { attachMove = true; }
  137775. this._inputManager.attachControl(attachUp, attachDown, attachMove);
  137776. };
  137777. /** Detaches all event handlers*/
  137778. Scene.prototype.detachControl = function () {
  137779. this._inputManager.detachControl();
  137780. };
  137781. /**
  137782. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  137783. * Delay loaded resources are not taking in account
  137784. * @return true if all required resources are ready
  137785. */
  137786. Scene.prototype.isReady = function () {
  137787. if (this._isDisposed) {
  137788. return false;
  137789. }
  137790. var index;
  137791. var engine = this.getEngine();
  137792. // Effects
  137793. if (!engine.areAllEffectsReady()) {
  137794. return false;
  137795. }
  137796. // Pending data
  137797. if (this._pendingData.length > 0) {
  137798. return false;
  137799. }
  137800. // Meshes
  137801. for (index = 0; index < this.meshes.length; index++) {
  137802. var mesh = this.meshes[index];
  137803. if (!mesh.isEnabled()) {
  137804. continue;
  137805. }
  137806. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  137807. continue;
  137808. }
  137809. if (!mesh.isReady(true)) {
  137810. return false;
  137811. }
  137812. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  137813. // Is Ready For Mesh
  137814. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  137815. var step = _a[_i];
  137816. if (!step.action(mesh, hardwareInstancedRendering)) {
  137817. return false;
  137818. }
  137819. }
  137820. }
  137821. // Geometries
  137822. for (index = 0; index < this.geometries.length; index++) {
  137823. var geometry = this.geometries[index];
  137824. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].DELAYLOADSTATE_LOADING) {
  137825. return false;
  137826. }
  137827. }
  137828. // Post-processes
  137829. if (this.activeCameras && this.activeCameras.length > 0) {
  137830. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  137831. var camera = _c[_b];
  137832. if (!camera.isReady(true)) {
  137833. return false;
  137834. }
  137835. }
  137836. }
  137837. else if (this.activeCamera) {
  137838. if (!this.activeCamera.isReady(true)) {
  137839. return false;
  137840. }
  137841. }
  137842. // Particles
  137843. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  137844. var particleSystem = _e[_d];
  137845. if (!particleSystem.isReady()) {
  137846. return false;
  137847. }
  137848. }
  137849. return true;
  137850. };
  137851. /** Resets all cached information relative to material (including effect and visibility) */
  137852. Scene.prototype.resetCachedMaterial = function () {
  137853. this._cachedMaterial = null;
  137854. this._cachedEffect = null;
  137855. this._cachedVisibility = null;
  137856. };
  137857. /**
  137858. * Registers a function to be called before every frame render
  137859. * @param func defines the function to register
  137860. */
  137861. Scene.prototype.registerBeforeRender = function (func) {
  137862. this.onBeforeRenderObservable.add(func);
  137863. };
  137864. /**
  137865. * Unregisters a function called before every frame render
  137866. * @param func defines the function to unregister
  137867. */
  137868. Scene.prototype.unregisterBeforeRender = function (func) {
  137869. this.onBeforeRenderObservable.removeCallback(func);
  137870. };
  137871. /**
  137872. * Registers a function to be called after every frame render
  137873. * @param func defines the function to register
  137874. */
  137875. Scene.prototype.registerAfterRender = function (func) {
  137876. this.onAfterRenderObservable.add(func);
  137877. };
  137878. /**
  137879. * Unregisters a function called after every frame render
  137880. * @param func defines the function to unregister
  137881. */
  137882. Scene.prototype.unregisterAfterRender = function (func) {
  137883. this.onAfterRenderObservable.removeCallback(func);
  137884. };
  137885. Scene.prototype._executeOnceBeforeRender = function (func) {
  137886. var _this = this;
  137887. var execFunc = function () {
  137888. func();
  137889. setTimeout(function () {
  137890. _this.unregisterBeforeRender(execFunc);
  137891. });
  137892. };
  137893. this.registerBeforeRender(execFunc);
  137894. };
  137895. /**
  137896. * The provided function will run before render once and will be disposed afterwards.
  137897. * A timeout delay can be provided so that the function will be executed in N ms.
  137898. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  137899. * @param func The function to be executed.
  137900. * @param timeout optional delay in ms
  137901. */
  137902. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  137903. var _this = this;
  137904. if (timeout !== undefined) {
  137905. setTimeout(function () {
  137906. _this._executeOnceBeforeRender(func);
  137907. }, timeout);
  137908. }
  137909. else {
  137910. this._executeOnceBeforeRender(func);
  137911. }
  137912. };
  137913. /** @hidden */
  137914. Scene.prototype._addPendingData = function (data) {
  137915. this._pendingData.push(data);
  137916. };
  137917. /** @hidden */
  137918. Scene.prototype._removePendingData = function (data) {
  137919. var wasLoading = this.isLoading;
  137920. var index = this._pendingData.indexOf(data);
  137921. if (index !== -1) {
  137922. this._pendingData.splice(index, 1);
  137923. }
  137924. if (wasLoading && !this.isLoading) {
  137925. this.onDataLoadedObservable.notifyObservers(this);
  137926. }
  137927. };
  137928. /**
  137929. * Returns the number of items waiting to be loaded
  137930. * @returns the number of items waiting to be loaded
  137931. */
  137932. Scene.prototype.getWaitingItemsCount = function () {
  137933. return this._pendingData.length;
  137934. };
  137935. Object.defineProperty(Scene.prototype, "isLoading", {
  137936. /**
  137937. * Returns a boolean indicating if the scene is still loading data
  137938. */
  137939. get: function () {
  137940. return this._pendingData.length > 0;
  137941. },
  137942. enumerable: true,
  137943. configurable: true
  137944. });
  137945. /**
  137946. * Registers a function to be executed when the scene is ready
  137947. * @param {Function} func - the function to be executed
  137948. */
  137949. Scene.prototype.executeWhenReady = function (func) {
  137950. var _this = this;
  137951. this.onReadyObservable.add(func);
  137952. if (this._executeWhenReadyTimeoutId !== -1) {
  137953. return;
  137954. }
  137955. this._executeWhenReadyTimeoutId = setTimeout(function () {
  137956. _this._checkIsReady();
  137957. }, 150);
  137958. };
  137959. /**
  137960. * Returns a promise that resolves when the scene is ready
  137961. * @returns A promise that resolves when the scene is ready
  137962. */
  137963. Scene.prototype.whenReadyAsync = function () {
  137964. var _this = this;
  137965. return new Promise(function (resolve) {
  137966. _this.executeWhenReady(function () {
  137967. resolve();
  137968. });
  137969. });
  137970. };
  137971. /** @hidden */
  137972. Scene.prototype._checkIsReady = function () {
  137973. var _this = this;
  137974. this._registerTransientComponents();
  137975. if (this.isReady()) {
  137976. this.onReadyObservable.notifyObservers(this);
  137977. this.onReadyObservable.clear();
  137978. this._executeWhenReadyTimeoutId = -1;
  137979. return;
  137980. }
  137981. this._executeWhenReadyTimeoutId = setTimeout(function () {
  137982. _this._checkIsReady();
  137983. }, 150);
  137984. };
  137985. Object.defineProperty(Scene.prototype, "animatables", {
  137986. /**
  137987. * Gets all animatable attached to the scene
  137988. */
  137989. get: function () {
  137990. return this._activeAnimatables;
  137991. },
  137992. enumerable: true,
  137993. configurable: true
  137994. });
  137995. /**
  137996. * Resets the last animation time frame.
  137997. * Useful to override when animations start running when loading a scene for the first time.
  137998. */
  137999. Scene.prototype.resetLastAnimationTimeFrame = function () {
  138000. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  138001. };
  138002. // Matrix
  138003. /**
  138004. * Gets the current view matrix
  138005. * @returns a Matrix
  138006. */
  138007. Scene.prototype.getViewMatrix = function () {
  138008. return this._viewMatrix;
  138009. };
  138010. /**
  138011. * Gets the current projection matrix
  138012. * @returns a Matrix
  138013. */
  138014. Scene.prototype.getProjectionMatrix = function () {
  138015. return this._projectionMatrix;
  138016. };
  138017. /**
  138018. * Gets the current transform matrix
  138019. * @returns a Matrix made of View * Projection
  138020. */
  138021. Scene.prototype.getTransformMatrix = function () {
  138022. return this._transformMatrix;
  138023. };
  138024. /**
  138025. * Sets the current transform matrix
  138026. * @param viewL defines the View matrix to use
  138027. * @param projectionL defines the Projection matrix to use
  138028. * @param viewR defines the right View matrix to use (if provided)
  138029. * @param projectionR defines the right Projection matrix to use (if provided)
  138030. */
  138031. Scene.prototype.setTransformMatrix = function (viewL, projectionL, viewR, projectionR) {
  138032. if (this._viewUpdateFlag === viewL.updateFlag && this._projectionUpdateFlag === projectionL.updateFlag) {
  138033. return;
  138034. }
  138035. this._viewUpdateFlag = viewL.updateFlag;
  138036. this._projectionUpdateFlag = projectionL.updateFlag;
  138037. this._viewMatrix = viewL;
  138038. this._projectionMatrix = projectionL;
  138039. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  138040. // Update frustum
  138041. if (!this._frustumPlanes) {
  138042. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  138043. }
  138044. else {
  138045. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  138046. }
  138047. if (this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo) {
  138048. this._updateMultiviewUbo(viewR, projectionR);
  138049. }
  138050. else if (this._sceneUbo.useUbo) {
  138051. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  138052. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  138053. this._sceneUbo.update();
  138054. }
  138055. };
  138056. /**
  138057. * Gets the uniform buffer used to store scene data
  138058. * @returns a UniformBuffer
  138059. */
  138060. Scene.prototype.getSceneUniformBuffer = function () {
  138061. return this._multiviewSceneUbo ? this._multiviewSceneUbo : this._sceneUbo;
  138062. };
  138063. /**
  138064. * Gets an unique (relatively to the current scene) Id
  138065. * @returns an unique number for the scene
  138066. */
  138067. Scene.prototype.getUniqueId = function () {
  138068. var result = Scene._uniqueIdCounter;
  138069. Scene._uniqueIdCounter++;
  138070. return result;
  138071. };
  138072. /**
  138073. * Add a mesh to the list of scene's meshes
  138074. * @param newMesh defines the mesh to add
  138075. * @param recursive if all child meshes should also be added to the scene
  138076. */
  138077. Scene.prototype.addMesh = function (newMesh, recursive) {
  138078. var _this = this;
  138079. if (recursive === void 0) { recursive = false; }
  138080. this.meshes.push(newMesh);
  138081. newMesh._resyncLightSources();
  138082. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  138083. if (recursive) {
  138084. newMesh.getChildMeshes().forEach(function (m) {
  138085. _this.addMesh(m);
  138086. });
  138087. }
  138088. };
  138089. /**
  138090. * Remove a mesh for the list of scene's meshes
  138091. * @param toRemove defines the mesh to remove
  138092. * @param recursive if all child meshes should also be removed from the scene
  138093. * @returns the index where the mesh was in the mesh list
  138094. */
  138095. Scene.prototype.removeMesh = function (toRemove, recursive) {
  138096. var _this = this;
  138097. if (recursive === void 0) { recursive = false; }
  138098. var index = this.meshes.indexOf(toRemove);
  138099. if (index !== -1) {
  138100. // Remove from the scene if mesh found
  138101. this.meshes[index] = this.meshes[this.meshes.length - 1];
  138102. this.meshes.pop();
  138103. }
  138104. this.onMeshRemovedObservable.notifyObservers(toRemove);
  138105. if (recursive) {
  138106. toRemove.getChildMeshes().forEach(function (m) {
  138107. _this.removeMesh(m);
  138108. });
  138109. }
  138110. return index;
  138111. };
  138112. /**
  138113. * Add a transform node to the list of scene's transform nodes
  138114. * @param newTransformNode defines the transform node to add
  138115. */
  138116. Scene.prototype.addTransformNode = function (newTransformNode) {
  138117. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  138118. this.transformNodes.push(newTransformNode);
  138119. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  138120. };
  138121. /**
  138122. * Remove a transform node for the list of scene's transform nodes
  138123. * @param toRemove defines the transform node to remove
  138124. * @returns the index where the transform node was in the transform node list
  138125. */
  138126. Scene.prototype.removeTransformNode = function (toRemove) {
  138127. var index = toRemove._indexInSceneTransformNodesArray;
  138128. if (index !== -1) {
  138129. if (index !== this.transformNodes.length - 1) {
  138130. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  138131. this.transformNodes[index] = lastNode;
  138132. lastNode._indexInSceneTransformNodesArray = index;
  138133. }
  138134. toRemove._indexInSceneTransformNodesArray = -1;
  138135. this.transformNodes.pop();
  138136. }
  138137. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  138138. return index;
  138139. };
  138140. /**
  138141. * Remove a skeleton for the list of scene's skeletons
  138142. * @param toRemove defines the skeleton to remove
  138143. * @returns the index where the skeleton was in the skeleton list
  138144. */
  138145. Scene.prototype.removeSkeleton = function (toRemove) {
  138146. var index = this.skeletons.indexOf(toRemove);
  138147. if (index !== -1) {
  138148. // Remove from the scene if found
  138149. this.skeletons.splice(index, 1);
  138150. this.onSkeletonRemovedObservable.notifyObservers(toRemove);
  138151. }
  138152. return index;
  138153. };
  138154. /**
  138155. * Remove a morph target for the list of scene's morph targets
  138156. * @param toRemove defines the morph target to remove
  138157. * @returns the index where the morph target was in the morph target list
  138158. */
  138159. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  138160. var index = this.morphTargetManagers.indexOf(toRemove);
  138161. if (index !== -1) {
  138162. // Remove from the scene if found
  138163. this.morphTargetManagers.splice(index, 1);
  138164. }
  138165. return index;
  138166. };
  138167. /**
  138168. * Remove a light for the list of scene's lights
  138169. * @param toRemove defines the light to remove
  138170. * @returns the index where the light was in the light list
  138171. */
  138172. Scene.prototype.removeLight = function (toRemove) {
  138173. var index = this.lights.indexOf(toRemove);
  138174. if (index !== -1) {
  138175. // Remove from meshes
  138176. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  138177. var mesh = _a[_i];
  138178. mesh._removeLightSource(toRemove);
  138179. }
  138180. // Remove from the scene if mesh found
  138181. this.lights.splice(index, 1);
  138182. this.sortLightsByPriority();
  138183. }
  138184. this.onLightRemovedObservable.notifyObservers(toRemove);
  138185. return index;
  138186. };
  138187. /**
  138188. * Remove a camera for the list of scene's cameras
  138189. * @param toRemove defines the camera to remove
  138190. * @returns the index where the camera was in the camera list
  138191. */
  138192. Scene.prototype.removeCamera = function (toRemove) {
  138193. var index = this.cameras.indexOf(toRemove);
  138194. if (index !== -1) {
  138195. // Remove from the scene if mesh found
  138196. this.cameras.splice(index, 1);
  138197. }
  138198. // Remove from activeCameras
  138199. var index2 = this.activeCameras.indexOf(toRemove);
  138200. if (index2 !== -1) {
  138201. // Remove from the scene if mesh found
  138202. this.activeCameras.splice(index2, 1);
  138203. }
  138204. // Reset the activeCamera
  138205. if (this.activeCamera === toRemove) {
  138206. if (this.cameras.length > 0) {
  138207. this.activeCamera = this.cameras[0];
  138208. }
  138209. else {
  138210. this.activeCamera = null;
  138211. }
  138212. }
  138213. this.onCameraRemovedObservable.notifyObservers(toRemove);
  138214. return index;
  138215. };
  138216. /**
  138217. * Remove a particle system for the list of scene's particle systems
  138218. * @param toRemove defines the particle system to remove
  138219. * @returns the index where the particle system was in the particle system list
  138220. */
  138221. Scene.prototype.removeParticleSystem = function (toRemove) {
  138222. var index = this.particleSystems.indexOf(toRemove);
  138223. if (index !== -1) {
  138224. this.particleSystems.splice(index, 1);
  138225. }
  138226. return index;
  138227. };
  138228. /**
  138229. * Remove a animation for the list of scene's animations
  138230. * @param toRemove defines the animation to remove
  138231. * @returns the index where the animation was in the animation list
  138232. */
  138233. Scene.prototype.removeAnimation = function (toRemove) {
  138234. var index = this.animations.indexOf(toRemove);
  138235. if (index !== -1) {
  138236. this.animations.splice(index, 1);
  138237. }
  138238. return index;
  138239. };
  138240. /**
  138241. * Will stop the animation of the given target
  138242. * @param target - the target
  138243. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  138244. * @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)
  138245. */
  138246. Scene.prototype.stopAnimation = function (target, animationName, targetMask) {
  138247. // Do nothing as code will be provided by animation component
  138248. };
  138249. /**
  138250. * Removes the given animation group from this scene.
  138251. * @param toRemove The animation group to remove
  138252. * @returns The index of the removed animation group
  138253. */
  138254. Scene.prototype.removeAnimationGroup = function (toRemove) {
  138255. var index = this.animationGroups.indexOf(toRemove);
  138256. if (index !== -1) {
  138257. this.animationGroups.splice(index, 1);
  138258. }
  138259. return index;
  138260. };
  138261. /**
  138262. * Removes the given multi-material from this scene.
  138263. * @param toRemove The multi-material to remove
  138264. * @returns The index of the removed multi-material
  138265. */
  138266. Scene.prototype.removeMultiMaterial = function (toRemove) {
  138267. var index = this.multiMaterials.indexOf(toRemove);
  138268. if (index !== -1) {
  138269. this.multiMaterials.splice(index, 1);
  138270. }
  138271. return index;
  138272. };
  138273. /**
  138274. * Removes the given material from this scene.
  138275. * @param toRemove The material to remove
  138276. * @returns The index of the removed material
  138277. */
  138278. Scene.prototype.removeMaterial = function (toRemove) {
  138279. var index = toRemove._indexInSceneMaterialArray;
  138280. if (index !== -1 && index < this.materials.length) {
  138281. if (index !== this.materials.length - 1) {
  138282. var lastMaterial = this.materials[this.materials.length - 1];
  138283. this.materials[index] = lastMaterial;
  138284. lastMaterial._indexInSceneMaterialArray = index;
  138285. }
  138286. toRemove._indexInSceneMaterialArray = -1;
  138287. this.materials.pop();
  138288. }
  138289. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  138290. return index;
  138291. };
  138292. /**
  138293. * Removes the given action manager from this scene.
  138294. * @param toRemove The action manager to remove
  138295. * @returns The index of the removed action manager
  138296. */
  138297. Scene.prototype.removeActionManager = function (toRemove) {
  138298. var index = this.actionManagers.indexOf(toRemove);
  138299. if (index !== -1) {
  138300. this.actionManagers.splice(index, 1);
  138301. }
  138302. return index;
  138303. };
  138304. /**
  138305. * Removes the given texture from this scene.
  138306. * @param toRemove The texture to remove
  138307. * @returns The index of the removed texture
  138308. */
  138309. Scene.prototype.removeTexture = function (toRemove) {
  138310. var index = this.textures.indexOf(toRemove);
  138311. if (index !== -1) {
  138312. this.textures.splice(index, 1);
  138313. }
  138314. this.onTextureRemovedObservable.notifyObservers(toRemove);
  138315. return index;
  138316. };
  138317. /**
  138318. * Adds the given light to this scene
  138319. * @param newLight The light to add
  138320. */
  138321. Scene.prototype.addLight = function (newLight) {
  138322. this.lights.push(newLight);
  138323. this.sortLightsByPriority();
  138324. // Add light to all meshes (To support if the light is removed and then readded)
  138325. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  138326. var mesh = _a[_i];
  138327. if (mesh.lightSources.indexOf(newLight) === -1) {
  138328. mesh.lightSources.push(newLight);
  138329. mesh._resyncLightSources();
  138330. }
  138331. }
  138332. this.onNewLightAddedObservable.notifyObservers(newLight);
  138333. };
  138334. /**
  138335. * Sorts the list list based on light priorities
  138336. */
  138337. Scene.prototype.sortLightsByPriority = function () {
  138338. if (this.requireLightSorting) {
  138339. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_14__["Light"].CompareLightsPriority);
  138340. }
  138341. };
  138342. /**
  138343. * Adds the given camera to this scene
  138344. * @param newCamera The camera to add
  138345. */
  138346. Scene.prototype.addCamera = function (newCamera) {
  138347. this.cameras.push(newCamera);
  138348. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  138349. };
  138350. /**
  138351. * Adds the given skeleton to this scene
  138352. * @param newSkeleton The skeleton to add
  138353. */
  138354. Scene.prototype.addSkeleton = function (newSkeleton) {
  138355. this.skeletons.push(newSkeleton);
  138356. this.onNewSkeletonAddedObservable.notifyObservers(newSkeleton);
  138357. };
  138358. /**
  138359. * Adds the given particle system to this scene
  138360. * @param newParticleSystem The particle system to add
  138361. */
  138362. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  138363. this.particleSystems.push(newParticleSystem);
  138364. };
  138365. /**
  138366. * Adds the given animation to this scene
  138367. * @param newAnimation The animation to add
  138368. */
  138369. Scene.prototype.addAnimation = function (newAnimation) {
  138370. this.animations.push(newAnimation);
  138371. };
  138372. /**
  138373. * Adds the given animation group to this scene.
  138374. * @param newAnimationGroup The animation group to add
  138375. */
  138376. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  138377. this.animationGroups.push(newAnimationGroup);
  138378. };
  138379. /**
  138380. * Adds the given multi-material to this scene
  138381. * @param newMultiMaterial The multi-material to add
  138382. */
  138383. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  138384. this.multiMaterials.push(newMultiMaterial);
  138385. };
  138386. /**
  138387. * Adds the given material to this scene
  138388. * @param newMaterial The material to add
  138389. */
  138390. Scene.prototype.addMaterial = function (newMaterial) {
  138391. newMaterial._indexInSceneMaterialArray = this.materials.length;
  138392. this.materials.push(newMaterial);
  138393. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  138394. };
  138395. /**
  138396. * Adds the given morph target to this scene
  138397. * @param newMorphTargetManager The morph target to add
  138398. */
  138399. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  138400. this.morphTargetManagers.push(newMorphTargetManager);
  138401. };
  138402. /**
  138403. * Adds the given geometry to this scene
  138404. * @param newGeometry The geometry to add
  138405. */
  138406. Scene.prototype.addGeometry = function (newGeometry) {
  138407. if (this.geometriesByUniqueId) {
  138408. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  138409. }
  138410. this.geometries.push(newGeometry);
  138411. };
  138412. /**
  138413. * Adds the given action manager to this scene
  138414. * @param newActionManager The action manager to add
  138415. */
  138416. Scene.prototype.addActionManager = function (newActionManager) {
  138417. this.actionManagers.push(newActionManager);
  138418. };
  138419. /**
  138420. * Adds the given texture to this scene.
  138421. * @param newTexture The texture to add
  138422. */
  138423. Scene.prototype.addTexture = function (newTexture) {
  138424. this.textures.push(newTexture);
  138425. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  138426. };
  138427. /**
  138428. * Switch active camera
  138429. * @param newCamera defines the new active camera
  138430. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  138431. */
  138432. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  138433. if (attachControl === void 0) { attachControl = true; }
  138434. var canvas = this._engine.getRenderingCanvas();
  138435. if (!canvas) {
  138436. return;
  138437. }
  138438. if (this.activeCamera) {
  138439. this.activeCamera.detachControl(canvas);
  138440. }
  138441. this.activeCamera = newCamera;
  138442. if (attachControl) {
  138443. newCamera.attachControl(canvas);
  138444. }
  138445. };
  138446. /**
  138447. * sets the active camera of the scene using its ID
  138448. * @param id defines the camera's ID
  138449. * @return the new active camera or null if none found.
  138450. */
  138451. Scene.prototype.setActiveCameraByID = function (id) {
  138452. var camera = this.getCameraByID(id);
  138453. if (camera) {
  138454. this.activeCamera = camera;
  138455. return camera;
  138456. }
  138457. return null;
  138458. };
  138459. /**
  138460. * sets the active camera of the scene using its name
  138461. * @param name defines the camera's name
  138462. * @returns the new active camera or null if none found.
  138463. */
  138464. Scene.prototype.setActiveCameraByName = function (name) {
  138465. var camera = this.getCameraByName(name);
  138466. if (camera) {
  138467. this.activeCamera = camera;
  138468. return camera;
  138469. }
  138470. return null;
  138471. };
  138472. /**
  138473. * get an animation group using its name
  138474. * @param name defines the material's name
  138475. * @return the animation group or null if none found.
  138476. */
  138477. Scene.prototype.getAnimationGroupByName = function (name) {
  138478. for (var index = 0; index < this.animationGroups.length; index++) {
  138479. if (this.animationGroups[index].name === name) {
  138480. return this.animationGroups[index];
  138481. }
  138482. }
  138483. return null;
  138484. };
  138485. /**
  138486. * Get a material using its unique id
  138487. * @param uniqueId defines the material's unique id
  138488. * @return the material or null if none found.
  138489. */
  138490. Scene.prototype.getMaterialByUniqueID = function (uniqueId) {
  138491. for (var index = 0; index < this.materials.length; index++) {
  138492. if (this.materials[index].uniqueId === uniqueId) {
  138493. return this.materials[index];
  138494. }
  138495. }
  138496. return null;
  138497. };
  138498. /**
  138499. * get a material using its id
  138500. * @param id defines the material's ID
  138501. * @return the material or null if none found.
  138502. */
  138503. Scene.prototype.getMaterialByID = function (id) {
  138504. for (var index = 0; index < this.materials.length; index++) {
  138505. if (this.materials[index].id === id) {
  138506. return this.materials[index];
  138507. }
  138508. }
  138509. return null;
  138510. };
  138511. /**
  138512. * Gets a material using its name
  138513. * @param name defines the material's name
  138514. * @return the material or null if none found.
  138515. */
  138516. Scene.prototype.getMaterialByName = function (name) {
  138517. for (var index = 0; index < this.materials.length; index++) {
  138518. if (this.materials[index].name === name) {
  138519. return this.materials[index];
  138520. }
  138521. }
  138522. return null;
  138523. };
  138524. /**
  138525. * Gets a camera using its id
  138526. * @param id defines the id to look for
  138527. * @returns the camera or null if not found
  138528. */
  138529. Scene.prototype.getCameraByID = function (id) {
  138530. for (var index = 0; index < this.cameras.length; index++) {
  138531. if (this.cameras[index].id === id) {
  138532. return this.cameras[index];
  138533. }
  138534. }
  138535. return null;
  138536. };
  138537. /**
  138538. * Gets a camera using its unique id
  138539. * @param uniqueId defines the unique id to look for
  138540. * @returns the camera or null if not found
  138541. */
  138542. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  138543. for (var index = 0; index < this.cameras.length; index++) {
  138544. if (this.cameras[index].uniqueId === uniqueId) {
  138545. return this.cameras[index];
  138546. }
  138547. }
  138548. return null;
  138549. };
  138550. /**
  138551. * Gets a camera using its name
  138552. * @param name defines the camera's name
  138553. * @return the camera or null if none found.
  138554. */
  138555. Scene.prototype.getCameraByName = function (name) {
  138556. for (var index = 0; index < this.cameras.length; index++) {
  138557. if (this.cameras[index].name === name) {
  138558. return this.cameras[index];
  138559. }
  138560. }
  138561. return null;
  138562. };
  138563. /**
  138564. * Gets a bone using its id
  138565. * @param id defines the bone's id
  138566. * @return the bone or null if not found
  138567. */
  138568. Scene.prototype.getBoneByID = function (id) {
  138569. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  138570. var skeleton = this.skeletons[skeletonIndex];
  138571. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  138572. if (skeleton.bones[boneIndex].id === id) {
  138573. return skeleton.bones[boneIndex];
  138574. }
  138575. }
  138576. }
  138577. return null;
  138578. };
  138579. /**
  138580. * Gets a bone using its id
  138581. * @param name defines the bone's name
  138582. * @return the bone or null if not found
  138583. */
  138584. Scene.prototype.getBoneByName = function (name) {
  138585. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  138586. var skeleton = this.skeletons[skeletonIndex];
  138587. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  138588. if (skeleton.bones[boneIndex].name === name) {
  138589. return skeleton.bones[boneIndex];
  138590. }
  138591. }
  138592. }
  138593. return null;
  138594. };
  138595. /**
  138596. * Gets a light node using its name
  138597. * @param name defines the the light's name
  138598. * @return the light or null if none found.
  138599. */
  138600. Scene.prototype.getLightByName = function (name) {
  138601. for (var index = 0; index < this.lights.length; index++) {
  138602. if (this.lights[index].name === name) {
  138603. return this.lights[index];
  138604. }
  138605. }
  138606. return null;
  138607. };
  138608. /**
  138609. * Gets a light node using its id
  138610. * @param id defines the light's id
  138611. * @return the light or null if none found.
  138612. */
  138613. Scene.prototype.getLightByID = function (id) {
  138614. for (var index = 0; index < this.lights.length; index++) {
  138615. if (this.lights[index].id === id) {
  138616. return this.lights[index];
  138617. }
  138618. }
  138619. return null;
  138620. };
  138621. /**
  138622. * Gets a light node using its scene-generated unique ID
  138623. * @param uniqueId defines the light's unique id
  138624. * @return the light or null if none found.
  138625. */
  138626. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  138627. for (var index = 0; index < this.lights.length; index++) {
  138628. if (this.lights[index].uniqueId === uniqueId) {
  138629. return this.lights[index];
  138630. }
  138631. }
  138632. return null;
  138633. };
  138634. /**
  138635. * Gets a particle system by id
  138636. * @param id defines the particle system id
  138637. * @return the corresponding system or null if none found
  138638. */
  138639. Scene.prototype.getParticleSystemByID = function (id) {
  138640. for (var index = 0; index < this.particleSystems.length; index++) {
  138641. if (this.particleSystems[index].id === id) {
  138642. return this.particleSystems[index];
  138643. }
  138644. }
  138645. return null;
  138646. };
  138647. /**
  138648. * Gets a geometry using its ID
  138649. * @param id defines the geometry's id
  138650. * @return the geometry or null if none found.
  138651. */
  138652. Scene.prototype.getGeometryByID = function (id) {
  138653. for (var index = 0; index < this.geometries.length; index++) {
  138654. if (this.geometries[index].id === id) {
  138655. return this.geometries[index];
  138656. }
  138657. }
  138658. return null;
  138659. };
  138660. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  138661. if (this.geometriesByUniqueId) {
  138662. var index_1 = this.geometriesByUniqueId[uniqueId];
  138663. if (index_1 !== undefined) {
  138664. return this.geometries[index_1];
  138665. }
  138666. }
  138667. else {
  138668. for (var index = 0; index < this.geometries.length; index++) {
  138669. if (this.geometries[index].uniqueId === uniqueId) {
  138670. return this.geometries[index];
  138671. }
  138672. }
  138673. }
  138674. return null;
  138675. };
  138676. /**
  138677. * Add a new geometry to this scene
  138678. * @param geometry defines the geometry to be added to the scene.
  138679. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  138680. * @return a boolean defining if the geometry was added or not
  138681. */
  138682. Scene.prototype.pushGeometry = function (geometry, force) {
  138683. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  138684. return false;
  138685. }
  138686. this.addGeometry(geometry);
  138687. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  138688. return true;
  138689. };
  138690. /**
  138691. * Removes an existing geometry
  138692. * @param geometry defines the geometry to be removed from the scene
  138693. * @return a boolean defining if the geometry was removed or not
  138694. */
  138695. Scene.prototype.removeGeometry = function (geometry) {
  138696. var index;
  138697. if (this.geometriesByUniqueId) {
  138698. index = this.geometriesByUniqueId[geometry.uniqueId];
  138699. if (index === undefined) {
  138700. return false;
  138701. }
  138702. }
  138703. else {
  138704. index = this.geometries.indexOf(geometry);
  138705. if (index < 0) {
  138706. return false;
  138707. }
  138708. }
  138709. if (index !== this.geometries.length - 1) {
  138710. var lastGeometry = this.geometries[this.geometries.length - 1];
  138711. this.geometries[index] = lastGeometry;
  138712. if (this.geometriesByUniqueId) {
  138713. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  138714. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  138715. }
  138716. }
  138717. this.geometries.pop();
  138718. this.onGeometryRemovedObservable.notifyObservers(geometry);
  138719. return true;
  138720. };
  138721. /**
  138722. * Gets the list of geometries attached to the scene
  138723. * @returns an array of Geometry
  138724. */
  138725. Scene.prototype.getGeometries = function () {
  138726. return this.geometries;
  138727. };
  138728. /**
  138729. * Gets the first added mesh found of a given ID
  138730. * @param id defines the id to search for
  138731. * @return the mesh found or null if not found at all
  138732. */
  138733. Scene.prototype.getMeshByID = function (id) {
  138734. for (var index = 0; index < this.meshes.length; index++) {
  138735. if (this.meshes[index].id === id) {
  138736. return this.meshes[index];
  138737. }
  138738. }
  138739. return null;
  138740. };
  138741. /**
  138742. * Gets a list of meshes using their id
  138743. * @param id defines the id to search for
  138744. * @returns a list of meshes
  138745. */
  138746. Scene.prototype.getMeshesByID = function (id) {
  138747. return this.meshes.filter(function (m) {
  138748. return m.id === id;
  138749. });
  138750. };
  138751. /**
  138752. * Gets the first added transform node found of a given ID
  138753. * @param id defines the id to search for
  138754. * @return the found transform node or null if not found at all.
  138755. */
  138756. Scene.prototype.getTransformNodeByID = function (id) {
  138757. for (var index = 0; index < this.transformNodes.length; index++) {
  138758. if (this.transformNodes[index].id === id) {
  138759. return this.transformNodes[index];
  138760. }
  138761. }
  138762. return null;
  138763. };
  138764. /**
  138765. * Gets a transform node with its auto-generated unique id
  138766. * @param uniqueId efines the unique id to search for
  138767. * @return the found transform node or null if not found at all.
  138768. */
  138769. Scene.prototype.getTransformNodeByUniqueID = function (uniqueId) {
  138770. for (var index = 0; index < this.transformNodes.length; index++) {
  138771. if (this.transformNodes[index].uniqueId === uniqueId) {
  138772. return this.transformNodes[index];
  138773. }
  138774. }
  138775. return null;
  138776. };
  138777. /**
  138778. * Gets a list of transform nodes using their id
  138779. * @param id defines the id to search for
  138780. * @returns a list of transform nodes
  138781. */
  138782. Scene.prototype.getTransformNodesByID = function (id) {
  138783. return this.transformNodes.filter(function (m) {
  138784. return m.id === id;
  138785. });
  138786. };
  138787. /**
  138788. * Gets a mesh with its auto-generated unique id
  138789. * @param uniqueId defines the unique id to search for
  138790. * @return the found mesh or null if not found at all.
  138791. */
  138792. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  138793. for (var index = 0; index < this.meshes.length; index++) {
  138794. if (this.meshes[index].uniqueId === uniqueId) {
  138795. return this.meshes[index];
  138796. }
  138797. }
  138798. return null;
  138799. };
  138800. /**
  138801. * Gets a the last added mesh using a given id
  138802. * @param id defines the id to search for
  138803. * @return the found mesh or null if not found at all.
  138804. */
  138805. Scene.prototype.getLastMeshByID = function (id) {
  138806. for (var index = this.meshes.length - 1; index >= 0; index--) {
  138807. if (this.meshes[index].id === id) {
  138808. return this.meshes[index];
  138809. }
  138810. }
  138811. return null;
  138812. };
  138813. /**
  138814. * Gets a the last added node (Mesh, Camera, Light) using a given id
  138815. * @param id defines the id to search for
  138816. * @return the found node or null if not found at all
  138817. */
  138818. Scene.prototype.getLastEntryByID = function (id) {
  138819. var index;
  138820. for (index = this.meshes.length - 1; index >= 0; index--) {
  138821. if (this.meshes[index].id === id) {
  138822. return this.meshes[index];
  138823. }
  138824. }
  138825. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  138826. if (this.transformNodes[index].id === id) {
  138827. return this.transformNodes[index];
  138828. }
  138829. }
  138830. for (index = this.cameras.length - 1; index >= 0; index--) {
  138831. if (this.cameras[index].id === id) {
  138832. return this.cameras[index];
  138833. }
  138834. }
  138835. for (index = this.lights.length - 1; index >= 0; index--) {
  138836. if (this.lights[index].id === id) {
  138837. return this.lights[index];
  138838. }
  138839. }
  138840. return null;
  138841. };
  138842. /**
  138843. * Gets a node (Mesh, Camera, Light) using a given id
  138844. * @param id defines the id to search for
  138845. * @return the found node or null if not found at all
  138846. */
  138847. Scene.prototype.getNodeByID = function (id) {
  138848. var mesh = this.getMeshByID(id);
  138849. if (mesh) {
  138850. return mesh;
  138851. }
  138852. var transformNode = this.getTransformNodeByID(id);
  138853. if (transformNode) {
  138854. return transformNode;
  138855. }
  138856. var light = this.getLightByID(id);
  138857. if (light) {
  138858. return light;
  138859. }
  138860. var camera = this.getCameraByID(id);
  138861. if (camera) {
  138862. return camera;
  138863. }
  138864. var bone = this.getBoneByID(id);
  138865. if (bone) {
  138866. return bone;
  138867. }
  138868. return null;
  138869. };
  138870. /**
  138871. * Gets a node (Mesh, Camera, Light) using a given name
  138872. * @param name defines the name to search for
  138873. * @return the found node or null if not found at all.
  138874. */
  138875. Scene.prototype.getNodeByName = function (name) {
  138876. var mesh = this.getMeshByName(name);
  138877. if (mesh) {
  138878. return mesh;
  138879. }
  138880. var transformNode = this.getTransformNodeByName(name);
  138881. if (transformNode) {
  138882. return transformNode;
  138883. }
  138884. var light = this.getLightByName(name);
  138885. if (light) {
  138886. return light;
  138887. }
  138888. var camera = this.getCameraByName(name);
  138889. if (camera) {
  138890. return camera;
  138891. }
  138892. var bone = this.getBoneByName(name);
  138893. if (bone) {
  138894. return bone;
  138895. }
  138896. return null;
  138897. };
  138898. /**
  138899. * Gets a mesh using a given name
  138900. * @param name defines the name to search for
  138901. * @return the found mesh or null if not found at all.
  138902. */
  138903. Scene.prototype.getMeshByName = function (name) {
  138904. for (var index = 0; index < this.meshes.length; index++) {
  138905. if (this.meshes[index].name === name) {
  138906. return this.meshes[index];
  138907. }
  138908. }
  138909. return null;
  138910. };
  138911. /**
  138912. * Gets a transform node using a given name
  138913. * @param name defines the name to search for
  138914. * @return the found transform node or null if not found at all.
  138915. */
  138916. Scene.prototype.getTransformNodeByName = function (name) {
  138917. for (var index = 0; index < this.transformNodes.length; index++) {
  138918. if (this.transformNodes[index].name === name) {
  138919. return this.transformNodes[index];
  138920. }
  138921. }
  138922. return null;
  138923. };
  138924. /**
  138925. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  138926. * @param id defines the id to search for
  138927. * @return the found skeleton or null if not found at all.
  138928. */
  138929. Scene.prototype.getLastSkeletonByID = function (id) {
  138930. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  138931. if (this.skeletons[index].id === id) {
  138932. return this.skeletons[index];
  138933. }
  138934. }
  138935. return null;
  138936. };
  138937. /**
  138938. * Gets a skeleton using a given auto generated unique id
  138939. * @param uniqueId defines the unique id to search for
  138940. * @return the found skeleton or null if not found at all.
  138941. */
  138942. Scene.prototype.getSkeletonByUniqueId = function (uniqueId) {
  138943. for (var index = 0; index < this.skeletons.length; index++) {
  138944. if (this.skeletons[index].uniqueId === uniqueId) {
  138945. return this.skeletons[index];
  138946. }
  138947. }
  138948. return null;
  138949. };
  138950. /**
  138951. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  138952. * @param id defines the id to search for
  138953. * @return the found skeleton or null if not found at all.
  138954. */
  138955. Scene.prototype.getSkeletonById = function (id) {
  138956. for (var index = 0; index < this.skeletons.length; index++) {
  138957. if (this.skeletons[index].id === id) {
  138958. return this.skeletons[index];
  138959. }
  138960. }
  138961. return null;
  138962. };
  138963. /**
  138964. * Gets a skeleton using a given name
  138965. * @param name defines the name to search for
  138966. * @return the found skeleton or null if not found at all.
  138967. */
  138968. Scene.prototype.getSkeletonByName = function (name) {
  138969. for (var index = 0; index < this.skeletons.length; index++) {
  138970. if (this.skeletons[index].name === name) {
  138971. return this.skeletons[index];
  138972. }
  138973. }
  138974. return null;
  138975. };
  138976. /**
  138977. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  138978. * @param id defines the id to search for
  138979. * @return the found morph target manager or null if not found at all.
  138980. */
  138981. Scene.prototype.getMorphTargetManagerById = function (id) {
  138982. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  138983. if (this.morphTargetManagers[index].uniqueId === id) {
  138984. return this.morphTargetManagers[index];
  138985. }
  138986. }
  138987. return null;
  138988. };
  138989. /**
  138990. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  138991. * @param id defines the id to search for
  138992. * @return the found morph target or null if not found at all.
  138993. */
  138994. Scene.prototype.getMorphTargetById = function (id) {
  138995. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  138996. var morphTargetManager = this.morphTargetManagers[managerIndex];
  138997. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  138998. var target = morphTargetManager.getTarget(index);
  138999. if (target.id === id) {
  139000. return target;
  139001. }
  139002. }
  139003. }
  139004. return null;
  139005. };
  139006. /**
  139007. * Gets a boolean indicating if the given mesh is active
  139008. * @param mesh defines the mesh to look for
  139009. * @returns true if the mesh is in the active list
  139010. */
  139011. Scene.prototype.isActiveMesh = function (mesh) {
  139012. return (this._activeMeshes.indexOf(mesh) !== -1);
  139013. };
  139014. Object.defineProperty(Scene.prototype, "uid", {
  139015. /**
  139016. * Return a unique id as a string which can serve as an identifier for the scene
  139017. */
  139018. get: function () {
  139019. if (!this._uid) {
  139020. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  139021. }
  139022. return this._uid;
  139023. },
  139024. enumerable: true,
  139025. configurable: true
  139026. });
  139027. /**
  139028. * Add an externaly attached data from its key.
  139029. * This method call will fail and return false, if such key already exists.
  139030. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  139031. * @param key the unique key that identifies the data
  139032. * @param data the data object to associate to the key for this Engine instance
  139033. * @return true if no such key were already present and the data was added successfully, false otherwise
  139034. */
  139035. Scene.prototype.addExternalData = function (key, data) {
  139036. if (!this._externalData) {
  139037. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  139038. }
  139039. return this._externalData.add(key, data);
  139040. };
  139041. /**
  139042. * Get an externaly attached data from its key
  139043. * @param key the unique key that identifies the data
  139044. * @return the associated data, if present (can be null), or undefined if not present
  139045. */
  139046. Scene.prototype.getExternalData = function (key) {
  139047. if (!this._externalData) {
  139048. return null;
  139049. }
  139050. return this._externalData.get(key);
  139051. };
  139052. /**
  139053. * Get an externaly attached data from its key, create it using a factory if it's not already present
  139054. * @param key the unique key that identifies the data
  139055. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  139056. * @return the associated data, can be null if the factory returned null.
  139057. */
  139058. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  139059. if (!this._externalData) {
  139060. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  139061. }
  139062. return this._externalData.getOrAddWithFactory(key, factory);
  139063. };
  139064. /**
  139065. * Remove an externaly attached data from the Engine instance
  139066. * @param key the unique key that identifies the data
  139067. * @return true if the data was successfully removed, false if it doesn't exist
  139068. */
  139069. Scene.prototype.removeExternalData = function (key) {
  139070. return this._externalData.remove(key);
  139071. };
  139072. Scene.prototype._evaluateSubMesh = function (subMesh, mesh, initialMesh) {
  139073. if (initialMesh.isAnInstance || this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  139074. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  139075. var step = _a[_i];
  139076. step.action(mesh, subMesh);
  139077. }
  139078. var material = subMesh.getMaterial();
  139079. if (material !== null && material !== undefined) {
  139080. // Render targets
  139081. if (material.hasRenderTargetTextures && material.getRenderTargetTextures != null) {
  139082. if (this._processedMaterials.indexOf(material) === -1) {
  139083. this._processedMaterials.push(material);
  139084. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  139085. }
  139086. }
  139087. // Dispatch
  139088. this._activeIndices.addCount(subMesh.indexCount, false);
  139089. this._renderingManager.dispatch(subMesh, mesh, material);
  139090. }
  139091. }
  139092. };
  139093. /**
  139094. * Clear the processed materials smart array preventing retention point in material dispose.
  139095. */
  139096. Scene.prototype.freeProcessedMaterials = function () {
  139097. this._processedMaterials.dispose();
  139098. };
  139099. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  139100. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  139101. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  139102. * when disposing several meshes in a row or a hierarchy of meshes.
  139103. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  139104. */
  139105. get: function () {
  139106. return this._preventFreeActiveMeshesAndRenderingGroups;
  139107. },
  139108. set: function (value) {
  139109. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  139110. return;
  139111. }
  139112. if (value) {
  139113. this.freeActiveMeshes();
  139114. this.freeRenderingGroups();
  139115. }
  139116. this._preventFreeActiveMeshesAndRenderingGroups = value;
  139117. },
  139118. enumerable: true,
  139119. configurable: true
  139120. });
  139121. /**
  139122. * Clear the active meshes smart array preventing retention point in mesh dispose.
  139123. */
  139124. Scene.prototype.freeActiveMeshes = function () {
  139125. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  139126. return;
  139127. }
  139128. this._activeMeshes.dispose();
  139129. if (this.activeCamera && this.activeCamera._activeMeshes) {
  139130. this.activeCamera._activeMeshes.dispose();
  139131. }
  139132. if (this.activeCameras) {
  139133. for (var i = 0; i < this.activeCameras.length; i++) {
  139134. var activeCamera = this.activeCameras[i];
  139135. if (activeCamera && activeCamera._activeMeshes) {
  139136. activeCamera._activeMeshes.dispose();
  139137. }
  139138. }
  139139. }
  139140. };
  139141. /**
  139142. * Clear the info related to rendering groups preventing retention points during dispose.
  139143. */
  139144. Scene.prototype.freeRenderingGroups = function () {
  139145. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  139146. return;
  139147. }
  139148. if (this._renderingManager) {
  139149. this._renderingManager.freeRenderingGroups();
  139150. }
  139151. if (this.textures) {
  139152. for (var i = 0; i < this.textures.length; i++) {
  139153. var texture = this.textures[i];
  139154. if (texture && texture.renderList) {
  139155. texture.freeRenderingGroups();
  139156. }
  139157. }
  139158. }
  139159. };
  139160. /** @hidden */
  139161. Scene.prototype._isInIntermediateRendering = function () {
  139162. return this._intermediateRendering;
  139163. };
  139164. /**
  139165. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  139166. * @returns the current scene
  139167. */
  139168. Scene.prototype.freezeActiveMeshes = function () {
  139169. if (!this.activeCamera) {
  139170. return this;
  139171. }
  139172. if (!this._frustumPlanes) {
  139173. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  139174. }
  139175. this._evaluateActiveMeshes();
  139176. this._activeMeshesFrozen = true;
  139177. for (var index = 0; index < this._activeMeshes.length; index++) {
  139178. this._activeMeshes.data[index]._freeze();
  139179. }
  139180. return this;
  139181. };
  139182. /**
  139183. * Use this function to restart evaluating active meshes on every frame
  139184. * @returns the current scene
  139185. */
  139186. Scene.prototype.unfreezeActiveMeshes = function () {
  139187. for (var index = 0; index < this._activeMeshes.length; index++) {
  139188. this._activeMeshes.data[index]._unFreeze();
  139189. }
  139190. this._activeMeshesFrozen = false;
  139191. return this;
  139192. };
  139193. Scene.prototype._evaluateActiveMeshes = function () {
  139194. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  139195. var len_1 = this._activeMeshes.length;
  139196. for (var i = 0; i < len_1; i++) {
  139197. var mesh = this._activeMeshes.data[i];
  139198. mesh.computeWorldMatrix();
  139199. }
  139200. return;
  139201. }
  139202. if (!this.activeCamera) {
  139203. return;
  139204. }
  139205. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  139206. this.activeCamera._activeMeshes.reset();
  139207. this._activeMeshes.reset();
  139208. this._renderingManager.reset();
  139209. this._processedMaterials.reset();
  139210. this._activeParticleSystems.reset();
  139211. this._activeSkeletons.reset();
  139212. this._softwareSkinnedMeshes.reset();
  139213. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  139214. var step = _a[_i];
  139215. step.action();
  139216. }
  139217. // Determine mesh candidates
  139218. var meshes = this.getActiveMeshCandidates();
  139219. // Check each mesh
  139220. var len = meshes.length;
  139221. for (var i = 0; i < len; i++) {
  139222. var mesh = meshes.data[i];
  139223. if (mesh.isBlocked) {
  139224. continue;
  139225. }
  139226. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  139227. if (!mesh.isReady() || !mesh.isEnabled() || mesh.scaling.lengthSquared() === 0) {
  139228. continue;
  139229. }
  139230. mesh.computeWorldMatrix();
  139231. // Intersections
  139232. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  139233. this._meshesForIntersections.pushNoDuplicate(mesh);
  139234. }
  139235. // Switch to current LOD
  139236. var meshToRender = this.customLODSelector ? this.customLODSelector(mesh, this.activeCamera) : mesh.getLOD(this.activeCamera);
  139237. if (meshToRender === undefined || meshToRender === null) {
  139238. continue;
  139239. }
  139240. // Compute world matrix if LOD is billboard
  139241. if (meshToRender !== mesh && meshToRender.billboardMode !== _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_8__["TransformNode"].BILLBOARDMODE_NONE) {
  139242. meshToRender.computeWorldMatrix();
  139243. }
  139244. mesh._preActivate();
  139245. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  139246. this._activeMeshes.push(mesh);
  139247. this.activeCamera._activeMeshes.push(mesh);
  139248. if (meshToRender !== mesh) {
  139249. meshToRender._activate(this._renderId, false);
  139250. }
  139251. if (mesh._activate(this._renderId, false)) {
  139252. if (!mesh.isAnInstance) {
  139253. meshToRender._internalAbstractMeshDataInfo._onlyForInstances = false;
  139254. }
  139255. meshToRender._internalAbstractMeshDataInfo._isActive = true;
  139256. this._activeMesh(mesh, meshToRender);
  139257. }
  139258. mesh._postActivate();
  139259. }
  139260. }
  139261. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  139262. // Particle systems
  139263. if (this.particlesEnabled) {
  139264. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  139265. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  139266. var particleSystem = this.particleSystems[particleIndex];
  139267. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  139268. continue;
  139269. }
  139270. var emitter = particleSystem.emitter;
  139271. if (!emitter.position || emitter.isEnabled()) {
  139272. this._activeParticleSystems.push(particleSystem);
  139273. particleSystem.animate();
  139274. this._renderingManager.dispatchParticles(particleSystem);
  139275. }
  139276. }
  139277. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  139278. }
  139279. };
  139280. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  139281. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  139282. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  139283. mesh.skeleton.prepare();
  139284. }
  139285. if (!mesh.computeBonesUsingShaders) {
  139286. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  139287. }
  139288. }
  139289. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  139290. var step = _a[_i];
  139291. step.action(sourceMesh, mesh);
  139292. }
  139293. if (mesh !== undefined && mesh !== null
  139294. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  139295. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  139296. var len = subMeshes.length;
  139297. for (var i = 0; i < len; i++) {
  139298. var subMesh = subMeshes.data[i];
  139299. this._evaluateSubMesh(subMesh, mesh, sourceMesh);
  139300. }
  139301. }
  139302. };
  139303. /**
  139304. * Update the transform matrix to update from the current active camera
  139305. * @param force defines a boolean used to force the update even if cache is up to date
  139306. */
  139307. Scene.prototype.updateTransformMatrix = function (force) {
  139308. if (!this.activeCamera) {
  139309. return;
  139310. }
  139311. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  139312. };
  139313. Scene.prototype._bindFrameBuffer = function () {
  139314. if (this.activeCamera && this.activeCamera._multiviewTexture) {
  139315. this.activeCamera._multiviewTexture._bindFrameBuffer();
  139316. }
  139317. else if (this.activeCamera && this.activeCamera.outputRenderTarget) {
  139318. var useMultiview = this.getEngine().getCaps().multiview && this.activeCamera.outputRenderTarget && this.activeCamera.outputRenderTarget.getViewCount() > 1;
  139319. if (useMultiview) {
  139320. this.activeCamera.outputRenderTarget._bindFrameBuffer();
  139321. }
  139322. else {
  139323. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  139324. if (internalTexture) {
  139325. this.getEngine().bindFramebuffer(internalTexture);
  139326. }
  139327. else {
  139328. _Misc_logger__WEBPACK_IMPORTED_MODULE_22__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  139329. }
  139330. }
  139331. }
  139332. else {
  139333. this.getEngine().restoreDefaultFramebuffer(); // Restore back buffer if needed
  139334. }
  139335. };
  139336. /** @hidden */
  139337. Scene.prototype._renderForCamera = function (camera, rigParent) {
  139338. if (camera && camera._skipRendering) {
  139339. return;
  139340. }
  139341. var engine = this._engine;
  139342. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  139343. this._activeCamera = camera;
  139344. if (!this.activeCamera) {
  139345. throw new Error("Active camera not set");
  139346. }
  139347. // Viewport
  139348. engine.setViewport(this.activeCamera.viewport);
  139349. // Camera
  139350. this.resetCachedMaterial();
  139351. this._renderId++;
  139352. var useMultiview = this.getEngine().getCaps().multiview && camera.outputRenderTarget && camera.outputRenderTarget.getViewCount() > 1;
  139353. if (useMultiview) {
  139354. this.setTransformMatrix(camera._rigCameras[0].getViewMatrix(), camera._rigCameras[0].getProjectionMatrix(), camera._rigCameras[1].getViewMatrix(), camera._rigCameras[1].getProjectionMatrix());
  139355. }
  139356. else {
  139357. this.updateTransformMatrix();
  139358. }
  139359. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  139360. // Meshes
  139361. this._evaluateActiveMeshes();
  139362. // Software skinning
  139363. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  139364. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  139365. mesh.applySkeleton(mesh.skeleton);
  139366. }
  139367. // Render targets
  139368. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  139369. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  139370. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  139371. }
  139372. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  139373. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  139374. }
  139375. // Collects render targets from external components.
  139376. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  139377. var step = _a[_i];
  139378. step.action(this._renderTargets);
  139379. }
  139380. if (this.renderTargetsEnabled) {
  139381. this._intermediateRendering = true;
  139382. var needRebind = false;
  139383. if (this._renderTargets.length > 0) {
  139384. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  139385. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  139386. var renderTarget = this._renderTargets.data[renderIndex];
  139387. if (renderTarget._shouldRender()) {
  139388. this._renderId++;
  139389. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  139390. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  139391. needRebind = true;
  139392. }
  139393. }
  139394. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  139395. this._renderId++;
  139396. }
  139397. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  139398. var step = _c[_b];
  139399. needRebind = step.action(this.activeCamera) || needRebind;
  139400. }
  139401. this._intermediateRendering = false;
  139402. // Restore framebuffer after rendering to targets
  139403. if (needRebind) {
  139404. this._bindFrameBuffer();
  139405. }
  139406. }
  139407. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  139408. // Prepare Frame
  139409. if (this.postProcessManager && !camera._multiviewTexture) {
  139410. this.postProcessManager._prepareFrame();
  139411. }
  139412. // Before Camera Draw
  139413. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  139414. var step = _e[_d];
  139415. step.action(this.activeCamera);
  139416. }
  139417. // Render
  139418. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  139419. this._renderingManager.render(null, null, true, true);
  139420. this.onAfterDrawPhaseObservable.notifyObservers(this);
  139421. // After Camera Draw
  139422. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  139423. var step = _g[_f];
  139424. step.action(this.activeCamera);
  139425. }
  139426. // Finalize frame
  139427. if (this.postProcessManager && !camera._multiviewTexture) {
  139428. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  139429. }
  139430. // Reset some special arrays
  139431. this._renderTargets.reset();
  139432. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  139433. };
  139434. Scene.prototype._processSubCameras = function (camera) {
  139435. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE || (camera.outputRenderTarget && camera.outputRenderTarget.getViewCount() > 1 && this.getEngine().getCaps().multiview)) {
  139436. this._renderForCamera(camera);
  139437. return;
  139438. }
  139439. if (camera._useMultiviewToSingleView) {
  139440. this._renderMultiviewToSingleView(camera);
  139441. }
  139442. else {
  139443. // rig cameras
  139444. for (var index = 0; index < camera._rigCameras.length; index++) {
  139445. this._renderForCamera(camera._rigCameras[index], camera);
  139446. }
  139447. }
  139448. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  139449. this._activeCamera = camera;
  139450. this.setTransformMatrix(this._activeCamera.getViewMatrix(), this._activeCamera.getProjectionMatrix());
  139451. };
  139452. Scene.prototype._checkIntersections = function () {
  139453. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  139454. var sourceMesh = this._meshesForIntersections.data[index];
  139455. if (!sourceMesh.actionManager) {
  139456. continue;
  139457. }
  139458. for (var actionIndex = 0; sourceMesh.actionManager && actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  139459. var action = sourceMesh.actionManager.actions[actionIndex];
  139460. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionExitTrigger) {
  139461. var parameters = action.getTriggerParameter();
  139462. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__["AbstractMesh"] ? parameters : parameters.mesh;
  139463. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  139464. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  139465. if (areIntersecting && currentIntersectionInProgress === -1) {
  139466. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  139467. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_16__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  139468. sourceMesh._intersectionsInProgress.push(otherMesh);
  139469. }
  139470. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionExitTrigger) {
  139471. sourceMesh._intersectionsInProgress.push(otherMesh);
  139472. }
  139473. }
  139474. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  139475. //They intersected, and now they don't.
  139476. //is this trigger an exit trigger? execute an event.
  139477. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionExitTrigger) {
  139478. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_16__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  139479. }
  139480. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  139481. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  139482. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__["AbstractMesh"] ? parameter : parameter.mesh;
  139483. return otherMesh === parameterMesh;
  139484. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnIntersectionExitTrigger) {
  139485. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  139486. }
  139487. }
  139488. }
  139489. }
  139490. }
  139491. };
  139492. /** @hidden */
  139493. Scene.prototype._advancePhysicsEngineStep = function (step) {
  139494. // Do nothing. Code will be replaced if physics engine component is referenced
  139495. };
  139496. /** @hidden */
  139497. Scene.prototype._animate = function () {
  139498. // Nothing to do as long as Animatable have not been imported.
  139499. };
  139500. /** Execute all animations (for a frame) */
  139501. Scene.prototype.animate = function () {
  139502. if (this._engine.isDeterministicLockStep()) {
  139503. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  139504. var defaultFPS = (60.0 / 1000.0);
  139505. var defaultFrameTime = this.getDeterministicFrameTime();
  139506. var stepsTaken = 0;
  139507. var maxSubSteps = this._engine.getLockstepMaxSteps();
  139508. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  139509. internalSteps = Math.min(internalSteps, maxSubSteps);
  139510. do {
  139511. this.onBeforeStepObservable.notifyObservers(this);
  139512. // Animations
  139513. this._animationRatio = defaultFrameTime * defaultFPS;
  139514. this._animate();
  139515. this.onAfterAnimationsObservable.notifyObservers(this);
  139516. // Physics
  139517. this._advancePhysicsEngineStep(defaultFrameTime);
  139518. this.onAfterStepObservable.notifyObservers(this);
  139519. this._currentStepId++;
  139520. stepsTaken++;
  139521. deltaTime -= defaultFrameTime;
  139522. } while (deltaTime > 0 && stepsTaken < internalSteps);
  139523. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  139524. }
  139525. else {
  139526. // Animations
  139527. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  139528. this._animationRatio = deltaTime * (60.0 / 1000.0);
  139529. this._animate();
  139530. this.onAfterAnimationsObservable.notifyObservers(this);
  139531. // Physics
  139532. this._advancePhysicsEngineStep(deltaTime);
  139533. }
  139534. };
  139535. /**
  139536. * Render the scene
  139537. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  139538. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  139539. */
  139540. Scene.prototype.render = function (updateCameras, ignoreAnimations) {
  139541. if (updateCameras === void 0) { updateCameras = true; }
  139542. if (ignoreAnimations === void 0) { ignoreAnimations = false; }
  139543. if (this.isDisposed) {
  139544. return;
  139545. }
  139546. this._frameId++;
  139547. // Register components that have been associated lately to the scene.
  139548. this._registerTransientComponents();
  139549. this._activeParticles.fetchNewFrame();
  139550. this._totalVertices.fetchNewFrame();
  139551. this._activeIndices.fetchNewFrame();
  139552. this._activeBones.fetchNewFrame();
  139553. this._meshesForIntersections.reset();
  139554. this.resetCachedMaterial();
  139555. this.onBeforeAnimationsObservable.notifyObservers(this);
  139556. // Actions
  139557. if (this.actionManager) {
  139558. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ACTION_OnEveryFrameTrigger);
  139559. }
  139560. // Animations
  139561. if (!ignoreAnimations) {
  139562. this.animate();
  139563. }
  139564. // Before camera update steps
  139565. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  139566. var step = _a[_i];
  139567. step.action();
  139568. }
  139569. // Update Cameras
  139570. if (updateCameras) {
  139571. if (this.activeCameras.length > 0) {
  139572. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  139573. var camera = this.activeCameras[cameraIndex];
  139574. camera.update();
  139575. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE) {
  139576. // rig cameras
  139577. for (var index = 0; index < camera._rigCameras.length; index++) {
  139578. camera._rigCameras[index].update();
  139579. }
  139580. }
  139581. }
  139582. }
  139583. else if (this.activeCamera) {
  139584. this.activeCamera.update();
  139585. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE) {
  139586. // rig cameras
  139587. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  139588. this.activeCamera._rigCameras[index].update();
  139589. }
  139590. }
  139591. }
  139592. }
  139593. // Before render
  139594. this.onBeforeRenderObservable.notifyObservers(this);
  139595. // Customs render targets
  139596. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  139597. var engine = this.getEngine();
  139598. var currentActiveCamera = this.activeCamera;
  139599. if (this.renderTargetsEnabled) {
  139600. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  139601. this._intermediateRendering = true;
  139602. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  139603. var renderTarget = this.customRenderTargets[customIndex];
  139604. if (renderTarget._shouldRender()) {
  139605. this._renderId++;
  139606. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  139607. if (!this.activeCamera) {
  139608. throw new Error("Active camera not set");
  139609. }
  139610. // Viewport
  139611. engine.setViewport(this.activeCamera.viewport);
  139612. // Camera
  139613. this.updateTransformMatrix();
  139614. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  139615. }
  139616. }
  139617. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  139618. this._intermediateRendering = false;
  139619. this._renderId++;
  139620. }
  139621. // Restore back buffer
  139622. this.activeCamera = currentActiveCamera;
  139623. this._bindFrameBuffer();
  139624. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  139625. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  139626. var step = _c[_b];
  139627. step.action();
  139628. }
  139629. // Clear
  139630. if (this.autoClearDepthAndStencil || this.autoClear) {
  139631. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  139632. }
  139633. // Collects render targets from external components.
  139634. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  139635. var step = _e[_d];
  139636. step.action(this._renderTargets);
  139637. }
  139638. // Multi-cameras?
  139639. if (this.activeCameras.length > 0) {
  139640. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  139641. if (cameraIndex > 0) {
  139642. this._engine.clear(null, false, true, true);
  139643. }
  139644. this._processSubCameras(this.activeCameras[cameraIndex]);
  139645. }
  139646. }
  139647. else {
  139648. if (!this.activeCamera) {
  139649. throw new Error("No camera defined");
  139650. }
  139651. this._processSubCameras(this.activeCamera);
  139652. }
  139653. // Intersection checks
  139654. this._checkIntersections();
  139655. // Executes the after render stage actions.
  139656. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  139657. var step = _g[_f];
  139658. step.action();
  139659. }
  139660. // After render
  139661. if (this.afterRender) {
  139662. this.afterRender();
  139663. }
  139664. this.onAfterRenderObservable.notifyObservers(this);
  139665. // Cleaning
  139666. if (this._toBeDisposed.length) {
  139667. for (var index = 0; index < this._toBeDisposed.length; index++) {
  139668. var data = this._toBeDisposed[index];
  139669. if (data) {
  139670. data.dispose();
  139671. }
  139672. }
  139673. this._toBeDisposed = [];
  139674. }
  139675. if (this.dumpNextRenderTargets) {
  139676. this.dumpNextRenderTargets = false;
  139677. }
  139678. this._activeBones.addCount(0, true);
  139679. this._activeIndices.addCount(0, true);
  139680. this._activeParticles.addCount(0, true);
  139681. };
  139682. /**
  139683. * Freeze all materials
  139684. * A frozen material will not be updatable but should be faster to render
  139685. */
  139686. Scene.prototype.freezeMaterials = function () {
  139687. for (var i = 0; i < this.materials.length; i++) {
  139688. this.materials[i].freeze();
  139689. }
  139690. };
  139691. /**
  139692. * Unfreeze all materials
  139693. * A frozen material will not be updatable but should be faster to render
  139694. */
  139695. Scene.prototype.unfreezeMaterials = function () {
  139696. for (var i = 0; i < this.materials.length; i++) {
  139697. this.materials[i].unfreeze();
  139698. }
  139699. };
  139700. /**
  139701. * Releases all held ressources
  139702. */
  139703. Scene.prototype.dispose = function () {
  139704. this.beforeRender = null;
  139705. this.afterRender = null;
  139706. this.skeletons = [];
  139707. this.morphTargetManagers = [];
  139708. this._transientComponents = [];
  139709. this._isReadyForMeshStage.clear();
  139710. this._beforeEvaluateActiveMeshStage.clear();
  139711. this._evaluateSubMeshStage.clear();
  139712. this._activeMeshStage.clear();
  139713. this._cameraDrawRenderTargetStage.clear();
  139714. this._beforeCameraDrawStage.clear();
  139715. this._beforeRenderTargetDrawStage.clear();
  139716. this._beforeRenderingGroupDrawStage.clear();
  139717. this._beforeRenderingMeshStage.clear();
  139718. this._afterRenderingMeshStage.clear();
  139719. this._afterRenderingGroupDrawStage.clear();
  139720. this._afterCameraDrawStage.clear();
  139721. this._afterRenderTargetDrawStage.clear();
  139722. this._afterRenderStage.clear();
  139723. this._beforeCameraUpdateStage.clear();
  139724. this._beforeClearStage.clear();
  139725. this._gatherRenderTargetsStage.clear();
  139726. this._gatherActiveCameraRenderTargetsStage.clear();
  139727. this._pointerMoveStage.clear();
  139728. this._pointerDownStage.clear();
  139729. this._pointerUpStage.clear();
  139730. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  139731. var component = _a[_i];
  139732. component.dispose();
  139733. }
  139734. this.importedMeshesFiles = new Array();
  139735. if (this.stopAllAnimations) {
  139736. this.stopAllAnimations();
  139737. }
  139738. this.resetCachedMaterial();
  139739. // Smart arrays
  139740. if (this.activeCamera) {
  139741. this.activeCamera._activeMeshes.dispose();
  139742. this.activeCamera = null;
  139743. }
  139744. this._activeMeshes.dispose();
  139745. this._renderingManager.dispose();
  139746. this._processedMaterials.dispose();
  139747. this._activeParticleSystems.dispose();
  139748. this._activeSkeletons.dispose();
  139749. this._softwareSkinnedMeshes.dispose();
  139750. this._renderTargets.dispose();
  139751. this._registeredForLateAnimationBindings.dispose();
  139752. this._meshesForIntersections.dispose();
  139753. this._toBeDisposed = [];
  139754. // Abort active requests
  139755. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  139756. var request = _c[_b];
  139757. request.abort();
  139758. }
  139759. // Events
  139760. this.onDisposeObservable.notifyObservers(this);
  139761. this.onDisposeObservable.clear();
  139762. this.onBeforeRenderObservable.clear();
  139763. this.onAfterRenderObservable.clear();
  139764. this.onBeforeRenderTargetsRenderObservable.clear();
  139765. this.onAfterRenderTargetsRenderObservable.clear();
  139766. this.onAfterStepObservable.clear();
  139767. this.onBeforeStepObservable.clear();
  139768. this.onBeforeActiveMeshesEvaluationObservable.clear();
  139769. this.onAfterActiveMeshesEvaluationObservable.clear();
  139770. this.onBeforeParticlesRenderingObservable.clear();
  139771. this.onAfterParticlesRenderingObservable.clear();
  139772. this.onBeforeDrawPhaseObservable.clear();
  139773. this.onAfterDrawPhaseObservable.clear();
  139774. this.onBeforeAnimationsObservable.clear();
  139775. this.onAfterAnimationsObservable.clear();
  139776. this.onDataLoadedObservable.clear();
  139777. this.onBeforeRenderingGroupObservable.clear();
  139778. this.onAfterRenderingGroupObservable.clear();
  139779. this.onMeshImportedObservable.clear();
  139780. this.onBeforeCameraRenderObservable.clear();
  139781. this.onAfterCameraRenderObservable.clear();
  139782. this.onReadyObservable.clear();
  139783. this.onNewCameraAddedObservable.clear();
  139784. this.onCameraRemovedObservable.clear();
  139785. this.onNewLightAddedObservable.clear();
  139786. this.onLightRemovedObservable.clear();
  139787. this.onNewGeometryAddedObservable.clear();
  139788. this.onGeometryRemovedObservable.clear();
  139789. this.onNewTransformNodeAddedObservable.clear();
  139790. this.onTransformNodeRemovedObservable.clear();
  139791. this.onNewMeshAddedObservable.clear();
  139792. this.onMeshRemovedObservable.clear();
  139793. this.onNewSkeletonAddedObservable.clear();
  139794. this.onSkeletonRemovedObservable.clear();
  139795. this.onNewMaterialAddedObservable.clear();
  139796. this.onMaterialRemovedObservable.clear();
  139797. this.onNewTextureAddedObservable.clear();
  139798. this.onTextureRemovedObservable.clear();
  139799. this.onPrePointerObservable.clear();
  139800. this.onPointerObservable.clear();
  139801. this.onPreKeyboardObservable.clear();
  139802. this.onKeyboardObservable.clear();
  139803. this.onActiveCameraChanged.clear();
  139804. this.detachControl();
  139805. // Detach cameras
  139806. var canvas = this._engine.getRenderingCanvas();
  139807. if (canvas) {
  139808. var index;
  139809. for (index = 0; index < this.cameras.length; index++) {
  139810. this.cameras[index].detachControl(canvas);
  139811. }
  139812. }
  139813. // Release animation groups
  139814. while (this.animationGroups.length) {
  139815. this.animationGroups[0].dispose();
  139816. }
  139817. // Release lights
  139818. while (this.lights.length) {
  139819. this.lights[0].dispose();
  139820. }
  139821. // Release meshes
  139822. while (this.meshes.length) {
  139823. this.meshes[0].dispose(true);
  139824. }
  139825. while (this.transformNodes.length) {
  139826. this.transformNodes[0].dispose(true);
  139827. }
  139828. // Release cameras
  139829. while (this.cameras.length) {
  139830. this.cameras[0].dispose();
  139831. }
  139832. // Release materials
  139833. if (this._defaultMaterial) {
  139834. this._defaultMaterial.dispose();
  139835. }
  139836. while (this.multiMaterials.length) {
  139837. this.multiMaterials[0].dispose();
  139838. }
  139839. while (this.materials.length) {
  139840. this.materials[0].dispose();
  139841. }
  139842. // Release particles
  139843. while (this.particleSystems.length) {
  139844. this.particleSystems[0].dispose();
  139845. }
  139846. // Release postProcesses
  139847. while (this.postProcesses.length) {
  139848. this.postProcesses[0].dispose();
  139849. }
  139850. // Release textures
  139851. while (this.textures.length) {
  139852. this.textures[0].dispose();
  139853. }
  139854. // Release UBO
  139855. this._sceneUbo.dispose();
  139856. if (this._multiviewSceneUbo) {
  139857. this._multiviewSceneUbo.dispose();
  139858. }
  139859. // Post-processes
  139860. this.postProcessManager.dispose();
  139861. // Remove from engine
  139862. index = this._engine.scenes.indexOf(this);
  139863. if (index > -1) {
  139864. this._engine.scenes.splice(index, 1);
  139865. }
  139866. this._engine.wipeCaches(true);
  139867. this._isDisposed = true;
  139868. };
  139869. Object.defineProperty(Scene.prototype, "isDisposed", {
  139870. /**
  139871. * Gets if the scene is already disposed
  139872. */
  139873. get: function () {
  139874. return this._isDisposed;
  139875. },
  139876. enumerable: true,
  139877. configurable: true
  139878. });
  139879. /**
  139880. * Call this function to reduce memory footprint of the scene.
  139881. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  139882. */
  139883. Scene.prototype.clearCachedVertexData = function () {
  139884. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  139885. var mesh = this.meshes[meshIndex];
  139886. var geometry = mesh.geometry;
  139887. if (geometry) {
  139888. geometry._indices = [];
  139889. for (var vbName in geometry._vertexBuffers) {
  139890. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  139891. continue;
  139892. }
  139893. geometry._vertexBuffers[vbName]._buffer._data = null;
  139894. }
  139895. }
  139896. }
  139897. };
  139898. /**
  139899. * This function will remove the local cached buffer data from texture.
  139900. * It will save memory but will prevent the texture from being rebuilt
  139901. */
  139902. Scene.prototype.cleanCachedTextureBuffer = function () {
  139903. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  139904. var baseTexture = _a[_i];
  139905. var buffer = baseTexture._buffer;
  139906. if (buffer) {
  139907. baseTexture._buffer = null;
  139908. }
  139909. }
  139910. };
  139911. /**
  139912. * Get the world extend vectors with an optional filter
  139913. *
  139914. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  139915. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  139916. */
  139917. Scene.prototype.getWorldExtends = function (filterPredicate) {
  139918. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  139919. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  139920. filterPredicate = filterPredicate || (function () { return true; });
  139921. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  139922. mesh.computeWorldMatrix(true);
  139923. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  139924. return;
  139925. }
  139926. var boundingInfo = mesh.getBoundingInfo();
  139927. var minBox = boundingInfo.boundingBox.minimumWorld;
  139928. var maxBox = boundingInfo.boundingBox.maximumWorld;
  139929. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  139930. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  139931. });
  139932. return {
  139933. min: min,
  139934. max: max
  139935. };
  139936. };
  139937. // Picking
  139938. /**
  139939. * Creates a ray that can be used to pick in the scene
  139940. * @param x defines the x coordinate of the origin (on-screen)
  139941. * @param y defines the y coordinate of the origin (on-screen)
  139942. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  139943. * @param camera defines the camera to use for the picking
  139944. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  139945. * @returns a Ray
  139946. */
  139947. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  139948. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  139949. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("Ray");
  139950. };
  139951. /**
  139952. * Creates a ray that can be used to pick in the scene
  139953. * @param x defines the x coordinate of the origin (on-screen)
  139954. * @param y defines the y coordinate of the origin (on-screen)
  139955. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  139956. * @param result defines the ray where to store the picking ray
  139957. * @param camera defines the camera to use for the picking
  139958. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  139959. * @returns the current scene
  139960. */
  139961. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  139962. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  139963. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("Ray");
  139964. };
  139965. /**
  139966. * Creates a ray that can be used to pick in the scene
  139967. * @param x defines the x coordinate of the origin (on-screen)
  139968. * @param y defines the y coordinate of the origin (on-screen)
  139969. * @param camera defines the camera to use for the picking
  139970. * @returns a Ray
  139971. */
  139972. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  139973. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("Ray");
  139974. };
  139975. /**
  139976. * Creates a ray that can be used to pick in the scene
  139977. * @param x defines the x coordinate of the origin (on-screen)
  139978. * @param y defines the y coordinate of the origin (on-screen)
  139979. * @param result defines the ray where to store the picking ray
  139980. * @param camera defines the camera to use for the picking
  139981. * @returns the current scene
  139982. */
  139983. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  139984. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("Ray");
  139985. };
  139986. /** Launch a ray to try to pick a mesh in the scene
  139987. * @param x position on screen
  139988. * @param y position on screen
  139989. * @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
  139990. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  139991. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  139992. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  139993. * @returns a PickingInfo
  139994. */
  139995. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  139996. // Dummy info if picking as not been imported
  139997. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_15__["PickingInfo"]();
  139998. pi._pickingUnavailable = true;
  139999. return pi;
  140000. };
  140001. /** Use the given ray to pick a mesh in the scene
  140002. * @param ray The ray to use to pick meshes
  140003. * @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
  140004. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  140005. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  140006. * @returns a PickingInfo
  140007. */
  140008. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  140009. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("Ray");
  140010. };
  140011. /**
  140012. * Launch a ray to try to pick a mesh in the scene
  140013. * @param x X position on screen
  140014. * @param y Y position on screen
  140015. * @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
  140016. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  140017. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  140018. * @returns an array of PickingInfo
  140019. */
  140020. Scene.prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  140021. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("Ray");
  140022. };
  140023. /**
  140024. * Launch a ray to try to pick a mesh in the scene
  140025. * @param ray Ray to use
  140026. * @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
  140027. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  140028. * @returns an array of PickingInfo
  140029. */
  140030. Scene.prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  140031. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_24__["_DevTools"].WarnImport("Ray");
  140032. };
  140033. /**
  140034. * Force the value of meshUnderPointer
  140035. * @param mesh defines the mesh to use
  140036. */
  140037. Scene.prototype.setPointerOverMesh = function (mesh) {
  140038. this._inputManager.setPointerOverMesh(mesh);
  140039. };
  140040. /**
  140041. * Gets the mesh under the pointer
  140042. * @returns a Mesh or null if no mesh is under the pointer
  140043. */
  140044. Scene.prototype.getPointerOverMesh = function () {
  140045. return this._inputManager.getPointerOverMesh();
  140046. };
  140047. // Misc.
  140048. /** @hidden */
  140049. Scene.prototype._rebuildGeometries = function () {
  140050. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  140051. var geometry = _a[_i];
  140052. geometry._rebuild();
  140053. }
  140054. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  140055. var mesh = _c[_b];
  140056. mesh._rebuild();
  140057. }
  140058. if (this.postProcessManager) {
  140059. this.postProcessManager._rebuild();
  140060. }
  140061. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  140062. var component = _e[_d];
  140063. component.rebuild();
  140064. }
  140065. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  140066. var system = _g[_f];
  140067. system.rebuild();
  140068. }
  140069. };
  140070. /** @hidden */
  140071. Scene.prototype._rebuildTextures = function () {
  140072. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  140073. var texture = _a[_i];
  140074. texture._rebuild();
  140075. }
  140076. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_TextureDirtyFlag);
  140077. };
  140078. // Tags
  140079. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  140080. if (tagsQuery === undefined) {
  140081. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  140082. return list;
  140083. }
  140084. var listByTags = [];
  140085. forEach = forEach || (function (item) { return; });
  140086. for (var i in list) {
  140087. var item = list[i];
  140088. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  140089. listByTags.push(item);
  140090. forEach(item);
  140091. }
  140092. }
  140093. return listByTags;
  140094. };
  140095. /**
  140096. * Get a list of meshes by tags
  140097. * @param tagsQuery defines the tags query to use
  140098. * @param forEach defines a predicate used to filter results
  140099. * @returns an array of Mesh
  140100. */
  140101. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  140102. return this._getByTags(this.meshes, tagsQuery, forEach);
  140103. };
  140104. /**
  140105. * Get a list of cameras by tags
  140106. * @param tagsQuery defines the tags query to use
  140107. * @param forEach defines a predicate used to filter results
  140108. * @returns an array of Camera
  140109. */
  140110. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  140111. return this._getByTags(this.cameras, tagsQuery, forEach);
  140112. };
  140113. /**
  140114. * Get a list of lights by tags
  140115. * @param tagsQuery defines the tags query to use
  140116. * @param forEach defines a predicate used to filter results
  140117. * @returns an array of Light
  140118. */
  140119. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  140120. return this._getByTags(this.lights, tagsQuery, forEach);
  140121. };
  140122. /**
  140123. * Get a list of materials by tags
  140124. * @param tagsQuery defines the tags query to use
  140125. * @param forEach defines a predicate used to filter results
  140126. * @returns an array of Material
  140127. */
  140128. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  140129. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  140130. };
  140131. /**
  140132. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  140133. * This allowed control for front to back rendering or reversly depending of the special needs.
  140134. *
  140135. * @param renderingGroupId The rendering group id corresponding to its index
  140136. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  140137. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  140138. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  140139. */
  140140. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  140141. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  140142. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  140143. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  140144. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  140145. };
  140146. /**
  140147. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  140148. *
  140149. * @param renderingGroupId The rendering group id corresponding to its index
  140150. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  140151. * @param depth Automatically clears depth between groups if true and autoClear is true.
  140152. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  140153. */
  140154. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  140155. if (depth === void 0) { depth = true; }
  140156. if (stencil === void 0) { stencil = true; }
  140157. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  140158. };
  140159. /**
  140160. * Gets the current auto clear configuration for one rendering group of the rendering
  140161. * manager.
  140162. * @param index the rendering group index to get the information for
  140163. * @returns The auto clear setup for the requested rendering group
  140164. */
  140165. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  140166. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  140167. };
  140168. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  140169. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  140170. get: function () {
  140171. return this._blockMaterialDirtyMechanism;
  140172. },
  140173. set: function (value) {
  140174. if (this._blockMaterialDirtyMechanism === value) {
  140175. return;
  140176. }
  140177. this._blockMaterialDirtyMechanism = value;
  140178. if (!value) { // Do a complete update
  140179. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].MATERIAL_AllDirtyFlag);
  140180. }
  140181. },
  140182. enumerable: true,
  140183. configurable: true
  140184. });
  140185. /**
  140186. * Will flag all materials as dirty to trigger new shader compilation
  140187. * @param flag defines the flag used to specify which material part must be marked as dirty
  140188. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  140189. */
  140190. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  140191. if (this._blockMaterialDirtyMechanism) {
  140192. return;
  140193. }
  140194. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  140195. var material = _a[_i];
  140196. if (predicate && !predicate(material)) {
  140197. continue;
  140198. }
  140199. material.markAsDirty(flag);
  140200. }
  140201. };
  140202. /** @hidden */
  140203. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  140204. var _this = this;
  140205. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  140206. this._activeRequests.push(request);
  140207. request.onCompleteObservable.add(function (request) {
  140208. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  140209. });
  140210. return request;
  140211. };
  140212. /** @hidden */
  140213. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  140214. var _this = this;
  140215. return new Promise(function (resolve, reject) {
  140216. _this._loadFile(url, function (data) {
  140217. resolve(data);
  140218. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  140219. reject(exception);
  140220. });
  140221. });
  140222. };
  140223. // Statics
  140224. Scene._uniqueIdCounter = 0;
  140225. /** The fog is deactivated */
  140226. Scene.FOGMODE_NONE = 0;
  140227. /** The fog density is following an exponential function */
  140228. Scene.FOGMODE_EXP = 1;
  140229. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  140230. Scene.FOGMODE_EXP2 = 2;
  140231. /** The fog density is following a linear function. */
  140232. Scene.FOGMODE_LINEAR = 3;
  140233. /**
  140234. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  140235. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  140236. */
  140237. Scene.MinDeltaTime = 1.0;
  140238. /**
  140239. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  140240. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  140241. */
  140242. Scene.MaxDeltaTime = 1000.0;
  140243. return Scene;
  140244. }(_abstractScene__WEBPACK_IMPORTED_MODULE_11__["AbstractScene"]));
  140245. /***/ }),
  140246. /***/ "./sceneComponent.ts":
  140247. /*!***************************!*\
  140248. !*** ./sceneComponent.ts ***!
  140249. \***************************/
  140250. /*! exports provided: SceneComponentConstants, Stage */
  140251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  140252. "use strict";
  140253. __webpack_require__.r(__webpack_exports__);
  140254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  140255. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  140256. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  140257. /**
  140258. * Groups all the scene component constants in one place to ease maintenance.
  140259. * @hidden
  140260. */
  140261. var SceneComponentConstants = /** @class */ (function () {
  140262. function SceneComponentConstants() {
  140263. }
  140264. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  140265. SceneComponentConstants.NAME_LAYER = "Layer";
  140266. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  140267. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  140268. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  140269. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  140270. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  140271. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  140272. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  140273. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  140274. SceneComponentConstants.NAME_SPRITE = "Sprite";
  140275. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  140276. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  140277. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  140278. SceneComponentConstants.NAME_OCTREE = "Octree";
  140279. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  140280. SceneComponentConstants.NAME_AUDIO = "Audio";
  140281. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  140282. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  140283. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  140284. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  140285. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  140286. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  140287. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  140288. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  140289. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  140290. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  140291. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  140292. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  140293. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  140294. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  140295. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  140296. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  140297. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  140298. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  140299. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  140300. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  140301. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  140302. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  140303. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  140304. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  140305. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  140306. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  140307. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  140308. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  140309. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  140310. return SceneComponentConstants;
  140311. }());
  140312. /**
  140313. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  140314. * @hidden
  140315. */
  140316. var Stage = /** @class */ (function (_super) {
  140317. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  140318. /**
  140319. * Hide ctor from the rest of the world.
  140320. * @param items The items to add.
  140321. */
  140322. function Stage(items) {
  140323. return _super.apply(this, items) || this;
  140324. }
  140325. /**
  140326. * Creates a new Stage.
  140327. * @returns A new instance of a Stage
  140328. */
  140329. Stage.Create = function () {
  140330. return Object.create(Stage.prototype);
  140331. };
  140332. /**
  140333. * Registers a step in an ordered way in the targeted stage.
  140334. * @param index Defines the position to register the step in
  140335. * @param component Defines the component attached to the step
  140336. * @param action Defines the action to launch during the step
  140337. */
  140338. Stage.prototype.registerStep = function (index, component, action) {
  140339. var i = 0;
  140340. var maxIndex = Number.MAX_VALUE;
  140341. for (; i < this.length; i++) {
  140342. var step = this[i];
  140343. maxIndex = step.index;
  140344. if (index < maxIndex) {
  140345. break;
  140346. }
  140347. }
  140348. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  140349. };
  140350. /**
  140351. * Clears all the steps from the stage.
  140352. */
  140353. Stage.prototype.clear = function () {
  140354. this.length = 0;
  140355. };
  140356. return Stage;
  140357. }(Array));
  140358. /***/ })
  140359. /******/ });
  140360. });
  140361. //# sourceMappingURL=babylon.max.js.map